feat(sdk): add HttpApi clients and embedded host (#33445)
This commit is contained in:
parent
c45d1db9a0
commit
cdd67cf30f
59 changed files with 4629 additions and 316 deletions
45
packages/httpapi-codegen/test/fixture.ts
Normal file
45
packages/httpapi-codegen/test/fixture.ts
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
import { Schema } from "effect"
|
||||
import { HttpApi, HttpApiEndpoint, HttpApiGroup, HttpApiSchema } from "effect/unstable/httpapi"
|
||||
|
||||
export class Missing extends Schema.TaggedErrorClass<Missing>()("Missing", {
|
||||
message: Schema.String,
|
||||
}) {}
|
||||
|
||||
export const Api = HttpApi.make("fixture")
|
||||
.add(
|
||||
HttpApiGroup.make("session")
|
||||
.add(HttpApiEndpoint.get("health", "/session/health", { success: Schema.String }))
|
||||
.add(
|
||||
HttpApiEndpoint.get("list", "/session", {
|
||||
query: { archived: Schema.optional(Schema.Boolean) },
|
||||
success: Schema.Array(Schema.String),
|
||||
}),
|
||||
)
|
||||
.add(
|
||||
HttpApiEndpoint.get("get", "/session/:sessionID", {
|
||||
params: { sessionID: Schema.String },
|
||||
success: Schema.Struct({ data: Schema.String }),
|
||||
error: Missing.pipe(HttpApiSchema.status(404)),
|
||||
}),
|
||||
)
|
||||
.add(
|
||||
HttpApiEndpoint.post("interrupt", "/session/:sessionID/interrupt", {
|
||||
params: { sessionID: Schema.String },
|
||||
success: HttpApiSchema.NoContent,
|
||||
}),
|
||||
),
|
||||
)
|
||||
.add(
|
||||
HttpApiGroup.make("event").add(
|
||||
HttpApiEndpoint.get("subscribe", "/event", {
|
||||
success: HttpApiSchema.StreamSse({ data: Schema.Struct({ type: Schema.String }) }).pipe(
|
||||
HttpApiSchema.status(202),
|
||||
),
|
||||
}),
|
||||
),
|
||||
)
|
||||
.add(
|
||||
HttpApiGroup.make("system", { topLevel: true }).add(
|
||||
HttpApiEndpoint.get("status", "/status", { success: Schema.String }),
|
||||
),
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue