UNPKG

@ords/modules

Version:

Modules for ords-core microservices based upon proposals

38 lines (37 loc) 998 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const express = require("express"); /** * Express connector */ class ConnectorExpress { constructor() { /** * Maps that bind application logic */ this.maps = []; /** * Express instance */ this.einstance = express(); } /** * Start listening for incomming traffic */ listen(port, hostname) { // compile instance with routes for (let route of this.maps) { this.einstance.use(route); } // set the routes to undefined so that people will get an error tryign to add paths to late this.maps = undefined; // check if hostname specificed and watch on that if (hostname !== undefined) { this.einstance.listen(port, hostname); } else { this.einstance.listen(port); } } } exports.ConnectorExpress = ConnectorExpress;