-
-
Notifications
You must be signed in to change notification settings - Fork 13
Migrate project to Bun runtime #5
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
Migrate project to Bun runtime #5
Conversation
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.
Pull Request Overview
This PR migrates the project from Node.js to the Bun runtime by switching clients, drivers, scripts, and documentation.
- Replace ioredis with Bun’s native
RedisClient
and adjust connection logic - Swap
@libsql/client
for Bun’sbun:sqlite
, add a lightweight wrapper, and update Drizzle initialization - Update docs, package scripts, and engine definitions for Bun compatibility
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
File | Description |
---|---|
src/lib/redis.ts | Swapped ioredis for Bun’s RedisClient and refactored event handling |
src/lib/db/index.ts | Replaced libSQL client with Bun’s SQLite API and wrapper; updated Drizzle import |
src/content/docs/quickstart.md | Changed runtime prerequisite to Bun 1.2.9+ |
src/content/docs/configuration.md | Clarified NODE_ENV description |
src/content/docs/architecture.md | Updated backend runtime references to Bun |
package.json | Updated engines , scripts (bun /bunx ), and removed unused deps |
README.md | Updated prerequisites and backend runtime to Bun |
Comments suppressed due to low confidence (2)
src/lib/db/index.ts:18
- The new SQLite wrapper’s
execute
method isn’t covered by tests. Adding unit tests for both read and write paths will help catch regressions and ensure correct behavior.
export const client = {
src/lib/db/index.ts:31
- Drizzle is now initialized with the raw Bun SQLite instance instead of the wrapper client. Verify that this meets your parameter substitution and transaction needs—if not, consider passing the wrapper client to Drizzle.
export const db = drizzle(sqlite);
return new RedisClient(redisUrl, { | ||
autoReconnect: true, | ||
}); | ||
} | ||
|
||
export const redis = new Redis(redisUrl, redisOptions); | ||
export const redisPublisher = new Redis(redisUrl, redisOptions); // For publishing | ||
export const redisSubscriber = new Redis(redisUrl, redisOptions); // For subscribing | ||
export const redis = createClient(); | ||
export const redisPublisher = createClient(); | ||
export const redisSubscriber = createClient(); | ||
|
||
// Log connection events | ||
redis.on('connect', () => console.log('Redis client connected')); | ||
redis.on('error', (err) => console.error('Redis client error:', err)); | ||
redis.on('ready', () => console.log('Redis client ready')); | ||
redis.on('reconnecting', () => console.log('Redis client reconnecting...')); | ||
redis.onconnect = () => console.log("Connected to Redis server"); | ||
redis.onclose = (err) => { | ||
if (err) console.error("Disconnected from Redis server:", err); | ||
}; |
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.
Event handlers are only attached to the primary Redis client, not to the publisher or subscriber. Consider registering common connection/error logging inside createClient so all instances receive consistent handling.
Copilot uses AI. Check for mistakes.
|
||
// Simple async wrapper around Bun's SQLite API for compatibility | ||
export const client = { | ||
async execute(sql: string, params?: any[]) { |
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.
Detection of SELECT queries via a simple regex could fail for SQL with leading comments or unusual whitespace. Consider separate read/write methods or a more robust strategy for distinguishing query types.
Copilot uses AI. Check for mistakes.
Summary
Testing
bun x vitest run