@ot06/be-utils
Advanced tools
Comparing version 0.0.5 to 0.0.6
@@ -7,7 +7,2 @@ 'use strict'; | ||
exports.default = void 0; | ||
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } | ||
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } | ||
var expressMiddlewares = { | ||
@@ -19,28 +14,21 @@ asyncWrapper | ||
function asyncWrapper(_x) { | ||
return _asyncWrapper.apply(this, arguments); | ||
} | ||
function asyncWrapper(middleware) { | ||
return (request, response, next) => { | ||
if (response.body) { | ||
return process.nextTick(next); | ||
} | ||
function _asyncWrapper() { | ||
_asyncWrapper = _asyncToGenerator(function* (middleware) { | ||
return (request, response, next) => { | ||
if (response.body) { | ||
return process.nextTick(next); | ||
return Promise.resolve(middleware(request, response, next)).catch(error => { | ||
var responseBody; | ||
if (error.constructor.name === 'ResponseBody') { | ||
response.body = error; | ||
} else { | ||
response.error = error; | ||
} | ||
return Promise.resolve(middleware(request, response, next)).catch(error => { | ||
var responseBody; | ||
if (error.constructor.name === 'ResponseBody') { | ||
response.body = error; | ||
} else { | ||
response.error = error; | ||
} | ||
response.body = responseBody; | ||
next(); | ||
}); | ||
}; | ||
}); | ||
return _asyncWrapper.apply(this, arguments); | ||
response.body = responseBody; | ||
next(); | ||
}); | ||
}; | ||
} |
{ | ||
"name": "@ot06/be-utils", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"description": "Backend Utilities Module", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5636
105