-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
37 lines (29 loc) · 922 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
require('dotenv').config();
const express = require('express')
const cors = require('cors')
const app = express();
const server = require('http').Server(app)
const io = require('socket.io')(server, {
cors: {
origin: "*"
}
});
// Create Database if not exists
require('./backend/models/models.js')();
// Middlewares
app.use(express.static("./public"));
app.use(express.json());
// Cross Origin Resource Sharing
var corsOptions = {
origin: '*',
optionsSuccessStatus: 200
}
app.use(cors(corsOptions));
// Routes
app.use('/register', require('./backend/routes/register'));
app.use('/login', require('./backend/routes/login'));
app.use((req, res) => res.status(404).send({ status: "fail", message: "PAGE NOT FOUND"}));
// Sockets
require('./backend/sockets/sockets')(io);
const PORT = process.env.PORT || 8080;
server.listen(PORT, console.log(`Server running at http://localhost:${PORT}...`));