Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export default function (router) {
// What's this?
// This trick lets us construct an API for each request.
// That means that it may store request-local state.
const api = makeInvoker(makeFunctionalApi)
// router is a KoaRouter.
router
.get('/api/functional', api('getStuff'))
.post('/api/functional', api('postStuff'))
}
ctx.request.rawBody || ''
);
const cookies = response.cookies;
if (cookies.length > 0) {
ctx.set('set-cookie', cookies);
}
ctx.status = response.status;
ctx.set(response.headers);
ctx.body = response.body;
}
}
const handler = makeInvoker(RequestHandler);
export const respondToRequest = handler('respondToRequest');