From 1636a899188826671148fa485b8a09ffed67e90e Mon Sep 17 00:00:00 2001 From: Mateusz Stawecki Date: Wed, 11 Mar 2020 14:19:37 +0000 Subject: [PATCH] TS support api.register/routes, req.namespace #137 --- index.d.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/index.d.ts b/index.d.ts index 7e67a0e..113ebae 100644 --- a/index.d.ts +++ b/index.d.ts @@ -32,8 +32,12 @@ export declare interface FileOptions { private?: boolean; } +export declare interface RegisterOptions { + prefix?: string; +} + export declare interface App { - [namespace: string]: HandlerFunction; + [namespace: string]: any; } export declare type Middleware = (req: Request, res: Response, next: () => void) => void; @@ -138,6 +142,7 @@ export declare class Request { userAgent: string; clientType: 'desktop' | 'mobile' | 'tv' | 'tablet' | 'unknown'; clientCountry: string; + namespace: App; log: { trace: LoggerFunction; @@ -202,7 +207,10 @@ export declare class API { any(...handler: HandlerFunction[]): void; METHOD(method: METHODS, path: string, ...handler: HandlerFunction[]): void; METHOD(method: METHODS, ...handler: HandlerFunction[]): void; - + register(routes: (api: API, options?: RegisterOptions) => void, options?: RegisterOptions): void; + routes(format: true): void; + routes(format: false): string[][]; + routes(): string[][];