@c9up/ream 0.2.15 → 0.2.16

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.
Files changed (52) hide show
  1. package/README.md +1 -1
  2. package/dist/Ignitor.d.ts +9 -0
  3. package/dist/Ignitor.d.ts.map +1 -1
  4. package/dist/Ignitor.js +29 -3
  5. package/dist/Ignitor.js.map +1 -1
  6. package/dist/bodyparser/BodyParserMiddleware.d.ts +1 -1
  7. package/dist/bodyparser/BodyParserMiddleware.d.ts.map +1 -1
  8. package/dist/bodyparser/BodyParserMiddleware.js +12 -1
  9. package/dist/bodyparser/BodyParserMiddleware.js.map +1 -1
  10. package/dist/bodyparser/config.d.ts +15 -0
  11. package/dist/bodyparser/config.d.ts.map +1 -0
  12. package/dist/bodyparser/config.js +16 -0
  13. package/dist/bodyparser/config.js.map +1 -0
  14. package/dist/config/moduleConfig.d.ts +15 -0
  15. package/dist/config/moduleConfig.d.ts.map +1 -0
  16. package/dist/config/moduleConfig.js +24 -0
  17. package/dist/config/moduleConfig.js.map +1 -0
  18. package/dist/console/cliui.d.ts +2 -0
  19. package/dist/console/cliui.d.ts.map +1 -1
  20. package/dist/console/cliui.js +2 -1
  21. package/dist/console/cliui.js.map +1 -1
  22. package/dist/index.d.ts +1 -1
  23. package/dist/index.js +1 -1
  24. package/dist/scheduler/ScheduleProvider.d.ts +15 -11
  25. package/dist/scheduler/ScheduleProvider.d.ts.map +1 -1
  26. package/dist/scheduler/ScheduleProvider.js +21 -12
  27. package/dist/scheduler/ScheduleProvider.js.map +1 -1
  28. package/dist/session/SessionMiddleware.d.ts +2 -4
  29. package/dist/session/SessionMiddleware.d.ts.map +1 -1
  30. package/dist/session/SessionMiddleware.js +13 -1
  31. package/dist/session/SessionMiddleware.js.map +1 -1
  32. package/dist/session/config.d.ts +25 -0
  33. package/dist/session/config.d.ts.map +1 -0
  34. package/dist/session/config.js +18 -0
  35. package/dist/session/config.js.map +1 -0
  36. package/events.win32-x64-msvc.node +0 -0
  37. package/index.win32-x64-msvc.node +0 -0
  38. package/package.json +11 -2
  39. package/scheduler.darwin-arm64.node +0 -0
  40. package/scheduler.darwin-x64.node +0 -0
  41. package/scheduler.linux-arm64-gnu.node +0 -0
  42. package/scheduler.linux-x64-gnu.node +0 -0
  43. package/scheduler.win32-x64-msvc.node +0 -0
  44. package/src/Ignitor.ts +42 -3
  45. package/src/bodyparser/BodyParserMiddleware.ts +12 -1
  46. package/src/bodyparser/config.ts +18 -0
  47. package/src/config/moduleConfig.ts +24 -0
  48. package/src/console/cliui.ts +2 -1
  49. package/src/index.ts +1 -1
  50. package/src/scheduler/ScheduleProvider.ts +22 -12
  51. package/src/session/SessionMiddleware.ts +15 -2
  52. package/src/session/config.ts +29 -0
@@ -10,7 +10,8 @@
10
10
  * throws, tasks 1..N-1 registered in the same boot are unregistered
11
11
  * before the error propagates, so the scheduler is never left in a
12
12
  * half-registered state.
13
- * - `start()` — launches the Rust tick loop.
13
+ * - `ready()` — discovers the tasks `app/modules/**` declared, then
14
+ * launches the Rust tick loop.
14
15
  * - `shutdown()` — cancels the Rust tick loop.
15
16
  *
16
17
  * The registered callback resolves the service **at invocation time**
