UNPKG

nest-koa-adapter

Version:
49 lines 2.98 kB
import { AbstractHttpAdapter } from '@nestjs/core'; import { NestApplicationOptions, NestMiddleware, RequestMethod, VersioningOptions } from '@nestjs/common'; import Koa from 'koa'; import * as http from 'http'; import * as https from 'https'; import { RequestHandler, VersionValue } from '@nestjs/common/interfaces'; import { CorsOptions } from '@nestjs/common/interfaces/external/cors-options.interface'; import { Options as ServeStaticOptions } from 'koa-static'; import { KoaViewsOptions } from './KoaViews'; type KoaHandler = RequestHandler<Koa.Request, Koa.Response>; export declare class KoaAdapter extends AbstractHttpAdapter<http.Server | https.Server, Koa.Request, Koa.Response> { private router?; constructor(instance?: Koa); private getRouter; delete(pathOrHandler: string | KoaHandler, handler?: KoaHandler): any; get(pathOrHandler: string | KoaHandler, handler?: KoaHandler): any; head(pathOrHandler: string | KoaHandler, handler?: KoaHandler): any; options(pathOrHandler: string | KoaHandler, handler?: KoaHandler): any; patch(pathOrHandler: string | KoaHandler, handler?: KoaHandler): any; post(pathOrHandler: string | KoaHandler, handler?: KoaHandler): any; put(pathOrHandler: string | KoaHandler, handler?: KoaHandler): any; private createRouteHandler; private getRouteAndHandler; close(): Promise<void>; getType(): string; initHttpServer(options: NestApplicationOptions): void; useStaticAssets(path: string, options?: ServeStaticOptions): any; setViewEngine(options: KoaViewsOptions | any): any; getRequestHostname(request: Koa.Request): string; getRequestMethod(request: Koa.Request): string; getRequestUrl(request: Koa.Request): string; status(response: Koa.Response, statusCode: number): any; reply(response: Koa.Response, body: any, statusCode?: number): void; render(response: Koa.Response, view: string, options: any): Promise<void>; redirect(response: Koa.Response, statusCode: number, url: string): any; setErrorHandler(handler: (err: Error, ctx: Koa.Context) => void, prefix?: string): any; setNotFoundHandler(handler: NestMiddleware['use'], prefix?: string): any; setHeader(response: Koa.Response, name: string, value: string): any; registerParserMiddleware(prefix?: string): any; enableCors(options: CorsOptions): void; createMiddlewareFactory(requestMethod: RequestMethod): (path: string, middleware: Function) => any; applyVersionFilter(handler: (...args: any[]) => any, version: VersionValue, versioningOptions: VersioningOptions): (req: Koa.Request, res: Koa.Response, next: () => void) => (...args: any[]) => any; end(response: Koa.Response, message: string | undefined): any; isHeadersSent(response: Koa.Response): any; appendHeader(response: Koa.Response, name: string, value: string): any; getHeader(response: Koa.Response, name: string): any; } export {}; //# sourceMappingURL=KoaAdapter.d.ts.map