Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const mockNoResponse = middleware (function mock() { return resolve (null); });
/* eslint-enable prefer-arrow-callback */
const resolveMiddlewareToFuture = async (ctx, next) => {
try {
return Future.resolve(await next())
} catch (error) {
if (error instanceof CustomError) {
return Future.reject(error)
}
// eslint-disable-next-line no-console
// console.error('error', error)
// ctx.app.emit('error', error, ctx)
return Future.reject(new InternalServerError(error))
}
}
const mock = middleware (_ => resolve (Next ({foo: 'bar'})));
const mockRes = {status: sinon.spy (), json: sinon.spy ()};
const mock = middleware (function mock() { return resolve (Json (200, {})); });
const mockNoFuture = middleware (function mock() { return null; });
module.exports = _ => resolve (Json (200, {foo: 'bar'}));
const mock = middleware (_ => resolve (Stream (201, 'jpeg', mockStream)));
const mockRes = {status: methodSpy (), type: methodSpy ()};
const mock = middleware (_ => resolve (Redirect (200, 'example.com')));
const mockRes = {redirect: sinon.spy ()};
const mock = middleware (_ => resolve (Json (200, {foo: 'bar'})));
const mockRes = {status: methodSpy (), json: methodSpy ()};
const mock = middleware (_ => resolve (Empty));
const mockRes = {status: methodSpy (), end: methodSpy ()};
.chainRej((error) =>
error instanceof AuthorizationError ? Future.resolve() : error,
)