Skip to content

Commit 8a4db8b

Browse files
committed
Migrate API to Bun/TypeScript with unified server
- Use Hono for internal routing - Use hono/aws-lambda for AWS Lambda compatibility - Rewrite middleware using Hono middleware pattern - Run on /api/v2 in dev - Build and pack with Bun - Remove old build scripts and dependencies - Update Makefile and GitHub Actions to use Bun
1 parent 295f374 commit 8a4db8b

236 files changed

Lines changed: 14262 additions & 34422 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/test-node.yml

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,14 @@ jobs:
1616
AWS_SECRET_ACCESS_KEY: ci
1717
steps:
1818
- uses: actions/checkout@v3
19-
- uses: actions/setup-node@v3
20-
with:
21-
node-version: 24.x
22-
cache: "npm"
23-
cache-dependency-path: "api/package-lock.json"
24-
- run: npm ci
19+
- uses: oven-sh/setup-bun@v2
20+
- run: bun install
2521
- name: Check code style
26-
run: npm run lint && npm run prettier
22+
run: bun run lint && bun run prettier
2723
- name: Run tests
28-
run: npm run test:coverage
24+
run: bun run test:coverage
2925
- name: Validate OpenAPI spec
30-
run: npm run validate-spec
26+
run: bun run validate-spec
3127
test-mcp:
3228
runs-on: ubuntu-latest
3329
defaults:

.husky/pre-commit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/usr/bin/env sh
22
. "$(dirname -- "$0")/_/husky.sh"
3-
cd api && npm run lint && npm run prettier && cd -
3+
cd api && bun run lint && bun run prettier && cd -
44
cd chat/src && uv run ruff check . && cd -

.tool-versions

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ java corretto-19.0.1.10.1
33
aws-sam-cli 1.148.0
44
python 3.12.2
55
uv 0.9.5
6+
bun 1.3.14

Makefile

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -36,36 +36,19 @@ help:
3636

3737
./chat/dependencies/requirements.txt: ./chat/pyproject.toml
3838
cd chat && uv export --format requirements-txt --no-hashes > dependencies/requirements.txt
39-
api: ./api/template.yaml ./api/src/package-lock.json $(wildcard ./api/src/**/*.js)
39+
api: ./api/template.yaml ./api/bun.lockb $(wildcard ./api/src/**/*.ts)
4040
chat: ./chat/template.yaml ./chat/dependencies/requirements.txt $(wildcard ./chat/src/**/*.py)
4141
av-download: ./av-download/template.yaml ./av-download/lambdas/package-lock.json $(wildcard ./av-download/lambdas/**/*.js)
4242
.aws-sam/build.toml: ./template.yaml api chat av-download
43-
sed -Ei.orig 's/"dependencies"/"devDependencies"/' api/src/package.json
44-
cp api/src/package-lock.json api/src/package-lock.json.orig
45-
cd api/src && npm i --package-lock-only && cd -
46-
for d in . api av-download chat docs ; do \
47-
sed -Ei.orig 's/^(\s+)#\*\s/\1/' $$d/template.yaml; \
48-
done
49-
50-
-sam build --cached --parallel
51-
52-
for d in . api av-download chat docs ; do \
53-
mv $$d/template.yaml.orig $$d/template.yaml; \
54-
done
55-
mv api/src/package.json.orig api/src/package.json
56-
mv api/src/package-lock.json.orig api/src/package-lock.json
43+
@sed -Ei.orig 's/^(\s+)#\*\s/\1/' chat/template.yaml; \
44+
sam build --cached --parallel
45+
@mv chat/template.yaml.orig chat/template.yaml
5746
av-download/layers/ffmpeg/bin/ffmpeg:
5847
mkdir -p av-download/layers/ffmpeg/bin ;\
5948
curl -L https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-amd64-static.tar.xz | \
6049
tar -C av-download/layers/ffmpeg/bin -xJ --strip-components=1 --wildcards '*/ffmpeg' '*/ffprobe'
6150
deps-api:
62-
cd api/src ;\
63-
npm list >/dev/null 2>&1 ;\
64-
src_deps=$$? ;\
65-
cd .. ;\
66-
npm list >/dev/null 2>&1 ;\
67-
dev_deps=$$? ;\
68-
test $$src_deps -eq 0 -a $$dev_deps -eq 0 || npm ci
51+
bun install --cwd api
6952
deps-av-download:
7053
cd av-download/lambdas ;\
7154
npm list >/dev/null 2>&1 || npm ci
@@ -102,10 +85,9 @@ validate:
10285
cfn-lint template.yaml **/template.yaml --ignore-checks E3510 W1028 W8001
10386
serve-http: deps-node
10487
@printf '\033[0;31mWARNING: Serving only the local HTTP API. The chat websocket API is not available in local mode.\033[0m\n'
105-
rm -rf .aws-sam
106-
sam local start-api -t api/template.yaml --env-vars $$PWD/env.json --host 0.0.0.0 --log-file dc-api.log ${SERVE_PARAMS}
107-
serve-https: SERVE_PARAMS = --port 3002 --ssl-cert-file $$HOME/.dev_cert/dev.rdc.cert.pem --ssl-key-file $$HOME/.dev_cert/dev.rdc.key.pem
108-
serve-https: serve-http
88+
bun run --cwd api -i dev
89+
serve-https:
90+
PORT=3002 HOST=0.0.0.0 SSL_CERT=$$HOME/.dev_cert/dev.rdc.cert.pem SSL_KEY=$$HOME/.dev_cert/dev.rdc.key.pem make serve-http
10991
serve: serve-https
11092
start-with-step: deps-node env.json
11193
export AWS_DEFAULT_REGION=us-east-1 ;\

api/.claude/settings.local.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"permissions": {
3+
"allow": [
4+
"Bash(bun run *)",
5+
"Bash(bun test *)"
6+
]
7+
}
8+
}

api/.mocharc.js

Lines changed: 0 additions & 5 deletions
This file was deleted.

api/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
build-apiFunction:
2+
bun build --target node --outdir $(ARTIFACTS_DIR) --entry-naming [name].mjs --sourcemap=linked src/index.ts

api/bun.lock

Lines changed: 738 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/bunfig.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[test]
2+
include = ["test/**/*.test.ts"]

0 commit comments

Comments
 (0)