TrpcFramework
@h4ad/serverless-adapter > TrpcFramework
(class) TrpcFramework
The framework that forwards requests to TRPC handler
Signature:
export declare class TrpcFramework<TContext extends TrpcAdapterBaseContext, TRouter extends AnyRouter = AnyRouter> implements FrameworkContract<TRouter>
Implements: FrameworkContract <TRouter>
(constructor)
Default constructor
Signature:
constructor(options?: TrpcFrameworkOptions<TContext> | undefined);
Parameters
Parameter | Type | Description |
---|---|---|
options | TrpcFrameworkOptions <TContext> | undefined | (Optional) |
(method) getSafeUrlForTrpc
Get safe url that can be used inside Trpc.
Signature:
protected getSafeUrlForTrpc(request: IncomingMessage): string;
Parameters
Parameter | Type | Description |
---|---|---|
request | IncomingMessage | The request object that will be forward to your app |
Returns:
string
Example
const url = getSafeUrlForTrpc('/users?input=hello');
console.log(url); // users
(method) mergeDefaultContextWithOptionsContext
Merge the default context (TrpcAdapterContext ) with the context created by the user.
Signature:
protected mergeDefaultContextWithOptionsContext(createContextOptions: NodeHTTPCreateContextFnOptions<IncomingMessage, ServerResponse>): TContext | Promise<TContext>;
Parameters
Parameter | Type | Description |
---|---|---|
createContextOptions | NodeHTTPCreateContextFnOptions<IncomingMessage, ServerResponse> | The options sent by trpc to create the context |
Returns:
TContext | Promise<TContext>
(property) options
Signature:
protected readonly options?: TrpcFrameworkOptions<TContext> | undefined;
(method) sendRequest
Signature:
sendRequest<TRouter extends AnyRouter>(app: TRouter, request: IncomingMessage, response: ServerResponse): void;
Parameters
Parameter | Type | Description |
---|---|---|
app | TRouter | |
request | IncomingMessage | |
response | ServerResponse |
Returns:
void
(method) wrapResolvedContextWithDefaultContext
Wraps the resolved context from the TrpcFrameworkOptions created with createContext
and merge with the TrpcAdapterContext generated by the library.
Signature:
protected wrapResolvedContextWithDefaultContext(resolvedContext: TContext, createContextOptions: NodeHTTPCreateContextFnOptions<IncomingMessage, ServerResponse>): TContext;
Parameters
Parameter | Type | Description |
---|---|---|
resolvedContext | TContext | The context created with |
createContextOptions | NodeHTTPCreateContextFnOptions<IncomingMessage, ServerResponse> | The options sent by trpc to create the context |
Returns:
TContext