-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathroutes.js
37 lines (30 loc) · 949 Bytes
/
routes.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
/**
* Main application routes
*/
'use strict';
var config = require('./server/config');
var compression = require('compression');
var helmet = require('helmet');
module.exports = function (app) {
app.use(compression());
app.use(helmet());
//allows CrossDomainAccess to API
app.use(function (req, res, next) {
res.header('Access-Control-Allow-Origin', '*');
res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE');
res.header('Access-Control-Allow-Headers', 'Content-Type, Authorization');
if (next) {
next();
}
});
app.use('/search/', require('./server/service/search'));
app.use('/api/v1/', require('./server/service/api'));
//put all the routers here
app.get('/', function (req, res) {
res.status(200).render(app.get('views') + '/index.html');
});
// All other routes should redirect to error page
app.get('*', function (req, res) {
res.status(404).sendFile(app.get('views') + '/404.html');
});
};