forked from MedTech-CS425/Assignment-1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
26 lines (26 loc) · 844 Bytes
/
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
const express = require('express');
const dotenv = require('dotenv');
const cors = require('cors');
const connectDB = require('./config/db');
dotenv.config({ path: './config/config.env' });
connectDB();
const app = express();
app.use(cors());
app.use(express.json());
app.use('/api',require("./routes/auth"));
app.use('/api',require("./routes/list"));
app.use('/api',require("./routes/item"));
app.use('/api',require("./routes/category"));
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'))
);
}
// Server listening
const PORT = process.env.PORT || 5000;
app.listen(PORT, () =>
console.log(
`Your sample of MERN authentication is running at ${PORT} in ${process.env.NODE_ENV} environment`
)
);