@shivaedev/server 0.24.2 → 0.26.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 +18 -0
- package/README.md +22 -16
- package/dist/AppHostFactory.d.ts +5 -5
- package/dist/AppHostFactory.d.ts.map +1 -1
- package/dist/AppHostInput.d.ts +16 -8
- package/dist/AppHostInput.d.ts.map +1 -1
- package/dist/appDatabase.d.ts +8 -3
- package/dist/appDatabase.d.ts.map +1 -1
- package/dist/appDatabase.js +16 -44
- package/dist/appDatabase.js.map +1 -1
- package/dist/appDatabaseHttp.d.ts +239 -0
- package/dist/appDatabaseHttp.d.ts.map +1 -0
- package/dist/appDatabaseHttp.js +10 -0
- package/dist/appDatabaseHttp.js.map +1 -0
- package/dist/appHost.d.ts +120 -18
- package/dist/appHost.d.ts.map +1 -1
- package/dist/appHost.js +7 -17
- package/dist/appHost.js.map +1 -1
- package/dist/appHostHttp.d.ts +0 -235
- package/dist/appHostHttp.d.ts.map +1 -1
- package/dist/appHostHttp.js +0 -7
- package/dist/appHostHttp.js.map +1 -1
- package/dist/hostOptions.d.ts +1 -2
- package/dist/hostOptions.d.ts.map +1 -1
- package/dist/hostPreflight.d.ts +9 -0
- package/dist/hostPreflight.d.ts.map +1 -0
- package/dist/hostPreflight.js +6 -0
- package/dist/hostPreflight.js.map +1 -0
- package/dist/prepareMigrations.d.ts +5 -0
- package/dist/prepareMigrations.d.ts.map +1 -0
- package/dist/prepareMigrations.js +46 -0
- package/dist/prepareMigrations.js.map +1 -0
- package/dist/workerHost.d.ts +1 -1
- package/dist/workerHost.d.ts.map +1 -1
- package/dist/workerHost.js.map +1 -1
- package/package.json +13 -17
- package/src/AppHostFactory.ts +5 -9
- package/src/AppHostInput.ts +53 -7
- package/src/appDatabase.ts +64 -54
- package/src/appDatabaseHttp.ts +78 -0
- package/src/appHost.ts +46 -79
- package/src/appHostHttp.ts +0 -74
- package/src/hostOptions.ts +1 -2
- package/src/hostPreflight.ts +22 -0
- package/src/prepareMigrations.ts +57 -0
- package/src/workerHost.ts +1 -2
- package/dist/testing/HostProcessError.d.ts +0 -10
- package/dist/testing/HostProcessError.d.ts.map +0 -1
- package/dist/testing/HostProcessError.js +0 -4
- package/dist/testing/HostProcessError.js.map +0 -1
- package/dist/testing/adapters/hostProcess.d.ts +0 -24
- package/dist/testing/adapters/hostProcess.d.ts.map +0 -1
- package/dist/testing/adapters/hostProcess.js +0 -111
- package/dist/testing/adapters/hostProcess.js.map +0 -1
- package/dist/testing/adapters/hostProcessReadouts.d.ts +0 -10
- package/dist/testing/adapters/hostProcessReadouts.d.ts.map +0 -1
- package/dist/testing/adapters/hostProcessReadouts.js +0 -26
- package/dist/testing/adapters/hostProcessReadouts.js.map +0 -1
- package/dist/testing/hostProcess.d.ts +0 -26
- package/dist/testing/hostProcess.d.ts.map +0 -1
- package/dist/testing/hostProcess.js +0 -56
- package/dist/testing/hostProcess.js.map +0 -1
- package/dist/testing/hostProcessChild.d.ts +0 -7
- package/dist/testing/hostProcessChild.d.ts.map +0 -1
- package/dist/testing/hostProcessChild.js +0 -19
- package/dist/testing/hostProcessChild.js.map +0 -1
- package/dist/testing/hostProcessProtocol.d.ts +0 -20
- package/dist/testing/hostProcessProtocol.d.ts.map +0 -1
- package/dist/testing/hostProcessProtocol.js +0 -11
- package/dist/testing/hostProcessProtocol.js.map +0 -1
- package/dist/testing/hostProcessReadouts.d.ts +0 -7
- package/dist/testing/hostProcessReadouts.d.ts.map +0 -1
- package/dist/testing/hostProcessReadouts.js +0 -37
- package/dist/testing/hostProcessReadouts.js.map +0 -1
- package/dist/testing/hostTime.d.ts +0 -9
- package/dist/testing/hostTime.d.ts.map +0 -1
- package/dist/testing/hostTime.js +0 -27
- package/dist/testing/hostTime.js.map +0 -1
- package/src/testing/HostProcessError.ts +0 -6
- package/src/testing/adapters/hostProcess.ts +0 -122
- package/src/testing/adapters/hostProcessReadouts.ts +0 -29
- package/src/testing/hostProcess.ts +0 -69
- package/src/testing/hostProcessChild.ts +0 -25
- package/src/testing/hostProcessProtocol.ts +0 -11
- package/src/testing/hostProcessReadouts.ts +0 -46
- package/src/testing/hostTime.ts +0 -33
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hostPreflight.d.ts","sourceRoot":"","sources":["../src/hostPreflight.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAGpD,MAAM,MAAM,aAAa,CAAC,SAAS,GAAG,KAAK,EAAE,MAAM,GAAG,KAAK,EAAE,aAAa,GAAG,KAAK,IAC/E;IAAE,QAAQ,CAAC,SAAS,EAAE,KAAK,CAAC,KAAK,CAAC,SAAS,EAAE,MAAM,EAAE,aAAa,CAAC,CAAA;CAAE,GACrE,CAAC,CAAC,SAAS,GAAG,MAAM,GAAG,aAAa,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG;IAAE,QAAQ,CAAC,SAAS,CAAC,EAAE,KAAK,CAAA;CAAE,GAAG,KAAK,CAAC,CAAC;AAEnG,MAAM,MAAM,aAAa,CAAC,KAAK,SAAS,KAAK,CAAC,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,aAAa,IAAI,KAAK,CAAC,KAAK,CACjG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,SAAS,EAChC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,MAAM,EAC3B,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,aAAa,EAAE,MAAM,CAAC,MAAM,CAAC,CACjG,CAAC;AAEF,wBAAgB,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,aAAa,EAAE,eAAe,EAC9E,OAAO,EAAE,KAAK,CAAC,KAAK,CAAC,SAAS,EAAE,MAAM,EAAE,aAAa,CAAC,GAAG,SAAS,EAClE,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,EAAE,eAAe,CAAC,mFAMnE"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Effect, Layer } from "effect";
|
|
2
|
+
import { redactingDiagnostics } from "#redactingDiagnostics.ts";
|
|
3
|
+
export function hostPreflight(startup, sensitive) {
|
|
4
|
+
return Layer.mergeAll(Layer.empty, ...(startup === undefined ? [] : [Layer.unwrap(Effect.map(sensitive, (policy) => startup.pipe(Layer.provide(redactingDiagnostics(policy)))))]));
|
|
5
|
+
}
|
|
6
|
+
//# sourceMappingURL=hostPreflight.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hostPreflight.js","sourceRoot":"","sources":["../src/hostPreflight.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,MAAM,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAYhE,MAAM,UAAU,aAAa,CAC5B,OAAkE,EAClE,SAAmE;IAEnE,OAAO,KAAK,CAAC,QAAQ,CACpB,KAAK,CAAC,KAAK,EACX,GAAG,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,SAAS,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAC9I,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import { Migrator } from "effect/sql";
|
|
3
|
+
import type { MigrationOptions } from "#MigrationOptions.ts";
|
|
4
|
+
export declare function prepareMigrations<R, E>(migrations: MigrationOptions<R, E>): Effect.Effect<undefined, E | Migrator.MigrationError | import("effect/Schema").SchemaError | import("effect/sql/SqlError").SqlError, R | import("effect/sql/SqlClient").SqlClient> | Effect.Effect<void, E | Migrator.MigrationError | import("effect/Schema").SchemaError | import("effect/sql/SqlError").SqlError, import("effect/sql/SqlClient").SqlClient | Exclude<R, import("effect/Scope").Scope>>;
|
|
5
|
+
//# sourceMappingURL=prepareMigrations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prepareMigrations.d.ts","sourceRoot":"","sources":["../src/prepareMigrations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,MAAM,EAAmB,MAAM,QAAQ,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAItC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAE7D,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,CAAC,EAAE,UAAU,EAAE,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAAC,6YAWzE"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Duration, Effect, Fiber, Schedule } from "effect";
|
|
2
|
+
import { Migrator } from "effect/sql";
|
|
3
|
+
import { assertPostgresMigrations, postgresMigrationError } from "@shivaedev/sql/assertPostgresMigrations.ts";
|
|
4
|
+
import { migratePostgres } from "@shivaedev/sql/migrations.ts";
|
|
5
|
+
import { pendingPostgresMigrations } from "@shivaedev/sql/pendingPostgresMigrations.ts";
|
|
6
|
+
export function prepareMigrations(migrations) {
|
|
7
|
+
switch (migrations.mode) {
|
|
8
|
+
case "check": {
|
|
9
|
+
const { release: _release, ...schema } = migrations;
|
|
10
|
+
return assertPostgresMigrations(schema);
|
|
11
|
+
}
|
|
12
|
+
case "wait":
|
|
13
|
+
return waitForMigrations(migrations);
|
|
14
|
+
default:
|
|
15
|
+
return migratePostgres({ ...migrations, lockTimeout: migrations.lockTimeout ?? "5 seconds" }).pipe(Effect.asVoid);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
function waitForMigrations(migrations) {
|
|
19
|
+
return Effect.gen(function* () {
|
|
20
|
+
const progressInterval = Duration.fromInputUnsafe(migrations.progressInterval ?? "30 seconds");
|
|
21
|
+
let pending = { components: [], migrations: [] };
|
|
22
|
+
let progress;
|
|
23
|
+
function log(message) {
|
|
24
|
+
return Effect.suspend(() => Effect.logInfo(message).pipe(Effect.annotateLogs({ pendingComponents: pending.components, pendingMigrations: pending.migrations })));
|
|
25
|
+
}
|
|
26
|
+
yield* Effect.gen(function* () {
|
|
27
|
+
pending = yield* pendingPostgresMigrations(migrations);
|
|
28
|
+
if (pending.migrations.length === 0 && pending.components.length === 0) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
if (progress === undefined) {
|
|
32
|
+
yield* log("Waiting for database migrations");
|
|
33
|
+
progress = yield* Effect.forever(Effect.sleep(progressInterval).pipe(Effect.andThen(log("Still waiting for database migrations")))).pipe(Effect.forkScoped);
|
|
34
|
+
}
|
|
35
|
+
return yield* Effect.fail(postgresMigrationError(pending));
|
|
36
|
+
}).pipe(Effect.retry({
|
|
37
|
+
schedule: Schedule.max([Schedule.spaced(migrations.pollInterval ?? "1 second"), Schedule.during(migrations.waitTimeout ?? "5 minutes")]),
|
|
38
|
+
while: (error) => error instanceof Migrator.MigrationError && error.kind === "BadState",
|
|
39
|
+
}), Effect.tapError((error) => error instanceof Migrator.MigrationError && error.kind === "BadState" ? log("Timed out waiting for database migrations") : Effect.void));
|
|
40
|
+
if (progress !== undefined) {
|
|
41
|
+
yield* Fiber.interrupt(progress);
|
|
42
|
+
yield* Effect.logInfo("Database migrations current");
|
|
43
|
+
}
|
|
44
|
+
}).pipe(Effect.scoped);
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=prepareMigrations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prepareMigrations.js","sourceRoot":"","sources":["../src/prepareMigrations.ts"],"names":[],"mappings":"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"}
|
package/dist/workerHost.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Layer } from "effect";
|
|
2
|
-
import type
|
|
2
|
+
import { type AppDatabaseOptions } from "#appDatabase.ts";
|
|
3
3
|
export declare function workerHost<R, E, TRequirements, TServices, TServiceError, TServiceRequirements, TMigrations = never, TMigrationError = never>(options: AppDatabaseOptions<TMigrations, TMigrationError> & {
|
|
4
4
|
readonly workers: Layer.Layer<R, E, TRequirements>;
|
|
5
5
|
readonly services: Layer.Layer<TServices, TServiceError, TServiceRequirements>;
|
package/dist/workerHost.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workerHost.d.ts","sourceRoot":"","sources":["../src/workerHost.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"workerHost.d.ts","sourceRoot":"","sources":["../src/workerHost.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAC/B,OAAO,EAAE,KAAK,kBAAkB,EAAe,MAAM,iBAAiB,CAAC;AAEvE,wBAAgB,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,aAAa,EAAE,SAAS,EAAE,aAAa,EAAE,oBAAoB,EAAE,WAAW,GAAG,KAAK,EAAE,eAAe,GAAG,KAAK,EAC3I,OAAO,EAAE,kBAAkB,CAAC,WAAW,EAAE,eAAe,CAAC,GAAG;IAC3D,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,aAAa,CAAC,CAAC;IACnD,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC,KAAK,CAAC,SAAS,EAAE,aAAa,EAAE,oBAAoB,CAAC,CAAC;CAC/E,m5CAGD"}
|
package/dist/workerHost.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workerHost.js","sourceRoot":"","sources":["../src/workerHost.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,kCAAkC,CAAC;AAC/D,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAC/B,OAAO,
|
|
1
|
+
{"version":3,"file":"workerHost.js","sourceRoot":"","sources":["../src/workerHost.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,kCAAkC,CAAC;AAC/D,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAC/B,OAAO,EAA2B,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEvE,MAAM,UAAU,UAAU,CACzB,OAGC;IAED,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,KAAK,CAAC,YAAY,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,EAAE,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC;AAC9I,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shivaedev/server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.26.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,25 +46,25 @@
|
|
|
46
46
|
],
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"@shivaedev/changes": "0.10.1",
|
|
49
|
-
"@shivaedev/contract": "0.
|
|
49
|
+
"@shivaedev/contract": "0.37.0",
|
|
50
50
|
"@shivaedev/errors": "0.9.1",
|
|
51
|
-
"@shivaedev/http": "0.
|
|
52
|
-
"@shivaedev/identity": "0.26.
|
|
51
|
+
"@shivaedev/http": "0.7.0",
|
|
52
|
+
"@shivaedev/identity": "0.26.2",
|
|
53
53
|
"@shivaedev/local-postgres": "0.14.1",
|
|
54
|
-
"@shivaedev/sql": "0.
|
|
54
|
+
"@shivaedev/sql": "0.41.0"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@effect/platform-node": "4.0.7",
|
|
58
58
|
"@effect/sql-pg": "4.0.7",
|
|
59
59
|
"@effect/vitest": "4.0.7",
|
|
60
60
|
"@shivaedev/access": "0.5.1",
|
|
61
|
-
"@shivaedev/admin": "0.20.
|
|
62
|
-
"@shivaedev/jobs": "0.
|
|
63
|
-
"@shivaedev/quality": "0.
|
|
64
|
-
"@shivaedev/rate-limit": "0.5.
|
|
65
|
-
"@shivaedev/test-kits": "0.
|
|
66
|
-
"@shivaedev/test-sql": "0.
|
|
67
|
-
"@shivaedev/test-story": "0.
|
|
61
|
+
"@shivaedev/admin": "0.20.4",
|
|
62
|
+
"@shivaedev/jobs": "0.37.1",
|
|
63
|
+
"@shivaedev/quality": "0.63.0",
|
|
64
|
+
"@shivaedev/rate-limit": "0.5.3",
|
|
65
|
+
"@shivaedev/test-kits": "0.6.0",
|
|
66
|
+
"@shivaedev/test-sql": "0.22.0",
|
|
67
|
+
"@shivaedev/test-story": "0.40.0",
|
|
68
68
|
"@types/node": "24.19.2",
|
|
69
69
|
"better-auth": "1.7.14",
|
|
70
70
|
"effect": "4.0.7",
|
|
@@ -76,8 +76,7 @@
|
|
|
76
76
|
"@effect/platform-node": "4.0.7",
|
|
77
77
|
"@effect/sql-pg": "4.0.7",
|
|
78
78
|
"@effect/vitest": "4.0.7",
|
|
79
|
-
"@shivaedev/admin": "0.20.
|
|
80
|
-
"@shivaedev/test-sql": "0.21.1",
|
|
79
|
+
"@shivaedev/admin": "0.20.4",
|
|
81
80
|
"better-auth": "1.7.14",
|
|
82
81
|
"effect": "4.0.7"
|
|
83
82
|
},
|
|
@@ -94,9 +93,6 @@
|
|
|
94
93
|
"@shivaedev/admin": {
|
|
95
94
|
"optional": true
|
|
96
95
|
},
|
|
97
|
-
"@shivaedev/test-sql": {
|
|
98
|
-
"optional": true
|
|
99
|
-
},
|
|
100
96
|
"better-auth": {
|
|
101
97
|
"optional": true
|
|
102
98
|
}
|
package/src/AppHostFactory.ts
CHANGED
|
@@ -1,15 +1,11 @@
|
|
|
1
|
-
import type { Crypto, Layer } from "effect";
|
|
2
1
|
import type { Rpc } from "effect/rpc";
|
|
3
2
|
import type { AppHostInput } from "#AppHostInput.ts";
|
|
4
|
-
import type { AppDatabaseOptions
|
|
5
|
-
import type {
|
|
3
|
+
import type { AppDatabaseOptions } from "#appDatabase.ts";
|
|
4
|
+
import type { deferredHost } from "#appDatabaseHttp.ts";
|
|
5
|
+
import type { AppHttpHostOptions } from "#appHost.ts";
|
|
6
|
+
import type { appHostHttp } from "#appHostHttp.ts";
|
|
6
7
|
import type { HostRouteRequirements } from "#hostOptions.ts";
|
|
7
|
-
|
|
8
|
-
type PreflightHost<THost extends Layer.Any, TServices, TError, TRequirements> = Layer.Layer<
|
|
9
|
-
Layer.Success<THost> | TServices,
|
|
10
|
-
Layer.Error<THost> | TError,
|
|
11
|
-
Exclude<Layer.Services<THost>, TServices | Crypto.Crypto> | Exclude<TRequirements, Crypto.Crypto>
|
|
12
|
-
>;
|
|
8
|
+
import type { PreflightHost } from "#hostPreflight.ts";
|
|
13
9
|
|
|
14
10
|
export interface AppHostFactory {
|
|
15
11
|
<
|
package/src/AppHostInput.ts
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import type { Effect
|
|
1
|
+
import type { Effect } from "effect";
|
|
2
2
|
import type { Rpc } from "effect/rpc";
|
|
3
|
-
import type { AppDatabaseOptions
|
|
4
|
-
import type {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
| { readonly preflight: Layer.Layer<TServices, TError, TRequirements> }
|
|
8
|
-
| ([TServices | TError | TRequirements] extends [never] ? { readonly preflight?: never } : never);
|
|
3
|
+
import type { AppDatabaseOptions } from "#appDatabase.ts";
|
|
4
|
+
import type { AppHttpHostOptions } from "#appHost.ts";
|
|
5
|
+
import type { HostCoreOptions, HostPolicy, HostRouteRequirements, HostRoutes } from "#hostOptions.ts";
|
|
6
|
+
import type { HostPreflight } from "#hostPreflight.ts";
|
|
9
7
|
|
|
10
8
|
export type AppHostInput<
|
|
11
9
|
TRpcs extends Rpc.Any,
|
|
@@ -93,3 +91,51 @@ export type AppHostInput<
|
|
|
93
91
|
TRouteRequirements
|
|
94
92
|
>
|
|
95
93
|
);
|
|
94
|
+
|
|
95
|
+
export type AppHostOptions<
|
|
96
|
+
TRpcs extends Rpc.Any = never,
|
|
97
|
+
THandlers = never,
|
|
98
|
+
THandlerError = never,
|
|
99
|
+
THandlerRequirements = never,
|
|
100
|
+
TServices = never,
|
|
101
|
+
TServiceError = never,
|
|
102
|
+
TServiceRequirements = never,
|
|
103
|
+
TMigrations = never,
|
|
104
|
+
TPreflight = never,
|
|
105
|
+
TPreflightError = never,
|
|
106
|
+
TPreflightRequirements = never,
|
|
107
|
+
TRouteError = never,
|
|
108
|
+
TRouteRequirements = HostRouteRequirements,
|
|
109
|
+
TMigrationError = never,
|
|
110
|
+
> = HostPreflight<TPreflight, TPreflightError, TPreflightRequirements> &
|
|
111
|
+
HostCoreOptions<TRpcs, THandlers, THandlerError, THandlerRequirements, TServices, TServiceError, TServiceRequirements> &
|
|
112
|
+
HostRoutes<TRouteError, TRouteRequirements> &
|
|
113
|
+
HostPolicy & {
|
|
114
|
+
readonly migrations: AppDatabaseOptions<TMigrations, TMigrationError>["migrations"];
|
|
115
|
+
readonly config?: AppDatabaseOptions["config"];
|
|
116
|
+
readonly policy?: undefined;
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
export type AppLocalHostOptions<
|
|
120
|
+
TRpcs extends Rpc.Any = never,
|
|
121
|
+
THandlers = never,
|
|
122
|
+
THandlerError = never,
|
|
123
|
+
THandlerRequirements = never,
|
|
124
|
+
TServices = never,
|
|
125
|
+
TServiceError = never,
|
|
126
|
+
TServiceRequirements = never,
|
|
127
|
+
TMigrations = never,
|
|
128
|
+
TPreflight = never,
|
|
129
|
+
TPreflightError = never,
|
|
130
|
+
TPreflightRequirements = never,
|
|
131
|
+
TRouteError = never,
|
|
132
|
+
TRouteRequirements = HostRouteRequirements,
|
|
133
|
+
TMigrationError = never,
|
|
134
|
+
> = HostPreflight<TPreflight, TPreflightError, TPreflightRequirements> &
|
|
135
|
+
HostCoreOptions<TRpcs, THandlers, THandlerError, THandlerRequirements, TServices, TServiceError, TServiceRequirements> &
|
|
136
|
+
HostRoutes<TRouteError, TRouteRequirements> & {
|
|
137
|
+
readonly migrations: AppDatabaseOptions<TMigrations, TMigrationError>["migrations"];
|
|
138
|
+
readonly config?: AppDatabaseOptions["config"];
|
|
139
|
+
readonly policy: "loopback";
|
|
140
|
+
readonly sessions?: never;
|
|
141
|
+
};
|
package/src/appDatabase.ts
CHANGED
|
@@ -1,17 +1,29 @@
|
|
|
1
|
+
import * as NodeCrypto from "@effect/platform-node/NodeCrypto";
|
|
1
2
|
import * as PgClient from "@effect/sql-pg/PgClient";
|
|
2
|
-
import { Clock, Config, Context, Crypto,
|
|
3
|
+
import { Clock, Config, Context, Crypto, Effect, Layer, Option, Redacted } from "effect";
|
|
3
4
|
import * as Hex from "effect/encoding/Hex";
|
|
4
5
|
import * as Reactivity from "effect/reactivity/Reactivity";
|
|
5
|
-
import {
|
|
6
|
+
import type { Rpc } from "effect/rpc";
|
|
6
7
|
import { LiveServer } from "@shivaedev/contract/LiveServer.ts";
|
|
7
|
-
import {
|
|
8
|
+
import { isSensitiveKey } from "@shivaedev/errors/sensitive.ts";
|
|
8
9
|
import { coordinateWorkerRelease } from "@shivaedev/sql/coordinateWorkerRelease.ts";
|
|
9
|
-
import { migratePostgres } from "@shivaedev/sql/migrations.ts";
|
|
10
|
-
import { type PendingPostgresMigrations, pendingPostgresMigrations } from "@shivaedev/sql/pendingPostgresMigrations.ts";
|
|
11
10
|
import { type PostgresChangesOptions, postgresChanges } from "@shivaedev/sql/postgresChanges.ts";
|
|
12
11
|
import { type PostgresOptions, postgresLayer } from "@shivaedev/sql/postgresLayer.ts";
|
|
13
12
|
import { WorkerRelease } from "@shivaedev/sql/WorkerRelease.ts";
|
|
14
|
-
import type {
|
|
13
|
+
import type { AppHostFactory } from "#AppHostFactory.ts";
|
|
14
|
+
import type { AppHostInput } from "#AppHostInput.ts";
|
|
15
|
+
import { deferredHost, migratedHost } from "#appDatabaseHttp.ts";
|
|
16
|
+
import { appHostHttp } from "#appHostHttp.ts";
|
|
17
|
+
import type { HostRouteRequirements } from "#hostOptions.ts";
|
|
18
|
+
import { hostPreflight } from "#hostPreflight.ts";
|
|
19
|
+
import { hostSensitiveKeys } from "#hostSensitiveKeys.ts";
|
|
20
|
+
import type { MigrationOptions } from "#MigrationOptions.ts";
|
|
21
|
+
import { prepareMigrations } from "#prepareMigrations.ts";
|
|
22
|
+
|
|
23
|
+
export interface AppDatabaseOptions<R = never, E = never> {
|
|
24
|
+
readonly config?: DatabaseConfig;
|
|
25
|
+
readonly migrations: MigrationOptions<R, E>;
|
|
26
|
+
}
|
|
15
27
|
|
|
16
28
|
export interface DatabaseConfig extends PostgresOptions {
|
|
17
29
|
readonly changes?: Partial<Omit<PostgresChangesOptions, "client" | "listenerClient" | "connectionSetting" | "connectionTTL" | "resync">>;
|
|
@@ -80,53 +92,51 @@ const defaultChangesChannel = Effect.fnUntraced(function* (name: string) {
|
|
|
80
92
|
return `changes_${Hex.encode(digest).slice(0, 32)}`;
|
|
81
93
|
});
|
|
82
94
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
95
|
+
export const appHost: AppHostFactory = <
|
|
96
|
+
TRpcs extends Rpc.Any = never,
|
|
97
|
+
THandlers = never,
|
|
98
|
+
THandlerError = never,
|
|
99
|
+
THandlerRequirements = never,
|
|
100
|
+
TServices = never,
|
|
101
|
+
TServiceError = never,
|
|
102
|
+
TServiceRequirements = never,
|
|
103
|
+
TMigrations = never,
|
|
104
|
+
TApplicationError = never,
|
|
105
|
+
TApplicationRequirements = never,
|
|
106
|
+
TPreflight = never,
|
|
107
|
+
TPreflightError = never,
|
|
108
|
+
TPreflightRequirements = never,
|
|
109
|
+
TRouteError = never,
|
|
110
|
+
TRouteRequirements = HostRouteRequirements,
|
|
111
|
+
TMigrationError = never,
|
|
112
|
+
>(
|
|
113
|
+
options: AppHostInput<
|
|
114
|
+
TRpcs,
|
|
115
|
+
THandlers,
|
|
116
|
+
THandlerError,
|
|
117
|
+
THandlerRequirements,
|
|
118
|
+
TServices,
|
|
119
|
+
TServiceError,
|
|
120
|
+
TServiceRequirements,
|
|
121
|
+
TMigrations,
|
|
122
|
+
TApplicationError,
|
|
123
|
+
TApplicationRequirements,
|
|
124
|
+
TPreflight,
|
|
125
|
+
TPreflightError,
|
|
126
|
+
TPreflightRequirements,
|
|
127
|
+
TRouteError,
|
|
128
|
+
TRouteRequirements,
|
|
129
|
+
TMigrationError
|
|
130
|
+
>,
|
|
131
|
+
) => {
|
|
132
|
+
const preflight = hostPreflight(options.preflight, "application" in options ? Effect.succeed(isSensitiveKey) : hostSensitiveKeys(options));
|
|
133
|
+
if ("application" in options) {
|
|
134
|
+
return deferredHost(options.application, appDatabase(options)).pipe(Layer.provideMerge(preflight), Layer.provide(NodeCrypto.layer));
|
|
93
135
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
let pending: PendingPostgresMigrations = { components: [], migrations: [] };
|
|
100
|
-
let progress: Fiber.Fiber<never> | undefined;
|
|
101
|
-
function log(message: string) {
|
|
102
|
-
return Effect.suspend(() =>
|
|
103
|
-
Effect.logInfo(message).pipe(Effect.annotateLogs({ pendingComponents: pending.components, pendingMigrations: pending.migrations })),
|
|
136
|
+
return options.migrations === undefined
|
|
137
|
+
? appHostHttp(options).pipe(Layer.provideMerge(preflight), Layer.provide(NodeCrypto.layer))
|
|
138
|
+
: migratedHost({ ...options, migrations: options.migrations }, appDatabase({ ...options, migrations: options.migrations })).pipe(
|
|
139
|
+
Layer.provideMerge(preflight),
|
|
140
|
+
Layer.provide(NodeCrypto.layer),
|
|
104
141
|
);
|
|
105
|
-
|
|
106
|
-
yield* Effect.gen(function* () {
|
|
107
|
-
pending = yield* pendingPostgresMigrations(migrations);
|
|
108
|
-
if (pending.migrations.length === 0 && pending.components.length === 0) {
|
|
109
|
-
return;
|
|
110
|
-
}
|
|
111
|
-
if (progress === undefined) {
|
|
112
|
-
yield* log("Waiting for database migrations");
|
|
113
|
-
progress = yield* Effect.forever(Effect.sleep(progressInterval).pipe(Effect.andThen(log("Still waiting for database migrations")))).pipe(
|
|
114
|
-
Effect.forkScoped,
|
|
115
|
-
);
|
|
116
|
-
}
|
|
117
|
-
return yield* Effect.fail(postgresMigrationError(pending));
|
|
118
|
-
}).pipe(
|
|
119
|
-
Effect.retry({
|
|
120
|
-
schedule: Schedule.max([Schedule.spaced(migrations.pollInterval ?? "1 second"), Schedule.during(migrations.waitTimeout ?? "5 minutes")]),
|
|
121
|
-
while: (error) => error instanceof Migrator.MigrationError && error.kind === "BadState",
|
|
122
|
-
}),
|
|
123
|
-
Effect.tapError((error) =>
|
|
124
|
-
error instanceof Migrator.MigrationError && error.kind === "BadState" ? log("Timed out waiting for database migrations") : Effect.void,
|
|
125
|
-
),
|
|
126
|
-
);
|
|
127
|
-
if (progress !== undefined) {
|
|
128
|
-
yield* Fiber.interrupt(progress);
|
|
129
|
-
yield* Effect.logInfo("Database migrations current");
|
|
130
|
-
}
|
|
131
|
-
}).pipe(Effect.scoped);
|
|
132
|
-
}
|
|
142
|
+
};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { Effect, Layer } from "effect";
|
|
2
|
+
import type { Rpc } from "effect/rpc";
|
|
3
|
+
import type { appDatabase } from "#appDatabase.ts";
|
|
4
|
+
import type { AppHttpHostOptions } from "#appHost.ts";
|
|
5
|
+
import { appHostHttp } from "#appHostHttp.ts";
|
|
6
|
+
import type { HostOptions, HostPolicy, HostRouteRequirements } from "#hostOptions.ts";
|
|
7
|
+
import type { MigrationOptions } from "#MigrationOptions.ts";
|
|
8
|
+
|
|
9
|
+
export function migratedHost<
|
|
10
|
+
TRpcs extends Rpc.Any,
|
|
11
|
+
THandlers,
|
|
12
|
+
THandlerError,
|
|
13
|
+
THandlerRequirements,
|
|
14
|
+
TServices,
|
|
15
|
+
TServiceError,
|
|
16
|
+
TServiceRequirements,
|
|
17
|
+
TMigrations,
|
|
18
|
+
TRouteError = never,
|
|
19
|
+
TRouteRequirements = HostRouteRequirements,
|
|
20
|
+
TMigrationError = never,
|
|
21
|
+
>(
|
|
22
|
+
options: HostOptions<
|
|
23
|
+
TRpcs,
|
|
24
|
+
THandlers,
|
|
25
|
+
THandlerError,
|
|
26
|
+
THandlerRequirements,
|
|
27
|
+
TServices,
|
|
28
|
+
TServiceError,
|
|
29
|
+
TServiceRequirements,
|
|
30
|
+
TRouteError,
|
|
31
|
+
TRouteRequirements
|
|
32
|
+
> &
|
|
33
|
+
HostPolicy & {
|
|
34
|
+
readonly migrations: MigrationOptions<TMigrations, TMigrationError>;
|
|
35
|
+
},
|
|
36
|
+
database: ReturnType<typeof appDatabase<TMigrations, TMigrationError>>,
|
|
37
|
+
) {
|
|
38
|
+
const services = Layer.mergeAll(options.services ?? Layer.empty);
|
|
39
|
+
return appHostHttp({ ...options, services: services.pipe(Layer.provideMerge(database)) });
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function deferredHost<
|
|
43
|
+
TRpcs extends Rpc.Any,
|
|
44
|
+
THandlers,
|
|
45
|
+
THandlerError,
|
|
46
|
+
THandlerRequirements,
|
|
47
|
+
TServices,
|
|
48
|
+
TServiceError,
|
|
49
|
+
TServiceRequirements,
|
|
50
|
+
TMigrations,
|
|
51
|
+
TApplicationError,
|
|
52
|
+
TApplicationRequirements,
|
|
53
|
+
TRouteError = never,
|
|
54
|
+
TRouteRequirements = HostRouteRequirements,
|
|
55
|
+
TMigrationError = never,
|
|
56
|
+
>(
|
|
57
|
+
application: Effect.Effect<
|
|
58
|
+
AppHttpHostOptions<
|
|
59
|
+
TRpcs,
|
|
60
|
+
THandlers,
|
|
61
|
+
THandlerError,
|
|
62
|
+
THandlerRequirements,
|
|
63
|
+
TServices,
|
|
64
|
+
TServiceError,
|
|
65
|
+
TServiceRequirements,
|
|
66
|
+
never,
|
|
67
|
+
never,
|
|
68
|
+
never,
|
|
69
|
+
TRouteError,
|
|
70
|
+
TRouteRequirements
|
|
71
|
+
>,
|
|
72
|
+
TApplicationError,
|
|
73
|
+
TApplicationRequirements
|
|
74
|
+
>,
|
|
75
|
+
database: ReturnType<typeof appDatabase<TMigrations, TMigrationError>>,
|
|
76
|
+
) {
|
|
77
|
+
return Layer.unwrap(Effect.map(application, (options) => appHostHttp(options))).pipe(Layer.provideMerge(database));
|
|
78
|
+
}
|
package/src/appHost.ts
CHANGED
|
@@ -1,22 +1,13 @@
|
|
|
1
1
|
import * as NodeCrypto from "@effect/platform-node/NodeCrypto";
|
|
2
|
-
import {
|
|
2
|
+
import { Layer } from "effect";
|
|
3
3
|
import type { Rpc } from "effect/rpc";
|
|
4
|
-
import {
|
|
5
|
-
import type { AppHostFactory } from "#AppHostFactory.ts";
|
|
6
|
-
import type { AppHostInput, HostPreflight } from "#AppHostInput.ts";
|
|
7
|
-
import { appDatabase, type DatabaseConfig } from "#appDatabase.ts";
|
|
8
|
-
import { appHostHttp, deferredHost, migratedHost } from "#appHostHttp.ts";
|
|
4
|
+
import { appHostHttp } from "#appHostHttp.ts";
|
|
9
5
|
import type { HostCoreOptions, HostPolicy, HostRouteRequirements, HostRoutes } from "#hostOptions.ts";
|
|
6
|
+
import type { HostPreflight } from "#hostPreflight.ts";
|
|
7
|
+
import { hostPreflight } from "#hostPreflight.ts";
|
|
10
8
|
import { hostSensitiveKeys } from "#hostSensitiveKeys.ts";
|
|
11
|
-
import type { MigrationOptions } from "#MigrationOptions.ts";
|
|
12
|
-
import { redactingDiagnostics } from "#redactingDiagnostics.ts";
|
|
13
9
|
|
|
14
|
-
export
|
|
15
|
-
readonly config?: DatabaseConfig;
|
|
16
|
-
readonly migrations: MigrationOptions<R, E>;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export type AppHostOptions<
|
|
10
|
+
export type AppHttpHostOptions<
|
|
20
11
|
TRpcs extends Rpc.Any = never,
|
|
21
12
|
THandlers = never,
|
|
22
13
|
THandlerError = never,
|
|
@@ -24,22 +15,16 @@ export type AppHostOptions<
|
|
|
24
15
|
TServices = never,
|
|
25
16
|
TServiceError = never,
|
|
26
17
|
TServiceRequirements = never,
|
|
27
|
-
TMigrations = never,
|
|
28
18
|
TPreflight = never,
|
|
29
19
|
TPreflightError = never,
|
|
30
20
|
TPreflightRequirements = never,
|
|
31
21
|
TRouteError = never,
|
|
32
22
|
TRouteRequirements = HostRouteRequirements,
|
|
33
|
-
TMigrationError = never,
|
|
34
23
|
> = HostPreflight<TPreflight, TPreflightError, TPreflightRequirements> &
|
|
35
24
|
HostCoreOptions<TRpcs, THandlers, THandlerError, THandlerRequirements, TServices, TServiceError, TServiceRequirements> &
|
|
36
25
|
HostRoutes<TRouteError, TRouteRequirements> &
|
|
37
|
-
HostPolicy & {
|
|
38
|
-
|
|
39
|
-
readonly policy?: undefined;
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
export type AppLocalHostOptions<
|
|
26
|
+
HostPolicy & { readonly migrations?: undefined };
|
|
27
|
+
function buildHttpHost<
|
|
43
28
|
TRpcs extends Rpc.Any = never,
|
|
44
29
|
THandlers = never,
|
|
45
30
|
THandlerError = never,
|
|
@@ -47,22 +32,31 @@ export type AppLocalHostOptions<
|
|
|
47
32
|
TServices = never,
|
|
48
33
|
TServiceError = never,
|
|
49
34
|
TServiceRequirements = never,
|
|
50
|
-
TMigrations = never,
|
|
51
35
|
TPreflight = never,
|
|
52
36
|
TPreflightError = never,
|
|
53
37
|
TPreflightRequirements = never,
|
|
54
38
|
TRouteError = never,
|
|
55
39
|
TRouteRequirements = HostRouteRequirements,
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
40
|
+
>(
|
|
41
|
+
options: AppHttpHostOptions<
|
|
42
|
+
TRpcs,
|
|
43
|
+
THandlers,
|
|
44
|
+
THandlerError,
|
|
45
|
+
THandlerRequirements,
|
|
46
|
+
TServices,
|
|
47
|
+
TServiceError,
|
|
48
|
+
TServiceRequirements,
|
|
49
|
+
TPreflight,
|
|
50
|
+
TPreflightError,
|
|
51
|
+
TPreflightRequirements,
|
|
52
|
+
TRouteError,
|
|
53
|
+
TRouteRequirements
|
|
54
|
+
>,
|
|
55
|
+
) {
|
|
56
|
+
return appHostHttp(options).pipe(Layer.provideMerge(hostPreflight(options.preflight, hostSensitiveKeys(options))), Layer.provide(NodeCrypto.layer));
|
|
57
|
+
}
|
|
64
58
|
|
|
65
|
-
|
|
59
|
+
type HttpHostFactory = <
|
|
66
60
|
TRpcs extends Rpc.Any = never,
|
|
67
61
|
THandlers = never,
|
|
68
62
|
THandlerError = never,
|
|
@@ -75,29 +69,8 @@ export type AppHttpHostOptions<
|
|
|
75
69
|
TPreflightRequirements = never,
|
|
76
70
|
TRouteError = never,
|
|
77
71
|
TRouteRequirements = HostRouteRequirements,
|
|
78
|
-
> = HostPreflight<TPreflight, TPreflightError, TPreflightRequirements> &
|
|
79
|
-
HostCoreOptions<TRpcs, THandlers, THandlerError, THandlerRequirements, TServices, TServiceError, TServiceRequirements> &
|
|
80
|
-
HostRoutes<TRouteError, TRouteRequirements> &
|
|
81
|
-
HostPolicy & { readonly migrations?: undefined };
|
|
82
|
-
export const appHost: AppHostFactory = <
|
|
83
|
-
TRpcs extends Rpc.Any = never,
|
|
84
|
-
THandlers = never,
|
|
85
|
-
THandlerError = never,
|
|
86
|
-
THandlerRequirements = never,
|
|
87
|
-
TServices = never,
|
|
88
|
-
TServiceError = never,
|
|
89
|
-
TServiceRequirements = never,
|
|
90
|
-
TMigrations = never,
|
|
91
|
-
TApplicationError = never,
|
|
92
|
-
TApplicationRequirements = never,
|
|
93
|
-
TPreflight = never,
|
|
94
|
-
TPreflightError = never,
|
|
95
|
-
TPreflightRequirements = never,
|
|
96
|
-
TRouteError = never,
|
|
97
|
-
TRouteRequirements = HostRouteRequirements,
|
|
98
|
-
TMigrationError = never,
|
|
99
72
|
>(
|
|
100
|
-
options:
|
|
73
|
+
options: AppHttpHostOptions<
|
|
101
74
|
TRpcs,
|
|
102
75
|
THandlers,
|
|
103
76
|
THandlerError,
|
|
@@ -105,33 +78,27 @@ export const appHost: AppHostFactory = <
|
|
|
105
78
|
TServices,
|
|
106
79
|
TServiceError,
|
|
107
80
|
TServiceRequirements,
|
|
108
|
-
TMigrations,
|
|
109
|
-
TApplicationError,
|
|
110
|
-
TApplicationRequirements,
|
|
111
81
|
TPreflight,
|
|
112
82
|
TPreflightError,
|
|
113
83
|
TPreflightRequirements,
|
|
114
84
|
TRouteError,
|
|
115
|
-
TRouteRequirements
|
|
116
|
-
TMigrationError
|
|
85
|
+
TRouteRequirements
|
|
117
86
|
>,
|
|
118
|
-
) =>
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
);
|
|
137
|
-
};
|
|
87
|
+
) => ReturnType<
|
|
88
|
+
typeof buildHttpHost<
|
|
89
|
+
TRpcs,
|
|
90
|
+
THandlers,
|
|
91
|
+
THandlerError,
|
|
92
|
+
THandlerRequirements,
|
|
93
|
+
TServices,
|
|
94
|
+
TServiceError,
|
|
95
|
+
TServiceRequirements,
|
|
96
|
+
NoInfer<TPreflight>,
|
|
97
|
+
NoInfer<TPreflightError>,
|
|
98
|
+
NoInfer<TPreflightRequirements>,
|
|
99
|
+
TRouteError,
|
|
100
|
+
TRouteRequirements
|
|
101
|
+
>
|
|
102
|
+
>;
|
|
103
|
+
|
|
104
|
+
export const appHost: HttpHostFactory = buildHttpHost;
|