forked from bradtraversy/react_webpack_starter
-
Notifications
You must be signed in to change notification settings - Fork 1
/
server.js
32 lines (23 loc) · 962 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
const express = require('express');
const cors = require('cors');
const app = express();
const port = process.env.PORT || 3000;
const mongoose = require('mongoose');
const reviewController = require('./router/controllers/reviewControllers');
const clothesController = require('./router/controllers/clothesController');
const dbKey = require('./config.js').dbKey;
const bodyParser = require('body-parser');
mongoose.connect(
dbKey,
() => console.log('Connected')
);
app.use(cors())
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.get('/reviews', reviewController.getReviews);
app.post('/reviews', reviewController.addReview);
app.get('/clothes', clothesController.getClothes);
app.post('/clothes', clothesController.addClothes);
app.delete('/clothes', clothesController.deleteClothes);
app.get('/clothes/id?:id', clothesController.findGarment);
app.listen(port, () => console.log(`Listening on port ${port}....`));