diff --git a/types/server.js b/types/server.js index ceb3d8d..5150f3e 100644 --- a/types/server.js +++ b/types/server.js @@ -91,6 +91,7 @@ class FabricHTTPServer extends Service { components: {}, middlewares: {}, redirects: {}, + routes: [], services: { audio: { address: '/devices/audio' @@ -347,6 +348,14 @@ class FabricHTTPServer extends Service { console.warn('[FABRIC:EDGE]', (new Date().toISOString()), content); } + _addAllRoutes () { + for (let i = 0; i < this.settings.routes.length; i++) { + this._addRoute(this.settings.routes[i]); + } + + return this; + } + _registerMethod (name, method) { this.methods[name] = method.bind(this); } @@ -862,6 +871,8 @@ class FabricHTTPServer extends Service { // NOTE: see `this.express.use(express.static('assets'));` this.express.get('/', this._handleIndexRequest.bind(this)); + this._addAllRoutes(); + // handle custom routes. // TODO: abolish this garbage in favor of resources. for (let i = 0; i < this.customRoutes.length; i++) {