-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
27 lines (19 loc) · 845 Bytes
/
server.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
//npm run server to start nodemon
const express = require('express');
const connectDB = require('./config/db');
const app = express();
//Call Connect to MongoDB
connectDB();
//Init Middleware
//Returns middleware that only parses json and only looks at requests where the Content-Type header matches the type option.
app.use(express.json({ extended: false }));
//Define routes //LHS route will replace route in RHS file
app.use('/api/users', require('./routes/api/users'));
app.use('/api/auth', require('./routes/api/auth'));
app.use('/api/profile', require('./routes/api/profile'));
app.use('/api/posts', require('./routes/api/posts'));
app.get('/', (req, res) =>
res.send('http://localhost:5000/ --> is my home page')
);
const port = process.env.PORT || 5000;
app.listen(port, () => console.log(`Server running on port ${port}`));