import { type RpcInit } from "https://deno.land/x/cav@0.0.21/mod.ts";
Initializer options for constructing Rpcs.
Properties
If the path of the request doesn't match this URLPattern string, a 404
Response will be returned before resolution starts. If this string starts
with "^", the full Request path is used instead of the Stack routed path.
The fallback behavior expects that the containing Stack(s) consumed the
entire path, equivalent to specifying path: "/"
. The full URLPattern
syntax is supported, and any captured path groups will be merged with the
path groups captured by the containing stack(s) before groups parsing. The
path that matched this string is available on the ResolveArg, CtxArg, and
ResolveErrorArg as the "path" property. Default: "/"
When a Request matches the path for this Rpc, all captured groups from the
Rpc and the Stack will be parsed using this Parser. If the Parser throws an
error, the Rpc will suppress the error and return a 404 Response. The
result of parsing is available on the ResolverArg as the "groups" property.
If the parser is "optional" (i.e. it successfully parses undefined
), all
parsing errors will be suppressed and that fallback value will be used for
the ResolveArg whenever an error is thrown. Default: null
This limits the maximum size of the Request body. Note that, currently, the
entire Request body is loaded into memory during request processing.
Support for large file uploads is in the works. Unit: bytes. Default: 5 * 1024 * 1024
(5 MB)
Keys used when creating the "cookie" that's available to the ctx, resolve,
and resolveError functions. If this isn't provided, a random fallback key
will be used. Default: null
Additional serializers to use when serializing and deserializing request
and response bodies and web socket messages. Default: null
If true, this causes requests to be upgraded into web sockets. Requests
that don't request an upgrade will be rejected. The resolve function should
return the response from the upgrade()
utility available on the
ResolveArg. Default: null
A function responsible for constructing the "ctx" property available to the
resolve function. This is only run if the requested path matched. Default:
null
A parser used to parse the "query" object created from the Request's query
string parameters. This data comes from the query string in the url of the
request. Default: null
A parser used to either (1) parse the Request body after it's deserialized
using deserializeBody or (2) parse the message received if this Rpc results
in a web socket connection via the "upgrade" option. Default: null
This function is called to resolve the parsed request into a response to serialize and send back to the client. If nothing is provided, the response will be a 204 no content.
When an error is thrown during processing, this function can handle the
error. The return value will be serialized into a Response to send back to
the client. Returning undefined or re-throwing the error will cause that
error to be serialized as the response, which is the default behavior.
Default: null