-
Notifications
You must be signed in to change notification settings - Fork 4
/
server.js
50 lines (36 loc) · 1.16 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
const express = require('express');
const app = express();
const cors = require('cors')
const controllers = require('./api/controllers');
const db = require('./api/models');
const connectDB = db.connectDB;
///setting up for socket io (when needed) -----
// const socketio = require("socket.io");
// const http = require("http");
// const server = http.createServer(app);
// const io = socketio(server);
///USER CONTROLLER(ROUTE)
const userController = require("./api/controllers/UserController");
connectDB();
const PORT = process.env.PORT || 5000;
///// MIDDLEWARE
app.use(express.urlencoded({ extended: false }));
app.use(express.json());
// ROUTES
app.use(cors()); /// if cors is required
app.get('/', (req, res) => {
res.send('API Running');
});
app.use('/api/kickoff', controllers.kickoff)
app.use('/user', userController);
//run when client connects
// io.on("connection", (socket) => {
// console.log("new ws connection...");
// });
app.listen(PORT, () => {
console.log(`Server on port ${PORT}`)
})
///CHANGING FROM APP.LISTEN TO SERVER.LISTEN BECUASE OF SOCKETIO
// server.listen(PORT, () => {
// console.log(`Server on port ${PORT}`)
// })