@shivaedev/platform 0.6.1 → 0.7.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.
Files changed (63) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/README.md +20 -10
  3. package/dist/rpc/middleware.d.ts +1 -1
  4. package/dist/rpc/middleware.d.ts.map +1 -1
  5. package/dist/rpc/middleware.js +1 -1
  6. package/dist/rpc/middleware.js.map +1 -1
  7. package/dist/server/appHost.d.ts +27 -22
  8. package/dist/server/appHost.d.ts.map +1 -1
  9. package/dist/server/appHost.js +7 -48
  10. package/dist/server/appHost.js.map +1 -1
  11. package/dist/server/appHostHttp.d.ts +11 -0
  12. package/dist/server/appHostHttp.d.ts.map +1 -0
  13. package/dist/server/appHostHttp.js +51 -0
  14. package/dist/server/appHostHttp.js.map +1 -0
  15. package/dist/server/boundedRpcRequest.d.ts +3 -0
  16. package/dist/server/boundedRpcRequest.d.ts.map +1 -0
  17. package/dist/server/boundedRpcRequest.js +41 -0
  18. package/dist/server/boundedRpcRequest.js.map +1 -0
  19. package/dist/server/databaseLayer.d.ts +6 -0
  20. package/dist/server/databaseLayer.d.ts.map +1 -0
  21. package/dist/server/databaseLayer.js +29 -0
  22. package/dist/server/databaseLayer.js.map +1 -0
  23. package/dist/server/hostOptions.d.ts +28 -0
  24. package/dist/server/hostOptions.d.ts.map +1 -0
  25. package/dist/server/hostOptions.js +2 -0
  26. package/dist/server/hostOptions.js.map +1 -0
  27. package/dist/server/rpc-server/local.d.ts +3 -3
  28. package/dist/server/rpc-server/local.d.ts.map +1 -1
  29. package/dist/server/rpc-server/local.js +16 -12
  30. package/dist/server/rpc-server/local.js.map +1 -1
  31. package/dist/server/rpc-server/origin.d.ts +1 -1
  32. package/dist/server/rpc-server/origin.d.ts.map +1 -1
  33. package/dist/server/rpc-server/origin.js +1 -1
  34. package/dist/server/rpc-server/origin.js.map +1 -1
  35. package/dist/server/rpc-server/session.d.ts +1 -1
  36. package/dist/server/rpc-server/session.d.ts.map +1 -1
  37. package/dist/server/rpc-server/tracing.js +1 -1
  38. package/dist/server/rpc-server/tracing.js.map +1 -1
  39. package/dist/server/rpc-server/transportHeaders.d.ts +1 -1
  40. package/dist/server/rpc-server/transportHeaders.d.ts.map +1 -1
  41. package/dist/server/rpc-server/transportHeaders.js +1 -1
  42. package/dist/server/rpc-server/transportHeaders.js.map +1 -1
  43. package/dist/server/rpc-server/trustedProxy.d.ts +6 -0
  44. package/dist/server/rpc-server/trustedProxy.d.ts.map +1 -0
  45. package/dist/server/rpc-server/trustedProxy.js +35 -0
  46. package/dist/server/rpc-server/trustedProxy.js.map +1 -0
  47. package/dist/server/runtime/makePlatform.js +1 -1
  48. package/docs/roadmap.md +1 -1
  49. package/package.json +27 -27
  50. package/src/rpc/middleware.ts +1 -1
  51. package/src/server/appHost.ts +90 -94
  52. package/src/server/appHostHttp.ts +101 -0
  53. package/src/server/boundedRpcRequest.ts +47 -0
  54. package/src/server/databaseLayer.ts +36 -0
  55. package/src/server/hostOptions.ts +25 -0
  56. package/src/server/rpc-server/adapters/betterAuthSessions.ts +1 -1
  57. package/src/server/rpc-server/local.ts +18 -16
  58. package/src/server/rpc-server/origin.ts +1 -1
  59. package/src/server/rpc-server/session.ts +1 -1
  60. package/src/server/rpc-server/tracing.ts +1 -1
  61. package/src/server/rpc-server/transportHeaders.ts +1 -1
  62. package/src/server/rpc-server/trustedProxy.ts +36 -0
  63. package/src/server/runtime/makePlatform.ts +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,28 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.7.0 - 2026-10-13
4
+
5
+ ### Added
6
+
7
+ - `appHost` accepts `rpcPath` to choose the NDJSON RPC route; it still defaults to `/rpc`.
8
+ - `appHost` accepts `policy: "loopback"` for local RPC without a session provider; `AppLocalHostOptions` describes this form. The transport still requires a loopback peer and Host, matching or absent Origin, and NDJSON content type; proxy trust does not apply to this policy.
9
+ - `appHost` can omit `migrations` to start without a PostgreSQL pool or database configuration. `AppHttpHostOptions` describes this form while `AppHostOptions` retains its required migrations. Applications can provide an `appDatabase` layer through `services`; existing callers that supply migrations keep the migrated database composition.
10
+ - `appDatabase` and the migrated `appHost` accept `config.maxConnections` to bound the PostgreSQL pool.
11
+ - `appHost` forwards `config.disablePreemptiveShutdown` to the native Node host so a scoped daemon can interrupt its RPC streams during shutdown. The native default remains unchanged when omitted.
12
+ - `appHost` accepts an optional native HTTP router layer through `routes`, so application endpoints such as Better Auth share the RPC and asset host.
13
+ - `appHost.assets` also accepts native static-server options, including `spa: true` for browser route deep links. Existing directory strings keep their behavior.
14
+ - `AppHostOptions.config.trustedProxy` / `TRUSTED_PROXY` and `localRpcGuard(effect, trustedProxy?)` accept comma-separated IPv4 and IPv6 addresses and CIDR ranges, including IPv4-mapped IPv6 peers. Invalid proxy addresses or ranges fail `appHost` startup with a typed `ConfigError` before migrations, services or HTTP start.
15
+ - `appHost` accepts `config.maxBodySize` and the `MAX_BODY_SIZE` environment variable to limit RPC request bodies in bytes; explicit config takes precedence.
16
+
17
+ ### Changed
18
+
19
+ - `appHost` accepts native router layers with typed request error annotations in `routes`, so applications can keep their route failures typed through the HTTP boundary.
20
+ - RPC request bodies default to a 1 MiB limit. Oversized NDJSON requests return a 4xx before any RPC handler runs.
21
+
22
+ ### Breaking
23
+
24
+ - Requires stable Effect 4.0.4 in place of 4.0.0-rc.112. Effect 4.0.4 moves the former `effect/unstable/*` modules to `effect/*` and renames constructors such as `Config.string` to `Config.String`. Install `@effect/platform-node`, `@effect/sql-pg` and `@effect/vitest` 4.0.4 alongside it; `@effect/vitest` 4.0.4 requires Vitest 5.
25
+
3
26
  ## 0.6.1 - 2026-10-12
4
27
 
5
28
  ### Added
package/README.md CHANGED
@@ -37,7 +37,7 @@ The optional modules solve different boundaries. `runtime/` carries Effect servi
37
37
 
38
38
  ### Host the application
39
39
 
40
- `appHost` is the server entry point for a PostgreSQL app. Supply the native RPC group, handler and service Layers, migration loader, session policy and static asset directory. The host completes migrations before acquiring application services, starts Node HTTP with NDJSON RPC at `/rpc`, and provides SQL, Reactivity and `AppChanges` to those Layers.
40
+ `appHost` is the server entry point for an Effect app. For a PostgreSQL app, supply the native RPC group, handler and service Layers, migration loader, session policy and static asset directory. The host completes migrations before acquiring application services, starts Node HTTP with NDJSON RPC at `/rpc`, and provides SQL, Reactivity and `AppChanges` to those Layers.
41
41
 
