@rhythmjs/rhythm 0.0.11 → 0.0.12

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 (2) hide show
  1. package/README.md +16 -16
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,13 +1,13 @@
1
1
  # @rhythmjs/rhythm
2
2
 
3
- The core composition kernel `@rhythmjs/router` and `@rhythmjs/cli` are built on. Framework-agnostic — no router, no HTTP layer, and never will be.
3
+ The composition kernel at the core of Rhythm, the Bun-native backend framework, the piece `@rhythmjs/router` and `@rhythmjs/cli` are built on. It gives an application its structure (onion middleware, lifecycle-managed providers, encapsulated modules, all checked at compile time) and deliberately nothing else: no router, no HTTP layer, and never will be.
4
4
 
5
5
  ## Concepts
6
6
 
7
- - **Onion middleware** — `use()` wraps downstream steps, running code before _and_ after `next()`.
8
- - **Providers** — `provide()` registers a value or async factory that resolves once and joins the context at its position in the chain: only middleware (and mounted controllers) added after it see the value. A returned key prefixed with `#` (e.g. `"#close"`) stays out of context but is still passed in full to `dispose()`.
9
- - **Encapsulated modules** — `register()` mounts a child `Rhythm`; its context stays sealed unless you explicitly export fields from it.
10
- - **Readonly context** — the context passed to middleware is deeply readonly at the type level; state only changes via `next(extra)`, or through a value branded with the `RhythmMutable` symbol (how `RhythmRouter`/`RhythmCli`'s response objects stay mutable).
7
+ - **Onion middleware**: `use()` wraps downstream steps, running code before _and_ after `next()`.
8
+ - **Providers**: `provide()` registers a value or async factory that resolves once and joins the context at its position in the chain: only middleware (and mounted controllers) added after it see the value. A returned key prefixed with `#` (e.g. `"#close"`) stays out of context but is still passed in full to `dispose()`.
9
+ - **Encapsulated modules**: `register()` mounts a child `Rhythm`; its context stays sealed unless you explicitly export fields from it.
10
+ - **Readonly context**: the context passed to middleware is deeply readonly at the type level; state only changes via `next(extra)`, or through a value branded with the `RhythmMutable` symbol (how `RhythmRouter`/`RhythmCli`'s response objects stay mutable).
11
11
 
12
12
  ## Example
13
13
 
@@ -32,7 +32,7 @@ await app.run({ userId: "u1" });
32
32
  await app.teardown();
33
33
  ```
34
34
 
35
- `provide()` factories run once, in declaration order, each receiving everything resolved so far via `deps`. On each `run()`, the whole chain — middleware and provider injections alike — executes in registration order, onion-style: everything only applies to what was chained after it.
35
+ `provide()` factories run once, in declaration order, each receiving everything resolved so far via `deps`. On each `run()`, the whole chain, middleware and provider injections alike, executes in registration order, onion-style: everything only applies to what was chained after it.
36
36
 
37
37
  ### Module registration
38
38
 
@@ -55,13 +55,13 @@ const app = new Rhythm<{ userId: string }>()
55
55
 
56
56
  ## API
57
57
 
58
- - `new Rhythm<TInput>(options?)` — creates a pipeline; `options.name`/`options.type` label errors from `register()`.
59
- - `.use(fn: (ctx, next) => Promise<void> | void)` — add an onion middleware step.
60
- - `.provide(factory: (deps) => TValue | Promise<TValue>, dispose?)` — register a provider; resolved once, injected at its chain position, disposed in reverse order on `teardown()`.
61
- - `.register(other: Rhythm, exportValue?)` — mount a child `Rhythm` module; sealed by default, opt in via `exportValue`. Controllers (`RhythmRouter`, `RhythmCli`) are not modules — they mount via `.use()` instead.
62
- - `.run(input)` — runs `setup()` if needed, dispatches `input` through the middleware chain.
63
- - `.callback()` — returns the cached, reusable `(input) => Promise<TContext>` handler `run()` uses internally.
64
- - `.middleware()` — returns this instance as a plain middleware, for flat mounting into a parent via `.use()` instead of `.register()`.
65
- - `.setup()` — resolves all providers, cascading into registered modules. Idempotent; retryable on failure.
66
- - `.teardown()` — disposes all providers in reverse order, cascading into registered modules.
67
- - `compose(middleware[])` — the standalone Koa-style onion dispatcher `Rhythm` is built on.
58
+ - `new Rhythm<TInput>(options?)`: creates a pipeline; `options.name`/`options.type` label errors from `register()`.
59
+ - `.use(fn: (ctx, next) => Promise<void> | void)`: add an onion middleware step.
60
+ - `.provide(factory: (deps) => TValue | Promise<TValue>, dispose?)`: register a provider; resolved once, injected at its chain position, disposed in reverse order on `teardown()`.
61
+ - `.register(other: Rhythm, exportValue?)`: mount a child `Rhythm` module; sealed by default, opt in via `exportValue`. Controllers (`RhythmRouter`, `RhythmCli`) are not modules; they mount via `.use()` instead.
62
+ - `.run(input)`: runs `setup()` if needed, dispatches `input` through the middleware chain.
63
+ - `.callback()`: returns the cached, reusable `(input) => Promise<TContext>` handler `run()` uses internally.
64
+ - `.middleware()`: returns this instance as a plain middleware, for flat mounting into a parent via `.use()` instead of `.register()`.
65
+ - `.setup()`: resolves all providers, cascading into registered modules. Idempotent; retryable on failure.
66
+ - `.teardown()`: disposes all providers in reverse order, cascading into registered modules.
67
+ - `compose(middleware[])`: the standalone Koa-style onion dispatcher `Rhythm` is built on.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rhythmjs/rhythm",
3
- "version": "0.0.11",
3
+ "version": "0.0.12",
4
4
  "description": "A minimal, type-safe onion-middleware and provider composition kernel.",
5
5
  "homepage": "https://rhythm.js.org/rhythm",
6
6
  "license": "ISC",