@nlpjs/express-api-server
Advanced tools
Comparing version 4.6.1 to 4.8.0
{ | ||
"name": "@nlpjs/express-api-server", | ||
"version": "4.6.1", | ||
"version": "4.8.0", | ||
"description": "Express API Server", | ||
@@ -32,3 +32,3 @@ "author": { | ||
}, | ||
"gitHead": "34fc7dd0ef786606271b845f36802e80eec63e97" | ||
"gitHead": "3b9b3bf69aed462ba336a249e41e349440c61668" | ||
} |
@@ -47,2 +47,7 @@ /* | ||
); | ||
if (!this.settings.apiRoot) { | ||
this.settings.apiRoot = '/api'; | ||
} | ||
this.plugins = []; | ||
this.routers = []; | ||
} | ||
@@ -62,11 +67,21 @@ | ||
newRouter() { | ||
return express.Router(); | ||
} | ||
start(input = {}) { | ||
const port = input.port || this.settings.port; | ||
this.app = express(); | ||
this.app.use(cors()); | ||
this.app.use(express.urlencoded({ extended: false })); | ||
this.app.use(express.json()); | ||
for (let i = 0; i < this.plugins.length; i += 1) { | ||
this.app.use(this.plugins[i]); | ||
} | ||
if (this.settings.serveBot) { | ||
this.app.use(express.static(path.join(__dirname, './public'))); | ||
} | ||
this.app.use(cors()); | ||
this.app.use(express.urlencoded({ extended: false })); | ||
this.app.use(express.json()); | ||
for (let i = 0; i < this.routers.length; i += 1) { | ||
this.app.use(this.settings.apiRoot, this.routers[i]); | ||
} | ||
if (port && port > 0) { | ||
@@ -73,0 +88,0 @@ this.app.listen(port, () => { |
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
2255710
8840