-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
41 lines (29 loc) · 1005 Bytes
/
server.js
File metadata and controls
41 lines (29 loc) · 1005 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
37
38
39
40
41
// CONFIG
const express = require('express');
const app = express();
const connectDB = require('./config/db');
const dotenv = require('dotenv');
const verifyLogin = require('./middleware/verifyLogin');
const path = require('path');
require('./models/User');
require('./models/Post');
require('./models/Apps');
require('./models/Draft');
dotenv.config({ path: './config/config.env' });
app.use(express.json());
// app.use(express.);
// APP
const auth = require('./routes/auth');
const post = require('./routes/post');
const apps = require('./routes/apps');
app.use('/api/auth', auth);
app.use('/api/post', post);
app.use('/api/apps', apps);
// START
connectDB();
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')));
}
const PORT = process.env.PORT || 5000;
app.listen(PORT, console.log(`Server running in ${process.env.NODE_ENV} mode on port ${PORT}`))