Creating a Web Server API Using Express.
Requirements:
- node.js
- Express - module.
- Nodemon - module.
- Mocha - module.
- Chai - module.
Process:
- Npm init -y
- npm install express nodemon mocha chai --save-dev
- node or
- Start nodmone server
- Create a script: "devStart": "nodemon server.js"
- Run npm run devStart
Views:
You can use a view to renderer for your html templates:
- ejs
- pug Embedded Javascript Templating:
npm install ejs --save-dev app.set('view engine', 'ejs'); // ejs or pug
mocha and chai:
These tools are used for testing and debugging. You can use them with Sinon module to spy on the app functions.
Router in Express:
Create a new router for each file in the application. const router = express.Router() app.use('/', router) => in the Routes folder
concepts : express, routes, rendering, middleware, backend, views, params, responses, requests, testing,