express-jwt-guard2

0.1.2 • Public • Published

# express-jwt-guard2

An Expressjs route guard middleware function that checks for a web token and verifies it against a secret.

Requires a .env file in the root directory of the Express app with a SECRET key

SECRET=secretstring

Usage

const express = require('express');
const jwtGuard = require('express-jwt-guard2');
const router = express.Router();

router.use(jwtGuard);

router.get('/', (req, res) => {
    // router logic
    // no token --> returns 403 with message 'No token provided.'
    // invalid token --> returns 401 with message 'Failed to authenticate token.'
}

NPM Dependencies

  • dotenv
  • jsonwebtoken

Readme

Keywords

none

Package Sidebar

Install

npm i express-jwt-guard2

Weekly Downloads

2

Version

0.1.2

License

MIT

Unpacked Size

1.77 kB

Total Files

3

Last publish

Collaborators

  • ochsec