-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
43 lines (33 loc) · 1.09 KB
/
app.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
36
37
38
39
40
41
42
43
'use strict'
const path = require('path');
const express = require('express');
const bodyParser = require('body-parser');
const cors = require('cors');
const compression = require('compression');
const authMiddleware = require('./src/middlewares/authMiddleware');
const v1GiftController = require('./src/controllers/v1/giftControllers');
const v2GiftController = require('./src/controllers/v2/giftControllers');
const app = express();
// Set up the routing.
var v1 = express.Router();
var v2 = express.Router();
const router = express.Router()
if (process.env.NODE_ENV === 'test') {
} else {
router.use(compression())
}
app.use(express.static(__dirname + '/public'));
//v1.use();
v1.use(cors())
v1.use(bodyParser.json())
v1.use(bodyParser.urlencoded({ extended: true }))
v2.use(authMiddleware);
v2.use(cors())
v2.use(bodyParser.json())
v2.use(bodyParser.urlencoded({ extended: true }))
v1.get('/gifts', v1GiftController.getGifts);
v1.get('/gifts/:giftId', authMiddleware, v1GiftController.getGiftById);
v2.get('/gifts', v2GiftController.getGifts)
app.use('/v1', v1);
app.use('/v2', v2);
module.exports = app