forked from recipe-hack/hackathon-or-something
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
29 lines (24 loc) · 844 Bytes
/
server.js
File metadata and controls
29 lines (24 loc) · 844 Bytes
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
const express = require('express');
const http = require('http');
const bodyParser = require('body-parser');
const cors = require('cors');
const app = express();
const path = require('path');
const { routes } = require('./api/routes/routes');
const corsOptions = {
origin: true,
methods: 'GET, HEAD, PUT, PATCH, POST, DELETE',
preflightContinue: true,
optionsSuccessStatus: 204,
credentials: true // enable set cookie
};
// const port = process.env.PORT || '5000';
// app.set('port', port);
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
app.use(cors(corsOptions));
app.use(express.static(path.join(__dirname, 'frontend/build')));
routes(app);
// const server = http.createServer(app);
// server.listen(port, () => console.log(`Running on path: ${port}`));
app.listen(process.env.PORT || 5000);