Remote / foldkit-remote-server
bodyLimit
function · packages/remote-server/src/body.ts:109
function bodyLimit(
maxBytes?: number,
): <E, R>(
endpoint: Effect.Effect<HttpServerResponse.HttpServerResponse, E, R>,
) => Effect.Effect<
HttpServerResponse.HttpServerResponse,
E,
R | HttpServerRequest.HttpServerRequest
>Effect HTTP middleware refusing a request body over maxBytes (default
1 MiB, serveFetch's) with a 413 and Remote's tooLarge answer, before
the endpoint reads it. For an endpoint that serves RemoteRpc through
RpcServer, where Effect's own MaxBodySize fails the body read as a
defect, a 500:
ts
HttpRouter.add('POST', '/rpc', bodyLimit(64 * 1024)(rpcHttpEffect))A body within the limit reaches the endpoint whole, read once.