1.0.12 • Published 5 months ago
@shahedofficial/expresscommon v1.0.12
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
- BadRequestError ( throw 400)
- DatabaseConnectionError ( throw 500)
- NotAuthorizedError ( throw 401)
- NotFoundError ( throw 404)
- RequestValidationError ( throw 400)
Password service ( Class Password)
- toHash method to generated hashed password
- Compare method to compare password to hashed password