Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 1361605

Browse files
naorpeledbilljohnston
andauthored
fix(type-defs): resolve middleware missing in route methods (#238)
Co-authored-by: Bill Johnston <1688630+billjohnston@users.noreply.github.com>
1 parent 73a6194 commit 1361605

File tree

1 file changed

+77
-22
lines changed

1 file changed

+77
-22
lines changed

‎index.d.ts‎

Lines changed: 77 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,13 @@ export declare interface App {
4646
export declare type Middleware = (
4747
req: Request,
4848
res: Response,
49-
next: ()=>void
49+
next: NextFunction
5050
) => void;
5151
export declare type ErrorHandlingMiddleware = (
5252
error: Error,
5353
req: Request,
5454
res: Response,
55-
next: ()=>void
55+
next: NextFunction
5656
) => void;
5757
export declare type ErrorCallback = (error?: Error) => void;
5858
export declare type HandlerFunction = (
@@ -193,39 +193,62 @@ export declare class Request {
193193

194194
export declare class Response {
195195
status(code: number): this;
196+
196197
sendStatus(code: number): void;
198+
197199
header(key: string, value?: string | Array<string>, append?: boolean): this;
200+
198201
getHeader(key: string): string;
202+
199203
hasHeader(key: string): boolean;
204+
200205
removeHeader(key: string): this;
206+
201207
getLink(
202208
s3Path: string,
203209
expires?: number,
204210
callback?: ErrorCallback
205211
): Promise<string>;
212+
206213
send(body: any): void;
214+
207215
json(body: any): void;
216+
208217
jsonp(body: any): void;
218+
209219
html(body: any): void;
220+
210221
type(type: string): this;
222+
211223
location(path: string): this;
224+
212225
redirect(status: number, path: string): void;
213226
redirect(path: string): void;
227+
214228
cors(options: CorsOptions): this;
229+
215230
error(message: string, detail?: any): void;
216231
error(code: number, message: string, detail?: any): void;
232+
217233
cookie(name: string, value: string, options?: CookieOptions): this;
234+
218235
clearCookie(name: string, options?: CookieOptions): this;
236+
219237
etag(enable?: boolean): this;
238+
220239
cache(age?: boolean | number | string, private?: boolean): this;
240+
221241
modified(date: boolean | string | Date): this;
242+
222243
attachment(fileName?: string): this;
244+
223245
download(
224246
file: string | Buffer,
225247
fileName?: string,
226248
options?: FileOptions,
227249
callback?: ErrorCallback
228250
): void;
251+
229252
sendFile(
230253
file: string | Buffer,
231254
options?: FileOptions,
@@ -237,37 +260,69 @@ export declare class API {
237260
app(namespace: string, package: Package): App;
238261
app(packages: App): App;
239262

240-
get(path: string, ...handler: HandlerFunction[]): void;
241263
get(
242264
path: string,
243-
middleware: Middleware,
244-
...handler: HandlerFunction[]
265+
...middlewaresAndHandler: (Middleware | HandlerFunction)[]
266+
): void;
267+
get(...middlewaresAndHandler: (Middleware | HandlerFunction)[]): void;
268+
269+
post(
270+
path: string,
271+
...middlewaresAndHandler: (Middleware | HandlerFunction)[]
272+
): void;
273+
post(...middlewaresAndHandler: (Middleware | HandlerFunction)[]): void;
274+
275+
put(
276+
path: string,
277+
...middlewaresAndHandler: (Middleware | HandlerFunction)[]
278+
): void;
279+
put(...middlewaresAndHandler: (Middleware | HandlerFunction)[]): void;
280+
281+
patch(
282+
path: string,
283+
...middlewaresAndHandler: (Middleware | HandlerFunction)[]
284+
): void;
285+
patch(...middlewaresAndHandler: (Middleware | HandlerFunction)[]): void;
286+
287+
delete(
288+
path: string,
289+
...middlewaresAndHandler: (Middleware | HandlerFunction)[]
290+
): void;
291+
delete(...middlewaresAndHandler: HandlerFunction[]): void;
292+
293+
options(
294+
path: string,
295+
...middlewaresAndHandler: (Middleware | HandlerFunction)[]
245296
): void;
246-
get(...handler: HandlerFunction[]): void;
247-
post(path: string, ...handler: HandlerFunction[]): void;
248-
post(...handler: HandlerFunction[]): void;
249-
put(path: string, ...handler: HandlerFunction[]): void;
250-
put(...handler: HandlerFunction[]): void;
251-
patch(path: string, ...handler: HandlerFunction[]): void;
252-
patch(...handler: HandlerFunction[]): void;
253-
delete(path: string, ...handler: HandlerFunction[]): void;
254-
delete(...handler: HandlerFunction[]): void;
255-
options(path: string, ...handler: HandlerFunction[]): void;
256-
options(...handler: HandlerFunction[]): void;
257-
head(path: string, ...handler: HandlerFunction[]): void;
258-
head(...handler: HandlerFunction[]): void;
259-
any(path: string, ...handler: HandlerFunction[]): void;
260-
any(...handler: HandlerFunction[]): void;
297+
options(...middlewaresAndHandler: (Middleware | HandlerFunction)[]): void;
298+
299+
head(
300+
path: string,
301+
...middlewaresAndHandler: (Middleware | HandlerFunction)[]
302+
): void;
303+
head(...middlewaresAndHandler: (Middleware | HandlerFunction)[]): void;
304+
305+
any(
306+
path: string,
307+
...middlewaresAndHandler: (Middleware | HandlerFunction)[]
308+
): void;
309+
any(...middlewaresAndHandler: (Middleware | HandlerFunction)[]): void;
310+
261311
METHOD(
262312
method: METHODS | METHODS[],
263313
path: string,
264-
...handler: HandlerFunction[]
314+
...middlewaresAndHandler: (Middleware | HandlerFunction)[]
315+
): void;
316+
METHOD(
317+
method: METHODS | METHODS[],
318+
...middlewaresAndHandler: (Middleware | HandlerFunction)[]
265319
): void;
266-
METHOD(method: METHODS|METHODS[], ...handler: HandlerFunction[]): void;
320+
267321
register(
268322
routes: (api: API, options?: RegisterOptions) => void,
269323
options?: RegisterOptions
270324
): void;
325+
271326
routes(format: true): void;
272327
routes(format: false): string[][];
273328
routes(): string[][];

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /