-
Notifications
You must be signed in to change notification settings - Fork 630
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update types and improve docs for server.enhanceMiddleware
Summary: Resolves #739. Usage example / types fix is inspired by use in `react-native-community/cli-plugin-metro`: https://github.com/react-native-community/cli/blob/main/packages/cli-plugin-metro/src/commands/start/runServer.ts#L87-L97 Changelog: **[Types]** Update config and `Server` types to use broader types from `connect` package Reviewed By: motiz88 Differential Revision: D46228146 fbshipit-source-id: 63718ae44bed12735bd798a9c819b128aeb5a9d6
- Loading branch information
1 parent
06682f8
commit d20d7c8
Showing
12 changed files
with
168 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/** | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @flow strict | ||
* @format | ||
* @oncall react_native | ||
*/ | ||
|
||
declare module 'connect' { | ||
import type http from 'http'; | ||
|
||
declare export type ServerHandle = HandleFunction | http.Server; | ||
|
||
declare type NextFunction = (err?: mixed) => void; | ||
|
||
declare export type NextHandleFunction = ( | ||
req: IncomingMessage, | ||
res: http.ServerResponse, | ||
next: NextFunction, | ||
) => void | Promise<void>; | ||
declare export type HandleFunction = | ||
| NextHandleFunction; | ||
|
||
declare export interface IncomingMessage extends http.IncomingMessage { | ||
originalUrl?: http.IncomingMessage['url']; | ||
} | ||
|
||
declare export interface Server extends events$EventEmitter { | ||
(req: IncomingMessage, res: http.ServerResponse): void; | ||
|
||
use(fn: HandleFunction): Server; | ||
use(route: string, fn: HandleFunction): Server; | ||
|
||
listen( | ||
port: number, | ||
hostname?: string, | ||
backlog?: number, | ||
callback?: Function, | ||
): http.Server; | ||
listen(port: number, hostname?: string, callback?: Function): http.Server; | ||
listen(path: string, callback?: Function): http.Server; | ||
listen(handle: any, listeningListener?: Function): http.Server; | ||
} | ||
|
||
declare type createServer = () => Server; | ||
|
||
declare module.exports: createServer; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.