Skip to content

Commit

Permalink
use Async/Await over P->Then ✨ ..
Browse files Browse the repository at this point in the history
  • Loading branch information
3imed-jaberi committed May 27, 2020
1 parent cdf8d2d commit 887f8f3
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ function makePromise(multer, name) {
multer[name] = function() {
const middleware = Reflect.apply(fn, this, arguments);

return (ctx, next) => {
return new Promise((resolve, reject) => {
return async (ctx, next) => {
await new Promise((resolve, reject) => {
middleware(ctx.req, ctx.res, err => {
if (err) return reject(err);
if ('request' in ctx) {
Expand All @@ -58,7 +58,9 @@ function makePromise(multer, name) {

resolve(ctx);
});
}).then(next);
});

return next();
};
};
}
Expand Down

0 comments on commit 887f8f3

Please sign in to comment.