forked from udyamwell/UdyamWell
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
43 lines (35 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
const dotenv = require('dotenv');
dotenv.config({path:'./config.env'})
const express = require('express');
const port = 8080;
const cors = require('cors');
const path = require('path');
// adding monggose
const errorHandler = require('./config/errorHandler')
const db = require('./config/mongoose').connect();
const app = express();
app.use(express.urlencoded({ extended: false }));
app.use(express.json());
const allowedOrigins = ['http://localhost:3000', 'https://udyamwell.azurewebsites.net']
app.use(cors()); // communicate with ui and backend
// use express router
app.use('/',require('./routes'));
app.use(errorHandler);
app.set('view engine', 'ejs');
app.set('views','./views');
// app.use('/uploads',express.static('./uploads'));
app.use('/uploads',express.static(__dirname +'/uploads'))
app.use(express.static('./frontend/build'));
// app.post('/register',(req,res)=>{
// res.send("I am live");
// });
app.get("*", (req, res) => {
res.sendFile(path.resolve(__dirname, "frontend", "build", "index.html"));
})
app.listen(port,(err)=>{
if(err){
console.log(`Error: ${err}`);
return;
}
console.log(`Server is running at port: ${port}`);
});