From 5b580413e6c9a380d65fab42942836bd12a38f93 Mon Sep 17 00:00:00 2001 From: Sylvain Lesage Date: Mon, 10 Mar 2025 11:25:32 +0100 Subject: [PATCH 1/3] remove dead code --- bin/serve.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/bin/serve.js b/bin/serve.js index 8b477d4d..cf250212 100644 --- a/bin/serve.js +++ b/bin/serve.js @@ -91,9 +91,6 @@ function handleRequest(req, serveDirectory) { } else if (pathname.startsWith('/assets/') || pathname.startsWith('/favicon') ) { // serve static files return handleStatic(`${hyperparamPath}/dist${pathname}`) - // else if (pathname.startsWith('/public/')) { - // // serve static files - // return handleStatic(`${hyperparamPath}${pathname.replace(/^(\/public).*/, '/dist')}`) } else if (serveDirectory && pathname === '/api/store/list') { // serve file list const prefix = parsedUrl.query.prefix || '' From fea8ab0b459bb37e3c719c3a1ff64bb388a9ce29 Mon Sep 17 00:00:00 2001 From: Sylvain Lesage Date: Mon, 10 Mar 2025 12:01:40 +0100 Subject: [PATCH 2/3] nit: fix variable name --- bin/serve.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/serve.js b/bin/serve.js index cf250212..54c06bdf 100644 --- a/bin/serve.js +++ b/bin/serve.js @@ -95,8 +95,8 @@ function handleRequest(req, serveDirectory) { // serve file list const prefix = parsedUrl.query.prefix || '' if (Array.isArray(prefix)) return { status: 400, content: 'bad request' } - const perfixPath = `${serveDirectory}/${decodeURIComponent(prefix)}` - return handleListing(perfixPath) + const prefixPath = `${serveDirectory}/${decodeURIComponent(prefix)}` + return handleListing(prefixPath) } else if (serveDirectory && pathname === '/api/store/get') { // serve file content const key = parsedUrl.query.key || '' From c038fe24f97c65fd95be9c52c0b9fe78587162c2 Mon Sep 17 00:00:00 2001 From: Sylvain Lesage Date: Mon, 10 Mar 2025 12:22:32 +0100 Subject: [PATCH 3/3] disable opening the page in browser when in development mode --- bin/serve.js | 11 +++++++---- package.json | 4 ++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/bin/serve.js b/bin/serve.js index 54c06bdf..8e1295a6 100644 --- a/bin/serve.js +++ b/bin/serve.js @@ -57,10 +57,13 @@ export async function serve(serveDirectory, key) { } } console.log(`hyperparam server running on http://localhost:${port}`) - if (!key) openUrl(`http://localhost:${port}`) - else { - key = encodeURIComponent(key) - openUrl(`http://localhost:${port}/files?key=${key}`) + const isDev = process.env.NODE_ENV === 'development' + if (!isDev) { + if (!key) openUrl(`http://localhost:${port}`) + else { + key = encodeURIComponent(key) + openUrl(`http://localhost:${port}/files?key=${key}`) + } } } diff --git a/package.json b/package.json index b638c228..5a888f74 100644 --- a/package.json +++ b/package.json @@ -43,8 +43,8 @@ "url": "run-p -l watch:ts watch:vite watch:url", "watch:ts": "tsc --watch", "watch:vite": "vite build --watch", - "watch:serve": "nodemon bin/cli.js", - "watch:url": "nodemon bin/cli.js https://hyperparam.blob.core.windows.net/hyperparam/starcoderdata-js-00000-of-00065.parquet" + "watch:serve": "NODE_ENV=development nodemon bin/cli.js", + "watch:url": "NODE_ENV=development nodemon bin/cli.js https://hyperparam.blob.core.windows.net/hyperparam/starcoderdata-js-00000-of-00065.parquet" }, "dependencies": { "hightable": "0.12.1",