-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
36 lines (26 loc) · 925 Bytes
/
Copy pathindex.js
File metadata and controls
36 lines (26 loc) · 925 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
32
33
34
35
36
require('dotenv').config();
const connectTomongo = require('./db')
const express = require('express')
var cors = require('cors')
var app = express()
const path = require("path");
app.use(cors());
connectTomongo();
const port = process.env.PORT|| 5000 //because on port 3000 react app will run
app.use(express.json())
console.log(process.env.NODE_ENV);
// app.use(express.static("public"));
//Available routes
app.use('/api/auth', require('./routes/auth'))
app.use('/api/notes', require('./routes/notes'))
app.use('/api/contact', require('./routes/contact'))
// app.get('/',(req,res)=>{res.send("hii");})
if (process.env.NODE_ENV === 'production') {
app.use(express.static( 'client/build' ));
app.get('*', (req, res) => {
res.sendFile(path.join(__dirname, 'client', 'build', 'index.html')); // relative path
});
}
app.listen(port, () => {
console.log(`iNotebook backend listening on port ${port}`)
})