Page MenuHomeDevCentral

D2189.id5508.diff
No OneTemporary

D2189.id5508.diff

diff --git a/app.js b/app.js
--- a/app.js
+++ b/app.js
@@ -20,4 +20,5 @@
module.exports = app;
-app.use('/', require('./routes'));
+const api_entry_point = process.env.API_ENTRY_POINT || '/datasources';
+app.use(api_entry_point, require('./routes'));
diff --git a/routes.js b/routes.js
--- a/routes.js
+++ b/routes.js
@@ -17,7 +17,7 @@
const datasources = [
{
- url: "dev/openfire/changelog",
+ url: "/dev/openfire/changelog",
controller: "/dev/openfire/changelog.js",
description: "Openfire changelog",
},
@@ -41,7 +41,7 @@
(protocol === "https" && port !== 443);
}
-function getUrl(req) {
+function getServerUrl(req) {
const port = app.get("port");
let url = req.protocol + "://" + req.hostname;
@@ -49,19 +49,18 @@
url += ":" + port;
}
- url += req.url;
-
return url;
}
-router.get('/', function(req, res) {
- let url = getUrl(req);
+router.get("/", function(req, res) {
+ const api_entry_point = process.env.API_ENTRY_POINT || '/datasources';
+ const url = getServerUrl(req) + api_entry_point;
res.send(JSON.stringify(formatDatasources(url)));
});
datasources.forEach(function (datasource) {
- router.get('/' + datasource.url, function (req, res) {
+ router.get(datasource.url, function (req, res) {
require("./controllers/" + datasource.controller)
.get(req, res);
});

File Metadata

Mime Type
text/plain
Expires
Tue, Nov 19, 15:25 (21 h, 34 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2251659
Default Alt Text
D2189.id5508.diff (1 KB)

Event Timeline