-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
56 lines (48 loc) · 1.64 KB
/
server.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
50
51
52
53
54
55
56
const express = require('express');
const Cors = require('cors');
const bodyParser = require('body-parser');
const passport = require('passport');
const fileUpload = require('express-fileupload');
const app = express();
const API_PORT = process.env.API_PORT || 3001;
const API_ADDRESS = process.env.API_ADDRESS || 'localhost';
require('./auth/passport');
app.use(Cors());
app.use(bodyParser.urlencoded({extended: false}));
app.use(bodyParser.json());
app.use(passport.initialize());
app.use(express.static('public'));
app.use(fileUpload({
limits: { fileSize: 50 * 1024 * 1024 },
}));
require('./routes/user/loginUser')(app);
require('./routes/user/registerUser')(app);
require('./routes/user/forgotPassword')(app);
require('./routes/user/resetPassword')(app);
require('./routes/user/updatePassword')(app);
require('./routes/user/updatePasswordViaEmail')(app);
require('./routes/user/findUsers')(app);
require('./routes/user/deleteUser')(app);
require('./routes/user/updateUser')(app);
require('./routes/game/getGames')(app);
require('./routes/game/getGame')(app);
require('./routes/game/updateGame')(app);
require('./routes/game/insertGame')(app);
require('./routes/game/fileUpload')(app);
require('./routes/game/deleteGame')(app);
require('./routes/tierlist/getTierList')(app);
require('./routes/tierlist/addTierList')(app);
require('./routes/tierlist/updateTierList')(app);
app.listen(API_PORT, () => {
console.log(`Listening on ${API_ADDRESS}:${API_PORT}`);
});
//Default error handling
app.use((error, req, res, next) => {
res.status(error.status || 500);
res.json({
error: {
message: error.message
}
});
});
module.exports = app;