-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathapp.js
48 lines (39 loc) · 1.48 KB
/
app.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
48
const express = require('express');
const logger = require('morgan');
const redis = require('async-redis');
const Sentry = require('@sentry/node');
const Tracing = require('@sentry/tracing');
const indexRouter = require('./routes/index');
const channelRouter = require('./routes/channel');
const clipRouter = require('./routes/clip');
const spiderRouter = require('./routes/spider');
const viewerRouter = require('./routes/viewer');
const offCommentsRouter = require('./routes/off_comments');
const app = express();
Sentry.init({
dsn: process.env.SentryDSN,
integrations: [
new Sentry.Integrations.Http({tracing: true}),
new Tracing.Integrations.Express({app}),
new Tracing.Integrations.Postgres()
],
tracesSampleRate: 0.01,
});
app.use(Sentry.Handlers.requestHandler());
app.use(Sentry.Handlers.tracingHandler());
app.use(Sentry.Handlers.errorHandler());
console.log(`Authorization is:${process.env.Authorization}, Sentry dsn: ${process.env.SentryDSN}, recaptcha site key: ${process.env.recaptcha}`);
app.locals.redis_client = redis.createClient({
url: process.env.REDIS_URL
});
// noinspection JSCheckFunctionSignatures
app.use(logger("short"));
app.use(express.json({limit: '500mb'}));
app.use(express.urlencoded({extended: false}));
app.use('/', indexRouter);
app.use('/channel', channelRouter);
app.use('/clip', clipRouter);
app.use('/spider', spiderRouter);
app.use('/viewer', viewerRouter);
app.use('/off_comments', offCommentsRouter);
module.exports = app;