-
Notifications
You must be signed in to change notification settings - Fork 167
Expand file tree
/
Copy pathapi.ts
More file actions
48 lines (42 loc) · 1.74 KB
/
Copy pathapi.ts
File metadata and controls
48 lines (42 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import { HttpApi, HttpApiEndpoint, HttpApiGroup } from "effect/unstable/httpapi";
import { Schema } from "effect";
// ---------------------------------------------------------------------------
// Public system API — unauthenticated status endpoints served under /api.
//
// GET /api/health readiness probe (used by the container healthcheck)
// GET /api/setup-status whether the instance still needs first-run setup, so
// the pre-login SPA can route a fresh operator to /setup
//
// Both are deliberately unauthenticated and return only booleans/status — no
// sensitive data — so they can be read before anyone has signed in.
// ---------------------------------------------------------------------------
export class SystemError extends Schema.TaggedErrorClass<SystemError>()(
"SystemError",
{ message: Schema.String },
{ httpApiStatus: 500 },
) {}
export const HealthResponse = Schema.Struct({ status: Schema.String });
export const SetupStatusResponse = Schema.Struct({ needsSetup: Schema.Boolean });
export const InviteStatusResponse = Schema.Struct({ valid: Schema.Boolean });
const InviteStatusParams = { code: Schema.String };
export const SystemApi = HttpApiGroup.make("system")
.add(
HttpApiEndpoint.get("health", "/health", {
success: HealthResponse,
error: [SystemError],
}),
)
.add(
HttpApiEndpoint.get("setupStatus", "/setup-status", {
success: SetupStatusResponse,
error: [SystemError],
}),
)
.add(
HttpApiEndpoint.get("inviteStatus", "/invite-status/:code", {
params: InviteStatusParams,
success: InviteStatusResponse,
error: [SystemError],
}),
);
export const SystemHttpApi = HttpApi.make("executor-self-host-system").add(SystemApi);