Skip to content

Commit 5cbd48f

Browse files
author
Maximilien Mellen
committed
Improve type declarations
1 parent 683a81c commit 5cbd48f

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

index.d.ts

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export declare interface FileOptions {
2727
maxAge?: number;
2828
root?: string;
2929
lastModified?: boolean | string;
30-
headers?: {};
30+
headers?: { [key: string]: string };
3131
cacheControl?: boolean | string;
3232
private?: boolean;
3333
}
@@ -36,10 +36,10 @@ export declare interface App {
3636
[namespace: string]: HandlerFunction;
3737
}
3838

39-
export declare type Middleware = (req: Request, res: Response, next: Middleware) => void;
39+
export declare type Middleware = (req: Request, res: Response, next: () => void) => void;
4040
export declare type ErrorHandlingMiddleware = (error: Error, req: Request, res: Response, next: ErrorHandlingMiddleware) => void;
4141
export declare type ErrorCallback = (error?: Error) => void;
42-
export declare type HandlerFunction = (req?: Request, res?: Response, next?: NextFunction) => void | {} | Promise<{}>;
42+
export declare type HandlerFunction = (req: Request, res: Response, next?: NextFunction) => void | any | Promise<any>;
4343
export declare type LoggerFunction = (message: string) => void;
4444
export declare type NextFunction = () => void;
4545
export declare type TimestampFunction = () => string;
@@ -80,7 +80,7 @@ export declare interface LoggerOptions {
8080
rules?: SamplingOptions[];
8181
};
8282
serializers?: {
83-
[name: string]: (req: Request) => {};
83+
[name: string]: (prop: any) => any;
8484
};
8585
stack?: boolean;
8686
}
@@ -100,17 +100,21 @@ export declare class Request {
100100
app: API;
101101
version: string;
102102
id: string;
103-
params: {};
103+
params: {
104+
[key: string]: string | undefined;
105+
};
104106
method: string;
105107
path: string;
106108
query: {
107-
[key: string]: string;
109+
[key: string]: string | undefined;
108110
};
109111
headers: {
110-
[key: string]: string;
112+
[key: string]: string | undefined;
111113
};
112-
rawHeaders?: {};
113-
body: {} | string;
114+
rawHeaders?: {
115+
[key: string]: string | undefined;
116+
};
117+
body: any;
114118
rawBody: string;
115119
route: '';
116120
requestContext: APIGatewayEventRequestContext;
@@ -119,8 +123,8 @@ export declare class Request {
119123
stageVariables: { [name: string]: string } | null;
120124
auth: {
121125
[key: string]: any;
122-
type: 'Bearer' | 'Basic' | 'OAuth' | 'Digest';
123-
value: string;
126+
type: 'Bearer' | 'Basic' | 'OAuth' | 'Digest' | 'none';
127+
value: string | null;
124128
};
125129
cookies: {
126130
[key: string]: CookieOptions;
@@ -141,10 +145,13 @@ export declare class Request {
141145
error: LoggerFunction;
142146
fatal: LoggerFunction;
143147
};
148+
149+
[key: string]: any;
144150
}
145151

146152
export declare class Response {
147153
status(code: number): this;
154+
sendStatus(code: number): void;
148155
header(key: string, value: string): this;
149156
getHeader(key: string): string;
150157
hasHeader(key: string): boolean;

0 commit comments

Comments
 (0)