@@ -50,21 +51,24 @@ export declare class ScheduleProvider extends Provider {
50
51
  */
51
52
  register(): void;
52
53
  /**
53
- * Discovery runs at START, not at boot, and that is the whole point.
54
+ * The pass that matters runs at READY, and the ordering is the reason.
54
55
  *
55
- * `app/modules/**` is auto-loaded during the start phase — after every
56
- * provider has booted. A `@Service()` carrying `@Schedule` there, which is
57
- * where one naturally lives, was therefore registered into the service
58
- * registry AFTER this had already read it. The task was never registered,
59
- * and nothing said so: no error, no warning, the application started
60
- * normally and the task simply never fired.
56
+ * A `@Service()` carrying `@Schedule` naturally lives in `app/modules/**`,
57
+ * which the application auto-loads at the END of the start phase — after
58
+ * every provider's `start()`. Discovering in `start()` therefore read the
59
+ * service registry before the modules had put anything in it: the task was
60
+ * never registered, and nothing said so. No error, no warning, the
61
+ * application started normally and the task simply never fired. `ready()`
62
+ * runs after the autoload, which is what makes the second pass real.
61
63
  *
62
- * Reading the registry once the modules are in place is what fixes it. A
63
- * service declared anywhere earlier — a provider, a preload — is in the
64
- * registry by then too, so nothing is lost by waiting.
64
+ * The earlier passes are kept because they cost nothing and shorten the gap:
65
+ * a service declared by a provider or a preload is registered as soon as it
66
+ * is seen. `#discover()` is idempotent, so a task found twice is registered
67
+ * once.
65
68
  */
66
69
  boot(): Promise<void>;
67
70
  start(): Promise<void>;
71
+ ready(): Promise<void>;
68
72
  shutdown(): Promise<void>;
69
73
  }
70
74
  export default ScheduleProvider;
@@ -1 +1 @@
1
- {"version":3,"file":"ScheduleProvider.d.ts","sourceRoot":"","sources":["../../src/scheduler/ScheduleProvider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAIH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAGzC,OAAO,EAAE,SAAS,EAAyB,MAAM,gBAAgB,CAAA;AAEjE,MAAM,WAAW,uBAAuB;IACtC;;;OAGG;IACH,SAAS,CAAC,EAAE,SAAS,CAAA;CACtB;AAKD,qBAAa,gBAAiB,SAAQ,QAAQ;;IAC5C,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAA;gBAKjB,GAAG,EAAE,UAAU,EAAE,OAAO,GAAE,uBAA4B;IAMlE;;;;;;;;;;;;;;OAcG;IACM,QAAQ,IAAI,IAAI;IAmBzB;;;;;;;;;;;;;OAaG;IACY,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAMrB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAkGtB,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;CAIzC;AAGD,eAAe,gBAAgB,CAAA"}
1
+ {"version":3,"file":"ScheduleProvider.d.ts","sourceRoot":"","sources":["../../src/scheduler/ScheduleProvider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAIH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAGzC,OAAO,EAAE,SAAS,EAAyB,MAAM,gBAAgB,CAAA;AAEjE,MAAM,WAAW,uBAAuB;IACtC;;;OAGG;IACH,SAAS,CAAC,EAAE,SAAS,CAAA;CACtB;AAKD,qBAAa,gBAAiB,SAAQ,QAAQ;;IAC5C,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAA;gBAKjB,GAAG,EAAE,UAAU,EAAE,OAAO,GAAE,uBAA4B;IAMlE;;;;;;;;;;;;;;OAcG;IACM,QAAQ,IAAI,IAAI;IAmBzB;;;;;;;;;;;;;;;OAeG;IACY,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAMrB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAMtB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAmGtB,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;CAIzC;AAGD,eAAe,gBAAgB,CAAA"}
@@ -10,7 +10,8 @@
10
10
  * throws, tasks 1..N-1 registered in the same boot are unregistered
11
11
  * before the error propagates, so the scheduler is never left in a
12
12
  * half-registered state.
13
- * - `start()` — launches the Rust tick loop.
13
+ * - `ready()` — discovers the tasks `app/modules/**` declared, then
14
+ * launches the Rust tick loop.
14
15
  * - `shutdown()` — cancels the Rust tick loop.
15
16
  *
16
17
  * The registered callback resolves the service **at invocation time**
@@ -67,25 +68,33 @@ export class ScheduleProvider extends Provider {
67
68
  this.#registered = true;
68
69
  }
69
70
  /**
70
- * Discovery runs at START, not at boot, and that is the whole point.
71
+ * The pass that matters runs at READY, and the ordering is the reason.
71
72
  *
72
- * `app/modules/**` is auto-loaded during the start phase — after every
73
- * provider has booted. A `@Service()` carrying `@Schedule` there, which is
74
- * where one naturally lives, was therefore registered into the service
75
- * registry AFTER this had already read it. The task was never registered,
76
- * and nothing said so: no error, no warning, the application started
77
- * normally and the task simply never fired.
73
+ * A `@Service()` carrying `@Schedule` naturally lives in `app/modules/**`,
74
+ * which the application auto-loads at the END of the start phase — after
75
+ * every provider's `start()`. Discovering in `start()` therefore read the
76
+ * service registry before the modules had put anything in it: the task was
77
+ * never registered, and nothing said so. No error, no warning, the
78
+ * application started normally and the task simply never fired. `ready()`
79
+ * runs after the autoload, which is what makes the second pass real.
78
80
  *
79
- * Reading the registry once the modules are in place is what fixes it. A
80
- * service declared anywhere earlier — a provider, a preload — is in the
81
- * registry by then too, so nothing is lost by waiting.
81
+ * The earlier passes are kept because they cost nothing and shorten the gap:
82
+ * a service declared by a provider or a preload is registered as soon as it
83
+ * is seen. `#discover()` is idempotent, so a task found twice is registered
84
+ * once.
82
85
  */
83
86
  async boot() {
84
87
  // Anything already in the registry — declared by a provider, or imported
85
- // by one. The rest is caught at start().
88
+ // by one. The rest is caught later.
86
89
  this.#discover();
87
90
  }
88
91
  async start() {
92
+ // Preloads have not run yet either; this catches whatever the boot phase
93
+ // added. The ticker deliberately does NOT start here.
94
+ this.#discover();
95
+ }
96
+ async ready() {
97
+ // The pass after `app/modules/**`.
89
98
  this.#discover();
90
99
  if (activeProvider !== undefined && activeProvider !== this) {
91
100
  // A previous app's scheduler is still running — stop it before this one
@@ -1 +1 @@
1
- {"version":3,"file":"ScheduleProvider.js","sourceRoot":"","sources":["../../src/scheduler/ScheduleProvider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAA;AAC7D,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AAElD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAEzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AACnD,OAAO,EAAE,SAAS,EAAyB,MAAM,gBAAgB,CAAA;AAUjE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rB,IAAI,cAAc,KAAK,IAAI;YAAE,cAAc,GAAG,SAAS,CAAA;QACvD,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,CAAA;IACvB,CAAC;CACF;AAED,2KAA2K;AAC3K,eAAe,gBAAgB,CAAA;AAE/B;;;;;;GAMG;AACH,SAAS,oBAAoB,CAAC,MAAmC;IAC/D,IAAI,MAAM,KAAK,SAAS;QAAE,OAAO,EAAE,CAAA;IACnC,MAAM,OAAO,GAAqB,EAAE,CAAA;IACpC,IAAI,MAAM,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QAC9B,OAAO,CAAC,WAAW,GAAG,OAAO,MAAM,CAAC,IAAI,KAAK,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAA;IACvF,CAAC;IACD,IAAI,MAAM,CAAC,gBAAgB,KAAK,SAAS,EAAE,CAAC;QAC1C,OAAO,CAAC,gBAAgB,GAAG,MAAM,CAAC,gBAAgB,CAAA;IACpD,CAAC;IACD,OAAO,OAAO,CAAA;AAChB,CAAC"}
@@ -5,12 +5,10 @@
5
5
  * and writes back after the handler runs.
6
6
  */
7
7
  import type { HttpContext } from '../http/HttpContext.js';
8
- import type { SessionConfig } from './Session.js';
8
+ import type { SessionConfigInput } from './config.js';
9
9
  export default class SessionMiddleware {
10
10
  #private;
11
- constructor(config?: SessionConfig & {
12
- secret?: string;
13
- });
11
+ constructor(explicitConfig?: SessionConfigInput | undefined);
14
12
  handle(ctx: HttpContext, next: () => Promise<void>): Promise<void>;
15
13
  }
16
14
  //# sourceMappingURL=SessionMiddleware.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"SessionMiddleware.d.ts","sourceRoot":"","sources":["../../src/session/SessionMiddleware.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAQzD,OAAO,KAAK,EAAE,aAAa,EAAiB,MAAM,cAAc,CAAA;AAqBhE,MAAM,CAAC,OAAO,OAAO,iBAAiB;;gBAKxB,MAAM,CAAC,EAAE,aAAa,GAAG;QAAE,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE;IA2DlD,MAAM,CAAC,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC;CAqHzD"}
1
+ {"version":3,"file":"SessionMiddleware.d.ts","sourceRoot":"","sources":["../../src/session/SessionMiddleware.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AACzD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AA6BrD,MAAM,CAAC,OAAO,OAAO,iBAAiB;;gBAKxB,cAAc,GAAE,kBAAkB,GAAG,SAAqB;IAsEhE,MAAM,CAAC,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC;CAqHzD"}
@@ -5,6 +5,7 @@
5
5
  * and writes back after the handler runs.
6
6
  */
7
7
  import { randomBytes } from 'node:crypto';
8
+ import { readModuleConfig } from '../config/moduleConfig.js';
8
9
  import { currentNodeEnv } from '../env/nodeEnv.js';
9
10
  import { durationToSeconds } from '../helpers/duration.js';
10
11
  import { CookieDriver } from './drivers/CookieDriver.js';
@@ -26,7 +27,18 @@ export default class SessionMiddleware {
26
27
  #driver;
27
28
  #cookieDriver = null;
28
29
  #config;
29
- constructor(config) {
30
+ constructor(explicitConfig = undefined) {
31
+ // The default value is load-bearing: an OPTIONAL parameter still counts
32
+ // toward `Function.length`, and the container refuses to auto-construct a
33
+ // class that declares parameters it has no metadata for. A parameter with a
34
+ // default counts for nothing, which is what lets
35
+ // `router.use([() => import('…')])` build this middleware.
36
+ // Nothing is passed when the container builds this middleware from
37
+ // `router.use([() => import('@c9up/ream/session_middleware')])`, which is
38
+ // the registration shape the framework documents. `config/session.ts` is
39
+ // where the settings live in that case — the same file the config loader
40
+ // already reads into `config.get('session')`.
41
+ const config = explicitConfig ?? readModuleConfig('session');
30
42
  // `store` + `stores` (AdonisJS) and `driver` (ream) name the same thing.
31
43
  // A named store supplies the driver and its own options, so
32
44
  // `{ store: 'redis', stores: { redis: { driver: 'redis' } } }` works.
@@ -1 +1 @@
1
- {"version":3,"file":"SessionMiddleware.js","sourceRoot":"","sources":["../../src/session/SessionMiddleware.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAE1D,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AACxD,OAAO,EAAE,cAAc,EAA4B,MAAM,6BAA6B,CAAA;AACtF,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAC9C,OAAO,EAAE,mBAAmB,EAAkB,MAAM,0BAA0B,CAAA;AAE9E,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAUtC,sEAAsE;AACtE,SAAS,qBAAqB,CAAC,KAAc;IAC3C,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,OAAO,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,OAAO,CAAC,KAAK,UAAU;QACjD,OAAO,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,SAAS,CAAC,KAAK,UAAU,CACpD,CAAA;AACH,CAAC;AAED,MAAM,CAAC,OAAO,OAAO,iBAAiB;IACpC,OAAO,CAAe;IACtB,aAAa,GAAwB,IA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YAAY;aACrB,CAAC,CAAA;QACJ,CAAC;IACH,CAAC;CACF;AAED,SAAS,iBAAiB;IACxB,OAAO,WAAW,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAA;AAC9C,CAAC;AAED;;;;;;GAMG;AACH,SAAS,oBAAoB,CAAC,GAAgB,EAAE,OAAgB;IAC9D,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,CAAA;IAC7C,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC,CAAA;IAChD,IAAI,OAAO,KAAK,KAAK,UAAU;QAAE,OAAM;IACvC,wEAAwE;IACxE,MAAM,aAAa,GAAG,OAAO,CAAC,aAAa,CAAA;IAC3C,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE;QACf,OAAO,EAAE,IAAI,mBAAmB,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC;QAC/C,aAAa;QACb,2DAA2D;QAC3D,GAAG,EAAE,CAAC,GAAc,EAAE,YAAsB,EAAW,EAAE,CAAC,aAAa,CAAC,GAAG,CAAC,GAAG,EAAE,YAAY,CAAC;KAC/F,CAAC,CAAA;AACJ,CAAC"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * `config/session.ts` — the session store's configuration, in the file the
3
+ * config loader reads (`config/<name>.ts` → `config.get('<name>')`).
4
+ *
5
+ * @example
6
+ * // config/session.ts
7
+ * import env from '#start/env.js'
8
+ * import { defineConfig } from '@c9up/ream/session/config'
9
+ *
10
+ * export default defineConfig({
11
+ * store: 'cookie',
12
+ * secret: env.get('APP_KEY'),
13
+ * })
14
+ */
15
+ import type { SessionConfig } from './Session.js';
16
+ /** What a session config file may declare. */
17
+ export type SessionConfigInput = SessionConfig & {
18
+ /**
19
+ * Signs the session cookie. Required by the cookie store, which carries the
20
+ * data itself and would otherwise hand the client something it could edit.
21
+ */
22
+ secret?: string;
23
+ };
24
+ export declare function defineConfig(config: SessionConfigInput): SessionConfigInput;
25
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/session/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAEjD,8CAA8C;AAC9C,MAAM,MAAM,kBAAkB,GAAG,aAAa,GAAG;IAC/C;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,CAAA;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,kBAAkB,GAAG,kBAAkB,CAE3E"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * `config/session.ts` — the session store's configuration, in the file the
3
+ * config loader reads (`config/<name>.ts` → `config.get('<name>')`).
4
+ *
5
+ * @example
6
+ * // config/session.ts
7
+ * import env from '#start/env.js'
8
+ * import { defineConfig } from '@c9up/ream/session/config'
9
+ *
10
+ * export default defineConfig({
11
+ * store: 'cookie',
12
+ * secret: env.get('APP_KEY'),
13
+ * })
14
+ */
15
+ export function defineConfig(config) {
16
+ return config;
17
+ }
18
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/session/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAaH,MAAM,UAAU,YAAY,CAAC,MAA0B;IACrD,OAAO,MAAM,CAAA;AACf,CAAC"}
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@c9up/ream",
3
- "version": "0.2.15",
3
+ "version": "0.2.16",
4
4
  "description": "Ream — Rust-powered Node.js application framework",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -187,6 +187,14 @@
187
187
  "./swcrc.app.json": "./swcrc.app.json",
188
188
  "./tsconfig.package.json": "./tsconfig.package.json",
189
189
  "./tsconfig.client.json": "./tsconfig.client.json",
190
+ "./session/config": {
191
+ "types": "./dist/session/config.d.ts",
192
+ "import": "./dist/session/config.js"
193
+ },
194
+ "./bodyparser/config": {
195
+ "types": "./dist/bodyparser/config.d.ts",
196
+ "import": "./dist/bodyparser/config.js"
197
+ },
190
198
  "./session_middleware": {
191
199
  "types": "./dist/session/SessionMiddleware.d.ts",
192
200
  "import": "./dist/session/SessionMiddleware.js"
@@ -231,6 +239,7 @@
231
239
  "@biomejs/biome": "2.5.12",
232
240
  "@c9up/comet": "^0.1.0",
233
241
  "@types/node": "^22.19.15",
242
+ "@vitest/coverage-v8": "^4.1.6",
234
243
  "mime-db": "^1.54.0",
235
244
  "mime-types": "^3.0.2",
236
245
  "typescript": "^6.0.2",
@@ -254,7 +263,7 @@
254
263
  "build:napi": "pnpm build:rust && pnpm build:napi-types && node scripts/copy-napi.mjs",
255
264
  "test": "vitest run",
256
265
  "test:rust": "cargo test --all",
257
- "lint": "biome check src/",
266
+ "lint": "biome check src/ tests/",
258
267
  "test:coverage": "vitest run --coverage",
259
268
  "typecheck": "tsc --noEmit",
260
269
  "typecheck:tests": "tsc --noEmit -p tsconfig.tests.json"
Binary file
Binary file
Binary file
Binary file
Binary file
package/src/Ignitor.ts CHANGED
@@ -210,6 +210,15 @@ export interface HyperServerLike {
210
210
  }
211
211
 
212
212
  export interface IgnitorConfig {
213
+ /**
214
+ * Bind port. Falls back to `process.env.PORT`, then to `3000`. Prefer the
215
+ * environment: the fallback is read when the server binds, AFTER `booting()`
216
+ * has loaded `#start/env`, whereas a value passed here is fixed at
217
+ * construction — before `.env` has been read at all.
218
+ *
219
+ * It stays available because a test harness booting several applications in
220
+ * one process needs to hand each one an ephemeral port it has already picked.
221
+ */
213
222
  port?: number
214
223
  /**
215
224
  * Bind address of the HTTP server. Falls back to `process.env.HOST`, then to
@@ -690,12 +699,31 @@ export class Ignitor {
690
699
  this.#phase = 'started'
691
700
  }
692
701
 
702
+ /**
703
+ * Whether this process should bind an HTTP server.
704
+ *
705
+ * Not the same question as "is the environment 'web'". A test harness needs
706
+ * the HTTP surface — it passes a `serverFactory` precisely to get one — but
707
+ * it also needs to declare itself as `test`, because that is what an
708
+ * environment-scoped provider entry reads. Tying the two together forced a
709
+ * test bootstrap to call `httpServer()`, which set the environment to
710
+ * `'web'`, so `{ environment: ['web'] }` excluded nothing from a test run and
711
+ * a scheduled task fired in the middle of the suite.
712
+ *
713
+ * A test process that passes no factory still gets no server, and no error.
714
+ */
715
+ #servesHttp(): boolean {
716
+ const environment = this.#app.getEnvironment()
717
+ if (environment === 'web') return true
718
+ return environment === 'test' && this.#config.serverFactory !== undefined
719
+ }
720
+
693
721
  async #phaseReady(): Promise<void> {
694
722
  // Boot the Server (resolves lazy error handler etc.)
695
723
  await this.#server.boot()
696
724
 
697
- // Start HTTP server if in web mode
698
- if (this.#app.getEnvironment() === 'web' && this.#config.serverFactory) {
725
+ // Start HTTP server if this process serves one
726
+ if (this.#servesHttp() && this.#config.serverFactory) {
699
727
  // Build the HttpKernel with server middleware + router middleware.
700
728
  // The streaming backend is resolved lazily — the HyperServer is
701
729
  // created a few lines down, after the kernel — so the kernel
@@ -737,7 +765,18 @@ export class Ignitor {
737
765
  },
738
766
  })
739
767
 
740
- const desiredPort = this.#config.port ?? 3000
768
+ // Read HERE, not at construction: `#start/env` runs in `booting()`, so a
769
+ // PORT living in `.env` does not exist in `process.env` until this point.
770
+ // Reading it early bound 3000 while every later reader — the boot banner
771
+ // included — saw 3007 and said so. Same lazy rule as `host` below.
772
+ const desiredPort = this.#config.port ?? Number(process.env.PORT || 3000)
773
+ if (!Number.isInteger(desiredPort) || desiredPort < 0 || desiredPort > 65535) {
774
+ throw new ReamError(
775
+ 'E_IGNITOR_INVALID_PORT',
776
+ `PORT must be an integer between 0 and 65535, received '${process.env.PORT}'.`,
777
+ { hint: 'Set PORT in .env, or pass { port } to the Ignitor.' },
778
+ )
779
+ }
741
780
  // Port-scan fallback (+1..+19) is a DEV convenience only. In production
742
781
  // a silent drift to :3001 while the LB targets :3000 is an outage —
743
782
  // bind the configured port and let EADDRINUSE fail loudly. The probe
@@ -6,6 +6,7 @@
6
6
  * Configured via config/bodyparser.ts.
7
7
  */
8
8
 
9
+ import { readModuleConfig } from '../config/moduleConfig.js'
9
10
  import { Exception } from '../http/Exception.js'
10
11
  import type { HttpContext } from '../http/HttpContext.js'
11
12
  import { hydrateMultipartPayload } from './MultipartFile.js'
@@ -98,7 +99,17 @@ const DEFAULT_CONFIG: ResolvedBodyParserConfig = {
98
99
  export default class BodyParserMiddleware {
99
100
  #config: ResolvedBodyParserConfig
100
101
 
101
- constructor(config?: BodyParserConfig) {
102
+ constructor(explicitConfig: BodyParserConfig | undefined = undefined) {
103
+ // The default value is load-bearing: an OPTIONAL parameter still counts
104
+ // toward `Function.length`, and the container refuses to auto-construct a
105
+ // class that declares parameters it has no metadata for. A parameter with a
106
+ // default counts for nothing, which is what lets
107
+ // `router.use([() => import('…')])` build this middleware.
108
+ // Nothing is passed when the container builds this middleware from
109
+ // `router.use([() => import('@c9up/ream/bodyparser_middleware')])`, so the
110
+ // settings come from `config/bodyparser.ts` — the file this class's own
111
+ // documentation has always named.
112
+ const config = explicitConfig ?? readModuleConfig<BodyParserConfig>('bodyparser')
102
113
  assertNoEnabledFlag(config)
103
114
  this.#config = {
104
115
  allowedMethods: config?.allowedMethods ?? DEFAULT_CONFIG.allowedMethods,
@@ -0,0 +1,18 @@
1
+ /**
2
+ * `config/bodyparser.ts` — body-parsing limits and types, in the file the
3
+ * config loader reads (`config/<name>.ts` → `config.get('<name>')`).
4
+ *
5
+ * @example
6
+ * // config/bodyparser.ts
7
+ * import { defineConfig } from '@c9up/ream/bodyparser/config'
8
+ *
9
+ * export default defineConfig({
10
+ * multipart: { limit: '20mb' },
11
+ * })
12
+ */
13
+
14
+ import type { BodyParserConfig } from './BodyParserMiddleware.js'
15
+
16
+ export function defineConfig(config: BodyParserConfig): BodyParserConfig {
17
+ return config
18
+ }
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Reading a module's own `config/<name>.ts` entry without demanding one.
3
+ *
4
+ * A middleware constructed by the container gets nothing passed to it — the
5
+ * resolver calls `make(Class)`, which is what makes `router.use([() =>
6
+ * import('…/session_middleware')])` possible. The configuration therefore has
7
+ * to come from the config store, the way it does everywhere else.
8
+ *
9
+ * The read is deliberately forgiving. The same classes are also constructed
10
+ * directly (`new BodyParserMiddleware()`) in tests and in embedding hosts that
11
+ * never boot an Application, and there the store does not exist. Throwing there
12
+ * would trade a working default for a crash.
13
+ */
14
+
15
+ import { getApp } from '../services/app.js'
16
+
17
+ export function readModuleConfig<T extends object>(key: string): T | undefined {
18
+ const store = getApp()?.config
19
+ if (store === undefined || !store.has(key)) return undefined
20
+ const value = store.get<T>(key)
21
+ // A config file exporting something that is not an object (a stray
22
+ // `export default 42`) is ignored rather than spread over the defaults.
23
+ return typeof value === 'object' && value !== null ? value : undefined
24
+ }
@@ -750,7 +750,8 @@ function pad(text: string, width: number): string {
750
750
  return text + ' '.repeat(Math.max(0, width - visibleWidth(text)))
751
751
  }
752
752
 
753
- function stripAnsi(text: string): string {
753
+ /** Removes the SGR escape sequences `colors` writes, leaving the visible text. */
754
+ export function stripAnsi(text: string): string {
754
755
  // biome-ignore lint/suspicious/noControlCharactersInRegex: matching ANSI escapes is the point
755
756
  return text.replace(/\u001B\[[0-9;]*m/g, '')
756
757
  }
package/src/index.ts CHANGED
@@ -378,4 +378,4 @@ export {
378
378
  StatsTracker,
379
379
  } from './scheduler/index.js'
380
380
 
381
- export const VERSION = '0.2.15'
381
+ export const VERSION = '0.2.16'
@@ -10,7 +10,8 @@
10
10
  * throws, tasks 1..N-1 registered in the same boot are unregistered
11
11
  * before the error propagates, so the scheduler is never left in a
12
12
  * half-registered state.
13
- * - `start()` — launches the Rust tick loop.
13
+ * - `ready()` — discovers the tasks `app/modules/**` declared, then
14
+ * launches the Rust tick loop.
14
15
  * - `shutdown()` — cancels the Rust tick loop.
15
16
  *
16
17
  * The registered callback resolves the service **at invocation time**
@@ -86,26 +87,35 @@ export class ScheduleProvider extends Provider {
86
87
  }
87
88
 
88
89
  /**
89
- * Discovery runs at START, not at boot, and that is the whole point.
90
+ * The pass that matters runs at READY, and the ordering is the reason.
90
91
  *
91
- * `app/modules/**` is auto-loaded during the start phase — after every
92
- * provider has booted. A `@Service()` carrying `@Schedule` there, which is
93
- * where one naturally lives, was therefore registered into the service
94
- * registry AFTER this had already read it. The task was never registered,
95
- * and nothing said so: no error, no warning, the application started
96
- * normally and the task simply never fired.
92
+ * A `@Service()` carrying `@Schedule` naturally lives in `app/modules/**`,
93
+ * which the application auto-loads at the END of the start phase — after
94
+ * every provider's `start()`. Discovering in `start()` therefore read the
95
+ * service registry before the modules had put anything in it: the task was
96
+ * never registered, and nothing said so. No error, no warning, the
97
+ * application started normally and the task simply never fired. `ready()`
98
+ * runs after the autoload, which is what makes the second pass real.
97
99
  *
98
- * Reading the registry once the modules are in place is what fixes it. A
99
- * service declared anywhere earlier — a provider, a preload — is in the
100
- * registry by then too, so nothing is lost by waiting.
100
+ * The earlier passes are kept because they cost nothing and shorten the gap:
101
+ * a service declared by a provider or a preload is registered as soon as it
102
+ * is seen. `#discover()` is idempotent, so a task found twice is registered
103
+ * once.
101
104
  */
102
105
  override async boot(): Promise<void> {
103
106
  // Anything already in the registry — declared by a provider, or imported
104
- // by one. The rest is caught at start().
107
+ // by one. The rest is caught later.
105
108
  this.#discover()
106
109
  }
107
110
 
108
111
  override async start(): Promise<void> {
112
+ // Preloads have not run yet either; this catches whatever the boot phase
113
+ // added. The ticker deliberately does NOT start here.
114
+ this.#discover()
115
+ }
116
+
117
+ override async ready(): Promise<void> {
118
+ // The pass after `app/modules/**`.
109
119
  this.#discover()
110
120
  if (activeProvider !== undefined && activeProvider !== this) {
111
121
  // A previous app's scheduler is still running — stop it before this one
@@ -6,9 +6,11 @@
6
6
  */
7
7
 
8
8
  import { randomBytes } from 'node:crypto'
9
+ import { readModuleConfig } from '../config/moduleConfig.js'
9
10
  import { currentNodeEnv } from '../env/nodeEnv.js'
10
11
  import { durationToSeconds } from '../helpers/duration.js'
11
12
  import type { HttpContext } from '../http/HttpContext.js'
13
+ import type { SessionConfigInput } from './config.js'
12
14
  import { CookieDriver } from './drivers/CookieDriver.js'
13
15
  import { DatabaseDriver, type SessionDbConnection } from './drivers/DatabaseDriver.js'
14
16
  import { FileDriver } from './drivers/FileDriver.js'
@@ -16,7 +18,7 @@ import { MemoryDriver } from './drivers/MemoryDriver.js'
16
18
  import { RedisDriver } from './drivers/RedisDriver.js'
17
19
  import { quasarConnection } from './quasar.js'
18
20
  import { ReadOnlyValuesStore, type ValuePath } from './ReadOnlyValuesStore.js'
19
- import type { SessionConfig, SessionDriver } from './Session.js'
21
+ import type { SessionDriver } from './Session.js'
20
22
  import { Session } from './Session.js'
21
23
 
22
24
  interface ResolvedSessionConfig {
@@ -42,7 +44,18 @@ export default class SessionMiddleware {
42
44
  #cookieDriver: CookieDriver | null = null
43
45
  #config: ResolvedSessionConfig
44
46
 
45
- constructor(config?: SessionConfig & { secret?: string }) {
47
+ constructor(explicitConfig: SessionConfigInput | undefined = undefined) {
48
+ // The default value is load-bearing: an OPTIONAL parameter still counts
49
+ // toward `Function.length`, and the container refuses to auto-construct a
50
+ // class that declares parameters it has no metadata for. A parameter with a
51
+ // default counts for nothing, which is what lets
52
+ // `router.use([() => import('…')])` build this middleware.
53
+ // Nothing is passed when the container builds this middleware from
54
+ // `router.use([() => import('@c9up/ream/session_middleware')])`, which is
55
+ // the registration shape the framework documents. `config/session.ts` is
56
+ // where the settings live in that case — the same file the config loader
57
+ // already reads into `config.get('session')`.
58
+ const config = explicitConfig ?? readModuleConfig<SessionConfigInput>('session')
46
59
  // `store` + `stores` (AdonisJS) and `driver` (ream) name the same thing.
47
60
  // A named store supplies the driver and its own options, so
48
61
  // `{ store: 'redis', stores: { redis: { driver: 'redis' } } }` works.
@@ -0,0 +1,29 @@
1
+ /**
2
+ * `config/session.ts` — the session store's configuration, in the file the
3
+ * config loader reads (`config/<name>.ts` → `config.get('<name>')`).
4
+ *
5
+ * @example
6
+ * // config/session.ts
7
+ * import env from '#start/env.js'
8
+ * import { defineConfig } from '@c9up/ream/session/config'
9
+ *
10
+ * export default defineConfig({
11
+ * store: 'cookie',
12
+ * secret: env.get('APP_KEY'),
13
+ * })
14
+ */
15
+
16
+ import type { SessionConfig } from './Session.js'
17
+
18
+ /** What a session config file may declare. */
19
+ export type SessionConfigInput = SessionConfig & {
20
+ /**
21
+ * Signs the session cookie. Required by the cookie store, which carries the
22
+ * data itself and would otherwise hand the client something it could edit.
23
+ */
24
+ secret?: string
25
+ }
26
+
27
+ export function defineConfig(config: SessionConfigInput): SessionConfigInput {
28
+ return config
29
+ }