Skip to content

A fully functional API along with written documentation in Swagger, including sample usage for user registration and login. Additionally, this API allows for creating, deleting, and retrieving any jobs created by the user. The front-end is currently under development.

Notifications You must be signed in to change notification settings

ArturBuja/job-api

Repository files navigation

Live with docs:

https://artur-jobs-api-3d435f7a2f0a.herokuapp.com/

Setup

npm install && npm start

Database Connection

  1. Import connect.js
  2. Invoke in start()
  3. Setup .env in the root
  4. Add MONGO_URI with correct value

Routers

  • auth.js
  • jobs.js

User Model

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,}))$/

Register User

  • Validate - name, email, password - with Mongoose
  • Hash Password (with bcryptjs)
  • Save User
  • Generate Token
  • Send Response with Token

Login User

  • 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

Mongoose Errors

  • Validation Errors
  • Duplicate (Email)
  • Cast Error

Security

  • 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

About

A fully functional API along with written documentation in Swagger, including sample usage for user registration and login. Additionally, this API allows for creating, deleting, and retrieving any jobs created by the user. The front-end is currently under development.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published