-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
46 lines (40 loc) · 1.17 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
// ES6 Imports (latest imports and to use we add module in package.json
import express from 'express';
import path from 'path';
// to resolve cors issue of backend eg. to run the different servers front and backend on localhost
import cors from 'cors';
import bodyParser from 'body-parser';
import dotenv from 'dotenv'
//components
// import Connection from './connection/db.js';
import Route from './routes/Route.js';
// import DefaultData from './default.js'
const port = process.env.PORT || 8000;
const app = express();
dotenv.config();
app.use(cors());
app.use(bodyParser.urlencoded({
extended: true
}));
app.use('/', Route);
// app.get('/', (req, res) => {
// res.sendFile(path.resolve('../Server/client/build/index.html'));
// });
// Heroku Deployment
// if (process.env.NODE_ENV === "production") {
// app.use(express.static("client/build"));
// app.get("*", (req, res) => {
// res.sendFile(path.resolve(__dirname, 'client', 'build', 'index.html'));
// });
// }
app.listen(port,
() => console.log(`Server is running successfully on PORT ${port}`));
//
/**
* Changed the name to frontend
*/
/**
* "engines": {
"node": "16.x"
}, in package.json
*/