- how would you start project : npm init -y
- what packages needs to be installed - express , nodemon (dev), jest (dev), supertest(dev)
- Create server and test folders
- add server/app.js and modify packagejson "main" key
- Modify start and test script
- Run npm start, npm test
- create folders : routes, controllers, utils, test, data in server
- create test files in test folder
- import express
- listen on port 3000
- ensure server starts without any error
- contains post routes code and export the router to app.js
- contains post controller code must be exported to be invoked in routes file
- contains helper functions must be exported and invoked by both controller and test units
- contains a file which holds actual and test data for the CRUD action ( This will be replaced by Mongo in future)
- contains test scripts to test the functionalities
- https://edstem.org/courses/4296/lessons/5486/slides/40675
- https://docs.github.com/en/free-pro-team@latest/actions/guides/building-and-testing-nodejs#starting-with-the-nodejs-workflow-template
app.js Build router. : Get all Posts, getPostByID. : GET /posts , /posts/:id Utilities Test utilities Controller Test from postman
Route : POST Add post: utility Test Controller
Route : Delete Delete post : utility Test Controller
Update Route: PUT UpdatePost : utility Test script update Controller test via postman