From 5ab2ece9de04c4ca4b3ac84df749b72b822fc653 Mon Sep 17 00:00:00 2001 From: "@jotadeveloper" <@jotadeveloper> Date: Wed, 23 May 2018 21:44:33 +0200 Subject: [PATCH] feat: add audit quick endpoint --- plugins/audit/src/index.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/plugins/audit/src/index.js b/plugins/audit/src/index.js index 1ba4b5e8..266fdfb3 100644 --- a/plugins/audit/src/index.js +++ b/plugins/audit/src/index.js @@ -40,18 +40,23 @@ export default class ProxyAudit { return fetchAu; }; - /* eslint new-cap:off */ - const router = express.Router(); - /* eslint new-cap:off */ - router.use(compression()); - router.use(bodyParser.json({ strict: false, limit: '50mb' })); - router.post('/audits', (req: $RequestExtend, res: $ResponseExtend) => { + + const handleAudit = (req: $RequestExtend, res: $ResponseExtend) => { if (this.enabled) { fetchAudit(req, res); } else { res.status(500).end(); } - }); + }; + + /* eslint new-cap:off */ + const router = express.Router(); + /* eslint new-cap:off */ + router.use(compression()); + router.use(bodyParser.json({ strict: false, limit: '50mb' })); + router.post('/audits', handleAudit); + + router.post('/audits/quick', handleAudit); app.use('/-/npm/v1/security', router); }