Endpoint to Open UI

Summary: Expose an endpoint to open Flipper UI. This will be used by the Flipper Server Cocoa app to open the UI.

Reviewed By: antonk52

Differential Revision: D51115327

fbshipit-source-id: 1ab1c32d93945cf8d75b145905983738331a6468
This commit is contained in:
Lorenzo Blasa
2023-11-08 09:20:13 -08:00
committed by Facebook GitHub Bot
parent 137e75ad46
commit 9b9eb00b63

View File

@@ -23,6 +23,7 @@ import {tracker} from '../tracker';
import {EnvironmentInfo, isProduction} from 'flipper-common';
import {GRAPH_SECRET} from '../fb-stubs/constants';
import {sessionId} from '../sessionId';
import {UIPreference, openUI} from '../utils/openUI';
type Config = {
port: number;
@@ -186,6 +187,13 @@ async function startHTTPServer(
res.end('flipper-ok');
});
app.get('/open-ui', (_req, res) => {
tracker.track('server-endpoint-hit', {name: 'open-ui'});
const preference = isProduction() ? UIPreference.PWA : UIPreference.Browser;
openUI(preference, config.port);
res.json({success: true});
});
app.use(express.static(config.staticPath));
const server = http.createServer(app);