-
Notifications
You must be signed in to change notification settings - Fork 3
/
app.js
38 lines (31 loc) · 786 Bytes
/
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
require('dotenv').config();
const express = require('express');
const bodyParser = require('body-parser');
const cors = require('cors');
const game = require('./controllers/game');
const config = require('./config');
const app = express();
const port = process.env.PORT || 4000;
app.use(
cors({
origin: '*',
methods: 'GET,HEAD,PUT,PATCH,POST,DELETE',
preflightContinue: false,
optionsSuccessStatus: 204,
})
);
app.post(
'/game/scores',
cors({
origin: config.game.telegram_origin,
methods: 'GET,HEAD,PUT,PATCH,POST,DELETE',
preflightContinue: false,
optionsSuccessStatus: 204,
}),
bodyParser.json(),
game.scores.bind(game)
);
app.listen(port, () => {
console.log(`App listening on ${port}`);
const { bot } = require('./bot');
});