@shivaedev/server 0.29.1 → 0.31.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 CHANGED
@@ -1,5 +1,21 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.31.0 - 2026-11-06
4
+
5
+ ### Added
6
+
7
+ - Answer RPC and mounted auth CORS preflights and responses with the exact declared sibling Origin and credentials enabled, retaining native bearer behavior and existing session cookie attributes.
8
+
9
+ ### Breaking
10
+
11
+ - Every hosted live query reloads its subscriber's session, checks its read policy and reruns its handler on matching changes or server reconciliation. Drop the query's `live` option; application handlers and results stay the same.
12
+
13
+ ## 0.30.0 - 2026-11-06
14
+
15
+ ### Breaking
16
+
17
+ - Declare `postgresSettings` explicitly when building `appDatabase`, a database-backed `appHost`, or `workerHost`; use `{}` to request no server changes. Startup applies differing PostgreSQL server settings outside migrations and warns about refused values and pending restarts. Drop calls and imports of the removed `trimPostgresPageCache`; page-cache trimming belongs in the PostgreSQL service start command.
18
+
3
19
  ## 0.29.1 - 2026-11-06
4
20
 
5
21
  ### Changed
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  The application host for Effect apps: one Layer that runs migrations, serves native RPC and static assets over Node HTTP, checks sessions, redacts diagnostics and exports traces. Applications describe their contracts, handlers and session policy; the host owns the process around them.
4
4
 
5
- For live queries, the host checks policies and registers read keys before reading and delivering the first result on the subscription. Default later changes send hints for the client to reread; queries that select rerun-and-compare keep server-side comparison.
5
+ For live queries, the host checks policies and registers read keys before reading and delivering the first result on the subscription. Every later matching change reloads the subscriber’s session and reruns its authorized handler in the process holding the socket. Each subscription keeps a result hash in memory, coalesces one pending rerun while another runs, and pushes changed values without a client read.
6
6
 
7
7
  ## Why you want this
8
8
 
@@ -15,7 +15,17 @@ import { appHost } from "@shivaedev/server/appDatabase.ts";
15
15
  import { Api, Handlers, Services, migrations, sessions } from "./app.ts";
16
16
 
17
17
  NodeRuntime.runMain(
18
- Layer.launch(appHost({ group: Api, handlers: Handlers, services: Services, migrations: { loader: migrations }, sessions, assets: "./public" })),
18
+ Layer.launch(
19
+ appHost({
20
+ group: Api,
21
+ handlers: Handlers,
22
+ services: Services,
23
+ postgresSettings: {},
24
+ migrations: { loader: migrations },
25
+ sessions,
26
+ assets: "./public",
27
+ }),
28
+ ),
19
29
  );
20
30
  ```
21
31
 
@@ -86,8 +96,8 @@ import { notes, tasks, sessions } from "./app.ts";
86
96
  const hosts = Effect.gen(function* () {
87
97
  const modules = yield* appModules([notes, tasks]);
88
98
  return {
89
- server: appHost({ ...modules, sessions }),
90
- worker: workerHost({ ...modules, migrations: { ...modules.migrations, mode: "wait" } }),
99
+ server: appHost({ ...modules, postgresSettings: {}, sessions }),
100
+ worker: workerHost({ ...modules, postgresSettings: {}, migrations: { ...modules.migrations, mode: "wait" } }),
91
101
  };
92
102
  });
93
103
  ```
