-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
49 lines (42 loc) · 1.24 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
48
49
require('dotenv').config();
require('./services/apm');
const express = require('express');
const bodyParser = require('body-parser');
const shows = require('./routes/shows.route');
const profile = require('./routes/profile');
const scrapeSchedule = require('./services/showService');
const memberScrape = require('./services/membersService');
const auth = require('./routes/auth');
const buy = require('./routes/buy');
const topup = require('./routes/topup');
const cors = require('cors');
scrapeSchedule.schedule();
// memberScrape.membersScheduler();
const app = express();
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(cors());
app.use('/shows', shows);
app.use('/auth', auth);
app.use('/buy', buy);
app.use('/profile', profile);
app.use('/topup', topup);
// catch 404 and forward to error handler
app.use((req, res, next) => {
var err = new Error('Not Found');
err.status = 404;
next(err);
})
// error handler
app.use((err, req, res, next) => {
res.locals.message = err.message;
console.log(err);
res.status(err.status || 500);
res.send({
error: err
});
})
app.listen(process.env.APPLICATION_PORT, () => {
console.log(`listening to port ${process.env.APPLICATION_PORT}`)
})
module.exports = app