// view engine setup app.set("views", path.join(rootDir(), "views")) app.set("view engine", "jade") // The request handler must be the first middleware on the app app.use(Raven.requestHandler())
// uncomment after placing your favicon in /public app.use(favicon(path.join(rootDir(), "public", "favicon.png"))) app.use(logger("dev")) app.use(bodyParser.json()) app.use(bodyParser.urlencoded({ extended: false })) app.use(cookieParser(Config().session.secret))
app.use(express.static(path.join(rootDir(), "public"))) // Raven.context(function() {}) // all your stuff goes here app.use("/api/project", routes.project) app.use("/api", routes.api)
// The error handler must be before any other error middleware app.use(Raven.errorHandler()) // catch 404 and forward to error handler app.use(function(req, res, next) { const err = newError("Not Found") // @ts-ignore err.status = 404 next(err) })
// error handler app.use((err: Error, req: Request, res: Response, next: NextFunction) => { // set locals, only providing error in development res.locals.message = err.message res.locals.error = req.app.get("env") === "development" ? err : {} res.locals.sentryID = (res asany).sentry // render the error page // @ts-ignore res.status(err.status || 500)