@logux/server 0.11.0 → 0.12.0

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,6 +94,7 @@ 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
97
98
  let data = await operations.load(
98
99
  ctx,
99
100
  ctx.params.id,
@@ -101,12 +102,14 @@ export function addSyncMap(server, plural, operations) {
101
102
  action,
102
103
  meta
103
104
  )
104
- await sendMap(
105
- server,
106
- changedType,
107
- data,
108
- action.since ? action.since.time : 0
109
- )
105
+ if (data !== false) {
106
+ await sendMap(
107
+ server,
108
+ changedType,
109
+ data,
110
+ action.since ? action.since.time : 0
111
+ )
112
+ }
110
113
  }
111
114
  })
112
115
  }
@@ -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.0",
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.4.2",
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
  }