2.1.0 • Published 3 days ago

padlock-auth v2.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 days ago

🔒 padlock-auth

Middleware & Services to implement token creation & validation for express app.

🚀 Quick start

  1. Install the package:
npm install padlock-auth
  1. create the .env file in the project root:
touch .env
  1. define the JWT_SECRET_KEY variable in the .env file:
JWT_SECRET_KEY = "<your-random-string>"
  1. Set the middleware for all protected routes:
router.post('/api/users', verifyTokenMiddleware, createUserController);
  1. Create the token where you need it:
const token = Token.create({ userId: user.id });
  1. (Optional) define the time the token will expire in the .env file (by default expires in 2 hours):
JWT_EXPIRES_IN = '2h'
  1. (Optional and not recomendable) define if you want to disable the token verification in the .env file:
VERIFY_TOKEN = 'false'
2.1.0

3 days ago

2.0.0

1 month ago

1.0.4

2 months ago

1.0.3

2 months ago

1.0.2

2 months ago

1.0.1

2 months ago

1.0.0

2 months ago