1
0
mirror of https://github.com/Foltik/Shimapan synced 2025-01-05 15:58:03 -05:00

Change wrap to only export itself

This commit is contained in:
Jack Foltz 2018-07-26 21:52:47 -04:00
parent 7441eaaf02
commit a8acf85052
Signed by: foltik
GPG Key ID: 303F88F996E95541
4 changed files with 7 additions and 5 deletions

View File

@ -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) {

View File

@ -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;

View File

@ -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;

View File

@ -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);
const wrap = fn =>
(req, res, next) => Promise.resolve(fn(req, res, next)).catch(next);
module.exports = wrap;