app.js 438 B

123456789101112131415161718
  1. 'use strict';
  2. const assert = require('assert');
  3. const MIDDLEWARE_NAME_JWT = 'jwt';
  4. module.exports = app => {
  5. const { config } = app;
  6. const index = config.appMiddleware.indexOf(MIDDLEWARE_NAME_JWT);
  7. assert.equal(
  8. index,
  9. -1,
  10. `Duplication of middleware name found: ${MIDDLEWARE_NAME_JWT}. Rename your middleware other than "${MIDDLEWARE_NAME_JWT}" please.`
  11. );
  12. config.appMiddleware.unshift(MIDDLEWARE_NAME_JWT);
  13. };