-
Notifications
You must be signed in to change notification settings - Fork 0
feat!: move from NodeJS to Bun #25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughReplaces Node/pnpm with Bun across runtime, CI, Docker, and scripts; adds root .dockerignore and Bun Dockerfile; moves DB init to Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor Client
participant BunServer as Bun.Server
participant App as Router/Application
participant Engine as wssEngine (Bun Engine)
participant WSS as Socket.IO Server
Client->>BunServer: HTTP request or WS upgrade
BunServer->>App: forward request to router
App->>Engine: on WS route call handleRequest(c.req.raw, BunServer)
Engine->>WSS: bind/upgrade connection
WSS->>Client: complete WS handshake / exchange events
sequenceDiagram
autonumber
participant Startup as App Startup
participant DB as Postgres (bun-sql/Drizzle)
participant Logger as Logger
Startup->>DB: create connection using env config and export db
Startup->>DB: migrate(db, { migrationsFolder: "./drizzle" })
DB-->>Startup: success / error
Startup->>Logger: log result (info / error & rethrow)
Possibly related PRs
🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 4
🤖 Fix all issues with AI agents
In @.github/workflows/test.yaml:
- Around line 15-21: CI is failing because the workflow uses bun install
--frozen-lockfile without committing bun.lockb and also leaves the Bun action
unpinned; add the generated bun.lockb to the repository root alongside
package.json and update the workflow's setup action reference (uses:
oven-sh/setup-bun@v2) to a fixed tag or commit (pin the version) so CI uses a
stable Bun release, keeping the bun install --frozen-lockfile step as-is to
ensure reproducible installs.
In `@package.json`:
- Line 47: The dependency "@socket.io/bun-engine": "^0.1.0" should be changed to
an exact version pin (e.g., "@socket.io/bun-engine": "0.1.0") to avoid pulling
incompatible minor updates; update package.json to use an exact version string
for the "@socket.io/bun-engine" entry, run CI install and dependency lockfile
update, then execute your load/stress tests against the Bun runtime you plan to
use to validate behavior before promoting to production.
In `@src/db/db.ts`:
- Around line 7-17: The current drizzle initialization using a connection object
must be changed to follow drizzle-orm's Bun SQL API: either call drizzle with a
single connection string (use env.DATABASE_URL) like drizzle(env.DATABASE_URL, {
schema }) or construct a Bun SQL client (import SQL from "bun", build new SQL({
url:
`postgres://${env.DB_USER}:${env.DB_PASS}@${env.DB_HOST}:${env.DB_PORT}/${env.DB_NAME}`,
tls: false, ... })) and pass it to drizzle as drizzle({ client, schema });
update the export of db accordingly and ensure the SQL import and env variables
are referenced (db, drizzle, env, SQL, client, schema).
- Around line 19-21: The current migration call swallows errors by logging them
only; change the migrate handling so failures abort startup: call migrate(db, {
migrationsFolder: "./drizzle" }) and on rejection rethrow or terminate (e.g.,
throw the caught error or call process.exit(1)) instead of only calling
logger.error, ensuring the migration error bubbles from this initialization code
(reference the migrate call and logger usage in src/db/db.ts) so the application
fails fast on migration errors.
🧹 Nitpick comments (4)
package/package.json (1)
30-33: Build script relies on being run from the package directory.The
cd ..pattern assumes the script is always executed from within thepackage/directory. This works fornpm publishworkflows but could be confusing if someone runsbun run buildfrom the repository root.Consider adding a brief comment in the README or package docs to clarify this is the npm package manifest and should be published from this directory.
Dockerfile (1)
11-15: Consider adding a health check.For production deployments, a
HEALTHCHECKinstruction can help container orchestrators determine if the service is healthy.Example health check
FROM base AS release COPY --from=build /build/dist ./ USER bun EXPOSE 3000 +HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \ + CMD wget --no-verbose --tries=1 --spider http://localhost:3000/health || exit 1 ENTRYPOINT ["bun", "run", "server.js"]This assumes you have a
/healthendpoint. Adjust the path as needed for your application.package.json (1)
37-38: Remove unusedtsxdependency.With the project's migration to Bun, which natively supports TypeScript execution, the
tsxpackage is no longer needed. No npm scripts or code references invoke it; all TypeScript execution is handled bybunortsup..github/workflows/docker.yaml (1)
19-19: Pin GitHub Actions to commit SHAs for supply‑chain safety.Tags are mutable; pinning to a commit SHA improves reproducibility and hardens the workflow against tag mutation attacks.
To find the SHA for v5, visit the actions/checkout releases page and use the commit SHA listed there.
🔧 Example pin
- - uses: actions/checkout@v5 + - uses: actions/checkout@<COMMIT_SHA> # v5
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@README.md`:
- Around line 5-22: Change the markdown heading "### WIP" to "## WIP" to
maintain proper heading hierarchy; fix the typo "fullfil" to "fulfill" in the
sentence starting "If you are using another language than TS..."; and hyphenate
the compound adjective by changing "Azure related" to "Azure-related" in the
note about making AZURE_* env vars optional and removing Azure related auth.
♻️ Duplicate comments (2)
src/db/db.ts (1)
7-17: Connection configuration uses undocumented pattern - verify stability.The
connection: { host, port, database, ... }object pattern doesn't appear in drizzle-orm's official Bun SQL documentation. While the developer confirmed this works, it may rely on internal implementation details that could change in future drizzle-orm updates.package.json (1)
47-47: Pin@socket.io/bun-engineto exact version for pre-1.0 stability.This package is still at 0.1.0 (pre-1.0), where even minor/patch versions could introduce breaking changes. Consider using exact version
"0.1.0"instead of"^0.1.0"until the package stabilizes.
🧹 Nitpick comments (1)
src/db/db.ts (1)
14-14: Consider makingsslconfigurable via environment variable.Hardcoding
ssl: falseworks for local development but may not suit production deployments where TLS is required for database connections (e.g., cloud-hosted Postgres).♻️ Suggested approach
Add an optional
DB_SSLenvironment variable inenv.ts:DB_SSL: z.coerce.boolean().default(false),Then use it here:
- ssl: false, + ssl: env.DB_SSL,
toto04
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ottima cosa aver spostato tutto a root level, mi dava un po' fastidio prima ngl
Sembra tutto ok ma ho 2 domande
- serve avere un
tsconfigseparato perpackageanche se è vuoto? nitpick più per curiosità tbh, anche prima era così anyway - per essere sicuro, hai testato che il package funzioni correttamente quando installato in un ambiente di node ora che è stato radicalmente cambiato il processo di build?
Credo sia corretto fare così, anche se è tendenzialmente vuoto il tsconfig di package, perché altrimenti usa quello del backend che non è totalmente corretto.
Ho provato a fare una build locale ed utilizzarla e non mi ha dato alcun problema, anche perché il package alla fine non ha niente che sia in relazione con il runtime utilizzato, vengono soltanto esportati tipi e variabili (costanti), quindi con che runtime esegui il backend non influisce su quello. |
No description provided.