All files / app/routes/auth/token token-router.ts

84.62% Statements 11/13
100% Branches 0/0
0% Functions 0/1
84.62% Lines 11/13

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 321x 1x 1x 1x 1x 1x   1x 1x   1x               1x                       1x  
import * as express from 'express';
import tokenController from './token-controller';
import {postLoginJwtValidator} from '@app/routes/auth/jwt/jwt-util';
import debug from 'debug';
import config from '@config';
import expressJwt from 'express-jwt';
 
const log = debug('group-car:token');
const router: express.Router = express.Router();
 
const tokenLogger: express.RequestHandler = (req, res, next) => {
  log('IP %s requested login per token', req.ip);
  next();
};
 
/**
 * Add handler to chain.
 */
router.put('/',
    expressJwt({
      secret: config.jwt.secret,
      getToken: config.jwt.getToken,
      algorithms: ['HS512'],
      requestProperty: 'auth',
    }),
    postLoginJwtValidator,
    tokenLogger,
    tokenController,
);
 
export default router;