-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathapp.js
executable file
·56 lines (45 loc) · 1.51 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
'use strict';
let express = require('express');
let path = require('path');
let cookieParser = require('cookie-parser');
let bodyParser = require('body-parser');
let request = require('request');
// let request = require('tiny-json-http'); //migrate soon
const API_URI = require('./bin/settings').TOPO_SERVICES_URI;
let index = require('./routes/index');
let app = express();
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: false}));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));
app.use(express.static('./public'));
app.use(express.static('./public/stylesheets'));
app.use(express.static('./public/images'));
app.use(express.static('./public/javascripts'));
app.use(express.static('./public/downloads'));
app.use('/', index);
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'ejs');
app.use(function(req, res) {
res.status(404).send();
});
console.log('GeoBoost2 Started Up');
console.log('Testing GeoBoost2 Services API:' + API_URI);
request.get(API_URI, function (error, response, body) {
if (error) {
console.error('GeoBoost2 API test failed: '+error);
}
else if (response && response.statusCode === 200) {
console.log('GeoBoost2 API test suceeded with response: '+body);
}
else {
let err = 'unknown';
let status = 'unknown';
if (response) {
err = body;
status = response.statusCode;
}
console.error('GeoBoost2 API test failed with status: '+status+'\nand message: '+err);
}
});
module.exports = app;