1.0.12 • Published 5 months ago

@shahedofficial/expresscommon v1.0.12

Weekly downloads
-
License
ISC
Repository
-
Last release
5 months ago

Personal use for express (nodejs) project

MiddleWare

error-handler

Catch Error from error handler

request validation

catch request validation error , filtered by Express validator throw 400 error if not valid

current user

check if user have valid JSON Web Token (JWT) payload, if not throw 401 unauthorized error

require auth

Check if user is logged in, if false throw 401 unauthorized error

Error Handler

  1. BadRequestError ( throw 400)
  2. DatabaseConnectionError ( throw 500)
  3. NotAuthorizedError ( throw 401)
  4. NotFoundError ( throw 404)
  5. RequestValidationError ( throw 400)

Password service ( Class Password)

  1. toHash method to generated hashed password
  2. Compare method to compare password to hashed password