-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
39 lines (32 loc) · 1.15 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
const config = require('config');
const express = require('express');
const Sentry = require('@sentry/node');
const Tracing = require("@sentry/tracing");
const bp = require('body-parser');
const cors = require('cors');
const server = require('./bin/app/server');
const student = require('./bin/app/student');
const app = express();
app.use(bp.urlencoded({ extended: false }));
app.use(bp.json());
app.use(cors());
app.use(config.get('pathStudentEndpoint'), student);
app.use('/', server);
Sentry.init({
dsn: config.get('dnsSentryUrl'),
integrations: [
new Sentry.Integrations.Http({ tracing: true }),
new Tracing.Integrations.Express({ app }),
],
tracesSampleRate: 1.0,
});
app.use(Sentry.Handlers.requestHandler());
app.use(Sentry.Handlers.tracingHandler());
app.use(Sentry.Handlers.errorHandler());
app.listen(config.get('ports'), (err) => {
const ctx = "index-listenPort";
(!err) ? console.log(ctx, `[✔] Server running at http://localhost:${config.get('ports')}`, `running server` )
:
console.log(ctx, `[x] Something went wrong, msg:${err}`, `Failed running server` )
new Error({'ctx' : ctx, 'message' : err})
});