@uniorg/localneo
Advanced tools
Comparing version 1.4.0 to 1.5.0
{ | ||
"name": "@uniorg/localneo", | ||
"version": "1.4.0", | ||
"version": "1.5.0", | ||
"author": "m.schmale@uniorg.de", | ||
@@ -21,11 +21,15 @@ "license": "MIT", | ||
"scripts": { | ||
"lint": "standard" | ||
"lint": "standard", | ||
"test": "tape test/**/*.js test/*.js" | ||
}, | ||
"dependencies": { | ||
"ecstatic": "^2.1.0", | ||
"http-proxy": "^1.16.2" | ||
"ecstatic": "^3.2.0", | ||
"http-proxy": "^1.16.2", | ||
"open": "0.0.5" | ||
}, | ||
"devDependencies": { | ||
"standard": "^8.6.0" | ||
"standard": "^11.0", | ||
"tape": "^4.9.0", | ||
"tape-chai": "^1.1.0" | ||
} | ||
} |
@@ -18,3 +18,5 @@ # localneo | ||
"server": { | ||
"port": "12345" | ||
"port": "12345", | ||
"hostname": "localhost", | ||
"open": true | ||
}, | ||
@@ -21,0 +23,0 @@ "service": { |
const StaticDirectory = require('./StaticDirectory') | ||
class Application extends StaticDirectory { | ||
/** | ||
* @param {string} root root directory | ||
* @param {string} index index file / welcome file | ||
* @param {Router[]} subRoutes handlers for other resources | ||
*/ | ||
constructor ({ root, index, subRoutes }) { | ||
@@ -5,0 +10,0 @@ super({ root, index }) |
@@ -8,2 +8,4 @@ const fs = require('fs') | ||
const AppRegistry = require('./Registry') | ||
const OpenListener = require('./OpenListener') | ||
const TargetInfo = require('./TargetInfo') | ||
@@ -34,6 +36,6 @@ class MapReader { | ||
return { path, desc, target, name } | ||
return new TargetInfo({ path, desc, target, name }) | ||
}) | ||
return new Application({ | ||
const app = new Application({ | ||
subRoutes, | ||
@@ -43,2 +45,8 @@ index: this.neoApp.welcomeFile || 'index.html', | ||
}) | ||
if (this.dest.server && this.dest.server.open) { | ||
OpenListener.addTo(app) | ||
} | ||
return app | ||
} | ||
@@ -54,3 +62,3 @@ | ||
case 'application': | ||
if (!this.dest.applications || !this.dest.applications[targetInfo.name]) { | ||
if (!this.dest.applications || !this.dest.applications[ targetInfo.name ]) { | ||
console.error(`${this.name}: cannot find application definition for target ${targetInfo.name}`) | ||
@@ -64,3 +72,3 @@ if (reg.has('app:' + targetInfo.name)) { | ||
let app = this.getAppTarget(this.dest.applications[targetInfo.name]) | ||
let app = this.getAppTarget(this.dest.applications[ targetInfo.name ]) | ||
@@ -72,3 +80,3 @@ if (app) { | ||
case 'destination': | ||
if (!this.dest.destinations || !this.dest.destinations[targetInfo.name]) { | ||
if (!this.dest.destinations || !this.dest.destinations[ targetInfo.name ]) { | ||
console.error(`${this.name}: cannot find destination definition for target ${targetInfo.name}`) | ||
@@ -82,3 +90,3 @@ if (reg.has('dest:' + targetInfo.name)) { | ||
let dest = this.getDestTarget(this.dest.destinations[targetInfo.name], targetInfo, targetPath) | ||
let dest = this.getDestTarget(this.dest.destinations[ targetInfo.name ], targetInfo, targetPath) | ||
if (dest) { | ||
@@ -91,4 +99,4 @@ reg.put('dest:' + targetInfo.name, dest) | ||
let serviceConfig = {} | ||
if (this.dest && this.dest.service && this.dest.service[targetInfo.name]) { | ||
serviceConfig = this.dest.service[targetInfo.name] | ||
if (this.dest && this.dest.service && this.dest.service[ targetInfo.name ]) { | ||
serviceConfig = this.dest.service[ targetInfo.name ] | ||
} | ||
@@ -95,0 +103,0 @@ return ServiceFactory.create(targetInfo, targetPath, serviceConfig) |
const http = require('http') | ||
const EventEmitter = require('events') | ||
class Router { | ||
class Router extends EventEmitter { | ||
handle (request, response) { | ||
@@ -8,5 +9,8 @@ throw new Error('unimplemented') | ||
listen (port, hostname, backlog, callback) { | ||
listen (port, hostname) { | ||
this.server = http.createServer(this.handle.bind(this)) | ||
return this.server.listen.apply(this.server, arguments) | ||
return this.server.listen(port, hostname, undefined, () => { | ||
this.emit('listening', this.server) | ||
}) | ||
} | ||
@@ -13,0 +17,0 @@ } |
@@ -17,3 +17,3 @@ const Router = require('../Router') | ||
if (serviceConfig.version) { | ||
prefix += serviceConfig.version | ||
prefix += serviceConfig.version + '/' | ||
} | ||
@@ -20,0 +20,0 @@ } |
@@ -6,4 +6,6 @@ #!/usr/bin/env node | ||
app.listen(map.port, map.hostname, undefined, () => { | ||
console.log('Server listening on http://%s:%s/', app.server.address().address, app.server.address().port) | ||
app.on('listening', (server) => { | ||
console.log('Server listening on http://%s:%s/', server.address().address, server.address().port) | ||
}) | ||
app.listen(map.port, map.hostname) |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
48688
18
402
58
3
3
+ Addedopen@0.0.5
+ Addedecstatic@3.3.2(transitive)
+ Addedopen@0.0.5(transitive)
- Removedecstatic@2.2.2(transitive)
Updatedecstatic@^3.2.0