From a8acf8505232c3835ffbf0dbc016d093a9634441 Mon Sep 17 00:00:00 2001 From: Jack Foltz Date: Thu, 26 Jul 2018 21:52:47 -0400 Subject: [PATCH] Change wrap to only export itself --- app/routes/auth.js | 2 +- app/routes/upload.js | 2 +- app/util/requireAuth.js | 2 +- app/util/wrap.js | 6 ++++-- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/app/routes/auth.js b/app/routes/auth.js index 26ea4f3..349f7fd 100644 --- a/app/routes/auth.js +++ b/app/routes/auth.js @@ -10,7 +10,7 @@ const passport = require('passport'); const canonicalizeRequest = require('../util/canonicalize').canonicalizeRequest; const requireAuth = require('../util/requireAuth').requireAuth; -const wrap = require('../util/wrap.js').wrap; +const wrap = require('../util/wrap.js'); // Wraps passport.authenticate to return a promise function authenticate(req, res, next) { diff --git a/app/routes/upload.js b/app/routes/upload.js index 2f4b732..0278d0c 100644 --- a/app/routes/upload.js +++ b/app/routes/upload.js @@ -12,7 +12,7 @@ const fileUpload = multer({dest: config.get('Upload.path')}).single('file'); const fsPromises = require('fs').promises; const requireAuth = require('../util/requireAuth').requireAuth; -const wrap = require('../util/wrap.js').wrap; +const wrap = require('../util/wrap.js'); const generatedIdExists = async id => await Upload.countDocuments({id: id}) === 1; diff --git a/app/util/requireAuth.js b/app/util/requireAuth.js index fe7be9e..a1f21b1 100644 --- a/app/util/requireAuth.js +++ b/app/util/requireAuth.js @@ -1,5 +1,5 @@ const Key = require('../models/Key.js'); -const wrap = require('./wrap.js').wrap; +const wrap = require('./wrap.js'); const verifyScope = (scope, requiredScope) => scope.indexOf(requiredScope) !== -1; diff --git a/app/util/wrap.js b/app/util/wrap.js index f4dfb5a..dd57b0f 100644 --- a/app/util/wrap.js +++ b/app/util/wrap.js @@ -1,3 +1,5 @@ // Wraps an async middleware function to catch promise rejection -exports.wrap = fn => - (req, res, next) => Promise.resolve(fn(req, res, next)).catch(next); \ No newline at end of file +const wrap = fn => + (req, res, next) => Promise.resolve(fn(req, res, next)).catch(next); + +module.exports = wrap; \ No newline at end of file