| 1 | import * as Schema from "effect/Schema"; |
| 2 | import * as HttpApi from "effect/http-api/HttpApi"; |
| 3 | import * as HttpApiEndpoint from "effect/http-api/HttpApiEndpoint"; |
| 4 | import * as HttpApiGroup from "effect/http-api/HttpApiGroup"; |
| 5 | import { User } from "./current-user.ts"; |
| 6 | import { Authentication } from "./middleware.ts"; |
| 7 | |
| 8 | export class Public extends HttpApiGroup.make("public").add( |
| 9 | HttpApiEndpoint.get("health", "/api/health", { |
| 10 | success: Schema.Struct({ ok: Schema.Literal(true) }), |
| 11 | }), |
| 12 | HttpApiEndpoint.get("providers", "/api/providers", { |
| 13 | success: Schema.Struct({ github: Schema.Boolean }), |
| 14 | }), |
| 15 | ) {} |
| 16 | |
| 17 | export class Private extends HttpApiGroup.make("private") |
| 18 | .add(HttpApiEndpoint.get("me", "/api/me", { success: User })) |
| 19 | .middleware(Authentication) {} |
| 20 | |
| 21 | export class Api extends HttpApi.make("app").add(Public, Private) {} |