v0.3.0
core:
- The client passes response bodies to codecs directly. A response body that fails while it is read now rejects like a body that cannot be decoded, with the read error as
cause. (da819aa)
core:
- The client skips event stream frames without data, such as keepalive comments, and drops an incomplete last frame, instead of ending the stream with an error. (da819aa)
core, server:
serializedBody()takes itsheadersas a plain object of header names and values instead of any FetchHeadersInit, andSerializedBody.headersis that object with lowercase names instead of a FetchHeaders. Replacenew Headers(...)or header tuples passed to it with an object, and read the headers of a serialized body asserialized.headers["content-type"]instead of withget(). (64804e5)
core, server:
- A
mountPaththat ends with a slash, such as/api/, now serves the routes like/api, instead of responding to every request with anINTERNAL_SERVER_ERROR. A.prefix()that ends with a slash is now a type error instead of a runtime error. (da819aa)
core, server:
- A body’s content type now always replaces a
content-typepassed in headers. Before, a passed header could override it, including the content type and multipart boundary the runtime sets forFormData. Routes with inferred responses now typecontentTypein client results as the received lowercase base media type, such astext/csvfortext/csv; charset=utf-8. On routes with defined responses,respond()usescontentTypeas given, so a value that is not one of the defined media types throws. (da819aa)
core, server:
- Body deserializers receive an
IncomingBodyand the complete content type, asdeserialize(body, contentType), like serializers receive the content type.IncomingBodyhastext(),json(),arrayBuffer(),blob()andbody, which Fetch requests and responses already have, so codecs that only use these work unchanged. Codecs that call otherRequestorResponsemembers, such asformData(), must read the body with these instead, such asnew Response(await body.arrayBuffer(), { headers: { "content-type": contentType } }).formData(). A codec used only on one side can no longer treat its source as aRequestorResponse. (64804e5)
server:
compileRoutesis renamedcreateRouteHandlers, and its options typeCompileRoutesOptionsis renamedCreateRouteHandlersOptions.createCatchAllHandlernow takes the route tree and the same options instead of compiled routes, in both@rest-rpc/serverand@rest-rpc/server/node: replacecreateCatchAllHandler(compileRoutes(routes, options))withcreateCatchAllHandler(routes, options). (64804e5)
server:
onErrorreceives a thrown defined error as it was thrown, instead of a copy with the defined status, validateddataand headers, and the thrown error ascause. Itscauseis now the one passed when throwing, soerrors.CODE({ cause })reachesonErroraserror.cause. The response still uses the definition. Anew RouteError(code)for a code the route defines keeps its own status inonError, which defaults to 400, while the defined status is sent. Defined errors with synchronous schemas are now resolved without a promise, and errors received fromcall()and the local client have nocause, like errors received over HTTP. (64804e5)
server:
serveandServeOptionsare removed from@rest-rpc/server/node. It now exportscreateApp, which takes the route tree and returns a request listener forhttp.createServer(), so the server is started and configured with Node’s own API: replaceserve(createApp(routes, options), { port })withcreateServer(createApp(routes, options)).listen(port), importingcreateAppfrom@rest-rpc/server/node. Itscontextfunction receives theIncomingMessage, andnotFoundwrites to theServerResponseand keeps the default response when it writes nothing. (64804e5)
server:
- Reject functions passed to
.static()in types, which accepted them on routes without defined responses although static values are not called. Type errors now say why a promise, function or stream is not a valid static value instead of reporting a barenever. Static routes no longer check at runtime for values that bypass the types. (05ab0d0)
server:
- Serve
createApproutes registered with Bun’s native router through one promise per request instead of nested async wrappers, which lowers per-request overhead. (359e26f)
server:
- The Node handlers from
@rest-rpc/server/noderead the Node request and write the Node response directly, instead of converting them to a FetchRequestandResponse, which lowers per-request overhead.onErrorpassed to them now receives theIncomingMessageinstead of a FetchRequest. Stream responses send their headers before the first item on Node. (64804e5)