EnvironmentInfo as argument to start server

Summary:
Clean initialisation by passing down the environment info to start server.

(Also rename dir to path as that's the name used in other places)

Reviewed By: passy

Differential Revision: D45731751

fbshipit-source-id: a60fdd49c567fc312d1f8da72db3a46a0828c140
This commit is contained in:
Lorenzo Blasa
2023-05-11 04:10:16 -07:00
committed by Facebook GitHub Bot
parent 0f9eeda2dd
commit a96caacb2b
4 changed files with 35 additions and 32 deletions

View File

@@ -27,7 +27,7 @@ import {validateAuthToken} from '../utils/certificateUtils';
type Config = {
port: number;
staticDir: string;
staticPath: string;
entry: string;
tcp: boolean;
};
@@ -99,7 +99,7 @@ async function startHTTPServer(config: Config): Promise<{
});
app.get('/', (_req, res) => {
fs.readFile(path.join(config.staticDir, config.entry), (_err, content) => {
fs.readFile(path.join(config.staticPath, config.entry), (_err, content) => {
res.end(content);
});
});
@@ -108,7 +108,7 @@ async function startHTTPServer(config: Config): Promise<{
res.end('flipper-ok');
});
app.use(express.static(config.staticDir));
app.use(express.static(config.staticPath));
return startProxyServer(config, app);
}