Wrapping Things Up

I am going to submit my work today. Will complete writing the readme file and wire things up.

New Project, Callback Hell

I have been working a couple of days on my new project, which is to solve a realistic business problem. This is a server app/API for a Coffee Shop, which sells monthly coffee memberships. For a single montly payment, the customer gets free coffee up to the following limits: Max 5 drinks per day One redemption in any 30 minutes. Given this is a very simple problem to solve; I have already ran into issues with complexity called callback-hell.

Project

I decided to dump my course project. It is archived in the coursework folder. My first idea was a microblogging site as this is a common sample across various tutorials. I think I was able to learn the concepts presented in the tutorials in a project context building something bigger. However, I am not keen to complete this project because it is not very exciting and I’d like to come up with something more original.

Express JS Crash Course ... express-handlebars

Today I will be finishing the tutorial and will be adding a view engine to the project. This project is using handlebars. https://handlebarsjs.com/ https://www.npmjs.com/package/express-handlebars We also added Bootstap which is a front-end toolkit. https://getbootstrap.com/ Datatables https://datatables.net/ I found this useful jQuery plugin which can add sorting and filtering to HTML tables. I wanted to test it on my app. I got this to work, but realised that I will need to figure out how to insert page specific scripts within the main template.

Express JS Crash Course ... continued

I’ve started to work on my project and have put some basics in place. I have started to build the data model with Mongoose. I’ve watched some additional videos, and searched documentation and samples on-line. I will be adding comments to my code to refenrence all the different sources that I have used. It is useful to have these “bookmarked” within the project for future reference, too. I will continue to watch the Crash Course on Express JS.

Express JS Crash Course

Started to watch the video again. This time working through the examples. Basic Server Syntax const express = require('express); // init express const app = express(); // create your endpoints / route handlers app.get('/', function (req, res) { // fetch from database... // load pages ... // return JSON ... // full access to request & response res.send('Hello World!'); }); // listen on a port app.listen(5000); Handling requests app.get() app.

REST Tutorial (Mongoose)

Youtube: Build A REST API With Node.js, Express, & MongoDB - Quick Starting the project npm init npm i mongoose express npm i –save-dev dotenv nodemon { "name": "build_a_rest_api_tutorial", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "devStart": "nodemon server.js" }, "author": "", "license": "ISC", "dependencies": { "express": "^4.17.1", "mongoose": "^5.10.18", "undefined": " " }, "devDependencies": { "dotenv": "^8.2.0", "nodemon": "^2.0.6" } } Create file .env .gitignore .env node_modules server.js

Express Friday

Ok .. so today I will watch the final YT on Express. I’m not going to work through the examples today while I’m wathcing.

Starting the MongoDB Crash Course

I started to watch the crash course video. Downloaded MongoDB server files into my coursework directory. I wanted to see if I can start the server and conntect using the CLI just by using the README and help. I created a local data/db directory. sudo mkdir -p ../data/db sudo chmod -R go+w ../data/db ./mongod --dbpath "../data/db" Server started. I opened another terminal window, and started the CLI (shell) in the bin directory:

Completing the node.js Crash Course

I am finally getting to the end of the node.js Crash Course. It’s been very basic so far, and there’s not many things to note. Deployment to Heroku Check-List PORT specified as process.env.PORT package.json must specify a start script "scripts": { "start": "node index", "dev": "nodemon index" }, Sign up for a Heroku account. Have Heroku CLI installed. On a Mac: % brew tap heroku/brew && brew install heroku login % heroku login Create a new heroku app % heroku create Creating app.