forked from IGNF/apicarto
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
81 lines (60 loc) · 2.34 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
const path = require('path');
const express = require('express');
const bodyParser = require('body-parser');
const cors = require('cors');
var app = express();
/*------------------------------------------------------------------------------
* common middlewares
------------------------------------------------------------------------------*/
var env = process.env.NODE_ENV;
if (env === 'production') {
// see http://expressjs.com/fr/guide/behind-proxies.html
app.enable('trust proxy');
}
app.use(bodyParser.json());
app.use(cors());
app.use(function (req, res, next) {
res.header('Cache-Control', 'private, no-cache, no-store, must-revalidate');
res.header('Expires', '-1');
res.header('Pragma', 'no-cache');
next();
});
app.use(require('./middlewares/request-logger')());
/*------------------------------------------------------------------------------
* /api/doc - expose documentation
-----------------------------------------------------------------------------*/
app.set('view engine', 'ejs');
app.set('views', path.join(__dirname, '/doc/views'));
app.use(
'/api/doc/vendor/swagger-ui',
express.static(__dirname + '/node_modules/swagger-ui-dist')
);
app.use('/api/doc', express.static(__dirname + '/doc'));
app.get('/api/doc',function(req,res){
res.render('index',{datasets: require('./datasets')});
});
app.get('/api/doc/:moduleName', function(req,res){
res.render('module',{moduleName: req.params.moduleName});
});
/* -----------------------------------------------------------------------------
* Routes
-----------------------------------------------------------------------------*/
/* Module cadastre */
app.use('/api/cadastre',require('./controllers/cadastre'));
/* Module AOC */
app.use('/api/aoc',require('./controllers/aoc'));
/* Module code postaux */
app.use('/api/codes-postaux', require('./controllers/codes-postaux'));
/* Module GPU */
app.use('/api/gpu',require('./controllers/gpu'));
/* Module RPG */
app.use('/api/rpg',require('./controllers/rpg'));
/* Module Nature */
app.use('/api/nature',require('./controllers/nature'));
/* Module all module IGN */
app.use('/api/wfs-geoportail',require('./controllers/wfs-geoportail'));
/* Module Espace Revendeur */
app.use('/api/er',require('./controllers/er'));
/* Module Dreal Corse */
app.use('/api/corse/',require('./controllers/corse'));
module.exports = app;