-
Notifications
You must be signed in to change notification settings - Fork 1
/
configure.ts
38 lines (29 loc) · 1.15 KB
/
configure.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env node
const bodyParser = require("body-parser")
const morgan = require("morgan")
const Sentry = require("@sentry/node")
module.exports = function (devServer) {
Sentry.init({
// Enable Sentry in production
// https://docs.sentry.io/development/sdk-dev/overview/#usage-for-end-users
dsn:
process.env.NODE_ENV === "production"
? "https://[email protected]/17"
: null,
})
// The request handler must be the first middleware on the app
devServer.app.use(Sentry.Handlers.requestHandler())
// Setup app
devServer.app.use("/api", require("./backend/api"))
devServer.app.use("/followups", require("./backend/followups"))
devServer.app.use(bodyParser.urlencoded({ extended: true, limit: "1024kb" }))
devServer.app.set("trust proxy", true)
// The error handler must be before any other error middleware and after all controllers
devServer.app.use(Sentry.Handlers.errorHandler())
if (devServer.app.get("env") == "development") {
devServer.app.use(morgan("dev"))
devServer.app.use(require("errorhandler")())
} else {
devServer.app.use(morgan("combined"))
}
}