-
-
Notifications
You must be signed in to change notification settings - Fork 164
/
app.js
31 lines (20 loc) · 935 Bytes
/
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
var app = require('express')();
var peliasConfig = require( 'pelias-config' ).generate(require('./schema'));
if( peliasConfig.api.accessLog ){
app.use( require( './middleware/access_log' ).createAccessLogger( peliasConfig.api.accessLog ) );
}
/** ----------------------- pre-processing-middleware ----------------------- **/
app.use( require('./middleware/headers') );
app.use( require('./middleware/cors') );
app.use( require('./middleware/robots') );
app.use( require('./middleware/options') );
app.use( require('./middleware/jsonp') );
/** ----------------------- routes ----------------------- **/
var defaultRoutes = require('./routes/default');
defaultRoutes.addRoutes(app);
var v1 = require('./routes/v1');
v1.addRoutes(app, peliasConfig);
/** ----------------------- error middleware ----------------------- **/
app.use( require('./middleware/404') );
app.use( require('./middleware/500') );
module.exports = app;