// Define the API with a single streaming endpoint
export const myApi = HttpApi.make("myApi").add(
HttpApiGroup.make("group")
.add(
HttpApiEndpoint.get("getStream", "/stream").addSuccess(
Schema.String.pipe(
HttpApiSchema.withEncoding({
kind: "Text",
contentType: "application/octet-stream",
}),
),
),
)
.prefix("/api"),
);
// Simulate a stream of data
const stream = Stream.make("a", "b", "c").pipe(
Stream.schedule(Schedule.spaced("500 millis")),
Stream.map((s) => new TextEncoder().encode(s)),
);
const groupLive = HttpApiBuilder.group(myApi, "group", (handlers) =>
handlers.handleRaw("getStream", () => HttpServerResponse.stream(stream)),
);
const MyApiLive = HttpApiBuilder.api(myApi).pipe(Layer.provide(groupLive));
// Define the API with a single streaming endpoint
export const myApi = HttpApi.make("myApi").add(
HttpApiGroup.make("group")
.add(
HttpApiEndpoint.get("getStream", "/stream").addSuccess(
Schema.String.pipe(
HttpApiSchema.withEncoding({
kind: "Text",
contentType: "application/octet-stream",
}),
),
),
)
.prefix("/api"),
);
// Simulate a stream of data
const stream = Stream.make("a", "b", "c").pipe(
Stream.schedule(Schedule.spaced("500 millis")),
Stream.map((s) => new TextEncoder().encode(s)),
);
const groupLive = HttpApiBuilder.group(myApi, "group", (handlers) =>
handlers.handleRaw("getStream", () => HttpServerResponse.stream(stream)),
);
const MyApiLive = HttpApiBuilder.api(myApi).pipe(Layer.provide(groupLive));