-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
35 lines (24 loc) · 969 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
28
29
30
31
32
33
34
35
const express = require('express');
const connectDB = require('./config/db');
const app = express();
//Init Middleware
app.use(express.json({ extended: false }));
connectDB();
// app.get('/', (req, res) => res.send('API Running'));
// CORS Enabled
app.use((req, res, next) => {
res.set('ACCESS-CONTROL-ALLOW-ORIGIN', '*');
res.set('ACCESS-CONTROL-ALLOW-HEADERS', '*');
res.set('ACCESS-CONTROL-ALLOW-METHODS', '*');
next();
});
app.use(express.static(__dirname + '/Client/build'));
// Define Routes
app.use('/api/register', require('./routes/api/register'));
app.use('/api/posts', require('./routes/api/posts'));
app.use('/api/profile', require('./routes/api/profile'));
app.use('/api/login', require('./routes/api/login'));
app.use('/api/reference', require('./routes/api/reference'));
app.use('/api/offer', require('./routes/api/offer'));
const PORT = process.env.PORT || 5000;
app.listen(PORT, () => console.log(`server started on port ${PORT}`));