@nlpjs/express-api-server
Advanced tools
Comparing version 4.19.8 to 4.21.0
{ | ||
"name": "@nlpjs/express-api-server", | ||
"version": "4.19.8", | ||
"version": "4.21.0", | ||
"description": "Express API Server", | ||
@@ -35,3 +35,3 @@ "author": { | ||
}, | ||
"gitHead": "49e973312ce0d74e38c6a7bec8610a7e50b4ec65" | ||
"gitHead": "e1938e389e4dc4e795d3223f8f01a50443118ea8" | ||
} |
@@ -27,2 +27,3 @@ /* | ||
const path = require('path'); | ||
const { logger } = require('@nlpjs/core'); | ||
@@ -49,6 +50,12 @@ class ExpressApiApp { | ||
if (this.settings.serveBot) { | ||
this.app.use(express.static(path.join(__dirname, './public'))); | ||
const clientPath = | ||
this.settings.clientPath || path.join(__dirname, './public'); | ||
logger.debug(`Serving bot client (path: ${clientPath}`); | ||
this.app.use(express.static(clientPath)); | ||
} | ||
for (let i = 0; i < this.routers.length; i += 1) { | ||
this.app.use(this.settings.apiRoot, this.routers[i]); | ||
const router = this.routers[i]; | ||
const routes = router.stack.map((layer) => layer.route.path); | ||
logger.debug(`Loading custom router: ${JSON.stringify(routes, null, 2)}`); | ||
this.app.use(this.settings.apiRoot, router); | ||
} | ||
@@ -55,0 +62,0 @@ return this.app; |
2257837
8894