How to use this project:
we register as a new user and later we can login as existing user, here we can manage(create,read,update,delete) multiple jobs.only the user that is logged in has access to the job operations.the user wont be able to manipulate other user's jobs as all users are protected with auth middleware that uses userId+JWT token that is provided once the user is logged in or registers.
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
- cors
- xss-clean
- express-rate-limit
Swagger UI
/jobs/{id}:
parameters:
- in: path
name: id
schema:
type: string
required: true
description: the job id