@orpc/server
Version:
<div align="center"> <image align="center" src="https://orpc.unnoq.com/logo.webp" width=280 alt="oRPC logo" /> </div>
80 lines (74 loc) • 3.39 kB
text/typescript
import { C as Context, R as Router } from '../../shared/server.CYNGeoCm.mjs';
import { Interceptor, MaybeOptionalOptions } from '@orpc/shared';
import { ToFetchResponseOptions } from '@orpc/standard-server-fetch';
import { g as StandardHandlerPlugin, C as CompositeStandardHandlerPlugin, b as StandardHandleOptions, f as StandardHandler } from '../../shared/server.gqRxT-yN.mjs';
import { F as FriendlyStandardHandleOptions } from '../../shared/server.BEFBl-Cb.mjs';
import { S as StandardRPCHandlerOptions } from '../../shared/server.BU4WI18A.mjs';
import '@orpc/client';
import '@orpc/contract';
import '@orpc/standard-server';
import '@orpc/client/standard';
import '../../shared/server.DhJj-1X9.mjs';
interface FetchHandlerPlugin<T extends Context> extends StandardHandlerPlugin<T> {
initRuntimeAdapter?(options: FetchHandlerOptions<T>): void;
}
declare class CompositeFetchHandlerPlugin<T extends Context, TPlugin extends FetchHandlerPlugin<T>> extends CompositeStandardHandlerPlugin<T, TPlugin> implements FetchHandlerPlugin<T> {
initRuntimeAdapter(options: FetchHandlerOptions<T>): void;
}
type FetchHandleResult = {
matched: true;
response: Response;
} | {
matched: false;
response: undefined;
};
interface FetchHandlerInterceptorOptions<T extends Context> extends StandardHandleOptions<T> {
request: Request;
toFetchResponseOptions: ToFetchResponseOptions;
}
interface FetchHandlerOptions<T extends Context> extends ToFetchResponseOptions {
adapterInterceptors?: Interceptor<FetchHandlerInterceptorOptions<T>, Promise<FetchHandleResult>>[];
plugins?: FetchHandlerPlugin<T>[];
}
declare class FetchHandler<T extends Context> {
private readonly standardHandler;
private readonly toFetchResponseOptions;
private readonly adapterInterceptors;
constructor(standardHandler: StandardHandler<T>, options?: NoInfer<FetchHandlerOptions<T>>);
handle(request: Request, ...rest: MaybeOptionalOptions<FriendlyStandardHandleOptions<T>>): Promise<FetchHandleResult>;
}
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 Fetch Server.
*
* @see {@link https://orpc.unnoq.com/docs/plugins/body-limit Body Limit Plugin Docs}
*/
declare class BodyLimitPlugin<T extends Context> implements FetchHandlerPlugin<T> {
private readonly maxBodySize;
constructor(options: BodyLimitPluginOptions);
initRuntimeAdapter(options: FetchHandlerOptions<T>): void;
}
type RPCHandlerOptions<T extends Context> = FetchHandlerOptions<T> & StandardRPCHandlerOptions<T> & {
/**
* Enables or disables the StrictGetMethodPlugin.
*
* @default true
*/
strictGetMethodPluginEnabled?: boolean;
};
/**
* RPC Handler for Fetch 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 FetchHandler<T> {
constructor(router: Router<any, T>, options?: NoInfer<RPCHandlerOptions<T>>);
}
export { BodyLimitPlugin, CompositeFetchHandlerPlugin, FetchHandler, RPCHandler };
export type { BodyLimitPluginOptions, FetchHandleResult, FetchHandlerInterceptorOptions, FetchHandlerOptions, FetchHandlerPlugin, RPCHandlerOptions };