- Coding Ninja Backend Skill Test 3
- Authentication and Authorization using jwt token
- Session management
- Doctor Login
- Patients register
- Create report
- Edit and delete report
- Track Covid patient status
- Resource Management
- Global Error Handling
- Logging Request and errors
- Extensible code flow and Folder structure
- Best env variable setup
- First browser sends the request to the server
- Server points to our specific routes
- before the controller, it may be that there will be middlewares or validators or maybe both
- If no Middleware of the validator then the request goes to the specific controller
- Controllers will send back the response, if no need to call services
- Services are basically functions that help us to get data from DB (here is Mongo DB)
- Service may use models to save data in some specific format
Note: Middleware/validators may or may not be there Services/models may or may not be there
Image for better understanding
- bcrypt -> To hash and compare the hashed password
- compression -> To compress res bodies
- cookie-parser -> To interact with cookies
- dotenv -> To store sensitive configurations in a .env file
- express -> To create Servers (with minimal code)
- express-async-handler -> To wrap controller function so that if any error comes it will next function with the error automatically
- express-rate-limit -> To prevent or limit repeated requests to our APIs (a normal user can not send more than 60 request per second)
- express-session -> To manage Sessions
- express-validator -> To validate request body data
- helmet -> Helmet helps secure Express apps by setting HTTP response headers.
- jsonwebtoken -> To create jwt token
- nodemailer -> To send email
- winston -> It helps us to log the req or res in a very easy way
- mongoose -> to interact with mongodb
- connect-mongo -> to store all sessions in mongodb
- swagger-ui-express -> to show api docs for better usability of api end points
- Clone this repository
- create a .env file at the root of this project
- create all env variable which is given in the .env.example file with proper info
- then run npm install (to install all packages used in this project)
- then run npm run start
- go to the link shown in the terminal all api docs are there
- you can use postman as well, i have attached one postman-collection import and change accordingly base on api docs
- Now you are good to go
- Thank YOU
Note:
- if you put mongoUri of atlas, then please store user and password in .env file and uncomment in db.config.js (user and pass) refer .env.example file
- if you are using local mongodb and no user and password is required then comment user and password in db.config.js