@shivaedev/server 0.39.0 → 0.40.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.
- package/CHANGELOG.md +6 -0
- package/README.md +5 -2
- package/dist/appDatabaseHttp.d.ts +104 -104
- package/dist/appDatabaseHttp.d.ts.map +1 -1
- package/dist/appHost.d.ts +52 -52
- package/dist/appHost.d.ts.map +1 -1
- package/dist/appHostHttp.d.ts +52 -52
- package/dist/appHostHttp.d.ts.map +1 -1
- package/dist/hostRpc.d.ts +2 -3
- package/dist/hostRpc.d.ts.map +1 -1
- package/dist/hostRpc.js +4 -11
- package/dist/hostRpc.js.map +1 -1
- package/dist/hostRpcRoutes.d.ts +18 -18
- package/dist/hostRpcRoutes.d.ts.map +1 -1
- package/dist/hostRpcRoutes.js +2 -4
- package/dist/hostRpcRoutes.js.map +1 -1
- package/dist/servedGroup.d.ts +7 -0
- package/dist/servedGroup.d.ts.map +1 -0
- package/dist/servedGroup.js +15 -0
- package/dist/servedGroup.js.map +1 -0
- package/dist/servedHandlers.d.ts +10 -0
- package/dist/servedHandlers.d.ts.map +1 -0
- package/dist/servedHandlers.js +8 -0
- package/dist/servedHandlers.js.map +1 -0
- package/package.json +8 -8
- package/src/hostRpc.ts +4 -12
- package/src/hostRpcRoutes.ts +2 -6
- package/src/servedGroup.ts +16 -0
- package/src/servedHandlers.ts +13 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.40.0 - 2026-11-21
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- `servedGroup(group, websocket)` from `@shivaedev/server/servedGroup.ts` and `servedHandlers(group, handlers, buildVersion?)` from `@shivaedev/server/servedHandlers.ts` are the composition `appHost` serves its RPC group with: the read policy guard, which refuses `$changes` over HTTP, the command guard, the change stream, the host version and live sync. A native RPC host uses them to serve as `appHost` does.
|
|
8
|
+
|
|
3
9
|
## 0.39.0 - 2026-11-21
|
|
4
10
|
|
|
5
11
|
### Added
|
package/README.md
CHANGED
|
@@ -102,6 +102,8 @@ const hosts = Effect.gen(function* () {
|
|
|
102
102
|
});
|
|
103
103
|
```
|
|
104
104
|
|
|
105
|
+
An application built with [`@shivaedev/build`](https://github.com/ShivaeDev/platform/tree/main/packages/build#the-servers-module-list) writes no such list: its generator finds every exported registration written `satisfies AppModule` and writes them to `src/generated/server/modules.ts` in the order of their files' paths, and the application passes that list to `appModules` beside the registrations that are not module folders, such as its foundation, so a module is registered by creating its folder. Admin navigation and the order in which `appModules` composes Layers follow the list. What the merged Layers provide and the migrations do not depend on it, because migrations run by their number. An application that needs another order renames a module's folder, or composes that registration beside its foundation where the generator does not find it, such as a function that returns it.
|
|
106
|
+
|
|
105
107
|
A module defined with `defineModule` from `@shivaedev/contract/defineModule.ts` registers as `module:`, and the host builds its group and its handlers with `moduleHandlers`. Its handlers need the services its operations' `run` and read policies yield, less what its middleware and subject provide per call; the registration's `services` and `ports` provide them, except the SQL client and the other services the host provides. An RPC group that is not a defined module, such as a contract served by hand-written handlers, registers as `group` plus `handlers` instead, and both kinds sit in one application's module list:
|
|
106
108
|
|
|
107
109
|
```ts
|
|
@@ -355,7 +357,7 @@ To pass worker-release time in a story, build `hostTime()` from `@shivaedev/test
|
|
|
355
357
|
|
|
356
358
|
For a deployment behind a proxy, set `HOST=0.0.0.0` and `TRUSTED_PROXY` to a comma-separated list of proxy peer IPs or CIDR ranges (IPv4 or IPv6), or use `config.host` and `config.trustedProxy`. Only matching peers may supply `X-Forwarded-Host` and `X-Forwarded-Proto` (`http` or `https`) for the guard's same-origin check; the proxy must overwrite both headers and preserve Origin. A single authority is required, and comma-separated forwarding chains are refused. IPv4-mapped IPv6 peers match their IPv4 address. A session host bound to a non-loopback address refuses to boot without `TRUSTED_PROXY` or `config.trustedProxy`, with a typed `TrustedProxyRequired` error from `@shivaedev/server/TrustedProxyRequired.ts` naming both settings and how to supply proxy peer addresses or CIDR ranges. Local loopback hosts keep working without proxy trust; `policy: "loopback"` does not use proxy trust. Malformed addresses or ranges fail `appHost` startup with a typed `ConfigError`. The starter's Railway deployment works out of the box: its web configuration supplies `TRUSTED_PROXY=100.64.0.0/10` and `AUTH_CLIENT_IP_HEADER=x-real-ip`, so matching peers supply forwarded client IPs for auth and the HTTPS authority for RPC origin checks. Set `PUBLIC_URL` to the app's HTTPS URL for secure session cookies. NDJSON and the application's session Origin policy still apply. See the [deployment quickstart](https://github.com/ShivaeDev/platform/blob/main/docs/framework/quickstart.md#deploy).
|
|
357
359
|
|
|
358
|
-
When mounting Better Auth routes yourself on Railway, use `betterAuthMount(
|
|
360
|
+
When mounting Better Auth routes yourself on Railway, use `betterAuthMount(AppAuth, { clientIp: "railway" })` from `@shivaedev/identity/server/better-auth/mount.ts` with `TRUSTED_PROXY=100.64.0.0/10`. The `clientIp` preset selects `X-Real-IP` for auth and ignores spoofed `X-Forwarded-For`, overriding `AUTH_CLIENT_IP_HEADER`. Untrusted peers and requests without `X-Real-IP` use the connection address.
|
|
359
361
|
|
|
360
362
|
A host given an RPC group directly, rather than the `appModules` result, takes handlers for that group: build them with `Api.application.toLayer(...)` (and `Api.application.of(...)` for an Effect-built handler map), then pass the full `Api` to the host and client. `Api.application` is the native RPC group without the reserved `$changes` stream; the host supplies that handler. The explicit `Api.omit("<namespace>.$changes")` form also works.
|
|
361
363
|
|
|
@@ -477,7 +479,7 @@ A nested `runWithServices` call replaces the outer invocation's overrides for it
|
|
|
477
479
|
|
|
478
480
|
### Node subscriptions: combine cancellation and clean up
|
|
479
481
|
|
|
480
|
-
A native host
|
|
482
|
+
A native RPC host serves what `appHost` serves through two pieces. `yield* servedGroup(group, websocket)` from `@shivaedev/server/servedGroup.ts` returns the `group` to serve, with the read policy guard and the command guard in place, and the `guards` Layer to provide: a host with `websocket: false` refuses `$changes` calls with `WebSocketRequired`, as `appHost`'s HTTP route does. `servedHandlers(group, handlers, buildVersion?)` from `@shivaedev/server/servedHandlers.ts` adds the group's change stream, the host version and live sync to the application's handlers; the change stream depends on the ordinary handlers because a subscription runs the authorized query to produce its first result. `appHost` composes both itself.
|
|
481
483
|
|
|
482
484
|
A long-lived response can receive cancellation from a Web request, a procedure and its underlying Node connection:
|
|
483
485
|
|
|
@@ -589,6 +591,7 @@ Import the module that defines the name; there is no package-root entry. Paths b
|
|
|
589
591
|
| `migrationsIn.ts` | `migrationsIn(directory)`: an `AppModule` `migrations` value that loads the `migrations` folder in `directory` under Node. |
|
|
590
592
|
| `adapters/makePlatformRuntime.ts` | `makePlatformRuntime(layer, { developmentCacheKey? })`. |
|
|
591
593
|
| `subscriptionSignal.ts` | `nodeSubscriptionSignal({ nodeRequest?, request?, signals? })`, returning `{ signal, dispose }`. |
|
|
594
|
+
| `servedGroup.ts`, `servedHandlers.ts` | `servedGroup(group, websocket)`, `servedHandlers(group, handlers, buildVersion?)`: the served group, guards and handlers `appHost` composes, for a native RPC host. |
|
|
592
595
|
|
|
593
596
|
### Install, setup and limits
|
|
594
597
|
|