RESTful Express API with full CRUD functionality
https://jobs-api-wcxm.onrender.com
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 (if user does not provide one of the values)
- Duplicate (Email) (email not unique)
- Cast Error (/:id syntax doesnt match exactly to what mongoose is looking for)
-
helmet {for security, to prevent possible attacks}
-
cors {cross origin resource sharing, for adding ability to access api with different domains/front-ends}
-
xss-clean {sanitizes the user input in body,params etc , prevent cross site scripting attacks}
-
express-rate-limit {limits the amount of requests that the user can make}