@ikoabo/server
Advanced tools
Comparing version 1.1.15 to 1.1.16
# CHANGELOG | ||
## [1.1.16] - 2020-11-11 | ||
- Adding conditional body request log | ||
- Adding conditional body response log | ||
- Add slave hook to dispatch actions before routes initialization | ||
## [1.1.15] - 2020-11-02 | ||
@@ -4,0 +9,0 @@ - Adding GeoJSON date model |
@@ -9,2 +9,3 @@ /// <reference types="node" /> | ||
preExpress?: () => Promise<void>; | ||
preRoutes?: (app: express.Application) => Promise<void>; | ||
postExpress?: (app: express.Application) => Promise<void>; | ||
@@ -11,0 +12,0 @@ running?: () => Promise<void>; |
@@ -142,3 +142,3 @@ "use strict"; | ||
return new Promise((resolve) => { | ||
server.initExpress(cluster_1.default.worker, routes).then(resolve); | ||
server.initExpress(cluster_1.default.worker, this._slaveHooks.preRoutes, routes).then(resolve); | ||
}); | ||
@@ -145,0 +145,0 @@ } |
@@ -14,3 +14,3 @@ /// <reference types="node" /> | ||
initMongo(): Promise<any>; | ||
initExpress(worker?: any, routes?: any): Promise<void>; | ||
initExpress(worker?: any, preRoutes?: any, routes?: any): Promise<void>; | ||
get app(): express.Application; | ||
@@ -17,0 +17,0 @@ use(middleware: any, route?: any): void; |
@@ -59,3 +59,3 @@ "use strict"; | ||
} | ||
initExpress(worker, routes) { | ||
initExpress(worker, preRoutes, routes) { | ||
return new Promise((resolve) => { | ||
@@ -98,16 +98,22 @@ this._worker = worker; | ||
on_finished_1.default(res, (err, resp) => { | ||
const request = { | ||
method: req.method, | ||
url: req.originalUrl, | ||
headers: req.headers | ||
}; | ||
const response = { | ||
status: resp.statusCode, | ||
message: resp.statusMessage | ||
}; | ||
if (process.env.BODY_TRACE) { | ||
request["body"] = req.body; | ||
} | ||
if (process.env.RESPONSE_TRACE) { | ||
response["body"] = resp.locals; | ||
} | ||
const requestTrace = { | ||
stamp: moment_1.default.utc().toDate().getTime(), | ||
err: err, | ||
req: { | ||
method: req.method, | ||
url: req.originalUrl, | ||
body: req.body, | ||
headers: req.headers | ||
}, | ||
res: { | ||
status: resp.statusCode, | ||
message: resp.statusMessage, | ||
locals: resp.locals | ||
}, | ||
req: request, | ||
res: response, | ||
worker: this.worker | ||
@@ -132,2 +138,8 @@ }; | ||
this._app.use("/version", version_middleware_1.default); | ||
if (preRoutes) { | ||
return preRoutes(this._app).finally(() => { | ||
this._registerRoutes(routes); | ||
resolve(); | ||
}); | ||
} | ||
this._registerRoutes(routes); | ||
@@ -134,0 +146,0 @@ resolve(); |
{ | ||
"name": "@ikoabo/server", | ||
"version": "1.1.15", | ||
"version": "1.1.16", | ||
"description": "IKOA Business Opportunity Server API", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
Sorry, the diff of this file is not supported yet
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
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
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
78280
870
23