@@ -110,6 +120,7 @@ const Server = appHost({
110
120
  group: Api,
111
121
  handlers: Handlers,
112
122
  services: Services,
123
+ postgresSettings: {},
113
124
  migrations: { loader: migrations },
114
125
  sessions,
115
126
  assets: "./public",
@@ -146,7 +157,26 @@ const Routes = HttpRouter.add("*", "/.well-known/app", AppMetadata.pipe(Effect.m
146
157
  const Server = appHost({ group: Api, handlers: Handlers, services: Services, routes: Routes, sessions });
147
158
  ```
148
159
 
149
- `AppMetadata` is an app service supplied by `Services`. Register `OPTIONS` or `"*"` for a route whose native `HttpMiddleware.cors` must answer preflight. The host restricts foreign-origin preflights only on `rpcPath` (default `/rpc`) and `/api/auth/*`, including `/api/auth` itself. Application endpoints own their CORS policy. `nativeOrigins` lists exact native-client origins admitted by the host’s RPC and auth CORS policy; other foreign origins receive 403 on those paths.
160
+ `AppMetadata` is an app service supplied by `Services`. Register `OPTIONS` or `"*"` for a route whose native `HttpMiddleware.cors` must answer preflight. The host restricts foreign-origin preflights only on `rpcPath` (default `/rpc`) and `/api/auth/*`, including `/api/auth` itself. Application endpoints own their CORS policy. `nativeOrigins` lists exact native-client origins admitted by the host’s RPC and auth CORS policy. Browser sibling origins come from identity’s `trustedOrigins` policy on `SessionPolicy.origin`; other foreign origins receive 403 on those preflights.
161
+
162
+ To let a separate frontend call HTTP RPC with the user's session cookie, declare its exact origin through identity:
163
+
164
+ ```ts
165
+ import { Layer } from "effect";
166
+ import { trustedOrigins } from "@shivaedev/identity/server/adapters/trustedOrigins.ts";
167
+ import { SessionPolicy } from "@shivaedev/identity/server/SessionPolicy.ts";
168
+
169
+ const browserOrigins = ["https://app.example.com", "https://www.example.com"];
170
+ const sessions = Layer.succeed(SessionPolicy, {
171
+ ...mounted.sessions,
172
+ origin: trustedOrigins({ allow: browserOrigins, missing: "allow", sameOrigin: {} }),
173
+ });
174
+ const Server = appHost({ group: Api, handlers: Handlers, routes: mounted.routes, sessions });
175
+ ```
176
+
177
+ Identity owns this list; the host uses it for transport admission, RPC CORS and mounted auth CORS, including preflights. Each listed origin receives its exact value in `Access-Control-Allow-Origin` and `Access-Control-Allow-Credentials: true`. Wildcards and patterns are not expanded. Reuse `browserOrigins` in Better Auth's `trustedOrigins` option to align provider CSRF checks. Browser fetch calls must use `credentials: "include"`. Application HTTP endpoints still own their CORS policy. `nativeOrigins` takes precedence for bundled clients and keeps its credential-free bearer behavior.
178
+
179
+ Cookie SameSite and Secure settings remain the application's choice. Same-site HTTPS sibling subdomains can keep their current attributes; a frontend on another registrable domain needs Better Auth's `advanced.defaultCookieAttributes: { sameSite: "none", secure: true }` and an HTTPS API for cross-site cookies. Browser third-party-cookie restrictions still apply.
150
180
 
151
181
  `assets` accepts a directory string or an `AssetOptions` object, extending native static-server options. For direct navigation to browser routes, use `{ root: "dist", spa: true }`. HTML files, including SPA fallbacks, default to `Cache-Control: no-store`, `Content-Security-Policy: frame-ancestors 'none'` and `X-Frame-Options: DENY`. Fingerprinted assets default to `public, max-age=31536000, immutable`; other files use `no-cache`. A fingerprint is a dot- or hyphen-separated filename suffix before the extension with at least eight hexadecimal characters, or at least eight letters, digits, underscores or hyphens containing a digit or uppercase letter. HTML policy takes precedence over fingerprint detection, including custom HTML MIME types. HEAD, partial and conditional responses retain the selected file's policy.
152
182
 
@@ -207,11 +237,12 @@ Supply `preflight: AppConfigLive` to `appHost` to build a native Layer before ch
207
237
 
208
238
  Preflight logs pass through the host's redaction, including logged failure causes and annotations. The original typed failure remains available to callers. Direct hosts derive the policy from their RPC schemas and `config.sensitiveKeys`; deferred hosts use the default credential policy during preflight, before their application's schemas are available. Ordinary startup messages and annotations remain intact.
209
239
 
210
- When construction itself touches the schema, use `appHost({ migrations, config, application })`. `application` is a native Effect that returns the HTTP host options (`group`, handler and service Layers, session policy, and optional HTTP config). The host first builds `appDatabase`, then evaluates this Effect in the host scope with SQL, Reactivity and `LiveServer` from `@shivaedev/contract/live-server/service.ts` available. A failed migration or schema-current check prevents construction. Initialization requirements and errors stay in the returned Layer's types, and acquired resources close with the host scope.
240
+ When construction itself touches the schema, use `appHost({ migrations, config, postgresSettings, application })`. `application` is a native Effect that returns the HTTP host options (`group`, handler and service Layers, session policy, and optional HTTP config). The host first builds `appDatabase`, then evaluates this Effect in the host scope with SQL, Reactivity and `LiveServer` from `@shivaedev/contract/live-server/service.ts` available. A failed migration or schema-current check prevents construction. Initialization requirements and errors stay in the returned Layer's types, and acquired resources close with the host scope.
211
241
 
212
242
  ```ts
213
243
  const host = appHost({
214
244
  config: { databaseUrl },
245
+ postgresSettings: {},
215
246
  migrations: { loader: migrations, mode: "check" },
216
247
  preflight: AppConfigLive,
217
248
  application: Effect.gen(function* () {
@@ -270,9 +301,9 @@ Both JSON and protobuf export serialization apply sensitive-key and credential-t
270
301
 
271
302
  Set `config.maxConnections` on `appDatabase` or a migrated `appHost` to bound the PostgreSQL pool. The host composes sql's [`postgresLayer`](https://github.com/ShivaeDev/platform/blob/main/packages/sql/README.md#one-postgresql-pool-per-application), exposing the native `PgPool` service alongside `PgClient` and `SqlClient`. Application services that need raw connections read `PgPool` from `@effect/sql-pg/PgPool`; reservations share the client's connection budget. The change listener reserves one connection; when transactions hold the remaining connections, another query waits until a transaction releases its connection. A daemon with long-lived RPC streams can use `config.disablePreemptiveShutdown: true` so scope closure interrupts an active HTTP RPC stream and runs its finalizer before host disposal completes, without waiting for Node's preemptive graceful-shutdown timeout. Omitting it keeps Node's native graceful-shutdown default.
272
303
 
273
- The host defaults to `config.connectionTTL: "10 minutes"` and `config.idleTimeout: "1 minute"`. Both accept native Effect durations; `config.minConnections` controls the idle floor. Lifetime expiry replaces a query connection on its next checkout, allowing active queries and transactions to finish. The reserved change listener renews on the same lifetime, resynchronizes live subscribers across renewal and resumes committed hints, including with a separate listener URL. No PostgreSQL `idle_session_timeout` is set: an idle LISTEN session must stay alive until its owner renews it.
304
+ The host defaults to `config.connectionTTL: "10 minutes"` and `config.idleTimeout: "1 minute"`. Both accept native Effect durations; `config.minConnections` controls the idle floor. Lifetime expiry replaces a query connection on its next checkout, allowing active queries and transactions to finish. The reserved change listener stays connected past the pool lifetime, including with a separate listener URL. Heartbeat failures or a lost connection trigger reconnection and resynchronize live subscribers to cover missed hints. No PostgreSQL `idle_session_timeout` is set: an idle LISTEN session must stay alive.
274
305
 
275
- Database pool maintenance, worker-release coordination and change-listener heartbeats, deadlines, retries and renewal use the live clock. A story can advance its application clock by days while the host and job worker keep running; handlers and jobs still see the advanced application time. For stories about database lifecycle timers, pass the story's native `Clock.Clock` service as `config.clock` on `appDatabase` or `appHost`. This option applies to worker-release timers and both application and separate listener pools; it does not change the application clock or migration wait timers.
306
+ Database pool maintenance, worker-release coordination and change-listener heartbeats, deadlines and retries use the live clock. A story can advance its application clock by days while the host and job worker keep running; handlers and jobs still see the advanced application time. For stories about database lifecycle timers, pass the story's native `Clock.Clock` service as `config.clock` on `appDatabase` or `appHost`. This option applies to worker-release timers and both application and separate listener pools; it does not change the application clock or migration wait timers.
276
307
 
277
308
  To pass worker-release time in a story, build `hostTime()` from `@shivaedev/test-kits/host/time.ts` under a native `TestClock`, then provide its `layer` to the worker host. `timePasses(duration)` advances that clock, writes the worker's lease heartbeat at the new time and waits for its release check. Production leases retain PostgreSQL's wall clock. Give separate worker processes the same starting timestamp. When an old worker drains a deliberately held job, advance it with `{ poll: false }` to write its heartbeat without waiting for the drain, then advance the replacement normally. After killing a worker, advance only the replacement; the crashed lease then expires on story time.
278
309
 
@@ -284,7 +315,7 @@ Build application handlers with `Api.application.toLayer(...)` (and `Api.applica
284
315
 
285
316
  Set `LISTEN_DATABASE_URL` to a direct or session-mode connection when `DATABASE_URL` uses a transaction pooler. `config.listenDatabaseUrl` overrides that setting; when neither is set, the listener shares the application pool. Both URLs must reach the same database. A separate listener pool reserves one connection; the application pool continues to own migrations, writes and heartbeat publication. Startup waits for the listener to receive its own heartbeat. A timeout fails the host with `PostgresListenerError` from `@shivaedev/sql/PostgresListenerError.ts`, naming the selected connection setting. Fix the URL before restarting; a startup timeout does not fall back to periodic reconnects. Established listeners retain their reconnect and Resync behavior.
286
317
 
287
- Database-backed hosts enable PostgreSQL change delivery by default and serve each contract's reserved change stream under its middleware. After a command handler succeeds, its declared invalidation keys publish without repeating keys already announced by repository commits. The handler keeps ownership of its transactions and error mapping. `config.changes.channel` overrides the app-derived default, and heartbeat and retry settings remain optional. Use the same application name or channel across web and worker processes. A worker can provide `appDatabase({ migrations, config })` without starting HTTP. See [commit-bound changes](https://github.com/ShivaeDev/platform/blob/main/docs/framework/changes.md) for defaults and limits.
318
+ Database-backed hosts enable PostgreSQL change delivery by default and serve each contract's reserved change stream under its middleware. After a command handler succeeds, its declared invalidation keys publish without repeating keys already announced by repository commits. The handler keeps ownership of its transactions and error mapping. `config.changes.channel` overrides the app-derived default, and heartbeat and retry settings remain optional. Use the same application name or channel across web and worker processes. A worker can provide `appDatabase({ migrations, config, postgresSettings })` without starting HTTP. See [commit-bound changes](https://github.com/ShivaeDev/platform/blob/main/docs/framework/changes.md) for defaults and limits.
288
319
 
289
320
  ### Public client configuration
290
321
 
@@ -469,32 +500,27 @@ Wrap disposal of the host scope or runtime with `readouts.shutdown(dispose)`, th
469
500
 
470
501
  To exercise PostgreSQL recovery, install the optional `@shivaedev/test-sql` peer and pass a redacted `databaseUrl` to `hostProcess`. The kit opens a `disconnectProxy` in its owning scope and gives the child its URL through `DATABASE_URL`; the child must use that setting. This mode uses the explicit `env` record plus the proxy's `DATABASE_URL` as the child's environment. Call `disconnectIdlePostgres()` once the host's database connections are idle. It cuts the proxy's existing connections while allowing new ones, so a following HTTP health request can exercise the host's PostgreSQL pool recovery.
471
502
 
472
- ### Low-memory PostgreSQL hosts
503
+ ### PostgreSQL server settings
473
504
 
474
- Use sql's [opt-in preset](https://github.com/ShivaeDev/platform/tree/main/packages/sql#low-memory-postgresql-hosts) with the host's ten-minute connection lifetime and one-minute idle timeout. The preset bounds PostgreSQL shared memory and per-operation work; connection recycling releases backend memory, and a page-cache trim releases clean file pages charged to the container. A busy workload still needs memory for its working set.
475
-
476
- `trimPostgresPageCache(dataDirectory)` from `@shivaedev/server/trimPostgresPageCache.ts` runs `find` and GNU `dd` through Effect's `ChildProcessSpawner`. Run it inside the PostgreSQL container, or in a process that can read its mounted PGDATA, as the PGDATA owner. Provide `NodeServices.layer` at the entry point. It needs Linux, GNU coreutils (`dd iflag=nocache`) and `find`; Alpine's BusyBox `dd` does not support this flag. Spawn failures remain typed `PlatformError`s; a nonzero trim exit fails with `PostgresPageCacheTrimError`.
505
+ Every `appDatabase`, database-backed `appHost` and `workerHost` requires `postgresSettings`. Omitting the declaration is a TypeScript error; `{}` explicitly requests no server changes. The declaration uses PostgreSQL names and string values, separate from client pool options such as `config.maxConnections`.
477
506
 
478
507
  ```ts
479
- import * as NodeServices from "@effect/platform-node/NodeServices";
480
- import { Config, Effect, Schedule } from "effect";
481
- import { trimPostgresPageCache } from "@shivaedev/server/trimPostgresPageCache.ts";
482
-
483
- const trim = Effect.gen(function* () {
484
- const dataDirectory = yield* Config.String("PGDATA");
485
- yield* trimPostgresPageCache(dataDirectory).pipe(Effect.repeat(Schedule.spaced("5 minutes")));
486
- }).pipe(Effect.provide(NodeServices.layer));
487
- ```
508
+ import { appDatabase } from "@shivaedev/server/appDatabase.ts";
488
509
 
489
- The cadence starts with one trim, then waits five minutes between completed runs. Scope or interrupt the Effect with its owning process. For a PostgreSQL image without Node, schedule the equivalent command every five minutes using that image's scheduler, as its database OS user:
490
-
491
- ```sh
492
- find "$PGDATA" -type f -exec sh -c 'for path do dd if="$path" iflag=nocache count=0 status=none || exit; done' sh {} +
510
+ const Database = appDatabase({
511
+ migrations: { loader: migrations },
512
+ postgresSettings: {
513
+ shared_buffers: "32MB",
514
+ max_connections: "50",
515
+ jit: "off",
516
+ idle_in_transaction_session_timeout: "10min",
517
+ },
518
+ });
493
519
  ```
494
520
 
495
- The command reads no file contents and writes no data. It asks the kernel to discard only clean pages; dirty pages stay until ordinary PostgreSQL and kernel writeback makes them eligible. It requires no root privileges, global `drop_caches`, forced checkpoint or `sync`. It does not follow symlinks, including tablespace links. The next read can incur disk I/O, so begin with five minutes and lengthen the interval if cache misses affect latency. Files removed during a run can fail that run. The repeating Effect then fails; a cron scheduler launches a fresh run at its next tick. The reported Railway trim took 88 ms and left a 1 GB container at 68–191 MiB; duration and retained pages depend on the workload and filesystem.
521
+ The host applies the declaration on startup before listeners and migrations, outside any migration transaction. SQL's [settings applier](https://github.com/ShivaeDev/platform/tree/main/packages/sql#postgresql-server-settings) reads `pg_settings`, writes only differing values with `ALTER SYSTEM SET`, and requests a reload. Startup logs settings awaiting a PostgreSQL restart with the values they will take. In this example, `shared_buffers` and `max_connections` wait for the next PostgreSQL redeploy or image update. `idle_in_transaction_session_timeout` ends sessions left in an open transaction without terminating idle LISTEN connections.
496
522
 
497
- Enable the preset and trim per app in a throwaway environment first. Record `memory.current` and `memory.stat` inside the PostgreSQL cgroup before applying the preset, after restart, after a representative request/backup peak, and at five and ten minutes idle with trimming and the normal pool lifetime enabled. Check that LISTEN delivery and application reads still work. `docker stats` can subtract cache and is not the billed cgroup total. Keep PITR and non-PITR trials separate. Roll out to production only after that consumer trial; starter deployments must also keep these operations opt-in until the trial succeeds. The starter does not apply instance settings or schedule a trim during application startup.
523
+ Railway's template connects as the `postgres` superuser. Its wrapper appends `max_connections = 500` only when no such line exists in `postgresql.auto.conf`, so an `ALTER SYSTEM` value survives a restart. On a non-superuser deployment, or a refused setting, the host warns with the setting name, live value and wanted value and continues starting. The database operator must apply settings the app cannot change. Server settings apply to the entire PostgreSQL cluster; all apps sharing it must agree on the declaration.
498
524
 
499
525
  ### API
500
526
 
@@ -11,11 +11,13 @@ export type AppHostInput<TRpcs extends Rpc.Any, THandlers, THandlerError, THandl
11
11
  })));
12
12
  export type AppHostOptions<TRpcs extends Rpc.Any = never, THandlers = never, THandlerError = never, THandlerRequirements = never, TServices = never, TServiceError = never, TServiceRequirements = never, TMigrations = never, TPreflight = never, TPreflightError = never, TPreflightRequirements = never, TRouteError = never, TRouteRequirements = HostRouteRequirements, TMigrationError = never, TRequestServices = never, TRequestRequirements = never> = HostPreflight<TPreflight, TPreflightError, TPreflightRequirements> & HostCoreOptions<TRpcs, THandlers, THandlerError, THandlerRequirements, TServices, TServiceError, TServiceRequirements, TRequestServices, TRequestRequirements> & HostRoutes<TRouteError, TRouteRequirements> & HostPolicy & {
13
13
  readonly migrations: AppDatabaseOptions<TMigrations, TMigrationError>["migrations"];
14
+ readonly postgresSettings: AppDatabaseOptions["postgresSettings"];
14
15
  readonly config?: AppDatabaseOptions["config"];
15
16
  readonly policy?: undefined;
16
17
  };
17
18
  export type AppLocalHostOptions<TRpcs extends Rpc.Any = never, THandlers = never, THandlerError = never, THandlerRequirements = never, TServices = never, TServiceError = never, TServiceRequirements = never, TMigrations = never, TPreflight = never, TPreflightError = never, TPreflightRequirements = never, TRouteError = never, TRouteRequirements = HostRouteRequirements, TMigrationError = never, TRequestServices = never, TRequestRequirements = never> = HostPreflight<TPreflight, TPreflightError, TPreflightRequirements> & HostCoreOptions<TRpcs, THandlers, THandlerError, THandlerRequirements, TServices, TServiceError, TServiceRequirements, TRequestServices, TRequestRequirements> & HostRoutes<TRouteError, TRouteRequirements> & {
18
19
  readonly migrations: AppDatabaseOptions<TMigrations, TMigrationError>["migrations"];
20
+ readonly postgresSettings: AppDatabaseOptions["postgresSettings"];
19
21
  readonly config?: AppDatabaseOptions["config"];
20
22
  readonly policy: "loopback";
21
23
  readonly sessions?: never;
@@ -1 +1 @@
1
- {"version":3,"file":"AppHostInput.d.ts","sourceRoot":"","sources":["../src/AppHostInput.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,qBAAqB,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AACtG,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEvD,MAAM,MAAM,YAAY,CACvB,KAAK,SAAS,GAAG,CAAC,GAAG,EACrB,SAAS,EACT,aAAa,EACb,oBAAoB,EACpB,SAAS,GAAG,KAAK,EACjB,aAAa,GAAG,KAAK,EACrB,oBAAoB,GAAG,KAAK,EAC5B,WAAW,GAAG,KAAK,EACnB,iBAAiB,GAAG,KAAK,EACzB,wBAAwB,GAAG,KAAK,EAChC,UAAU,GAAG,KAAK,EAClB,eAAe,GAAG,KAAK,EACvB,sBAAsB,GAAG,KAAK,EAC9B,WAAW,GAAG,KAAK,EACnB,kBAAkB,GAAG,qBAAqB,EAC1C,eAAe,GAAG,KAAK,EACvB,gBAAgB,GAAG,KAAK,EACxB,oBAAoB,GAAG,KAAK,IACzB,aAAa,CAAC,UAAU,EAAE,eAAe,EAAE,sBAAsB,CAAC,GACrE,CACG,CAAC,kBAAkB,CAAC,WAAW,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,CAAC;IAC5B,QAAQ,CAAC,QAAQ,CAAC,EAAE,KAAK,CAAC;CAC1B,CAAC"}
@@ -4,14 +4,16 @@ import { Digest } from "effect/crypto";
4
4
  import * as Reactivity from "effect/reactivity/Reactivity";
5
5
  import { type PostgresChangesOptions } from "@shivaedev/sql/postgresChanges.ts";
6
6
  import { type PostgresOptions } from "@shivaedev/sql/postgresLayer.ts";
7
+ import { type PostgresSettings } from "@shivaedev/sql/postgresSettings.ts";
7
8
  import type { AppHostFactory } from "#AppHostFactory.ts";
8
9
  import type { MigrationOptions } from "#MigrationOptions.ts";
9
10
  export interface AppDatabaseOptions<R = never, E = never> {
10
11
  readonly config?: DatabaseConfig;
11
12
  readonly migrations: MigrationOptions<R, E>;
13
+ readonly postgresSettings: PostgresSettings;
12
14
  }
13
15
  export interface DatabaseConfig extends PostgresOptions {
14
- readonly changes?: Partial<Omit<PostgresChangesOptions, "client" | "listenerClient" | "connectionSetting" | "connectionTTL" | "resync">>;
16
+ readonly changes?: Partial<Omit<PostgresChangesOptions, "client" | "listenerClient" | "connectionSetting" | "resync">>;
15
17
  readonly clock?: Clock.Clock;
16
18
  readonly databaseUrl?: Redacted.Redacted<string>;
17
19
  readonly listenDatabaseUrl?: Redacted.Redacted<string>;
@@ -1 +1 @@
1
- {"version":3,"file":"appDatabase.d.ts","sourceRoot":"","sources":["../src/appDatabase.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,QAAQ,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,KAAK,EAAE,MAAM,EAAmB,KAAK,EAAU,QAAQ,EAAE,MAAM,QAAQ,CAAC;AACjF,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,KAAK,UAAU,MAAM,8BAA8B,CAAC;AAM3D,OAAO,EAAE,KAAK,sBAAsB,EAAmB,MAAM,mCAAmC,CAAC;AACjG,OAAO,EAAE,KAAK,eAAe,EAAiB,MAAM,iCAAiC,CAAC;AAEtF,OAAO,KAAK,EA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} from "@shivaedev/sql/postgresChanges.ts";
11
11
  import { postgresLayer } from "@shivaedev/sql/postgresLayer.ts";
12
+ import { applyPostgresSettings } from "@shivaedev/sql/postgresSettings.ts";
12
13
  import { WorkerRelease } from "@shivaedev/sql/worker-release/service.ts";
13
14
  import { deferredHost, migratedHost } from "#appDatabaseHttp.ts";
14
15
  import { appHostHttp } from "#appHostHttp.ts";
@@ -32,6 +33,7 @@ export function appDatabase(options) {
32
33
  const changes = options.config?.changes;
33
34
  const connected = Layer.unwrap(Effect.gen(function* () {
34
35
  const client = yield* PgClient.PgClient;
36
+ yield* applyPostgresSettings(options.postgresSettings);
35
37
  const hints = yield* LiveServer;
36
38
  const url = options.config?.databaseUrl ?? (yield* Config.Redacted("DATABASE_URL"));
37
39
  const name = yield* Config.String("APP_NAME").pipe(Config.withDefault(new URL(Redacted.value(url)).pathname));
@@ -49,7 +51,6 @@ export function appDatabase(options) {
49
51
  channel,
50
52
  client,
51
53
  connectionSetting,
52
- "connectionTTL": config.connectionTTL,
53
54
  listenerClient,
54
55
  resync: hints.resync(),
55
56
  }).pipe(Layer.provide(clock));
@@ -1 +1 @@
1
- {"version":3,"file":"appDatabase.js","sourceRoot":"","sources":["../src/appDatabase.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,kCAAkC,CAAC;AAC/D,OAAO,KAAK,QAAQ,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AACjF,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,KAAK,UAAU,MAAM,8BAA8B,CAAC;AAE3D,OAAO,EAAE,eAAe,EAAE,MAAM,0CAA0C,CAAC;AAC3E,OAAO,EAAE,UAAU,EAAE,MAAM,4CAA4C,CAAC;AACxE,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CA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ts","sourceRoot":"","sources":["../src/nativeClientOrigins.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,MAAM,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,EAA2B,UAAU,EAAyC,MAAM,aAAa,CAAC;AAIzG,eAAO,MAAM,aAAa,8BAYzB,CAAC;AAEF,wBAAgB,mBAAmB,CAClC,OAAO,EAAE,SAAS,MAAM,EAAE,EAC1B,YAAY,EAAE,MAAM,GAAG,SAAS,EAChC,IAAI,GAAE,OAAO,GAAG,WAAmB,EACnC,OAAO,GAAE,UAAU,CAAC,SAAkB,qDA+BtC"}
1
+ {"version":3,"file":"nativeClientOrigins.d.ts","sourceRoot":"","sources":["../src/nativeClientOrigins.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChD,OAAO,EAA2B,UAAU,EAAyC,MAAM,aAAa,CAAC;AAKzG,eAAO,MAAM,aAAa,8BAYzB,CAAC;AAEF,wBAAgB,mBAAmB,CAClC,OAAO,EAAE,SAAS,MAAM,EAAE,EAC1B,YAAY,EAAE,MAAM,GAAG,SAAS,EAChC,IAAI,GAAE,OAAO,GAAG,WAAmB,EACnC,OAAO,GAAE,UAAU,CAAC,SAAkB,qDAoBtC"}
@@ -1,7 +1,8 @@
1
- import { Effect, Schema } from "effect";
1
+ import { Effect, Option, Schema } from "effect";
2
2
  import { Headers, HttpMiddleware, HttpRouter, HttpServerRequest, HttpServerResponse } from "effect/http";
3
3
  import * as HttpStatus from "effect/http/HttpStatus";
4
4
  import { localTransport } from "@shivaedev/identity/server/adapters/local.ts";
5
+ import { SessionPolicy } from "@shivaedev/identity/server/SessionPolicy.ts";
5
6
  export const NativeOrigins = Schema.Array(Schema.String.check(Schema.makeFilter((origin) => {
6
7
  try {
7
8
  const url = new URL(origin);
@@ -14,31 +15,37 @@ export const NativeOrigins = Schema.Array(Schema.String.check(Schema.makeFilter(
14
15
  })));
15
16
  export function nativeClientOrigins(origins, trustedProxy, auth = false, rpcPath = "/rpc") {
16
17
  const matchesPath = auth ? (path) => path === "/api/auth" || path.startsWith("/api/auth/") : (path) => path === rpcPath;
17
- const allowed = localTransport(trustedProxy, origins);
18
- const cors = HttpMiddleware.cors({
19
- allowedHeaders: ["Authorization", "Content-Type"],
20
- allowedMethods: auth ? ["GET", "POST"] : ["POST"],
21
- allowedOrigins: (origin) => origins.includes(origin),
22
- credentials: false,
23
- exposedHeaders: auth ? ["set-auth-token"] : [],
24
- });
25
18
  return HttpRouter.middleware((effect) => Effect.gen(function* () {
26
19
  const request = yield* HttpServerRequest.HttpServerRequest;
27
20
  if (!matchesPath(request.url.split("?")[0] ?? "")) {
28
21
  return yield* effect;
29
22
  }
23
+ const policy = yield* Effect.serviceOption(SessionPolicy);
24
+ const declared = Option.getOrUndefined(policy)?.origin.trustedOrigins ?? [];
25
+ const allowed = localTransport(trustedProxy, [...origins, ...declared]);
30
26
  if ((auth === true || request.method === "OPTIONS") && !allowed(request)) {
31
27
  return HttpServerResponse.text("Local same-origin requests only", {
32
28
  status: HttpStatus.fromLiteral("Forbidden"),
33
29
  });
34
30
  }
35
- if (!origins.includes(request.headers.origin ?? "")) {
36
- return yield* effect;
37
- }
38
- const native = request.modify({
39
- headers: Headers.remove(request.headers, "cookie"),
40
- });
41
- return yield* cors(effect).pipe(Effect.provideService(HttpServerRequest.HttpServerRequest, native));
31
+ return yield* withClientCors(effect, origins, declared, auth !== false);
42
32
  })).layer;
43
33
  }
34
+ const withClientCors = Effect.fnUntraced(function* (effect, nativeOrigins, declared, auth) {
35
+ const request = yield* HttpServerRequest.HttpServerRequest;
36
+ const origin = request.headers.origin ?? "";
37
+ const native = nativeOrigins.includes(origin);
38
+ const credentialed = !(native || origin.includes("*")) && declared.includes(origin);
39
+ if (!(native || credentialed)) {
40
+ return yield* effect;
41
+ }
42
+ const transport = native ? request.modify({ headers: Headers.remove(request.headers, "cookie") }) : request;
43
+ return yield* HttpMiddleware.cors({
44
+ allowedHeaders: ["Authorization", "Content-Type"],
45
+ allowedMethods: auth ? ["GET", "POST"] : ["POST"],
46
+ allowedOrigins: [origin],
47
+ credentials: credentialed,
48
+ exposedHeaders: auth && native ? ["set-auth-token"] : [],
49
+ })(effect).pipe(Effect.provideService(HttpServerRequest.HttpServerRequest, transport));
50
+ });
44
51
  //# sourceMappingURL=nativeClientOrigins.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"nativeClientOrigins.js","sourceRoot":"","sources":["../src/nativeClientOrigins.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACzG,OAAO,KAAK,UAAU,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,8CAA8C,CAAC;AAE9E,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAC,KAAK,CACxC,MAAM,CAAC,MAAM,CAAC,KAAK,CAClB,MAAM,CAAC,UAAU,CAAC,CAAC,MAAM,EAAE,EAAE;IAC5B,IAAI,CAAC;QACJ,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC;QAC5B,MAAM,SAAS,GAAG,GAAG,CAAC,MAAM,KAAK,MAAM,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,QAAQ,KAAK,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC;QACtF,OAAO,GAAG,CAAC,IAAI,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,SAAS,KAAK,MAAM,CAAC;IACzE,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,KAAK,CAAC;IACd,CAAC;AACF,CAAC,CAAC,CACF,CACD,CAAC;AAEF,MAAM,UAAU,mBAAmB,CAClC,OAA0B,EAC1B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AAC,MAAM,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;IAC5G,OAAO,KAAK,CAAC,CAAC,cAAc,CAAC,IAAI,CAAC;QACjC,cAAc,EAAE,CAAC,eAAe,EAAE,cAAc,CAAC;QACjD,cAAc,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;QACjD,cAAc,EAAE,CAAC,MAAM,CAAC;QACxB,WAAW,EAAE,YAAY;QACzB,cAAc,EAAE,IAAI,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,EAAE;KACxD,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,iBAAiB,CAAC,iBAAiB,EAAE,SAAS,CAAC,CAAC,CAAC;AACxF,CAAC,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shivaedev/server",
3
- "version": "0.29.1",
3
+ "version": "0.31.0",
4
4
  "description": "The Effect application host: HTTP and RPC serving, health, OTLP export, database and migrations, and development mode",
5
5
  "keywords": [
6
6
  "effect"
@@ -46,26 +46,26 @@
46
46
  ],
47
47
  "dependencies": {
48
48
  "@shivaedev/changes": "0.11.0",
49
- "@shivaedev/contract": "0.42.0",
49
+ "@shivaedev/contract": "0.43.0",
50
50
  "@shivaedev/errors": "0.10.0",
51
51
  "@shivaedev/http": "0.8.0",
52
- "@shivaedev/identity": "0.29.1",
52
+ "@shivaedev/identity": "0.30.0",
53
53
  "@shivaedev/local-postgres": "0.15.0",
54
- "@shivaedev/sql": "0.44.0"
54
+ "@shivaedev/sql": "0.45.0"
55
55
  },
56
56
  "devDependencies": {
57
57
  "@effect/platform-node": "4.1.0",
58
58
  "@effect/sql-pg": "4.1.0",
59
59
  "@effect/vitest": "4.1.0",
60
60
  "@shivaedev/access": "0.6.0",
61
- "@shivaedev/admin": "0.22.1",
62
- "@shivaedev/jobs": "0.40.1",
63
- "@shivaedev/quality": "0.67.3",
64
- "@shivaedev/rate-limit": "0.6.2",
61
+ "@shivaedev/admin": "0.23.1",
62
+ "@shivaedev/jobs": "0.41.0",
63
+ "@shivaedev/quality": "0.69.3",
64
+ "@shivaedev/rate-limit": "0.6.3",
65
65
  "@shivaedev/service": "0.8.0",
66
- "@shivaedev/test-kits": "0.9.2",
67
- "@shivaedev/test-sql": "0.24.2",
68
- "@shivaedev/test-story": "0.44.1",
66
+ "@shivaedev/test-kits": "0.10.0",
67
+ "@shivaedev/test-sql": "0.24.3",
68
+ "@shivaedev/test-story": "0.45.0",
69
69
  "@types/node": "24.19.2",
70
70
  "better-auth": "1.7.14",
71
71
  "effect": "4.1.0",
@@ -77,7 +77,7 @@
77
77
  "@effect/platform-node": "4.1.0",
78
78
  "@effect/sql-pg": "4.1.0",
79
79
  "@effect/vitest": "4.1.0",
80
- "@shivaedev/admin": "0.22.1",
80
+ "@shivaedev/admin": "0.23.1",
81
81
  "better-auth": "1.7.14",
82
82
  "effect": "4.1.0"
83
83
  },
@@ -96,6 +96,7 @@ export type AppHostOptions<
96
96
  HostRoutes<TRouteError, TRouteRequirements> &
97
97
  HostPolicy & {
98
98
  readonly migrations: AppDatabaseOptions<TMigrations, TMigrationError>["migrations"];
99
+ readonly postgresSettings: AppDatabaseOptions["postgresSettings"];
99
100
  readonly config?: AppDatabaseOptions["config"];
100
101
  readonly policy?: undefined;
101
102
  };
@@ -131,6 +132,7 @@ export type AppLocalHostOptions<
131
132
  > &
132
133
  HostRoutes<TRouteError, TRouteRequirements> & {
133
134
  readonly migrations: AppDatabaseOptions<TMigrations, TMigrationError>["migrations"];
135
+ readonly postgresSettings: AppDatabaseOptions["postgresSettings"];
134
136
  readonly config?: AppDatabaseOptions["config"];
135
137
  readonly policy: "loopback";
136
138
  readonly sessions?: never;
@@ -10,6 +10,7 @@ import { isSensitiveKey } from "@shivaedev/errors/sensitive.ts";
10
10
  import { coordinateWorkerRelease } from "@shivaedev/sql/coordinateWorkerRelease.ts";
11
11
  import { type PostgresChangesOptions, postgresChanges } from "@shivaedev/sql/postgresChanges.ts";
12
12
  import { type PostgresOptions, postgresLayer } from "@shivaedev/sql/postgresLayer.ts";
13
+ import { applyPostgresSettings, type PostgresSettings } from "@shivaedev/sql/postgresSettings.ts";
13
14
  import { WorkerRelease } from "@shivaedev/sql/worker-release/service.ts";
14
15
  import type { AppHostFactory } from "#AppHostFactory.ts";
15
16
  import type { AppHostInput } from "#AppHostInput.ts";
@@ -24,10 +25,11 @@ import { prepareMigrations } from "#prepareMigrations.ts";
24
25
  export interface AppDatabaseOptions<R = never, E = never> {
25
26
  readonly config?: DatabaseConfig;
26
27
  readonly migrations: MigrationOptions<R, E>;
28
+ readonly postgresSettings: PostgresSettings;
27
29
  }
28
30
 
29
31
  export interface DatabaseConfig extends PostgresOptions {
30
- readonly changes?: Partial<Omit<PostgresChangesOptions, "client" | "listenerClient" | "connectionSetting" | "connectionTTL" | "resync">>;
32
+ readonly changes?: Partial<Omit<PostgresChangesOptions, "client" | "listenerClient" | "connectionSetting" | "resync">>;
31
33
  readonly clock?: Clock.Clock;
32
34
  readonly databaseUrl?: Redacted.Redacted<string>;
33
35
  readonly listenDatabaseUrl?: Redacted.Redacted<string>;
@@ -56,6 +58,7 @@ export function appDatabase<R, E = never>(options: AppDatabaseOptions<R, E>) {
56
58
  const connected = Layer.unwrap(
57
59
  Effect.gen(function* () {
58
60
  const client = yield* PgClient.PgClient;
61
+ yield* applyPostgresSettings(options.postgresSettings);
59
62
  const hints = yield* LiveServer;
60
63
  const url = options.config?.databaseUrl ?? (yield* Config.Redacted("DATABASE_URL"));
61
64
  const name = yield* Config.String("APP_NAME").pipe(Config.withDefault(new URL(Redacted.value(url)).pathname));
@@ -77,7 +80,6 @@ export function appDatabase<R, E = never>(options: AppDatabaseOptions<R, E>) {
77
80
  channel,
78
81
  client,
79
82
  connectionSetting,
80
- "connectionTTL": config.connectionTTL,
81
83
  listenerClient,
82
84
  resync: hints.resync(),
83
85
  }).pipe(Layer.provide(clock));
@@ -37,7 +37,7 @@ const initializeHostChanges = Effect.fnUntraced(function* (group: RpcGroup.RpcGr
37
37
  const refresh = refreshSession(viewer, rpc._tag);
38
38
  const read = rerunQuery(group, options);
39
39
  type Failure = Effect.Error<typeof subscription.authorized | typeof refresh | ReturnType<typeof read>>;
40
- const pending = subscribeQueries<Failure, Effect.Services<ReturnType<typeof read>>, typeof read>({ ...subscription, refresh }, read);
40
+ const pending = subscribeQueries<Failure, Effect.Services<ReturnType<typeof read>>>({ ...subscription, refresh }, read);
41
41
  const stream = Option.isSome(changes)
42
42
  ? Stream.unwrap(pending.pipe(Effect.provideService(LiveServer, changes.value)))
43
43
  : Stream.concat(
@@ -1,7 +1,8 @@
1
- import { Effect, Schema } from "effect";
1
+ import { Effect, Option, Schema } from "effect";
2
2
  import { Headers, HttpMiddleware, HttpRouter, HttpServerRequest, HttpServerResponse } from "effect/http";
3
3
  import * as HttpStatus from "effect/http/HttpStatus";
4
4
  import { localTransport } from "@shivaedev/identity/server/adapters/local.ts";
5
+ import { SessionPolicy } from "@shivaedev/identity/server/SessionPolicy.ts";
5
6
 
6
7
  export const NativeOrigins = Schema.Array(
7
8
  Schema.String.check(
@@ -24,32 +25,44 @@ export function nativeClientOrigins(
24
25
  rpcPath: HttpRouter.PathInput = "/rpc",
25
26
  ) {
26
27
  const matchesPath = auth ? (path: string) => path === "/api/auth" || path.startsWith("/api/auth/") : (path: string) => path === rpcPath;
27
- const allowed = localTransport(trustedProxy, origins);
28
- const cors = HttpMiddleware.cors({
29
- allowedHeaders: ["Authorization", "Content-Type"],
30
- allowedMethods: auth ? ["GET", "POST"] : ["POST"],
31
- allowedOrigins: (origin) => origins.includes(origin),
32
- credentials: false,
33
- exposedHeaders: auth ? ["set-auth-token"] : [],
34
- });
35
28
  return HttpRouter.middleware((effect) =>
36
29
  Effect.gen(function* () {
37
30
  const request = yield* HttpServerRequest.HttpServerRequest;
38
31
  if (!matchesPath(request.url.split("?")[0] ?? "")) {
39
32
  return yield* effect;
40
33
  }
34
+ const policy = yield* Effect.serviceOption(SessionPolicy);
35
+ const declared = Option.getOrUndefined(policy)?.origin.trustedOrigins ?? [];
36
+ const allowed = localTransport(trustedProxy, [...origins, ...declared]);
41
37
  if ((auth === true || request.method === "OPTIONS") && !allowed(request)) {
42
38
  return HttpServerResponse.text("Local same-origin requests only", {
43
39
  status: HttpStatus.fromLiteral("Forbidden"),
44
40
  });
45
41
  }
46
- if (!origins.includes(request.headers.origin ?? "")) {
47
- return yield* effect;
48
- }
49
- const native = request.modify({
50
- headers: Headers.remove(request.headers, "cookie"),
51
- });
52
- return yield* cors(effect).pipe(Effect.provideService(HttpServerRequest.HttpServerRequest, native));
42
+ return yield* withClientCors(effect, origins, declared, auth !== false);
53
43
  }),
54
44
  ).layer;
55
45
  }
46
+
47
+ const withClientCors = Effect.fnUntraced(function* <E, R>(
48
+ effect: Effect.Effect<HttpServerResponse.HttpServerResponse, E, R>,
49
+ nativeOrigins: readonly string[],
50
+ declared: readonly string[],
51
+ auth: boolean,
52
+ ) {
53
+ const request = yield* HttpServerRequest.HttpServerRequest;
54
+ const origin = request.headers.origin ?? "";
55
+ const native = nativeOrigins.includes(origin);
56
+ const credentialed = !(native || origin.includes("*")) && declared.includes(origin);
57
+ if (!(native || credentialed)) {
58
+ return yield* effect;
59
+ }
60
+ const transport = native ? request.modify({ headers: Headers.remove(request.headers, "cookie") }) : request;
61
+ return yield* HttpMiddleware.cors({
62
+ allowedHeaders: ["Authorization", "Content-Type"],
63
+ allowedMethods: auth ? ["GET", "POST"] : ["POST"],
64
+ allowedOrigins: [origin],
65
+ credentials: credentialed,
66
+ exposedHeaders: auth && native ? ["set-auth-token"] : [],
67
+ })(effect).pipe(Effect.provideService(HttpServerRequest.HttpServerRequest, transport));
68
+ });
@@ -1,10 +0,0 @@
1
- import { Effect, Schema } from "effect";
2
- import { ChildProcessSpawner } from "effect/process";
3
- declare const PostgresPageCacheTrimError_base: Schema.Class<PostgresPageCacheTrimError, Schema.TaggedStruct<"PostgresPageCacheTrimError", {
4
- readonly exitCode: Schema.Number;
5
- }>, import("effect/Cause").YieldableError>;
6
- export declare class PostgresPageCacheTrimError extends PostgresPageCacheTrimError_base {
7
- }
8
- export declare const trimPostgresPageCache: (dataDirectory: string) => Effect.Effect<undefined, import("effect/PlatformError").PlatformError | PostgresPageCacheTrimError, ChildProcessSpawner.ChildProcessSpawner>;
9
- export {};
10
- //# sourceMappingURL=trimPostgresPageCache.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"trimPostgresPageCache.d.ts","sourceRoot":"","sources":["../src/trimPostgresPageCache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,EAAgB,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;;;;AAEnE,qBAAa,0BAA2B,SAAQ,+BAE9C;CAAG;AAEL,eAAO,MAAM,qBAAqB,yKAuBhC,CAAC"}
@@ -1,25 +0,0 @@
1
- import { Effect, Schema } from "effect";
2
- import { ChildProcess, ChildProcessSpawner } from "effect/process";
3
- export class PostgresPageCacheTrimError extends Schema.TaggedError()("PostgresPageCacheTrimError", {
4
- exitCode: Schema.Number,
5
- }) {
6
- }
7
- export const trimPostgresPageCache = Effect.fn("Server.trimPostgresPageCache")(function* (dataDirectory) {
8
- const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
9
- const code = yield* spawner.exitCode(ChildProcess.make("find", [
10
- dataDirectory,
11
- "-type",
12
- "f",
13
- "-exec",
14
- "sh",
15
- "-c",
16
- 'for path do dd if="$path" iflag=nocache count=0 status=none || exit; done',
17
- "sh",
18
- "{}",
19
- "+",
20
- ], { stderr: "inherit", stdout: "ignore" }));
21
- if (code !== 0) {
22
- return yield* new PostgresPageCacheTrimError({ exitCode: Number(code) });
23
- }
24
- });
25
- //# sourceMappingURL=trimPostgresPageCache.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"trimPostgresPageCache.js","sourceRoot":"","sources":["../src/trimPostgresPageCache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAEnE,MAAM,OAAO,0BAA2B,SAAQ,MAAM,CAAC,WAAW,EAA8B,CAAC,4BAA4B,EAAE;IAC9H,QAAQ,EAAE,MAAM,CAAC,MAAM;CACvB,CAAC;CAAG;AAEL,MAAM,CAAC,MAAM,qBAAqB,GAAG,MAAM,CAAC,EAAE,CAAC,8BAA8B,CAAC,CAAC,QAAQ,CAAC,EAAE,aAAqB;IAC9G,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,mBAAmB,CAAC,mBAAmB,CAAC;IAC/D,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,OAAO,CAAC,QAAQ,CACnC,YAAY,CAAC,IAAI,CAChB,MAAM,EACN;QACC,aAAa;QACb,OAAO;QACP,GAAG;QACH,OAAO;QACP,IAAI;QACJ,IAAI;QACJ,2EAA2E;QAC3E,IAAI;QACJ,IAAI;QACJ,GAAG;KACH,EACD,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,CACvC,CACD,CAAC;IACF,IAAI,IAAI,KAAK,CAAC,EAAE,CAAC;QAChB,OAAO,KAAK,CAAC,CAAC,IAAI,0BAA0B,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC1E,CAAC;AACF,CAAC,CAAC,CAAC"}
@@ -1,31 +0,0 @@
1
- import { Effect, Schema } from "effect";
2
- import { ChildProcess, ChildProcessSpawner } from "effect/process";
3
-
4
- export class PostgresPageCacheTrimError extends Schema.TaggedError<PostgresPageCacheTrimError>()("PostgresPageCacheTrimError", {
5
- exitCode: Schema.Number,
6
- }) {}
7
-
8
- export const trimPostgresPageCache = Effect.fn("Server.trimPostgresPageCache")(function* (dataDirectory: string) {
9
- const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
10
- const code = yield* spawner.exitCode(
11
- ChildProcess.make(
12
- "find",
13
- [
14
- dataDirectory,
15
- "-type",
16
- "f",
17
- "-exec",
18
- "sh",
19
- "-c",
20
- 'for path do dd if="$path" iflag=nocache count=0 status=none || exit; done',
21
- "sh",
22
- "{}",
23
- "+",
24
- ],
25
- { stderr: "inherit", stdout: "ignore" },
26
- ),
27
- );
28
- if (code !== 0) {
29
- return yield* new PostgresPageCacheTrimError({ exitCode: Number(code) });
30
- }
31
- });