-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
47 lines (35 loc) · 1.05 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
const express = require("express");
const routes = require("./src/routes/index");
const cors = require('cors');
const bodyParser = require('body-parser');
const http = require('http');
const logger = require('./src/utils/logger');
const Server = require('socket.io').Server
const { socketOrder } = require('./src/sockets/order.socket')
const app = express()
// setup the http server and socketio config
const httpServer = http.createServer(app);
const io = new Server(httpServer , { cors: {
origin : "https://smash-food.netlify.app"
}});
socketOrder(io);
// json parser
app.use(bodyParser.urlencoded({extended: true}));
// cors to be changed later
app.use(cors())
app.options('*', cors());
//upload
app.use(express.static("uploads"));
app.use(express.json());
//route
app.use('/api', routes);
app.get('*', function(req, res){
res.status(404).send({ Message: 'Not found'})
});
const port = process.env.PORT || 3000
httpServer.listen(port, () => {
logger.info(`Listening to port 3000`);
console.log(
`Listening to port 3000`
);
});