From 993dc203f7cd28ee266f93fa0bf0690bc6048144 Mon Sep 17 00:00:00 2001 From: Rusty Key Date: Sat, 21 Sep 2024 16:38:32 +0200 Subject: [PATCH] return promise --- commands/reshowcase | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/commands/reshowcase b/commands/reshowcase index 437701c..b01b4bc 100755 --- a/commands/reshowcase +++ b/commands/reshowcase @@ -233,7 +233,7 @@ if (isBuild) { // ensure that esbuild doesn't take server's port port: port + 1, }); - return {esbuildServer: server, esbuildCtx: ctx} + return server.then(esbuildServer => ({esbuildServer, esbuildCtx: ctx})); }) .then(({esbuildServer, esbuildCtx}) => { const server = http.createServer((req, res) => { @@ -243,12 +243,12 @@ if (isBuild) { headers: req.headers, }; - const rewrite = pathRewrites?.find(rewrite => req.url.startsWith(rewrite.context)) + const rewrite = pathRewrites?.find(rewrite => req.url.startsWith(rewrite.context)); if (rewrite) { if (rewrite.socketPath) { options.socketPath = rewrite.socketPath; - console.info(`[reshowcase] forwarding ${req.url} to ${options.socketPath}`) + console.info(`[reshowcase] forwarding ${req.url} to ${options.socketPath}`); } else { const url = new URL(rewrite.target); options.host = url.hostname; @@ -265,9 +265,9 @@ if (isBuild) { } const proxyReq = http.request(options, proxyRes => { - res.writeHead(proxyRes.statusCode, proxyRes.headers) - proxyRes.pipe(res, { end: true }) - }) + res.writeHead(proxyRes.statusCode, proxyRes.headers); + proxyRes.pipe(res, { end: true }); + }); proxyReq.on("error", err => { console.error("[reshowcase] Proxy request error:", err);