Skip to content

A job Api allowing users to register, log in, create jobs and see their jobs

Notifications You must be signed in to change notification settings

udodinho/job-app-ts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Setup

npm install && npm run dev

Database Connection

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

Routers

  • auth-route.ts
  • job-route.ts

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 - in auth-middleware with yup
  • Hash Password (with bcryptjs)
  • Save User
  • Generate Token
  • Send Response with Token

Login User

  • Validate - email, password - in auth-middleware
  • 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

About

A job Api allowing users to register, log in, create jobs and see their jobs

Resources

Stars

Watchers

Forks