@nlpjs/express-api-server
Advanced tools
Comparing version 4.23.4 to 4.25.0
{ | ||
"name": "@nlpjs/express-api-server", | ||
"version": "4.23.4", | ||
"version": "4.25.0", | ||
"description": "Express API Server", | ||
@@ -28,3 +28,3 @@ "author": { | ||
"dependencies": { | ||
"@nlpjs/core": "^4.23.4", | ||
"@nlpjs/core": "^4.25.0", | ||
"cors": "^2.8.5", | ||
@@ -36,3 +36,3 @@ "express": "^4.17.1" | ||
}, | ||
"gitHead": "ad0a639c4cd58735903a21272f7a04a8ace886ab" | ||
"gitHead": "3065165b42ea2160d2a27c10c412c4b4c491332a" | ||
} |
@@ -25,2 +25,4 @@ /* | ||
const { defaultContainer, Clonable } = require('@nlpjs/core'); | ||
const http = require('http'); | ||
const https = require('https'); | ||
const ExpressApiApp = require('./express-api-app'); | ||
@@ -79,8 +81,36 @@ | ||
if (port && port > 0) { | ||
this.server = this.app.listen(port, () => { | ||
if (!port || port < 1) { | ||
return false; | ||
} | ||
let expressServer; | ||
const fs = this.container.get('fs'); | ||
let protocol = ''; | ||
if (this.settings.key || this.settings.cert) { | ||
try { | ||
expressServer = https.createServer( | ||
{ | ||
key: fs.readFileSync(this.settings.key), | ||
cert: fs.readFileSync(this.settings.cert), | ||
}, | ||
this.app | ||
); | ||
protocol = 'https'; | ||
} catch (error) { | ||
this.container.get('log').error('Error inititlising HTTPS server'); | ||
throw error; | ||
} | ||
} else { | ||
expressServer = http.createServer(this.app); | ||
protocol = 'http'; | ||
} | ||
this.server = expressServer.listen.apply(expressServer, [ | ||
port, | ||
() => { | ||
const logger = this.container.get('logger'); | ||
logger.info(`${this.settings.tag} listening on port ${port}!`); | ||
}); | ||
} | ||
logger.info( | ||
`${this.settings.tag} listening on port ${port} using ${protocol}!` | ||
); | ||
}, | ||
]); | ||
return this.server !== null; | ||
@@ -87,0 +117,0 @@ } |
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
Network access
Supply chain riskThis module accesses the network.
Found 2 instances 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
2258539
8929
2
Updated@nlpjs/core@^4.25.0