This is a jobs (RESTful) api project hosted on render.com.
The api UI is simply setup via Swagger UI.
Click here to explore: https://jobs-api-bwjg.onrender.com/api-docs/
This app is built using:
- Node.js with Express.js
- MongoDB
- Swagger UI
- json Web Token Authentication
- and many more...
npm install && npm start
- Import connect.js
- Invoke in start()
- Setup .env in the root
- Add MONGO_URI with correct value
- auth.js
- jobs.js
Email Validation Regex
/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
- Validate - name, email, password - with Mongoose
- Hash Password (with bcryptjs)
- Save User
- Generate Token
- Send Response with Token
- Validate - email, password - in controller
- If email or password is missing, throw BadRequestError
- Find User
- Compare Passwords
- If no user or password does not match, throw UnauthenticatedError
- If correct, generate Token
- Send Response with Token
- Validation Errors
- Duplicate (Email)
- Cast Error
- helmet - sets various http headers to prevent numerous possible attacks
- cors (stands for cross-origin resource sharing) - ensures our API is accessible from different domain. It is a mechanism to allow or restrict requested resources on a web server.
- (!! deprecated) xss-clean - sanitizes the user input in req.body,req.query and req.params, thus protecting us from cross-site scripting attacks where the attacker tries to inject some malicious code.
- express-rate-limit - to limit the amount of request the user can make
Swagger UI
/jobs/{id}: parameters: - in: path name: id schema: type: string required: true description: the job id
- This project is done in conjunction with Instructor John Smilga in the following course
- Instructor John Smilga - Node.js course (https://johnsmilga.com/)