42
42
  ```ts
43
43
  import { NodeRuntime } from "@effect/platform-node";
@@ -59,11 +59,21 @@ NodeRuntime.runMain(Layer.launch(Server));
59
59
 
60
60
  `app.ts` exports the application's contracts, native Layers, numbered `Migrator.Loader` and `SessionPolicy`. The host needs the optional peers `@effect/platform-node` and `@effect/sql-pg` at the workspace's Effect version; install both for this entry point. The `errors/`, `node-http/`, `rpc/`, `rpc-server/` and `runtime/` entries still work without them.
61
61
 
62
- The listener uses `HOST` or `127.0.0.1`, uses `PORT` or 3000, and reads `DATABASE_URL`. Set overrides in the one `config` object: `host`, `port` (0 selects an ephemeral port), `trustedProxy`, `databaseUrl` (an Effect `Redacted<string>`), `applicationName`, and optional `changes`. Migration options accept `table` and `lockTimeout` (default `effect_sql_migrations` and five seconds). Native Layer failures remain in the build error channel; missing application dependencies remain in the requirement type.
62
+ `assets` accepts a directory string or native `HttpStaticServer.layer` options. For a browser app whose routes must also work on direct navigation or reload, use `{ root: "dist", spa: true }` or merge `HttpStaticServer.layer({ root: "dist", spa: true })` from `effect/http` alongside the handler Layer. Native route Layers can register additional endpoints in that same composition; `routes` also accepts a native `Layer<never, never, HttpRouter>` for endpoints on the same listener. The [starter](https://github.com/ShivaeDev/platform/tree/main/examples/starter) uses it for static assets and Better Auth at `/api/auth/*`, with provider-owned cookies and the host's RPC session middleware.
63
63
 
64
- RPC uses the existing `localRpcGuard`: it requires a loopback peer and Host, same-origin or absent Origin, and the NDJSON content type. Session lookup uses transport headers. Contracts declare `Authenticated`, `MaybeAuthenticated` and `RequestTracing` as needed; the host supplies their implementations. Declared errors retain their Schema types. Applications still own resource authorization and use `rpcBoundary` when they need to map unexpected failures.
64
+ The listener uses `HOST` or `127.0.0.1`, uses `PORT` or 3000, and reads `DATABASE_URL`. Set overrides in the one `config` object: `host`, `port` (0 selects an ephemeral port), `trustedProxy`, `maxBodySize`, `databaseUrl` (an Effect `Redacted<string>`), `applicationName`, and optional `changes`. Migration options accept `table` and `lockTimeout` (default `effect_sql_migrations` and five seconds). Native Layer failures remain in the build error channel; missing application dependencies remain in the requirement type.
65
65
 
66
- For a deployment behind a proxy, set `HOST=0.0.0.0` and `TRUSTED_PROXY` to the proxy's exact peer IP, or use `config.host` and `config.trustedProxy`. Only that peer 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. NDJSON and the application's session Origin policy still apply. Real forwarding-proxy tests cover trusted and untrusted peers, configuration overrides and typed refusals; they do not establish any hosting provider's proxy configuration. See the [deployment quickstart](https://github.com/ShivaeDev/platform/blob/main/docs/framework/quickstart.md#deploy).
66
+ RPC request bodies are limited to 1 MiB by default. Set `MAX_BODY_SIZE` to a byte count or override it with `config.maxBodySize`, a nonnegative safe integer. An oversized NDJSON body returns a 4xx before any RPC handler runs; real HTTP tests cover fixed-length and chunked requests, byte counting, and configuration precedence. This limit applies to the host's RPC route.
67
+
68
+ RPC uses the existing `localRpcGuard`: it requires a loopback peer and Host, same-origin or absent Origin, and the NDJSON content type. Session lookup uses transport headers. With a session policy, contracts declare `Authenticated`, `MaybeAuthenticated` and `RequestTracing` as needed; the host supplies their implementations. Declared errors retain their Schema types. Applications still own resource authorization and use `rpcBoundary` when they need to map unexpected failures.
69
+
70
+ For local tools, use `policy: "loopback"` with contracts that do not use session middleware to serve RPC without a session provider. The guard requires a loopback peer and Host, absent or same-origin Origin, and NDJSON content type. This policy does not use `TRUSTED_PROXY` or `config.trustedProxy`. Set `rpcPath` to choose another native RPC route; `/rpc` remains the default.
71
+
72
+ Omit `migrations` to host an app without a database. This form creates no SQL pool and reads no `DATABASE_URL`; `AppHttpHostOptions` describes it. `AppHostOptions` retains its required migrations for existing typed callers. A service that needs SQL still requires a SQL Layer. Provide `appDatabase` to the application’s service Layer when it owns database composition, as Fleet's daemon does with its migration loader and namespace ledger. Real HTTP tests cover the custom route, session-free loopback guard and database-free startup; Fleet's PostgreSQL daemon tests cover the adopted composition.
73
+
74
+ Set `config.maxConnections` on `appDatabase` or a migrated `appHost` to bound the pool. A daemon with long-lived RPC streams can use `config.disablePreemptiveShutdown: true` to let scope closure interrupt those streams before closing the listener; omitting it keeps Node's native graceful-shutdown default. Fleet's daemon tests cover one bounded pool and scoped provider and listener cleanup, including follower reconnection after shutdown.
75
+
76
+ 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. Malformed addresses or ranges fail `appHost` startup with a typed `ConfigError`. NDJSON and the application's session Origin policy still apply. Real forwarding-proxy tests cover trusted and untrusted peers, configuration overrides and typed refusals; they do not establish any hosting provider's proxy configuration. See the [deployment quickstart](https://github.com/ShivaeDev/platform/blob/main/docs/framework/quickstart.md#deploy).
67
77
 
68
78
  A subscription handler reads `AppChanges` and returns `changes.stream(keys)` after its authorization check. Writes use `transact` and `invalidateOnCommit` from effect-sql: local streams receive committed invalidations and rollback emits none. For delivery between processes, set `config.changes: { channel: "app_changes" }`; the host binds PostgreSQL LISTEN/NOTIFY to the same SQL pool and resyncs streams when its listener recovers. The native heartbeat and retry options may be supplied in `changes`. A worker can provide `appDatabase({ migrations, config })` to its service Layer to share this database and delivery composition without starting HTTP.
69
79
 
@@ -75,7 +85,7 @@ Declare the RPC group in a shared module:
75
85
 
76
86
  ```ts
77
87
  import { Effect, Schema } from "effect";
78
- import { Rpc, RpcGroup } from "effect/unstable/rpc";
88
+ import { Rpc, RpcGroup } from "effect/rpc";
79
89
  import { Forbidden } from "@shivaedev/platform/errors/taxonomy.ts";
80
90
  import { Identity } from "@shivaedev/platform/rpc/identity.ts";
81
91
  import { Authenticated, RequestTracing } from "@shivaedev/platform/rpc/middleware.ts";
@@ -133,7 +143,7 @@ Use `Authenticated` when the operation needs `Identity`, and `MaybeAuthenticated
133
143
 
134
144
  ```ts
135
145
  import { Effect, Option, Schema } from "effect";
136
- import { Rpc, RpcGroup } from "effect/unstable/rpc";
146
+ import { Rpc, RpcGroup } from "effect/rpc";
137
147
  import { OptionalIdentity } from "@shivaedev/platform/rpc/identity.ts";
138
148
  import { MaybeAuthenticated } from "@shivaedev/platform/rpc/middleware.ts";
139
149
 
@@ -156,7 +166,7 @@ A missing session produces `Option.none()` here. The same policy still rejects f
156
166
 
157
167
  For an HTTP RPC server that serves only the local machine, wrap its HTTP effect with `localRpcGuard` from `@shivaedev/platform/rpc-server/local.ts`. Provide the native `HttpServerRequest` and `RpcSerialization` services around the returned effect, using the same serialization as the RPC server. No session provider is required.
158
168
 
159
- By default, the guard returns HTTP 403 before running the effect unless the transport reports a loopback peer address, the Host is a loopback host, any Origin matches the HTTP Host, and the content type matches the serialization. An absent peer address is rejected. Real Node HTTP tests cover accepted local requests and rejected Origin, Host and content-type requests, including a DNS-rebinding Host on a loopback connection. The optional second argument, `localRpcGuard(effect, trustedProxy)`, enables the same exact-peer forwarding policy as `appHost`.
169
+ By default, the guard returns HTTP 403 before running the effect unless the transport reports a loopback peer address, the Host is a loopback host, any Origin matches the HTTP Host, and the content type matches the serialization. An absent peer address is rejected. Real Node HTTP tests cover accepted local requests and rejected Origin, Host and content-type requests, including a DNS-rebinding Host on a loopback connection. The optional second argument, `localRpcGuard(effect, trustedProxy)`, enables the same address and range forwarding policy as `appHost`.
160
170
 
161
171
  The same module exports `loopbackOnly(handler)` for local page routes and `sameOrigin(request)` for an HTTP Origin check. `loopbackOnly` checks Host and any known peer address; it permits an absent peer address so embedded Fetch page handlers remain usable. It does not check Origin or content type.
162
172
 
@@ -164,7 +174,7 @@ Declare expected refusals in the RPC's error schema:
164
174
 
165
175
  ```ts
166
176
  import { Schema } from "effect";
167
- import { Rpc } from "effect/unstable/rpc";
177
+ import { Rpc } from "effect/rpc";
168
178
  import { BadRequest, Conflict } from "@shivaedev/platform/errors/taxonomy.ts";
169
179
 
170
180
  export const Rename = Rpc.make("Rename", {
@@ -355,7 +365,7 @@ Import the module that defines the name; there is no package-root entry. Paths b
355
365
 
356
366
  | Module | Names and purpose |
357
367
  | --- | --- |
358
- | `appHost.ts` | `appHost({ group, handlers, services, migrations, sessions, assets?, config? })`, `appDatabase({ migrations, config? })`, `AppChanges`, `AppHostOptions`, `AppDatabaseOptions`: scoped HTTP and PostgreSQL composition with loopback defaults and optional proxy trust. |
368
+ | `appHost.ts` | `appHost({ group, handlers, services, migrations?, sessions?, policy?, rpcPath?, assets?, routes?, config? })`, `appDatabase({ migrations, config? })`, `AppChanges`, `AppHostOptions`, `AppHttpHostOptions`, `AppLocalHostOptions`, `AppDatabaseOptions`: scoped HTTP and PostgreSQL composition with loopback defaults and optional proxy trust. |
359
369
  | `errors/taxonomy.ts` | `NotFound`, `Unauthorized`, `Forbidden`, `BadRequest`, `Conflict`, `PreconditionFailed`, `TooManyRequests`, `AuthUnavailable`, `InternalServerError`, `ServiceUnavailable`: Schema tagged error classes with a `message`; `BadRequest` and `Conflict` also accept an optional `field`. |
360
370
  | `errors/rejected-field.ts` | `rejectedField(unknown): Option<RejectedField>`; `RejectedField` is `{ field: string, message: string }`. |
361
371
  | `rpc/identity.ts` | `RequestId`: string service. `Identity`: `IdentityValue`, `{ id: string }`. `OptionalIdentity`: `Option<IdentityValue>`. |
@@ -384,7 +394,7 @@ The exports also include the adapter's translation modules: `makeRowAdapter` and
384
394
  ### Install, setup and limits
385
395
 
386
396
  ```sh
387
- pnpm add @shivaedev/platform effect@4.0.0-rc.112
397
+ pnpm add @shivaedev/platform effect@4.0.4
388
398
  ```
389
399
 
390
400
  Effect is the only required peer. The peer-free implementation lives in the shared `src/errors/` and `src/rpc/` folders and the `src/server/node-http/`, `src/server/rpc-server/` and `src/server/runtime/` folders; explicit exports retain the defining-module import paths listed above. The package-local `quality.fences.config.ts` prevents core from reaching optional peers listed in the manifest. The core errors, RPC declarations, server middleware, runtime and Node HTTP modules can be imported without the optional peers, including the Promise-based `betterAuthSessions` function. The runtime uses Node's `AsyncLocalStorage`; browser consumers import the shared `errors/` and `rpc/` modules.
@@ -1,5 +1,5 @@
1
1
  import { Schema } from "effect";
2
- import { RpcMiddleware } from "effect/unstable/rpc";
2
+ import { RpcMiddleware } from "effect/rpc";
3
3
  import { AuthUnavailable, Forbidden, Unauthorized } from "#errors/taxonomy.ts";
4
4
  import type { Identity, OptionalIdentity, RequestId } from "./identity.ts";
5
5
  declare const RequestTracing_base: RpcMiddleware.ServiceClass<RequestTracing, "@shivaedev/platform/rpc/RequestTracing", RequestId, Schema.Never, never, never, false>;
@@ -1 +1 @@
1
- {"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../../src/rpc/middleware.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAC/E,OAAO,KAAK,EAAE,QAAQ,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;;AAC3E,qBAAa,cAAe,SAAQ,mBAKS;CAAG;;AAChD,qBAAa,aAAc,SAAQ,kBAOjC;CAAG;;AACL,qBAAa,kBAAmB,SAAQ,uBAKgE;CAAG"}
1
+ {"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../../src/rpc/middleware.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAC/E,OAAO,KAAK,EAAE,QAAQ,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;;AAC3E,qBAAa,cAAe,SAAQ,mBAKS;CAAG;;AAChD,qBAAa,aAAc,SAAQ,kBAOjC;CAAG;;AACL,qBAAa,kBAAmB,SAAQ,uBAKgE;CAAG"}
@@ -1,5 +1,5 @@
1
1
  import { Schema } from "effect";
2
- import { RpcMiddleware } from "effect/unstable/rpc";
2
+ import { RpcMiddleware } from "effect/rpc";
3
3
  import { AuthUnavailable, Forbidden, Unauthorized } from "#errors/taxonomy.ts";
4
4
  export class RequestTracing extends RpcMiddleware.Service()("@shivaedev/platform/rpc/RequestTracing") {
5
5
  }
@@ -1 +1 @@
1
- {"version":3,"file":"middleware.js","sourceRoot":"","sources":["../../src/rpc/middleware.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAE/E,MAAM,OAAO,cAAe,SAAQ,aAAa,CAAC,OAAO,EAKtD,CAAC,wCAAwC,CAAC;CAAG;AAChD,MAAM,OAAO,aAAc,SAAQ,aAAa,CAAC,OAAO,EAKrD,CAAC,uCAAuC,EAAE;IAC5C,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,YAAY,EAAE,eAAe,EAAE,SAAS,CAAC,CAAC;CAC/D,CAAC;CAAG;AACL,MAAM,OAAO,kBAAmB,SAAQ,aAAa,CAAC,OAAO,EAK1D,CAAC,4CAA4C,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,eAAe,EAAE,SAAS,CAAC,CAAC,EAAE,CAAC;CAAG"}
1
+ {"version":3,"file":"middleware.js","sourceRoot":"","sources":["../../src/rpc/middleware.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAE/E,MAAM,OAAO,cAAe,SAAQ,aAAa,CAAC,OAAO,EAKtD,CAAC,wCAAwC,CAAC;CAAG;AAChD,MAAM,OAAO,aAAc,SAAQ,aAAa,CAAC,OAAO,EAKrD,CAAC,uCAAuC,EAAE;IAC5C,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,YAAY,EAAE,eAAe,EAAE,SAAS,CAAC,CAAC;CAC/D,CAAC;CAAG;AACL,MAAM,OAAO,kBAAmB,SAAQ,aAAa,CAAC,OAAO,EAK1D,CAAC,4CAA4C,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,eAAe,EAAE,SAAS,CAAC,CAAC,EAAE,CAAC;CAAG"}
@@ -1,13 +1,10 @@
1
- import { NodeServices } from "@effect/platform-node";
2
- import * as PgClient from "@effect/sql-pg/PgClient";
3
- import { Config, Context, type Duration, Effect, Layer, type Redacted } from "effect";
4
- import { HttpRouter } from "effect/unstable/http";
5
- import * as Reactivity from "effect/unstable/reactivity/Reactivity";
6
- import { type Rpc, type RpcGroup, RpcSerialization } from "effect/unstable/rpc";
7
- import type { Migrator } from "effect/unstable/sql";
8
- import { type PostgresChangesOptions } from "@shivaedev/effect-sql/postgresChanges.ts";
9
- import type { Authenticated, MaybeAuthenticated, RequestTracing } from "#rpc/middleware.ts";
10
- import { type SessionPolicy, type SessionShape } from "#rpc-server/session.ts";
1
+ import { Context, type Duration, type Effect, type Redacted } from "effect";
2
+ import type { Rpc } from "effect/rpc";
3
+ import type { Migrator } from "effect/sql";
4
+ import type { PostgresChangesOptions } from "@shivaedev/effect-sql/postgresChanges.ts";
5
+ import type { SessionPolicy, SessionShape } from "#rpc-server/session.ts";
6
+ import { appHostHttp, migratedHost } from "./appHostHttp.ts";
7
+ import type { HostOptions, HostPolicy } from "./hostOptions.ts";
11
8
  declare const AppChanges_base: Context.ServiceClass<AppChanges, "@shivaedev/platform/AppChanges", {
12
9
  resync: Effect.Effect<void, never, never>;
13
10
  stream: (keys: readonly import("@shivaedev/effect-contract/keys.ts").Key[]) => import("effect/Stream").Stream<{
@@ -30,6 +27,7 @@ export interface AppDatabaseOptions<R = never> {
30
27
  readonly config?: {
31
28
  readonly databaseUrl?: Redacted.Redacted<string>;
32
29
  readonly applicationName?: string;
30
+ readonly maxConnections?: number;
33
31
  readonly changes?: Omit<PostgresChangesOptions, "client" | "resync">;
34
32
  };
35
33
  readonly migrations: {
@@ -38,19 +36,26 @@ export interface AppDatabaseOptions<R = never> {
38
36
  readonly lockTimeout?: Duration.Input;
39
37
  };
40
38
  }
41
- export declare function appDatabase<R>(options: AppDatabaseOptions<R>): Layer.Layer<AppChanges | PgClient.PgClient | Reactivity.Reactivity | import("effect/unstable/sql/SqlClient").SqlClient, Config.ConfigError | Migrator.MigrationError | import("effect/unstable/sql/SqlError").SqlError, Exclude<Exclude<R, import("effect/Scope").Scope>, PgClient.PgClient | import("effect/unstable/sql/SqlClient").SqlClient>>;
42
- export interface AppHostOptions<TRpcs extends Rpc.Any, THandlers, THandlerError, THandlerRequirements, TServices, TServiceError, TServiceRequirements, TMigrations, TSession extends SessionShape> extends AppDatabaseOptions<TMigrations> {
43
- readonly assets?: string;
44
- readonly config?: AppDatabaseOptions<TMigrations>["config"] & {
45
- readonly port?: number;
46
- readonly host?: string;
47
- readonly trustedProxy?: string;
48
- };
49
- readonly group: RpcGroup.RpcGroup<TRpcs>;
50
- readonly handlers: Layer.Layer<THandlers, THandlerError, THandlerRequirements>;
51
- readonly services: Layer.Layer<TServices, TServiceError, TServiceRequirements>;
39
+ export declare function appDatabase<R>(options: AppDatabaseOptions<R>): import("effect/Layer").Layer<AppChanges | import("@effect/sql-pg/PgClient").PgClient | import("effect/reactivity/Reactivity").Reactivity | import("effect/sql/SqlClient").SqlClient, import("effect/Config").ConfigError | Migrator.MigrationError | import("effect/sql/SqlError").SqlError, Exclude<Exclude<R, import("effect/Scope").Scope>, import("@effect/sql-pg/PgClient").PgClient | import("effect/sql/SqlClient").SqlClient>>;
40
+ export interface AppHostOptions<TRpcs extends Rpc.Any, THandlers, THandlerError, THandlerRequirements, TServices, TServiceError, TServiceRequirements, TMigrations, TSession extends SessionShape> extends HostOptions<TRpcs, THandlers, THandlerError, THandlerRequirements, TServices, TServiceError, TServiceRequirements> {
41
+ readonly migrations: AppDatabaseOptions<TMigrations>["migrations"];
42
+ readonly policy?: undefined;
52
43
  readonly sessions: SessionPolicy<TSession>;
53
44
  }
54
- export declare function appHost<TRpcs extends Rpc.Any, THandlers, THandlerError, THandlerRequirements, TServices, TServiceError, TServiceRequirements, TMigrations, TSession extends SessionShape>(options: AppHostOptions<TRpcs, THandlers, THandlerError, THandlerRequirements, TServices, TServiceError, TServiceRequirements, TMigrations, TSession>): Layer.Layer<TServices | AppChanges | import("effect/unstable/http/Etag").Generator | import("effect/unstable/http/HttpPlatform").HttpPlatform | import("effect/unstable/http/HttpServer").HttpServer | PgClient.PgClient | Reactivity.Reactivity | import("effect/unstable/sql/SqlClient").SqlClient | NodeServices.NodeServices, TServiceError | Config.ConfigError | Migrator.MigrationError | import("effect/PlatformError").PlatformError | import("effect/unstable/http/HttpServerError").ServeError | import("effect/unstable/sql/SqlError").SqlError | HttpRouter.Request.Without<THandlerError>, Exclude<Exclude<Exclude<TServiceRequirements, AppChanges | PgClient.PgClient | Reactivity.Reactivity | import("effect/unstable/sql/SqlClient").SqlClient>, import("effect/unstable/http/Etag").Generator | import("effect/unstable/http/HttpPlatform").HttpPlatform | import("effect/unstable/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices> | Exclude<Exclude<Exclude<import("effect/FileSystem").FileSystem, TServices | AppChanges | PgClient.PgClient | Reactivity.Reactivity | import("effect/unstable/sql/SqlClient").SqlClient>, import("effect/unstable/http/Etag").Generator | import("effect/unstable/http/HttpPlatform").HttpPlatform | import("effect/unstable/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices> | Exclude<Exclude<Exclude<import("effect/unstable/http/HttpPlatform").HttpPlatform, TServices | AppChanges | PgClient.PgClient | Reactivity.Reactivity | import("effect/unstable/sql/SqlClient").SqlClient>, import("effect/unstable/http/Etag").Generator | import("effect/unstable/http/HttpPlatform").HttpPlatform | import("effect/unstable/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices> | Exclude<Exclude<Exclude<import("effect/unstable/http/HttpServer").HttpServer, TServices | AppChanges | PgClient.PgClient | Reactivity.Reactivity | import("effect/unstable/sql/SqlClient").SqlClient>, import("effect/unstable/http/Etag").Generator | import("effect/unstable/http/HttpPlatform").HttpPlatform | import("effect/unstable/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices> | Exclude<Exclude<Exclude<import("effect/Path").Path, TServices | AppChanges | PgClient.PgClient | Reactivity.Reactivity | import("effect/unstable/sql/SqlClient").SqlClient>, import("effect/unstable/http/Etag").Generator | import("effect/unstable/http/HttpPlatform").HttpPlatform | import("effect/unstable/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices> | Exclude<Exclude<Exclude<Exclude<TMigrations, import("effect/Scope").Scope>, PgClient.PgClient | import("effect/unstable/sql/SqlClient").SqlClient>, import("effect/unstable/http/Etag").Generator | import("effect/unstable/http/HttpPlatform").HttpPlatform | import("effect/unstable/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices> | Exclude<Exclude<Exclude<Exclude<Exclude<HttpRouter.Request.Only<"GlobalRequires", Exclude<THandlerRequirements, RpcSerialization.RpcSerialization>>, HttpRouter.GlobalProvided>, HttpRouter.HttpRouter>, TServices | AppChanges | PgClient.PgClient | Reactivity.Reactivity | import("effect/unstable/sql/SqlClient").SqlClient>, import("effect/unstable/http/Etag").Generator | import("effect/unstable/http/HttpPlatform").HttpPlatform | import("effect/unstable/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices> | Exclude<Exclude<Exclude<Exclude<Exclude<HttpRouter.Request.Only<"GlobalRequires", Exclude<Exclude<HttpRouter.HttpRouter, THandlers | Authenticated | MaybeAuthenticated | RequestTracing>, RpcSerialization.RpcSerialization>>, HttpRouter.GlobalProvided>, HttpRouter.HttpRouter>, TServices | AppChanges | PgClient.PgClient | Reactivity.Reactivity | import("effect/unstable/sql/SqlClient").SqlClient>, import("effect/unstable/http/Etag").Generator | import("effect/unstable/http/HttpPlatform").HttpPlatform | import("effect/unstable/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices> | Exclude<Exclude<Exclude<Exclude<Exclude<HttpRouter.Request.Only<"GlobalRequires", Exclude<Exclude<RpcSerialization.RpcSerialization, THandlers | Authenticated | MaybeAuthenticated | RequestTracing>, RpcSerialization.RpcSerialization>>, HttpRouter.GlobalProvided>, HttpRouter.HttpRouter>, TServices | AppChanges | PgClient.PgClient | Reactivity.Reactivity | import("effect/unstable/sql/SqlClient").SqlClient>, import("effect/unstable/http/Etag").Generator | import("effect/unstable/http/HttpPlatform").HttpPlatform | import("effect/unstable/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices> | Exclude<Exclude<Exclude<Exclude<Exclude<HttpRouter.Request.Only<"GlobalRequires", Exclude<Exclude<Exclude<Rpc.ServicesServer<TRpcs>, import("effect/Scope").Scope>, THandlers | Authenticated | MaybeAuthenticated | RequestTracing>, RpcSerialization.RpcSerialization>>, HttpRouter.GlobalProvided>, HttpRouter.HttpRouter>, TServices | AppChanges | PgClient.PgClient | Reactivity.Reactivity | import("effect/unstable/sql/SqlClient").SqlClient>, import("effect/unstable/http/Etag").Generator | import("effect/unstable/http/HttpPlatform").HttpPlatform | import("effect/unstable/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices> | Exclude<Exclude<Exclude<Exclude<Exclude<HttpRouter.Request.Only<"GlobalRequires", Exclude<Exclude<Exclude<Rpc.ToHandler<TRpcs>, import("effect/Scope").Scope>, THandlers | Authenticated | MaybeAuthenticated | RequestTracing>, RpcSerialization.RpcSerialization>>, HttpRouter.GlobalProvided>, HttpRouter.HttpRouter>, TServices | AppChanges | PgClient.PgClient | Reactivity.Reactivity | import("effect/unstable/sql/SqlClient").SqlClient>, import("effect/unstable/http/Etag").Generator | import("effect/unstable/http/HttpPlatform").HttpPlatform | import("effect/unstable/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices> | Exclude<Exclude<Exclude<Exclude<Exclude<HttpRouter.Request.Only<"Requires", Exclude<THandlerRequirements, RpcSerialization.RpcSerialization>>, HttpRouter.GlobalProvided>, HttpRouter.HttpRouter>, TServices | AppChanges | PgClient.PgClient | Reactivity.Reactivity | import("effect/unstable/sql/SqlClient").SqlClient>, import("effect/unstable/http/Etag").Generator | import("effect/unstable/http/HttpPlatform").HttpPlatform | import("effect/unstable/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices> | Exclude<Exclude<Exclude<Exclude<Exclude<HttpRouter.Request.Only<"Requires", Exclude<Exclude<HttpRouter.HttpRouter, THandlers | Authenticated | MaybeAuthenticated | RequestTracing>, RpcSerialization.RpcSerialization>>, HttpRouter.GlobalProvided>, HttpRouter.HttpRouter>, TServices | AppChanges | PgClient.PgClient | Reactivity.Reactivity | import("effect/unstable/sql/SqlClient").SqlClient>, import("effect/unstable/http/Etag").Generator | import("effect/unstable/http/HttpPlatform").HttpPlatform | import("effect/unstable/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices> | Exclude<Exclude<Exclude<Exclude<Exclude<HttpRouter.Request.Only<"Requires", Exclude<Exclude<RpcSerialization.RpcSerialization, THandlers | Authenticated | MaybeAuthenticated | RequestTracing>, RpcSerialization.RpcSerialization>>, HttpRouter.GlobalProvided>, HttpRouter.HttpRouter>, TServices | AppChanges | PgClient.PgClient | Reactivity.Reactivity | import("effect/unstable/sql/SqlClient").SqlClient>, import("effect/unstable/http/Etag").Generator | import("effect/unstable/http/HttpPlatform").HttpPlatform | import("effect/unstable/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices> | Exclude<Exclude<Exclude<Exclude<Exclude<HttpRouter.Request.Only<"Requires", Exclude<Exclude<Exclude<Rpc.ServicesServer<TRpcs>, import("effect/Scope").Scope>, THandlers | Authenticated | MaybeAuthenticated | RequestTracing>, RpcSerialization.RpcSerialization>>, HttpRouter.GlobalProvided>, HttpRouter.HttpRouter>, TServices | AppChanges | PgClient.PgClient | Reactivity.Reactivity | import("effect/unstable/sql/SqlClient").SqlClient>, import("effect/unstable/http/Etag").Generator | import("effect/unstable/http/HttpPlatform").HttpPlatform | import("effect/unstable/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices> | Exclude<Exclude<Exclude<Exclude<Exclude<HttpRouter.Request.Only<"Requires", Exclude<Exclude<Exclude<Rpc.ToHandler<TRpcs>, import("effect/Scope").Scope>, THandlers | Authenticated | MaybeAuthenticated | RequestTracing>, RpcSerialization.RpcSerialization>>, HttpRouter.GlobalProvided>, HttpRouter.HttpRouter>, TServices | AppChanges | PgClient.PgClient | Reactivity.Reactivity | import("effect/unstable/sql/SqlClient").SqlClient>, import("effect/unstable/http/Etag").Generator | import("effect/unstable/http/HttpPlatform").HttpPlatform | import("effect/unstable/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices> | Exclude<Exclude<Exclude<Exclude<HttpRouter.Request.Without<Exclude<THandlerRequirements, RpcSerialization.RpcSerialization>>, HttpRouter.HttpRouter>, TServices | AppChanges | PgClient.PgClient | Reactivity.Reactivity | import("effect/unstable/sql/SqlClient").SqlClient>, import("effect/unstable/http/Etag").Generator | import("effect/unstable/http/HttpPlatform").HttpPlatform | import("effect/unstable/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices> | Exclude<Exclude<Exclude<Exclude<HttpRouter.Request.Without<Exclude<Exclude<HttpRouter.HttpRouter, THandlers | Authenticated | MaybeAuthenticated | RequestTracing>, RpcSerialization.RpcSerialization>>, HttpRouter.HttpRouter>, TServices | AppChanges | PgClient.PgClient | Reactivity.Reactivity | import("effect/unstable/sql/SqlClient").SqlClient>, import("effect/unstable/http/Etag").Generator | import("effect/unstable/http/HttpPlatform").HttpPlatform | import("effect/unstable/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices> | Exclude<Exclude<Exclude<Exclude<HttpRouter.Request.Without<Exclude<Exclude<RpcSerialization.RpcSerialization, THandlers | Authenticated | MaybeAuthenticated | RequestTracing>, RpcSerialization.RpcSerialization>>, HttpRouter.HttpRouter>, TServices | AppChanges | PgClient.PgClient | Reactivity.Reactivity | import("effect/unstable/sql/SqlClient").SqlClient>, import("effect/unstable/http/Etag").Generator | import("effect/unstable/http/HttpPlatform").HttpPlatform | import("effect/unstable/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices> | Exclude<Exclude<Exclude<Exclude<HttpRouter.Request.Without<Exclude<Exclude<Exclude<Rpc.ServicesServer<TRpcs>, import("effect/Scope").Scope>, THandlers | Authenticated | MaybeAuthenticated | RequestTracing>, RpcSerialization.RpcSerialization>>, HttpRouter.HttpRouter>, TServices | AppChanges | PgClient.PgClient | Reactivity.Reactivity | import("effect/unstable/sql/SqlClient").SqlClient>, import("effect/unstable/http/Etag").Generator | import("effect/unstable/http/HttpPlatform").HttpPlatform | import("effect/unstable/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices> | Exclude<Exclude<Exclude<Exclude<HttpRouter.Request.Without<Exclude<Exclude<Exclude<Rpc.ToHandler<TRpcs>, import("effect/Scope").Scope>, THandlers | Authenticated | MaybeAuthenticated | RequestTracing>, RpcSerialization.RpcSerialization>>, HttpRouter.HttpRouter>, TServices | AppChanges | PgClient.PgClient | Reactivity.Reactivity | import("effect/unstable/sql/SqlClient").SqlClient>, import("effect/unstable/http/Etag").Generator | import("effect/unstable/http/HttpPlatform").HttpPlatform | import("effect/unstable/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices>>;
45
+ export type AppLocalHostOptions<TRpcs extends Rpc.Any, THandlers, THandlerError, THandlerRequirements, TServices, TServiceError, TServiceRequirements, TMigrations> = HostOptions<TRpcs, THandlers, THandlerError, THandlerRequirements, TServices, TServiceError, TServiceRequirements> & {
46
+ readonly migrations: AppDatabaseOptions<TMigrations>["migrations"];
47
+ readonly policy: "loopback";
48
+ readonly sessions?: never;
49
+ };
50
+ export type AppHttpHostOptions<TRpcs extends Rpc.Any, THandlers, THandlerError, THandlerRequirements, TServices, TServiceError, TServiceRequirements, TSession extends SessionShape> = HostOptions<TRpcs, THandlers, THandlerError, THandlerRequirements, TServices, TServiceError, TServiceRequirements> & HostPolicy<TSession> & {
51
+ readonly migrations?: undefined;
52
+ };
53
+ export declare function appHost<TRpcs extends Rpc.Any, THandlers, THandlerError, THandlerRequirements, TServices, TServiceError, TServiceRequirements, TMigrations, TSession extends SessionShape>(options: AppHostOptions<TRpcs, THandlers, THandlerError, THandlerRequirements, TServices, TServiceError, TServiceRequirements, TMigrations, TSession> | AppLocalHostOptions<TRpcs, THandlers, THandlerError, THandlerRequirements, TServices, TServiceError, TServiceRequirements, TMigrations>): ReturnType<typeof migratedHost<TRpcs, THandlers, THandlerError, THandlerRequirements, TServices, TServiceError, TServiceRequirements, TMigrations, TSession>>;
54
+ export declare function appHost<TRpcs extends Rpc.Any, THandlers, THandlerError, THandlerRequirements, TServices, TServiceError, TServiceRequirements>(options: HostOptions<TRpcs, THandlers, THandlerError, THandlerRequirements, TServices, TServiceError, TServiceRequirements> & {
55
+ readonly policy: "loopback";
56
+ readonly sessions?: never;
57
+ readonly migrations?: undefined;
58
+ }): ReturnType<typeof appHostHttp<TRpcs, THandlers, THandlerError, THandlerRequirements, TServices, TServiceError, TServiceRequirements, SessionShape>>;
59
+ export declare function appHost<TRpcs extends Rpc.Any, THandlers, THandlerError, THandlerRequirements, TServices, TServiceError, TServiceRequirements, TSession extends SessionShape>(options: AppHttpHostOptions<TRpcs, THandlers, THandlerError, THandlerRequirements, TServices, TServiceError, TServiceRequirements, TSession>): ReturnType<typeof appHostHttp<TRpcs, THandlers, THandlerError, THandlerRequirements, TServices, TServiceError, TServiceRequirements, TSession>>;
55
60
  export {};
56
61
  //# sourceMappingURL=appHost.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"appHost.d.ts","sourceRoot":"","sources":["../../src/server/appHost.ts"],"names":[],"mappings":"AACA,OAAO,EAAkB,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,KAAK,QAAQ,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAU,KAAK,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAC9F,OAAO,EAAE,UAAU,EAAuC,MAAM,sBAAsB,CAAC;AACvF,OAAO,KAAK,UAAU,MAAM,uCAAuC,CAAC;AACpE,OAAO,EAAE,KAAK,GAAG,EAAE,KAAK,QAAQ,EAAE,gBAAgB,EAAa,MAAM,qBAAqB,CAAC;AAC3F,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAGpD,OAAO,EAAE,KAAK,sBAAsB,EAAmB,MAAM,0CAA0C,CAAC;AACxG,OAAO,KAAK,EAAE,aAAa,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAE5F,OAAO,EAA+C,KAAK,aAAa,E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import { createServer } from "node:http";
2
- import { NodeHttpServer, NodeServices } from "@effect/platform-node";
3
- import * as PgClient from "@effect/sql-pg/PgClient";
4
- import { Config, Context, Effect, Layer, Option } from "effect";
5
- import { HttpRouter, HttpServerRequest, HttpStaticServer } from "effect/unstable/http";
6
- import * as Reactivity from "effect/unstable/reactivity/Reactivity";
7
- import { RpcSerialization, RpcServer } from "effect/unstable/rpc";
8
- import { makeLiveServer } from "@shivaedev/effect-contract/makeLiveServer.ts";
9
- import { migratePostgres } from "@shivaedev/effect-sql/migrations.ts";
10
- import { postgresChanges } from "@shivaedev/effect-sql/postgresChanges.ts";
11
- import { localRpcGuard } from "#rpc-server/local.ts";
12
- import { authenticatedLayer, maybeAuthenticatedLayer } from "#rpc-server/session.ts";
13
- import { requestTracingLayer } from "#rpc-server/tracing.ts";
1
+ import { Context } from "effect";
2
+ import { appHostHttp, migratedHost } from "./appHostHttp.js";
3
+ import { databaseLayer } from "./databaseLayer.js";
14
4
  export class AppChanges extends Context.Service()("@shivaedev/platform/AppChanges") {
15
5
  }
16
6
  export function appDatabase(options) {
17
- const pool = Layer.unwrap(Effect.gen(function* () {
18
- const url = options.config?.databaseUrl ?? (yield* Config.redacted("DATABASE_URL"));
19
- return PgClient.layer({
20
- url,
21
- ...(options.config?.applicationName === undefined ? {} : { applicationName: options.config.applicationName }),
22
- });
23
- }));
24
- const migrated = Layer.effectDiscard(migratePostgres({ ...options.migrations, lockTimeout: options.migrations.lockTimeout ?? "5 seconds" })).pipe(Layer.provideMerge(pool));
25
- const live = Layer.effect(AppChanges, makeLiveServer).pipe(Layer.provideMerge(Reactivity.layer));
26
- const base = Layer.merge(migrated, live);
27
- const changes = options.config?.changes;
28
- if (changes === undefined) {
29
- return base;
30
- }
31
- return Layer.unwrap(Effect.gen(function* () {
32
- const client = yield* PgClient.PgClient;
33
- const hints = yield* AppChanges;
34
- return postgresChanges({ ...changes, client, resync: hints.resync });
35
- })).pipe(Layer.provideMerge(base));
7
+ return databaseLayer(options, AppChanges);
36
8
  }
37
9
  export function appHost(options) {
38
- // Named middleware types keep NodeNext declarations on the package aliases.
39
- const middleware = Layer.mergeAll(authenticatedLayer(options.sessions), maybeAuthenticatedLayer(options.sessions), requestTracingLayer());
40
- const routes = HttpRouter.use((router) => Effect.gen(function* () {
41
- const trustedProxy = options.config?.trustedProxy ?? Option.getOrUndefined(yield* Config.string("TRUSTED_PROXY").pipe(Config.option));
42
- const wire = yield* RpcSerialization.RpcSerialization;
43
- const handler = yield* RpcServer.toHttpEffect(options.group);
44
- yield* router.add("POST", "/rpc", (request) => localRpcGuard(handler, trustedProxy).pipe(Effect.provideService(HttpServerRequest.HttpServerRequest, request), Effect.provideService(RpcSerialization.RpcSerialization, wire)));
45
- })).pipe(Layer.provide(Layer.merge(options.handlers, middleware)), Layer.provide(RpcSerialization.layerNdjson));
46
- const assets = options.assets === undefined ? Layer.empty : HttpStaticServer.layer({ root: options.assets });
47
- const application = options.services.pipe(Layer.provideMerge(appDatabase(options)));
48
- const server = Layer.unwrap(Effect.gen(function* () {
49
- const port = options.config?.port ?? (yield* Config.int("PORT").pipe(Config.withDefault(3000)));
50
- const host = options.config?.host ?? (yield* Config.string("HOST").pipe(Config.withDefault("127.0.0.1")));
51
- return NodeHttpServer.layer(createServer, { host, port });
52
- }));
53
- return HttpRouter.serve(Layer.merge(routes, assets), { disableLogger: true }).pipe(Layer.provideMerge(application), Layer.provideMerge(server), Layer.provide(NodeServices.layer));
10
+ return options.migrations === undefined
11
+ ? appHostHttp(options)
12
+ : migratedHost({ ...options, migrations: options.migrations }, appDatabase({ ...options, migrations: options.migrations }));
54
13
  }
55
14
  //# sourceMappingURL=appHost.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"appHost.js","sourceRoot":"","sources":["../../src/server/appHost.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrE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AGnD,MAAM,OAAO,UAAW,SAAQ,OAAO,CAAC,OAAO,EAAqD,CAAC,gCAAgC,CAAC;CAAG;AAezI,MAAM,UAAU,WAAW,CAAI,OAA8B;IAC5D,OAAO,aAAa,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;AAC3C,CAAC;AAmFD,MAAM,UAAU,OAAO,CAWtB,OAGsI;IAEtI,OAAO,OAAO,CAAC,UAAU,KAAK,SAAS;QACtC,CAAC,CAAC,WAAW,CAAC,OAAO,CAAC;QACtB,CAAC,CAAC,YAAY,CAAC,EAAE,GAAG,OAAO,EAAE,UAAU,EAAE,OAAO,CAAC,UAAU,EAAE,EAAE,WAAW,CAAC,EAAE,GAAG,OAAO,EAAE,UAAU,EAAE,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC;AAC9H,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { NodeServices } from "@effect/platform-node";
2
+ import { Config, Layer } from "effect";
3
+ import { HttpRouter } from "effect/http";
4
+ import { type Rpc, RpcSerialization } from "effect/rpc";
5
+ import { type SessionShape } from "#rpc-server/session.ts";
6
+ import type { AppHostOptions, AppLocalHostOptions } from "./appHost.ts";
7
+ import type { databaseLayer } from "./databaseLayer.ts";
8
+ import type { HostOptions, HostPolicy } from "./hostOptions.ts";
9
+ export declare function appHostHttp<TRpcs extends Rpc.Any, THandlers, THandlerError, THandlerRequirements, TServices, TServiceError, TServiceRequirements, TSession extends SessionShape>(options: HostOptions<TRpcs, THandlers, THandlerError, THandlerRequirements, TServices, TServiceError, TServiceRequirements> & HostPolicy<TSession>): Layer.Layer<TServices | import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices, TServiceError | Config.ConfigError | import("effect/PlatformError").PlatformError | import("effect/http/HttpServerError").ServeError | HttpRouter.Request.Without<THandlerError>, Exclude<Exclude<TServiceRequirements, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices> | Exclude<Exclude<Exclude<import("effect/FileSystem").FileSystem, TServices>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices> | Exclude<Exclude<Exclude<import("effect/http/HttpPlatform").HttpPlatform, TServices>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices> | Exclude<Exclude<Exclude<import("effect/http/HttpServer").HttpServer, TServices>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices> | Exclude<Exclude<Exclude<import("effect/Path").Path, TServices>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices> | Exclude<Exclude<Exclude<Exclude<Exclude<HttpRouter.Request.Only<"GlobalRequires", Exclude<THandlerRequirements, RpcSerialization.RpcSerialization>>, HttpRouter.GlobalProvided>, HttpRouter.HttpRouter>, TServices>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices> | Exclude<Exclude<Exclude<Exclude<Exclude<HttpRouter.Request.Only<"GlobalRequires", Exclude<Exclude<HttpRouter.HttpRouter, THandlers | import("../rpc/middleware.ts").RequestTracing>, RpcSerialization.RpcSerialization>>, HttpRouter.GlobalProvided>, HttpRouter.HttpRouter>, TServices>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices> | Exclude<Exclude<Exclude<Exclude<Exclude<HttpRouter.Request.Only<"GlobalRequires", Exclude<Exclude<RpcSerialization.RpcSerialization, THandlers | import("../rpc/middleware.ts").RequestTracing>, RpcSerialization.RpcSerialization>>, HttpRouter.GlobalProvided>, HttpRouter.HttpRouter>, TServices>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices> | Exclude<Exclude<Exclude<Exclude<Exclude<HttpRouter.Request.Only<"GlobalRequires", Exclude<Exclude<Exclude<Rpc.ServicesServer<TRpcs>, import("effect/Scope").Scope>, THandlers | import("../rpc/middleware.ts").RequestTracing>, RpcSerialization.RpcSerialization>>, HttpRouter.GlobalProvided>, HttpRouter.HttpRouter>, TServices>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices> | Exclude<Exclude<Exclude<Exclude<Exclude<HttpRouter.Request.Only<"GlobalRequires", Exclude<Exclude<Exclude<Rpc.ToHandler<TRpcs>, import("effect/Scope").Scope>, THandlers | import("../rpc/middleware.ts").RequestTracing>, RpcSerialization.RpcSerialization>>, HttpRouter.GlobalProvided>, HttpRouter.HttpRouter>, TServices>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices> | Exclude<Exclude<Exclude<Exclude<Exclude<HttpRouter.Request.Only<"Requires", Exclude<THandlerRequirements, RpcSerialization.RpcSerialization>>, HttpRouter.GlobalProvided>, HttpRouter.HttpRouter>, TServices>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices> | Exclude<Exclude<Exclude<Exclude<Exclude<HttpRouter.Request.Only<"Requires", Exclude<Exclude<HttpRouter.HttpRouter, THandlers | import("../rpc/middleware.ts").RequestTracing>, RpcSerialization.RpcSerialization>>, HttpRouter.GlobalProvided>, HttpRouter.HttpRouter>, TServices>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices> | Exclude<Exclude<Exclude<Exclude<Exclude<HttpRouter.Request.Only<"Requires", Exclude<Exclude<RpcSerialization.RpcSerialization, THandlers | import("../rpc/middleware.ts").RequestTracing>, RpcSerialization.RpcSerialization>>, HttpRouter.GlobalProvided>, HttpRouter.HttpRouter>, TServices>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices> | Exclude<Exclude<Exclude<Exclude<Exclude<HttpRouter.Request.Only<"Requires", Exclude<Exclude<Exclude<Rpc.ServicesServer<TRpcs>, import("effect/Scope").Scope>, THandlers | import("../rpc/middleware.ts").RequestTracing>, RpcSerialization.RpcSerialization>>, HttpRouter.GlobalProvided>, HttpRouter.HttpRouter>, TServices>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices> | Exclude<Exclude<Exclude<Exclude<Exclude<HttpRouter.Request.Only<"Requires", Exclude<Exclude<Exclude<Rpc.ToHandler<TRpcs>, import("effect/Scope").Scope>, THandlers | import("../rpc/middleware.ts").RequestTracing>, RpcSerialization.RpcSerialization>>, HttpRouter.GlobalProvided>, HttpRouter.HttpRouter>, TServices>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices> | Exclude<Exclude<Exclude<Exclude<HttpRouter.Request.Without<Exclude<THandlerRequirements, RpcSerialization.RpcSerialization>>, HttpRouter.HttpRouter>, TServices>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices> | Exclude<Exclude<Exclude<Exclude<HttpRouter.Request.Without<Exclude<Exclude<HttpRouter.HttpRouter, THandlers | import("../rpc/middleware.ts").RequestTracing>, RpcSerialization.RpcSerialization>>, HttpRouter.HttpRouter>, TServices>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices> | Exclude<Exclude<Exclude<Exclude<HttpRouter.Request.Without<Exclude<Exclude<RpcSerialization.RpcSerialization, THandlers | import("../rpc/middleware.ts").RequestTracing>, RpcSerialization.RpcSerialization>>, HttpRouter.HttpRouter>, TServices>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices> | Exclude<Exclude<Exclude<Exclude<HttpRouter.Request.Without<Exclude<Exclude<Exclude<Rpc.ServicesServer<TRpcs>, import("effect/Scope").Scope>, THandlers | import("../rpc/middleware.ts").RequestTracing>, RpcSerialization.RpcSerialization>>, HttpRouter.HttpRouter>, TServices>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices> | Exclude<Exclude<Exclude<Exclude<HttpRouter.Request.Without<Exclude<Exclude<Exclude<Rpc.ToHandler<TRpcs>, import("effect/Scope").Scope>, THandlers | import("../rpc/middleware.ts").RequestTracing>, RpcSerialization.RpcSerialization>>, HttpRouter.HttpRouter>, TServices>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices>>;
10
+ export declare function migratedHost<TRpcs extends Rpc.Any, THandlers, THandlerError, THandlerRequirements, TServices, TServiceError, TServiceRequirements, TMigrations, TSession extends SessionShape>(options: AppHostOptions<TRpcs, THandlers, THandlerError, THandlerRequirements, TServices, TServiceError, TServiceRequirements, TMigrations, TSession> | AppLocalHostOptions<TRpcs, THandlers, THandlerError, THandlerRequirements, TServices, TServiceError, TServiceRequirements, TMigrations>, database: ReturnType<typeof databaseLayer<TMigrations>>): Layer.Layer<TServices | import("./appHost.ts").AppChanges | import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | import("@effect/sql-pg/PgClient").PgClient | import("effect/reactivity/Reactivity").Reactivity | import("effect/sql/SqlClient").SqlClient | NodeServices.NodeServices, TServiceError | Config.ConfigError | import("effect/sql/Migrator").MigrationError | import("effect/PlatformError").PlatformError | import("effect/http/HttpServerError").ServeError | import("effect/sql/SqlError").SqlError | HttpRouter.Request.Without<THandlerError>, Exclude<Exclude<Exclude<TServiceRequirements, import("./appHost.ts").AppChanges | import("@effect/sql-pg/PgClient").PgClient | import("effect/reactivity/Reactivity").Reactivity | import("effect/sql/SqlClient").SqlClient>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices> | Exclude<Exclude<Exclude<import("effect/FileSystem").FileSystem, TServices | import("./appHost.ts").AppChanges | import("@effect/sql-pg/PgClient").PgClient | import("effect/reactivity/Reactivity").Reactivity | import("effect/sql/SqlClient").SqlClient>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices> | Exclude<Exclude<Exclude<import("effect/http/HttpPlatform").HttpPlatform, TServices | import("./appHost.ts").AppChanges | import("@effect/sql-pg/PgClient").PgClient | import("effect/reactivity/Reactivity").Reactivity | import("effect/sql/SqlClient").SqlClient>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices> | Exclude<Exclude<Exclude<import("effect/http/HttpServer").HttpServer, TServices | import("./appHost.ts").AppChanges | import("@effect/sql-pg/PgClient").PgClient | import("effect/reactivity/Reactivity").Reactivity | import("effect/sql/SqlClient").SqlClient>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices> | Exclude<Exclude<Exclude<import("effect/Path").Path, TServices | import("./appHost.ts").AppChanges | import("@effect/sql-pg/PgClient").PgClient | import("effect/reactivity/Reactivity").Reactivity | import("effect/sql/SqlClient").SqlClient>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices> | Exclude<Exclude<Exclude<Exclude<TMigrations, import("effect/Scope").Scope>, import("@effect/sql-pg/PgClient").PgClient | import("effect/sql/SqlClient").SqlClient>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices> | Exclude<Exclude<Exclude<Exclude<Exclude<HttpRouter.Request.Only<"GlobalRequires", Exclude<THandlerRequirements, RpcSerialization.RpcSerialization>>, HttpRouter.GlobalProvided>, HttpRouter.HttpRouter>, TServices | import("./appHost.ts").AppChanges | import("@effect/sql-pg/PgClient").PgClient | import("effect/reactivity/Reactivity").Reactivity | import("effect/sql/SqlClient").SqlClient>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices> | Exclude<Exclude<Exclude<Exclude<Exclude<HttpRouter.Request.Only<"GlobalRequires", Exclude<Exclude<HttpRouter.HttpRouter, THandlers | import("../rpc/middleware.ts").RequestTracing>, RpcSerialization.RpcSerialization>>, HttpRouter.GlobalProvided>, HttpRouter.HttpRouter>, TServices | import("./appHost.ts").AppChanges | import("@effect/sql-pg/PgClient").PgClient | import("effect/reactivity/Reactivity").Reactivity | import("effect/sql/SqlClient").SqlClient>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices> | Exclude<Exclude<Exclude<Exclude<Exclude<HttpRouter.Request.Only<"GlobalRequires", Exclude<Exclude<RpcSerialization.RpcSerialization, THandlers | import("../rpc/middleware.ts").RequestTracing>, RpcSerialization.RpcSerialization>>, HttpRouter.GlobalProvided>, HttpRouter.HttpRouter>, TServices | import("./appHost.ts").AppChanges | import("@effect/sql-pg/PgClient").PgClient | import("effect/reactivity/Reactivity").Reactivity | import("effect/sql/SqlClient").SqlClient>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices> | Exclude<Exclude<Exclude<Exclude<Exclude<HttpRouter.Request.Only<"GlobalRequires", Exclude<Exclude<Exclude<Rpc.ServicesServer<TRpcs>, import("effect/Scope").Scope>, THandlers | import("../rpc/middleware.ts").RequestTracing>, RpcSerialization.RpcSerialization>>, HttpRouter.GlobalProvided>, HttpRouter.HttpRouter>, TServices | import("./appHost.ts").AppChanges | import("@effect/sql-pg/PgClient").PgClient | import("effect/reactivity/Reactivity").Reactivity | import("effect/sql/SqlClient").SqlClient>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices> | Exclude<Exclude<Exclude<Exclude<Exclude<HttpRouter.Request.Only<"GlobalRequires", Exclude<Exclude<Exclude<Rpc.ToHandler<TRpcs>, import("effect/Scope").Scope>, THandlers | import("../rpc/middleware.ts").RequestTracing>, RpcSerialization.RpcSerialization>>, HttpRouter.GlobalProvided>, HttpRouter.HttpRouter>, TServices | import("./appHost.ts").AppChanges | import("@effect/sql-pg/PgClient").PgClient | import("effect/reactivity/Reactivity").Reactivity | import("effect/sql/SqlClient").SqlClient>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices> | Exclude<Exclude<Exclude<Exclude<Exclude<HttpRouter.Request.Only<"Requires", Exclude<THandlerRequirements, RpcSerialization.RpcSerialization>>, HttpRouter.GlobalProvided>, HttpRouter.HttpRouter>, TServices | import("./appHost.ts").AppChanges | import("@effect/sql-pg/PgClient").PgClient | import("effect/reactivity/Reactivity").Reactivity | import("effect/sql/SqlClient").SqlClient>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices> | Exclude<Exclude<Exclude<Exclude<Exclude<HttpRouter.Request.Only<"Requires", Exclude<Exclude<HttpRouter.HttpRouter, THandlers | import("../rpc/middleware.ts").RequestTracing>, RpcSerialization.RpcSerialization>>, HttpRouter.GlobalProvided>, HttpRouter.HttpRouter>, TServices | import("./appHost.ts").AppChanges | import("@effect/sql-pg/PgClient").PgClient | import("effect/reactivity/Reactivity").Reactivity | import("effect/sql/SqlClient").SqlClient>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices> | Exclude<Exclude<Exclude<Exclude<Exclude<HttpRouter.Request.Only<"Requires", Exclude<Exclude<RpcSerialization.RpcSerialization, THandlers | import("../rpc/middleware.ts").RequestTracing>, RpcSerialization.RpcSerialization>>, HttpRouter.GlobalProvided>, HttpRouter.HttpRouter>, TServices | import("./appHost.ts").AppChanges | import("@effect/sql-pg/PgClient").PgClient | import("effect/reactivity/Reactivity").Reactivity | import("effect/sql/SqlClient").SqlClient>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices> | Exclude<Exclude<Exclude<Exclude<Exclude<HttpRouter.Request.Only<"Requires", Exclude<Exclude<Exclude<Rpc.ServicesServer<TRpcs>, import("effect/Scope").Scope>, THandlers | import("../rpc/middleware.ts").RequestTracing>, RpcSerialization.RpcSerialization>>, HttpRouter.GlobalProvided>, HttpRouter.HttpRouter>, TServices | import("./appHost.ts").AppChanges | import("@effect/sql-pg/PgClient").PgClient | import("effect/reactivity/Reactivity").Reactivity | import("effect/sql/SqlClient").SqlClient>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices> | Exclude<Exclude<Exclude<Exclude<Exclude<HttpRouter.Request.Only<"Requires", Exclude<Exclude<Exclude<Rpc.ToHandler<TRpcs>, import("effect/Scope").Scope>, THandlers | import("../rpc/middleware.ts").RequestTracing>, RpcSerialization.RpcSerialization>>, HttpRouter.GlobalProvided>, HttpRouter.HttpRouter>, TServices | import("./appHost.ts").AppChanges | import("@effect/sql-pg/PgClient").PgClient | import("effect/reactivity/Reactivity").Reactivity | import("effect/sql/SqlClient").SqlClient>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices> | Exclude<Exclude<Exclude<Exclude<HttpRouter.Request.Without<Exclude<THandlerRequirements, RpcSerialization.RpcSerialization>>, HttpRouter.HttpRouter>, TServices | import("./appHost.ts").AppChanges | import("@effect/sql-pg/PgClient").PgClient | import("effect/reactivity/Reactivity").Reactivity | import("effect/sql/SqlClient").SqlClient>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices> | Exclude<Exclude<Exclude<Exclude<HttpRouter.Request.Without<Exclude<Exclude<HttpRouter.HttpRouter, THandlers | import("../rpc/middleware.ts").RequestTracing>, RpcSerialization.RpcSerialization>>, HttpRouter.HttpRouter>, TServices | import("./appHost.ts").AppChanges | import("@effect/sql-pg/PgClient").PgClient | import("effect/reactivity/Reactivity").Reactivity | import("effect/sql/SqlClient").SqlClient>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices> | Exclude<Exclude<Exclude<Exclude<HttpRouter.Request.Without<Exclude<Exclude<RpcSerialization.RpcSerialization, THandlers | import("../rpc/middleware.ts").RequestTracing>, RpcSerialization.RpcSerialization>>, HttpRouter.HttpRouter>, TServices | import("./appHost.ts").AppChanges | import("@effect/sql-pg/PgClient").PgClient | import("effect/reactivity/Reactivity").Reactivity | import("effect/sql/SqlClient").SqlClient>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices> | Exclude<Exclude<Exclude<Exclude<HttpRouter.Request.Without<Exclude<Exclude<Exclude<Rpc.ServicesServer<TRpcs>, import("effect/Scope").Scope>, THandlers | import("../rpc/middleware.ts").RequestTracing>, RpcSerialization.RpcSerialization>>, HttpRouter.HttpRouter>, TServices | import("./appHost.ts").AppChanges | import("@effect/sql-pg/PgClient").PgClient | import("effect/reactivity/Reactivity").Reactivity | import("effect/sql/SqlClient").SqlClient>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices> | Exclude<Exclude<Exclude<Exclude<HttpRouter.Request.Without<Exclude<Exclude<Exclude<Rpc.ToHandler<TRpcs>, import("effect/Scope").Scope>, THandlers | import("../rpc/middleware.ts").RequestTracing>, RpcSerialization.RpcSerialization>>, HttpRouter.HttpRouter>, TServices | import("./appHost.ts").AppChanges | import("@effect/sql-pg/PgClient").PgClient | import("effect/reactivity/Reactivity").Reactivity | import("effect/sql/SqlClient").SqlClient>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices>>;
11
+ //# sourceMappingURL=appHostHttp.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"appHostHttp.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AoB,EAAE,SAAS,EAAE,aAAa,EAAE,oBAAoB,EAAE,WAAW,CAAC,EAC1I,QAAQ,EAAE,UAAU,CAAC,OAAO,aAAa,CAAC,WAAW,CAAC,CAAC,26YAGvD"}
@@ -0,0 +1,51 @@
1
+ import { createServer } from "node:http";
2
+ import { NodeHttpServer, NodeServices } from "@effect/platform-node";
3
+ import { ByteSize, Config, Effect, Layer, Option, Schema } from "effect";
4
+ import { HttpIncomingMessage, HttpRouter, HttpServerRequest, HttpStaticServer } from "effect/http";
5
+ import { RpcSerialization, RpcServer } from "effect/rpc";
6
+ import { localRpcGuard } from "#rpc-server/local.ts";
7
+ import { authenticatedLayer, maybeAuthenticatedLayer } from "#rpc-server/session.ts";
8
+ import { requestTracingLayer } from "#rpc-server/tracing.ts";
9
+ import { TrustedProxy } from "#rpc-server/trustedProxy.ts";
10
+ import { boundedRpcRequest } from "./boundedRpcRequest.js";
11
+ export function appHostHttp(options) {
12
+ return Layer.unwrap(Effect.gen(function* () {
13
+ const maxBodySize = options.config?.maxBodySize ?? (yield* Config.Int("MAX_BODY_SIZE").pipe(Config.withDefault(1024 * 1024)));
14
+ const bodySize = yield* Schema.decodeUnknownEffect(Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)))(maxBodySize).pipe(Effect.mapError((cause) => new Config.ConfigError(cause)));
15
+ const trustedProxy = options.policy === "loopback"
16
+ ? undefined
17
+ : (options.config?.trustedProxy ?? Option.getOrUndefined(yield* Config.String("TRUSTED_PROXY").pipe(Config.option)));
18
+ if (trustedProxy !== undefined) {
19
+ yield* Schema.decodeUnknownEffect(TrustedProxy)(trustedProxy).pipe(Effect.mapError((cause) => new Config.ConfigError(cause)));
20
+ }
21
+ const middleware = options.policy === "loopback"
22
+ ? requestTracingLayer()
23
+ : Layer.mergeAll(authenticatedLayer(options.sessions), maybeAuthenticatedLayer(options.sessions), requestTracingLayer());
24
+ const routes = HttpRouter.use((router) => Effect.gen(function* () {
25
+ const wire = yield* RpcSerialization.RpcSerialization;
26
+ const handler = yield* RpcServer.toHttpEffect(options.group);
27
+ const guarded = localRpcGuard(handler, trustedProxy);
28
+ yield* router.add("POST", options.rpcPath ?? "/rpc", (request) => guarded.pipe(Effect.provideService(HttpIncomingMessage.MaxBodySize, ByteSize.bytes(bodySize)), Effect.provideService(HttpServerRequest.HttpServerRequest, boundedRpcRequest(request)), Effect.provideService(RpcSerialization.RpcSerialization, wire)));
29
+ })).pipe(Layer.provide(Layer.merge(options.handlers, middleware)), Layer.provide(RpcSerialization.layerNdjson));
30
+ const assets = options.assets === undefined
31
+ ? Layer.empty
32
+ : HttpStaticServer.layer(typeof options.assets === "string" ? { root: options.assets } : options.assets);
33
+ const application = options.services;
34
+ const server = Layer.unwrap(Effect.gen(function* () {
35
+ const port = options.config?.port ?? (yield* Config.Int("PORT").pipe(Config.withDefault(3000)));
36
+ const host = options.config?.host ?? (yield* Config.String("HOST").pipe(Config.withDefault("127.0.0.1")));
37
+ return NodeHttpServer.layer(createServer, {
38
+ host,
39
+ port,
40
+ ...(options.config?.disablePreemptiveShutdown === undefined
41
+ ? {}
42
+ : { disablePreemptiveShutdown: options.config.disablePreemptiveShutdown }),
43
+ });
44
+ }));
45
+ return HttpRouter.serve(Layer.mergeAll(routes, assets, options.routes ?? Layer.empty), { disableLogger: true }).pipe(Layer.provideMerge(application), Layer.provideMerge(server), Layer.provide(NodeServices.layer));
46
+ }));
47
+ }
48
+ export function migratedHost(options, database) {
49
+ return appHostHttp({ ...options, services: options.services.pipe(Layer.provideMerge(database)) });
50
+ }
51
+ //# sourceMappingURL=appHostHttp.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"appHostHttp.js","sourceRoot":"","sources":["../../src/server/appHostHttp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,M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;YAC1G,OAAO,cAAc,CAAC,KAAK,CAAC,YAAY,EAAE;gBACzC,IAAI;gBACJ,IAAI;gBACJ,GAAG,CAAC,OAAO,CAAC,MAAM,EAAE,yBAAyB,KAAK,SAAS;oBAC1D,CAAC,CAAC,EAAE;oBACJ,CAAC,CAAC,EAAE,yBAAyB,EAAE,OAAO,CAAC,MAAM,CAAC,yBAAyB,EAAE,CAAC;aAC3E,CAAC,CAAC;QACJ,CAAC,CAAC,CACF,CAAC;QACF,OAAO,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,IAAI,KAAK,CAAC,KAAK,CAAC,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CACnH,KAAK,CAAC,YAAY,CAAC,WAAW,CAAC,EAC/B,KAAK,CAAC,YAAY,CAAC,MAAM,CAAC,EAC1B,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC,CACjC,CAAC;IACH,CAAC,CAAC,CACF,CAAC;AACH,CAAC;AAED,MAAM,UAAU,YAAY,CAW3B,OAE0I,EAC1I,QAAuD;IAEvD,OAAO,WAAW,CAAC,EAAE,GAAG,OAAO,EAAE,QAAQ,EAAE,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC;AACnG,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { type HttpServerRequest } from "effect/http";
2
+ export declare function boundedRpcRequest(request: HttpServerRequest.HttpServerRequest): HttpServerRequest.HttpServerRequest;
3
+ //# sourceMappingURL=boundedRpcRequest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"boundedRpcRequest.d.ts","sourceRoot":"","sources":["../../src/server/boundedRpcRequest.ts"],"names":[],"mappings":"AAEA,OAAO,EAAwC,KAAK,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAE3F,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,iBAAiB,CAAC,iBAAiB,GAAG,iBAAiB,CAAC,iBAAiB,CA0CnH"}
@@ -0,0 +1,41 @@
1
+ import { NodeHttpServerRequest, NodeStream } from "@effect/platform-node";
2
+ import { Effect, Stream } from "effect";
3
+ import { HttpIncomingMessage, HttpServerError } from "effect/http";
4
+ export function boundedRpcRequest(request) {
5
+ const incoming = NodeHttpServerRequest.toIncomingMessage(request);
6
+ function error(cause) {
7
+ return new HttpServerError.HttpServerError({ reason: new HttpServerError.RequestParseError({ cause, request }) });
8
+ }
9
+ const text = Effect.gen(function* () {
10
+ const limit = yield* HttpIncomingMessage.MaxBodySize;
11
+ const chunks = [];
12
+ let size = 0n;
13
+ yield* NodeStream.fromReadable({
14
+ closeOnDone: false,
15
+ evaluate: () => incoming,
16
+ onError: error,
17
+ }).pipe(Stream.runForEach((chunk) => {
18
+ size += BigInt(chunk.byteLength);
19
+ if (limit !== undefined && size > limit) {
20
+ return Effect.fail(error(new Error("RPC body exceeds MAX_BODY_SIZE")));
21
+ }
22
+ chunks.push(chunk);
23
+ return Effect.void;
24
+ }));
25
+ return Buffer.concat(chunks).toString("utf8");
26
+ }).pipe(Effect.onError(() => Effect.sync(() => incoming.resume())), Effect.cached, Effect.runSync);
27
+ const arrayBuffer = Effect.map(text, (body) => new TextEncoder().encode(body).buffer);
28
+ // The native text reader destroys the HTTP socket on overflow, preventing a 4xx response.
29
+ return new Proxy(request, {
30
+ get: (target, key, receiver) => {
31
+ if (key === "text") {
32
+ return text;
33
+ }
34
+ if (key === "arrayBuffer") {
35
+ return arrayBuffer;
36
+ }
37
+ return Reflect.get(target, key, receiver);
38
+ },
39
+ });
40
+ }
41
+ //# sourceMappingURL=boundedRpcRequest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"boundedRpcRequest.js","sourceRoot":"","sources":["../../src/server/boundedRpcRequest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,UAAU,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,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC/C,CAAC,CAAC,CAAC,IAAI,CACN,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC,EAC1D,MAAM,CAAC,MAAM,EACb,MAAM,CAAC,OAAO,CACd,CAAC;IACF,MAAM,WAAW,GAAG,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC;IACtF,0FAA0F;IAC1F,OAAO,IAAI,KAAK,CAAC,OAAO,EAAE;QACzB,GAAG,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,EAAE;YAC9B,IAAI,GAAG,KAAK,MAAM,EAAE,CAAC;gBACpB,OAAO,IAAI,CAAC;YACb,CAAC;YACD,IAAI,GAAG,KAAK,aAAa,EAAE,CAAC;gBAC3B,OAAO,WAAW,CAAC;YACpB,CAAC;YACD,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,EAAE,QAAQ,CAAC,CAAC;QAC3C,CAAC;KACD,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,6 @@
1
+ import * as PgClient from "@effect/sql-pg/PgClient";
2
+ import { Config, Layer } from "effect";
3
+ import * as Reactivity from "effect/reactivity/Reactivity";
4
+ import type { AppChanges, AppDatabaseOptions } from "./appHost.ts";
5
+ export declare function databaseLayer<R>(options: AppDatabaseOptions<R>, changesService: typeof AppChanges): Layer.Layer<AppChanges | PgClient.PgClient | Reactivity.Reactivity | import("effect/sql/SqlClient").SqlClient, Config.ConfigError | import("effect/sql/Migrator").MigrationError | import("effect/sql/SqlError").SqlError, Exclude<Exclude<R, import("effect/Scope").Scope>, PgClient.PgClient | import("effect/sql/SqlClient").SqlClient>>;
6
+ //# sourceMappingURL=databaseLayer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"databaseLayer.d.ts","sourceRoot":"","sources":["../../src/server/databaseLayer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAU,KAAK,EAAE,MAAM,QAAQ,CAAC;AAC/C,OAAO,KAAK,UAAU,MAAM,8BAA8B,CAAC;AAI3D,OAAO,KAAK,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAEnE,wBAAgB,aAAa,CAAC,CAAC,EAAE,OAAO,EAAE,kBAAkB,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,OAAO,UAAU,+UA2BjG"}