UNPKG

@orpc/server

Version:

<div align="center"> <image align="center" src="https://orpc.unnoq.com/logo.webp" width=280 alt="oRPC logo" /> </div>

79 lines (73 loc) 3.59 kB
import { C as Context, R as Router } from '../../shared/server.CYNGeoCm.js'; import { Interceptor, MaybeOptionalOptions } from '@orpc/shared'; import { SendStandardResponseOptions, NodeHttpRequest, NodeHttpResponse } from '@orpc/standard-server-node'; import { g as StandardHandlerPlugin, C as CompositeStandardHandlerPlugin, b as StandardHandleOptions, f as StandardHandler } from '../../shared/server.Bmh5xd4n.js'; import { F as FriendlyStandardHandleOptions } from '../../shared/server.B7b2w3_i.js'; import { S as StandardRPCHandlerOptions } from '../../shared/server.D0H-iaY3.js'; import '@orpc/client'; import '@orpc/contract'; import '@orpc/standard-server'; import '@orpc/client/standard'; import '../../shared/server.jMTkVNIb.js'; interface NodeHttpHandlerPlugin<T extends Context> extends StandardHandlerPlugin<T> { initRuntimeAdapter?(options: NodeHttpHandlerOptions<T>): void; } declare class CompositeNodeHttpHandlerPlugin<T extends Context, TPlugin extends NodeHttpHandlerPlugin<T>> extends CompositeStandardHandlerPlugin<T, TPlugin> implements NodeHttpHandlerPlugin<T> { initRuntimeAdapter(options: NodeHttpHandlerOptions<T>): void; } type NodeHttpHandleResult = { matched: true; } | { matched: false; }; interface NodeHttpHandlerInterceptorOptions<T extends Context> extends StandardHandleOptions<T> { request: NodeHttpRequest; response: NodeHttpResponse; sendStandardResponseOptions: SendStandardResponseOptions; } interface NodeHttpHandlerOptions<T extends Context> extends SendStandardResponseOptions { adapterInterceptors?: Interceptor<NodeHttpHandlerInterceptorOptions<T>, Promise<NodeHttpHandleResult>>[]; plugins?: NodeHttpHandlerPlugin<T>[]; } declare class NodeHttpHandler<T extends Context> implements NodeHttpHandler<T> { private readonly standardHandler; private readonly sendStandardResponseOptions; private readonly adapterInterceptors; constructor(standardHandler: StandardHandler<T>, options?: NoInfer<NodeHttpHandlerOptions<T>>); handle(request: NodeHttpRequest, response: NodeHttpResponse, ...rest: MaybeOptionalOptions<FriendlyStandardHandleOptions<T>>): Promise<NodeHttpHandleResult>; } interface BodyLimitPluginOptions { /** * The maximum size of the body in bytes. */ maxBodySize: number; } /** * The Body Limit Plugin restricts the size of the request body for the Node.js HTTP Server. * * @see {@link https://orpc.unnoq.com/docs/plugins/body-limit Body Limit Plugin Docs} */ declare class BodyLimitPlugin<T extends Context> implements NodeHttpHandlerPlugin<T> { private readonly maxBodySize; constructor(options: BodyLimitPluginOptions); initRuntimeAdapter(options: NodeHttpHandlerOptions<T>): void; } type RPCHandlerOptions<T extends Context> = NodeHttpHandlerOptions<T> & StandardRPCHandlerOptions<T> & { /** * Enables or disables the StrictGetMethodPlugin. * * @default true */ strictGetMethodPluginEnabled?: boolean; }; /** * RPC Handler for Node.js HTTP Server * * @see {@link https://orpc.unnoq.com/docs/rpc-handler RPC Handler Docs} * @see {@link https://orpc.unnoq.com/docs/adapters/http HTTP Adapter Docs} */ declare class RPCHandler<T extends Context> extends NodeHttpHandler<T> { constructor(router: Router<any, T>, options?: NoInfer<RPCHandlerOptions<T>>); } export { BodyLimitPlugin, CompositeNodeHttpHandlerPlugin, NodeHttpHandler, RPCHandler }; export type { BodyLimitPluginOptions, NodeHttpHandleResult, NodeHttpHandlerInterceptorOptions, NodeHttpHandlerOptions, NodeHttpHandlerPlugin, RPCHandlerOptions };