Skip to content

Commit d19df68

Browse files
committed
Update evi-proxy to use Node and Vite
1 parent 2489113 commit d19df68

File tree

7 files changed

+47
-355
lines changed

7 files changed

+47
-355
lines changed

evi/evi-proxy/README.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@ It is also useful as a debugging tool: it supports
1212

1313
## Prerequisites
1414

15-
- [Bun](https://bun.sh/) runtime
16-
- Node.js (for web frontend build)
17-
- Hume AI API credentials
15+
- Node.js (for running the proxy and building the web frontend)
16+
- Hume AI API credentials
1817

1918
## Installation
2019

@@ -26,8 +25,8 @@ It is also useful as a debugging tool: it supports
2625

2726
2. Install dependencies for both app and web components:
2827
```bash
29-
cd app && bun install
30-
cd ../web && bun install
28+
cd app && npm install
29+
cd ../web && npm install && npm run build
3130
cd ..
3231
```
3332

@@ -50,7 +49,7 @@ To get your API key:
5049
### Start the Proxy Server
5150

5251
```bash
53-
cd app && bun run start
52+
cd app && npm start
5453
```
5554

5655
This starts the WebSocket proxy server on port 3000 with an interactive CLI interface. The CLI allows you to:
@@ -82,6 +81,9 @@ The proxy also includes a built-in web interface available at:
8281
```
8382
http://localhost:3000
8483
```
84+
The interface is built using [Vite](https://vitejs.dev). If you modify any
85+
frontend code, run `npm run build` in the `web/` directory again to rebuild the
86+
static assets.
8587

8688
### Recording and Playback
8789

@@ -93,7 +95,7 @@ http://localhost:3000
9395

9496
```
9597
eviproxy/
96-
├── app/ # Main proxy server (Bun/Node.js)
98+
├── app/ # Main proxy server (Node.js)
9799
│ ├── main.ts # Entry point and state machine
98100
│ ├── cli.ts # Interactive CLI interface
99101
│ ├── upstream.ts # Hume API connections

evi/evi-proxy/app/main.ts

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
import 'dotenv/config';
12
import * as fs from "fs";
23
import * as p from "@clack/prompts";
34
import * as http from "http";
5+
import * as path from "path";
6+
import { fileURLToPath } from "url";
47
import { CLI } from "./cli.js";
58
import type { Message, State, AppEvent, Effect } from '../shared/types.ts';
69
import { ERROR_CODES } from '../shared/types.ts';
@@ -9,6 +12,9 @@ import { BaseUpstream, LiveUpstream, PlaybackUpstream, UninitializedUpstream } f
912
import { Downstream } from "./downstream.js";
1013
import { exhaustive, truncateDataReplacer } from "./util.js";
1114

15+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
16+
const DIST_DIR = path.join(__dirname, "../out");
17+
1218
const PORT = 3000;
1319
const DOWNSTREAM_WS_PATH = "/v0/evi/chat";
1420
const UPSTREAM_WS_BASE_URL = "wss://api.hume.ai";
@@ -38,31 +44,26 @@ const serve = async (req: http.IncomingMessage, res: http.ServerResponse) => {
3844
}
3945
}
4046

41-
// This builds the frontend on each request
42-
await Bun.build({
43-
entrypoints: ["../web/index.html"],
44-
outdir: "../out",
45-
target: "browser",
46-
});
4747
if (url.pathname === "/" || url.pathname === "/index.html") {
48-
res.writeHead(200, {
49-
"Content-Type": "text/html",
50-
"Cache-Control": "no-cache",
51-
});
52-
res.write(await Bun.file("../out/index.html").text());
53-
res.end();
54-
return;
48+
const htmlPath = path.join(DIST_DIR, "index.html");
49+
if (fs.existsSync(htmlPath)) {
50+
res.writeHead(200, {
51+
"Content-Type": "text/html",
52+
"Cache-Control": "no-cache",
53+
});
54+
res.write(fs.readFileSync(htmlPath));
55+
res.end();
56+
return;
57+
}
5558
}
56-
// Serve any file from out/ (e.g. chunk-*.js, chunk-*.css)
57-
const filePath = `../out${url.pathname}`;
58-
const file = Bun.file(filePath);
59-
if (await file.exists()) {
59+
const filePath = path.join(DIST_DIR, url.pathname);
60+
if (fs.existsSync(filePath)) {
6061
let contentType = "application/octet-stream";
6162
if (filePath.endsWith(".js")) contentType = "application/javascript";
6263
else if (filePath.endsWith(".css")) contentType = "text/css";
6364
else if (filePath.endsWith(".html")) contentType = "text/html";
6465
res.writeHead(200, { "Content-Type": contentType });
65-
res.write(await file.text());
66+
res.write(fs.readFileSync(filePath));
6667
res.end();
6768
return;
6869
}

evi/evi-proxy/app/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,22 @@
44
"description": "",
55
"main": "main.ts",
66
"scripts": {
7-
"start": "bun run main.ts"
7+
"start": "node --loader tsx ./main.ts"
88
},
99
"keywords": [],
1010
"author": "",
1111
"license": "ISC",
1212
"dependencies": {
1313
"@clack/core": "^1.0.0-alpha.0",
14-
"@types/bun": "^1.2.12",
1514
"change-case": "^5.4.4",
15+
"dotenv": "^16.3.1",
1616
"is-unicode-supported": "^2.1.0"
1717
},
1818
"devDependencies": {
1919
"@types/express": "^4.17.21",
2020
"@types/node": "^22.7.0",
2121
"@types/ws": "^8.18.1",
2222
"@types/yargs": "^17.0.33",
23-
"bun-types": "^1.2.12",
2423
"tsx": "^4.19.4",
2524
"typescript": "^5.6.2",
2625
"ws": "^8.18.2",

evi/evi-proxy/web/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# dependencies (bun install)
1+
# dependencies
22
node_modules
33

44
# output

0 commit comments

Comments
 (0)