@morojs/engine 1.1.7 → 1.1.10

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
@@ -25,8 +25,14 @@ export interface EngineCapabilities {
25
25
  /** Explicit TLS cipher/group policy is parsed:
26
26
  * ServeOptions.ssl.ciphers, ciphersuites, and ecdhCurve. */
27
27
  tlsPolicy: boolean;
28
+ /** updateSsl() is available: the certificate/key (and policy) of a TLS
29
+ * server can be replaced for new handshakes without a restart. */
30
+ tlsReload: boolean;
28
31
  /** setStaticRoute() / clearStaticRoutes() are available. */
29
32
  staticRoutes: boolean;
33
+ /** setParamRoute() / clearParamRoutes() are available: a route with one
34
+ * variable path segment, echoed as the body, answered inside the engine. */
35
+ paramRoutes: boolean;
30
36
  /** prepareResponse() / releaseTemplates() / respondPrepared() /
31
37
  * respondPreparedEmpty() / writeHeadPrepared() / endWith() are available. */
32
38
  responseTemplates: boolean;
@@ -88,18 +94,20 @@ export interface EngineProbeResult {
88
94
  notify?: 'deferred' | 'sync';
89
95
  /** Fast-call build/install diagnostics. */
90
96
  fastApi?: FastApiInfo;
91
- /** I/O transport in use: 'uring' (Linux 6.1+ with io_uring permitted by the
92
- * sandbox) or 'uv' (libuv streams - macOS, Windows, older kernels,
93
- * seccomp-blocked containers, MORO_ENGINE_TRANSPORT=uv). Behaviour and wire
94
- * bytes are identical; only the syscall layer differs. */
95
- transport?: 'uv' | 'uring';
96
- /** Why the transport is not io_uring ('ok' when it is). */
97
+ /** I/O transport in use: 'epoll' (Linux default since 1.1.10: the engine's
98
+ * own readiness loop on one uv_poll, no libuv stream per connection),
99
+ * 'uring' (Linux 6.1+, MORO_ENGINE_TRANSPORT=uring, when the sandbox
100
+ * permits io_uring) or 'uv' (libuv streams - macOS, Windows,
101
+ * MORO_ENGINE_TRANSPORT=uv). Behaviour and wire bytes are identical; only
102
+ * the syscall layer differs. */
103
+ transport?: 'uv' | 'uring' | 'epoll';
104
+ /** Why this transport: 'ok' for io_uring, the default/override note otherwise. */
97
105
  transportReason?: string;
98
106
  /** 'uv', or the io_uring ring mode in use: 'defer-taskrun' (completions run
99
107
  * as one batch inside the engine's own io_uring_enter, woken through a
100
108
  * registered eventfd) or 'coop-taskrun' (the 1.1.6 mode). The probe tries
101
109
  * defer first; MORO_ENGINE_URING_TASKRUN=coop|defer pins one. */
102
- transportMode?: 'uv' | 'defer-taskrun' | 'coop-taskrun';
110
+ transportMode?: 'uv' | 'epoll' | 'defer-taskrun' | 'coop-taskrun';
103
111
  /** Per-thread fast/slow hit counters per hot entry point - present only when
104
112
  * MORO_ENGINE_FASTCALL_STATS=1 was set when the addon loaded (test/CI proof
105
113
  * that the fast path is taken). */
@@ -283,6 +291,14 @@ export function close(serverId: number): void;
283
291
  /** Stop accepting new connections while existing ones keep being served —
284
292
  * the drain phase of a graceful shutdown. Idempotent. */
285
293
  export function stopListening(serverId: number): void;
294
+ /** Replace the TLS certificate/key (and cipher policy) used for every
295
+ * handshake from now on, without restarting the listener (feature-detect via
296
+ * probe().capabilities.tlsReload). `ssl` is the full ServeOptions.ssl shape,
297
+ * not a diff; ticketKeys carry over when omitted so session resumption
298
+ * survives a rotation. Established connections keep the context they
299
+ * handshaked with. Throws (leaving the current context in place) on invalid
300
+ * material, and for a server that was not started with ssl. */
301
+ export function updateSsl(serverId: number, ssl: NonNullable<ServeOptions['ssl']>): void;
286
302
 
287
303
  // ---- per-request accessors (valid until the response ends / aborts) ----
288
304
  export function getMethod(reqId: number): string | undefined;
@@ -344,6 +360,29 @@ export function setStaticRoute(
344
360
  /** Drop every static route registered on this server. */
345
361
  export function clearStaticRoutes(serverId: number): void;
346
362
 
363
+ // ---- Parameter routes ----
364
+ /** Register a route with ONE variable path segment whose body IS that
365
+ * segment, answered entirely inside the engine like a static route:
366
+ * `/user/:id` is prefix "/user/" and suffix ""; `/files/:name.json` is
367
+ * prefix "/files/" and suffix ".json". The segment must be non-empty and
368
+ * contain no '/', so `/user/` and `/user/1/2` still reach onRequest. It is
369
+ * written as it is on the wire, undecoded (uWS's writeParameterValue does
370
+ * the same); a route that needs decoding stays a JS route. The header block
371
+ * is materialised once, so the reply is byte-identical to
372
+ * respond(status, headersFlat, segment). Only an exact method match
373
+ * short-circuits; re-registering (method, prefix, suffix) replaces it.
374
+ * Feature-detect via probe().capabilities.paramRoutes. */
375
+ export function setParamRoute(
376
+ serverId: number,
377
+ method: number,
378
+ prefix: string,
379
+ suffix: string,
380
+ status?: number,
381
+ headersFlat?: string[] | null
382
+ ): void;
383
+ /** Drop every parameter route registered on this server. */
384
+ export function clearParamRoutes(serverId: number): void;
385
+
347
386
  // ---- Prepared response templates ----
348
387
  /** Materialise status + headers ONCE (the same header builder respond() uses,
349
388
  * so the wire bytes are identical) and get back a template id to replay per
@@ -395,6 +434,7 @@ declare const engine: {
395
434
  listen: typeof listen;
396
435
  close: typeof close;
397
436
  stopListening: typeof stopListening;
437
+ updateSsl: typeof updateSsl;
398
438
  getMethod: typeof getMethod;
399
439
  getBatchBuffers: typeof getBatchBuffers;
400
440
  getPath: typeof getPath;
@@ -410,6 +450,8 @@ declare const engine: {
410
450
  end: typeof end;
411
451
  setStaticRoute: typeof setStaticRoute;
412
452
  clearStaticRoutes: typeof clearStaticRoutes;
453
+ setParamRoute: typeof setParamRoute;
454
+ clearParamRoutes: typeof clearParamRoutes;
413
455
  prepareResponse: typeof prepareResponse;
414
456
  releaseTemplates: typeof releaseTemplates;
415
457
  respondPrepared: typeof respondPrepared;
package/index.js CHANGED
@@ -153,6 +153,7 @@ const NATIVE_API = new Set([
153
153
  'listen',
154
154
  'close',
155
155
  'stopListening',
156
+ 'updateSsl',
156
157
  'getMethod',
157
158
  'getBatchBuffers',
158
159
  'getPath',
@@ -168,6 +169,8 @@ const NATIVE_API = new Set([
168
169
  'end',
169
170
  'setStaticRoute',
170
171
  'clearStaticRoutes',
172
+ 'setParamRoute',
173
+ 'clearParamRoutes',
171
174
  'prepareResponse',
172
175
  'releaseTemplates',
173
176
  'respondPrepared',
package/index.mjs CHANGED
@@ -30,6 +30,7 @@ export let serve = (...a) => (serve = engine.serve)(...a);
30
30
  export let listen = (...a) => (listen = engine.listen)(...a);
31
31
  export let close = (...a) => (close = engine.close)(...a);
32
32
  export let stopListening = (...a) => (stopListening = engine.stopListening)(...a);
33
+ export let updateSsl = (...a) => (updateSsl = engine.updateSsl)(...a);
33
34
  export let getMethod = (...a) => (getMethod = engine.getMethod)(...a);
34
35
  export let getBatchBuffers = (...a) => (getBatchBuffers = engine.getBatchBuffers)(...a);
35
36
  export let getPath = (...a) => (getPath = engine.getPath)(...a);
@@ -45,6 +46,8 @@ export let write = (...a) => (write = engine.write)(...a);
45
46
  export let end = (...a) => (end = engine.end)(...a);
46
47
  export let setStaticRoute = (...a) => (setStaticRoute = engine.setStaticRoute)(...a);
47
48
  export let clearStaticRoutes = (...a) => (clearStaticRoutes = engine.clearStaticRoutes)(...a);
49
+ export let setParamRoute = (...a) => (setParamRoute = engine.setParamRoute)(...a);
50
+ export let clearParamRoutes = (...a) => (clearParamRoutes = engine.clearParamRoutes)(...a);
48
51
  export let prepareResponse = (...a) => (prepareResponse = engine.prepareResponse)(...a);
49
52
  export let releaseTemplates = (...a) => (releaseTemplates = engine.releaseTemplates)(...a);
50
53
  export let respondPrepared = (...a) => (respondPrepared = engine.respondPrepared)(...a);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@morojs/engine",
3
- "version": "1.1.7",
3
+ "version": "1.1.10",
4
4
  "description": "MoroJS native HTTP engine - Moro-authored C++ core with per-platform prebuilt binaries and automatic Node.js fallback in MoroJS",
5
5
  "license": "MIT",
6
6
  "author": "CM Ventures Inc.",
@@ -38,13 +38,13 @@
38
38
  "provenance": true
39
39
  },
40
40
  "optionalDependencies": {
41
- "@morojs/engine-darwin-arm64": "1.1.7",
42
- "@morojs/engine-darwin-x64": "1.1.7",
43
- "@morojs/engine-linux-x64-gnu": "1.1.7",
44
- "@morojs/engine-linux-arm64-gnu": "1.1.7",
45
- "@morojs/engine-linux-x64-musl": "1.1.7",
46
- "@morojs/engine-linux-arm64-musl": "1.1.7",
47
- "@morojs/engine-win32-x64": "1.1.7"
41
+ "@morojs/engine-darwin-arm64": "1.1.10",
42
+ "@morojs/engine-darwin-x64": "1.1.10",
43
+ "@morojs/engine-linux-x64-gnu": "1.1.10",
44
+ "@morojs/engine-linux-arm64-gnu": "1.1.10",
45
+ "@morojs/engine-linux-x64-musl": "1.1.10",
46
+ "@morojs/engine-linux-arm64-musl": "1.1.10",
47
+ "@morojs/engine-win32-x64": "1.1.10"
48
48
  },
49
49
  "keywords": [
50
50
  "morojs",