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 CHANGED
@@ -61,7 +61,8 @@ declare class Connection {
61
61
  }
62
62
  export {};
63
63
  export class Gateway {
64
- static start(): Gateway;
64
+ static start(opts: any): Gateway;
65
+ constructor(opts: any);
65
66
  #private;
66
67
  }
67
68
  export const registry: Registry;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "geonix",
3
- "version": "1.12.1",
3
+ "version": "1.12.3",
4
4
  "type": "module",
5
5
  "description": "",
6
6
  "bin": {
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')
package/src/Util.js CHANGED
@@ -6,6 +6,8 @@ import { Transform } from 'node:stream'
6
6
  import { networkInterfaces } from 'os'
7
7
  import http from 'http'
8
8
  import https from 'http'
9
+ import net from 'net'
10
+
9
11
  /**
10
12
  * Wait for {delay} ms
11
13
  * @param {number} delay