- ProdURL endpoint: https://jobs-api-pd07.onrender.com
- Register user: ProdURL/api/v1/auth/register (POST)
- Login user: ProdURL/api/v1/auth/login (POST)
- Create job: ProdURL/api/v1/jobs (POST)
- Get all jobs: ProdURL/api/v1/jobs (GET)
- Get single job: ProdURL/api/v1/jobs/:jobId (GET)
- Update job: ProdURL/api/v1/jobs/:jobId (PATCH)
- Delete job: ProdURL/api/v1/jobs/:jobId (DELETE)
Hosted on render.com (initial deployment: 13-Dec-24)
In order to spin up the project locally, in the root create .env with these two variables, with your own values.
MONGO_URI JWT_SECRET JWT_LIFETIME
After that run this command
npm install && npm start
Note: for better local dev experience, change the start script command in package.json to nodemon app.js
- 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 (required property in schema)
- Duplicate (Email - unique property in schema)
- Cast Error (when id syntax doesn't match what mongoose is looking for)
- helmet (sets various http headers to prevent numerous attacks)
- cors (ensures our api is accessible from other domains)
- xss-clean (santizes user input in req.body, req.query, req.param and protects from cross-site scripting attack)
- express-rate-limit (limit the amount of request the user can make)