mirror of https://github.com/status-im/metro.git
Small flow tweaks in metro api
Reviewed By: jeanlauliac Differential Revision: D6666057 fbshipit-source-id: 6f0b56fcb531e8c7a10c782342291b35399cac2b
This commit is contained in:
parent
dad6c51f2a
commit
c4d319429c
|
@ -27,7 +27,7 @@ import type {TransformVariants} from './ModuleGraph/types.flow';
|
|||
import type {HasteImpl} from './node-haste/Module';
|
||||
import type {IncomingMessage, ServerResponse} from 'http';
|
||||
|
||||
type Middleware = (IncomingMessage, ServerResponse, ?(?Error) => void) => void;
|
||||
type Middleware = (IncomingMessage, ServerResponse, ?() => mixed) => mixed;
|
||||
|
||||
export type ConfigT = {
|
||||
assetRegistryPath: string,
|
||||
|
|
|
@ -390,11 +390,11 @@ class Server {
|
|||
return JSON.stringify(Object.assign({}, options, ignoredParams));
|
||||
}
|
||||
|
||||
async processRequest(
|
||||
processRequest = async (
|
||||
req: IncomingMessage,
|
||||
res: ServerResponse,
|
||||
next?: () => mixed,
|
||||
) {
|
||||
next: ?() => mixed,
|
||||
) => {
|
||||
const urlObj = url.parse(req.url, true);
|
||||
const {host} = req.headers;
|
||||
debug(`Handling request: ${host ? 'http://' + host : ''}${req.url}`);
|
||||
|
@ -421,7 +421,7 @@ class Server {
|
|||
res.writeHead(404);
|
||||
res.end();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
_prepareDeltaBundler(
|
||||
req: IncomingMessage,
|
||||
|
|
|
@ -136,7 +136,6 @@ type CreateConnectMiddlewareOptions = {|
|
|||
exports.createConnectMiddleware = async function(
|
||||
options: CreateConnectMiddlewareOptions,
|
||||
) {
|
||||
// $FlowFixMe I don't know why Flow thinks there's an error here... runMetro IS async
|
||||
const metroServer = await runMetro({
|
||||
config: options.config,
|
||||
maxWorkers: options.maxWorkers,
|
||||
|
@ -150,10 +149,7 @@ exports.createConnectMiddleware = async function(
|
|||
: Config.DEFAULT;
|
||||
|
||||
return {
|
||||
middleware: normalizedConfig.enhanceMiddleware(
|
||||
(req: IncomingMessage, res: ServerResponse, next: ?(?Error) => void) =>
|
||||
metroServer.processRequest(req, res, next),
|
||||
),
|
||||
middleware: normalizedConfig.enhanceMiddleware(metroServer.processRequest),
|
||||
end() {
|
||||
metroServer.end();
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue