Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import router from './routes';
import { readAssets } from './middleware/readAssets';
import serverErrorHandling from './middleware/serverErrorHandling';
import accessLog from './middleware/accessLog';
import initLogger from './middleware/initLogger';
import serveStatic from './middleware/serveStatic';
import sniffLocale from './middleware/sniffLocale';
const app = new Koa();
app
// add logger to context
.use(initLogger)
.use(accessLog)
.use(serverErrorHandling)
.use(cookiesMiddleware())
.use(bodyParser())
.use(sniffLocale)
.use(serveStatic)
.use(readAssets)
.use(router.routes());
if (process.env.NODE_ENV === 'production') {
app.on('error', err => {
Raven.captureException(err, (err, eventId) => {
console.log('Reported error ' + eventId);
});
});
}
app.listen(3001);