Posts

Showing posts with the label Node

Node.js Notes February

Image
February 1, 2021 1. Create package.json in Node.js npm init npm install nodemon --save-dev npm install express 2. Core Node.js Modules Exist Examples include http, https, fs const http = require('http') to import. Nothing needs to be installed since its a core package included with Node.js. 3. Middleware Example const app = express(); app.use('/users', (req, res, next) => { console.log('In another middleware'); // next(); res.send('users'); }); app.use('/', (req, res, next) => { console.log('keep going!'); res.send('hi there!!!').status(200); }); 4. body-parser npm install body-parser --save Save it with --save because we want to have it in production. body-parser gets added and removed in Node.js so its best practice to download it via third party. February 3, 2021 1. Express has a Router function. This can be used to seperate routes. Admin.js File const express = requ...