geonix 1.12.1 → 1.12.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +2 -1
- package/package.json +1 -1
- package/src/Gateway.js +17 -3
- package/src/Util.js +2 -0
package/index.d.ts
CHANGED
package/package.json
CHANGED
package/src/Gateway.js
CHANGED
|
@@ -27,12 +27,17 @@ const stats = {
|
|
|
27
27
|
debug_requests: 0
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
const defaultOpts = {
|
|
31
|
+
afterRequest: (req, res) => { },
|
|
32
|
+
}
|
|
33
|
+
|
|
30
34
|
export class Gateway {
|
|
31
35
|
|
|
32
|
-
static start() {
|
|
33
|
-
return new Gateway()
|
|
36
|
+
static start(opts) {
|
|
37
|
+
return new Gateway(opts)
|
|
34
38
|
}
|
|
35
39
|
|
|
40
|
+
#opts = defaultOpts
|
|
36
41
|
#api = express()
|
|
37
42
|
#router = (req, res, next) => next()
|
|
38
43
|
#activeServers = []
|
|
@@ -44,9 +49,11 @@ export class Gateway {
|
|
|
44
49
|
|
|
45
50
|
#registry = {}
|
|
46
51
|
|
|
47
|
-
constructor() {
|
|
52
|
+
constructor(opts) {
|
|
48
53
|
expressWs(this.#api)
|
|
49
54
|
|
|
55
|
+
this.#opts = { ...this.#opts, ...opts }
|
|
56
|
+
|
|
50
57
|
this.#start()
|
|
51
58
|
}
|
|
52
59
|
|
|
@@ -92,6 +99,13 @@ export class Gateway {
|
|
|
92
99
|
next()
|
|
93
100
|
})
|
|
94
101
|
|
|
102
|
+
this.#api.use((req, res, next) => {
|
|
103
|
+
if (this.#opts.afterRequest) {
|
|
104
|
+
this.#opts.afterRequest(req, res)
|
|
105
|
+
}
|
|
106
|
+
next()
|
|
107
|
+
})
|
|
108
|
+
|
|
95
109
|
// config
|
|
96
110
|
this.#api.disable('x-powered-by')
|
|
97
111
|
this.#api.disable('etag')
|