-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
31 lines (27 loc) · 961 Bytes
/
index.js
File metadata and controls
31 lines (27 loc) · 961 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
30
31
// express
const express = require('express');
const app = express();
// inits
const path = require('path');
const bodyParser = require('body-parser');
const cors = require('cors');
// imports
const config = require('./configs/constants');
// mongoose.connect(config.url,{ useNewUrlParser: true, useUnifiedTopology: true , useFindAndModify: false},(err)=>{
// if(err){
// alert("Could not connect to the database" + err);
// console.log("Could not connect to the database" + err);
// }else{
// console.log("Connected to database "+ config.dbname);
// }
// });
app.use(cors({ origin: 'https://localhost:3000' }));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(express.static(__dirname+'/public'));
app.get('*',(req,res)=>{
res.sendFile(path.join(__dirname+'/public/index.html'));
});
app.listen(config.port, () => {
console.log(`Server started on port `, config.port);
});