@logux/server 0.11.0 → 0.12.2

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.
@@ -81,7 +81,7 @@ interface SyncMapOperations<Value extends SyncMapValues> {
81
81
  since: number | undefined,
82
82
  action: LoguxSubscribeAction,
83
83
  meta: ServerMeta
84
- ): Promise<SyncMapData<Value>> | SyncMapData<Value>
84
+ ): Promise<SyncMapData<Value>> | SyncMapData<Value> | false | Promise<false>
85
85
 
86
86
  create?(
87
87
  ctx: Context,
@@ -94,19 +94,23 @@ export function addSyncMap(server, plural, operations) {
94
94
  return operations.access(ctx, ctx.params.id, action, meta)
95
95
  },
96
96
  async load(ctx, action, meta) {
97
+ if (action.creating) return
98
+ let since = action.since ? action.since.time : 0
97
99
  let data = await operations.load(
98
100
  ctx,
99
101
  ctx.params.id,
100
- action.since,
102
+ since,
101
103
  action,
102
104
  meta
103
105
  )
104
- await sendMap(
105
- server,
106
- changedType,
107
- data,
108
- action.since ? action.since.time : 0
109
- )
106
+ if (data !== false) {
107
+ await sendMap(
108
+ server,
109
+ changedType,
110
+ data,
111
+ since
112
+ )
113
+ }
110
114
  }
111
115
  })
112
116
  }
@@ -185,14 +189,14 @@ export function addSyncMapFilter(server, plural, operations) {
185
189
  }
186
190
  },
187
191
  async load(ctx, action, meta) {
192
+ let since = action.since ? action.since.time : 0
188
193
  let data = await operations.initial(
189
194
  ctx,
190
195
  action.filter,
191
- action.since,
196
+ since,
192
197
  action,
193
198
  meta
194
199
  )
195
- let since = action.since ? action.since.time : 0
196
200
  await Promise.all(
197
201
  data.map(async i => {
198
202
  await server.subscribe(ctx.nodeId, `${plural}/${i.id}`)
@@ -72,7 +72,7 @@ export interface ServerMeta extends Meta {
72
72
  node?: string
73
73
 
74
74
  /**
75
- * Client IDs, which will not recieve the action.
75
+ * Client IDs, which will not receive the action.
76
76
  */
77
77
  excludeClients?: string[]
78
78
  }
@@ -206,6 +206,14 @@ export interface BaseServerOptions {
206
206
  * By default it cleans `Bearer [^\s"]+`.
207
207
  */
208
208
  cleanFromLog?: RegExp
209
+
210
+ /**
211
+ * Disable health check endpoint, control HTTP API, {@link Server#http}.
212
+ *
213
+ * The server will process only WebSocket connection and ignore all other
214
+ * HTTP request (so they can be processed by other HTTP server).
215
+ */
216
+ disableHttpServer?: boolean
209
217
  }
210
218
 
211
219
  export interface AuthenticatorOptions<Headers extends object> {
@@ -382,6 +382,11 @@ export class BaseServer {
382
382
  }
383
383
 
384
384
  http(listener) {
385
+ if (this.options.disableHttpServer) {
386
+ throw new Error(
387
+ '`server.http()` can not be called when `disableHttpServer` enabled'
388
+ )
389
+ }
385
390
  this.httpListener = listener
386
391
  }
387
392
 
@@ -17,6 +17,17 @@ function isValidBody(body) {
17
17
  }
18
18
 
19
19
  export function bindControlServer(app, custom) {
20
+ if (app.options.disableHttpServer) {
21
+ if (app.options.controlSecret) {
22
+ let err = new Error(
23
+ '`controlSecret` can be set together with `disableHttpServer` option'
24
+ )
25
+ err.logux = true
26
+ throw err
27
+ }
28
+ return
29
+ }
30
+
20
31
  let masks = app.options.controlMask.split(/,\s*/).map(i => ip.cidrSubnet(i))
21
32
  app.httpServer.on('request', async (req, res) => {
22
33
  let urlString = req.url
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@logux/server",
3
- "version": "0.11.0",
3
+ "version": "0.12.2",
4
4
  "description": "Build own Logux server or make proxy between WebSocket and HTTP backend on any language",
5
5
  "keywords": [
6
6
  "logux",
@@ -18,7 +18,7 @@
18
18
  "homepage": "https://logux.io/",
19
19
  "repository": "logux/server",
20
20
  "engines": {
21
- "node": "^12.0.0 || ^14.0.0 || >=16.0.0"
21
+ "node": "^14.0.0 || ^16.0.0 || >=18.0.0"
22
22
  },
23
23
  "type": "module",
24
24
  "types": "./index.d.ts",
@@ -27,24 +27,24 @@
27
27
  "./package.json": "./package.json"
28
28
  },
29
29
  "dependencies": {
30
- "@logux/actions": "^0.2.3",
31
- "@logux/core": "^0.7.3",
30
+ "@logux/actions": "^0.3.0",
31
+ "@logux/core": "^0.8.0",
32
32
  "JSONStream": "^1.3.5",
33
33
  "cookie": "^0.5.0",
34
- "dotenv": "^16.0.0",
34
+ "dotenv": "^16.0.2",
35
35
  "fast-glob": "^3.2.11",
36
- "ip": "^1.1.5",
36
+ "ip": "^1.1.8",
37
37
  "nanodelay": "^2.0.2",
38
- "nanoevents": "^6.0.2",
39
- "nanoid": "^3.3.3",
38
+ "nanoevents": "^7.0.1",
39
+ "nanoid": "^4.0.0",
40
40
  "node-fetch": "^2.6.7",
41
41
  "picocolors": "^1.0.0",
42
- "pino": "7.10.0",
43
- "pino-abstract-transport": "^0.5.0",
42
+ "pino": "8.5.0",
43
+ "pino-abstract-transport": "^1.0.0",
44
44
  "semver": "^7.3.7",
45
45
  "strip-ansi": "^7.0.1",
46
46
  "url-pattern": "^1.0.3",
47
- "ws": "^8.5.0",
47
+ "ws": "^8.8.1",
48
48
  "yyyy-mm-dd": "^1.0.2"
49
49
  }
50
50
  }