-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
47 lines (36 loc) · 1.37 KB
/
index.js
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
39
40
41
42
43
44
45
46
47
import './middleware/instrument.js'
import * as Sentry from '@sentry/node';
import express from 'express'
import booksRouter from './routes/books.js'
import recordsRouter from './routes/records.js'
import loginRouter from './routes/login.js'
import log from './middleware/logMiddleware.js'
import 'dotenv/config';
const app = express();
// RequestHandler creates a separate execution context for each request
//app.use(Sentry.Handlers.requestHandler());
// Configure middleware and routing
app.use(express.json());
app.use(log);
// All controllers (routers) should live here
app.use('/books', booksRouter);
app.use('/records', recordsRouter);
app.use('/login', loginRouter);
app.get('/', (req, res) => {
res.send("Hello World!");
});
// RequestHandler creates a separate execution context, so that all
// transactions/spans/breadcrumbs are isolated across requests
//app.use(Sentry.Handlers.requestHandler());
// TracingHandler creates a trace for every incoming request
//app.use(Sentry.Handlers.tracingHandler());
// The error handler must be before any other error middleware and after all controllers
//app.use(Sentry.Handlers.errorHandler());
//app.use(errorHandler);
app.get("/debug-sentry", function mainHandler(req, res) {
throw new Error("My first Sentry error!");
});
// Start the server
app.listen(3000, () => {
console.log('Server is listening on port 3000')
})