-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.js
More file actions
44 lines (35 loc) · 1.17 KB
/
main.js
File metadata and controls
44 lines (35 loc) · 1.17 KB
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
const express = require('express');
const bodyParser = require("body-parser");
const cors = require("cors");
require('dotenv').config();
const app = express();
const db = require('./db');
const ObjectID = require('mongodb').ObjectID;
const http = require('http').createServer(app);
const io = require('socket.io')(http);
module.exports.io = io;
app.use(cors({origin: true, credentials: true}));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: true}));
app.get("/health", (req, res) => {
res.sendStatus(200);
});
const PORT = process.env.PORT || 3000;
console.log('Booting Service and Database');
db.Connect().then(_ => {
app.use('/auth', require('./routes/auth'));
app.use('/maps', require('./routes/maps'));
app.use('/systems', require('./routes/systems'));
app.emit('ready');
require('./cron');
});
const maps = db.Database().collection('maps');
const IsAuth = require('./middleware/auth');
app.get('/test', IsAuth, async (req, res) => {
res.sendStatus(200);
});
app.on('ready', function () {
http.listen(PORT, () => {
console.log(`Server is running on port ${PORT}.`);
});
});