-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
44 lines (29 loc) · 1007 Bytes
/
app.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
const express = require('express')
const app = express();
const cors = require('cors')
const path = require('path')
//datebase
const mongoDB = require('./config/db')
mongoDB();
//CROSS ORGIGIN
app.use(cors())
//setting up the port
const port = process.env.PORT || 5000;
//Parsing incoming Date
app.use(express.json());
app.use(express.urlencoded({ extended: false }))
//middleware Route
app.use('/auth', require('./routes/auth'))
app.use('/register', require('./routes/register'))
app.use('/forgot', require('./routes/forgot'))
app.use('/reset', require('./routes/reset'))
app.use('/blog', require('./routes/blog/blog'))
//server static data (React)
if(process.env.NODE_ENV === 'production') {
app.use(express.static(path.join(__dirname+'\\client\\build')));
app.get('*' , (req, res) => {
res.sendFile(path.resolve(__dirname , 'client' , 'build' , 'index.html'))
})
}
console.log(__dirname+'\\client\\build')
app.listen(port, () => console.log('connected on port' + port))