Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
process.on('unhandledRejection', (error, promise) => {
console.error('unhandled promise rejection:', { // eslint-disable-line no-console
error,
promise,
});
});
app.use(koaMount('/healthcare', healthcare));
// XmlHttpRequest shim for IE
app.use(xdomainRoute);
// Security headers
app.use(koaHelmet());
app.use(koaHelmet.contentSecurityPolicy({ directives: { defaultSrc: ["'self'"] } }));
app.use(koaHelmet.frameguard('deny'));
app.use(koaCors({
credentials: true,
exposeHeaders: [
'Authorization',
'Content-Disposition',
'Content-Type',
'X-Entities',
],
allowHeaders: [
'Authorization',
'Content-Disposition',
'Content-Type',
'X-Entities',
],
allowMethods: [
'DELETE',
process.on('unhandledRejection', (error, promise) => {
console.error('unhandled promise rejection:', { // eslint-disable-line no-console
error,
promise,
});
});
app.use(koaMount('/healthcare', healthcare));
// XmlHttpRequest shim for IE
app.use(xdomainRoute);
// Security headers
app.use(koaHelmet());
app.use(koaHelmet.contentSecurityPolicy({ directives: { defaultSrc: ["'self'"] } }));
app.use(koaHelmet.frameguard('deny'));
app.use(koaCors({
credentials: true,
exposeHeaders: [
'Authorization',
'Content-Disposition',
'Content-Type',
'X-Entities',
],
allowHeaders: [
'Authorization',
'Content-Disposition',
'Content-Type',
'X-Entities',
],
allowMethods: [
'DELETE',
status: ctx.status,
error: err.message,
stack: err.stack,
err: err,
};
httpLogger.log('error', typeof ctx.request !== 'undefined' ? ctx.request.url : '', errorDetails);
});
// XmlHttpRequest shim for IE
app.use(xdomainRoute);
// Security headers
app.use(koaHelmet());
app.use(koaHelmet.csp({ directives: { defaultSrc: ["'self'"] } }));
app.use(koaHelmet.frameguard('deny'));
app.use(koaMount('/', koaCors({
credentials: true,
headers: [
'Authorization',
'Content-Disposition',
'Content-Type',
'X-Entities',
],
methods: [
'DELETE',
'GET',
'POST',
'PUT',
],
origin: (request) => {
const origin = request.get('origin');
status: ctx.status,
error: err.message,
stack: err.stack,
err: err,
};
httpLogger.log('error', typeof ctx.request !== 'undefined' ? ctx.request.url : '', errorDetails);
});
// XmlHttpRequest shim for IE
app.use(xdomainRoute);
// Security headers
app.use(koaHelmet());
app.use(koaHelmet.csp({ directives: { defaultSrc: ["'self'"] } }));
app.use(koaHelmet.frameguard('deny'));
app.use(koaMount('/', koaCors({
credentials: true,
headers: [
'Authorization',
'Content-Disposition',
'Content-Type',
'X-Entities',
],
methods: [
'DELETE',
'GET',
'POST',
'PUT',
],
origin: (request) => {
const origin = request.get('origin');
match: /^(?!\/api)(?!\/app)/ // ...everything except /api and /app
})
);
}
app.use(ResponseTime());
app.use(Conditional());
app.use(Etag());
// app.use(Morgan('combined'));
const koaBunyanLogger = require("koa-bunyan-logger");
app.use(koaBunyanLogger());
app.use(koaBunyanLogger.requestIdContext());
app.use(koaBunyanLogger.requestLogger());
app.use(helmet.frameguard());
app.use(helmet.xssFilter());
app.use(helmet.ieNoOpen());
app.use(Compress());
app.keys = config.cookieKeys;
// Signed-cookies session support
// app.use(session({
// maxage: null
// }, app));
app.use(BodyParser());
// turn errors into a JSON structure
app.use(async (ctx, next) => {