blob: c43c30b2a8c0867bb35547e81d265b6c1b300bb1 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
import { Schema } from "effect";
type SyncDecodingSchema = Schema.Top & {
readonly DecodingServices: never;
};
export const decodeUnknownOrThrow = <S extends SyncDecodingSchema>(
schema: S,
input: unknown,
): S["Type"] => Schema.decodeUnknownSync(schema)(input);
export const decodeRequestJsonOrThrow = async <S extends SyncDecodingSchema>(
request: Request,
schema: S,
): Promise<S["Type"]> => decodeUnknownOrThrow(schema, await request.json());
|