UNPKG

@ffsm/napi

Version:

Napi - A framework using with Next.js for building APIs.

37 lines (36 loc) 1.37 kB
import { NextRequest } from "next/server"; import { NapiRouter } from "./router"; import { NapiClass, NapiRoutePayload } from "./types"; import { NapiController } from "./controller"; export interface NapiControllerInject<Instance = unknown> { class: NapiClass; instance: Instance; } export interface NapiExecuteContext<Response> { getRequest(): NextRequest; getRouter(): NapiRouter; getPayload(): NapiRoutePayload; getConfig<ConfigType = unknown>(name: string): ConfigType | undefined; getResponse(): Response; } export declare class NapiContext { private readonly prefix; private readonly controller; private readonly switchInstance; private routeParams; private decoratorParams; private method; constructor(prefix: string, controller: NapiController, switchInstance: NapiExecuteContext<unknown>, routeParams?: Record<string, string>); getRequest(): NextRequest; getRouter(): NapiRouter; getPayload(): NapiRoutePayload<unknown>; getConfig<ConfigType = unknown>(name: string): ConfigType | undefined; getResponse(): unknown; getController<Controller = unknown>(): Controller; execute(route: string): Promise<this>; getMethod(): string; getRouteParams(): Record<string, string>; getDecoratorParams(): unknown[]; private findMethod; private initDecoratorParams; }