-
Notifications
You must be signed in to change notification settings - Fork 1
Improved database initialization #36
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
emilkrebs
commented
Jan 10, 2026
- improved database initialization to increase memory efficiency
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 refactors database initialization to improve memory efficiency by moving from lazy initialization to eager initialization at application startup. The database instance is now created once in main.ts and exported for use across the application, eliminating the need for the getNoteDatabase() function and its associated service file.
Changes:
- Replaced lazy database initialization with eager initialization in
main.ts - Removed the
database-service.tsfile and replaced allgetNoteDatabase()calls with direct access to the exportednoteDatabaseinstance - Extracted copy button logic into a reusable
CopyButtoncomponent to reduce code duplication - Updated dependencies to newer versions and reformatted configuration files
Reviewed changes
Copilot reviewed 12 out of 13 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| main.ts | Added eager database initialization and export of noteDatabase instance |
| lib/services/database-service.ts | Removed lazy initialization service entirely |
| routes/api/notes/[id].ts | Replaced getNoteDatabase() calls with direct noteDatabase access |
| routes/api/notes.ts | Replaced getNoteDatabase() calls with direct noteDatabase access |
| routes/[id].tsx | Replaced getNoteDatabase() calls with direct noteDatabase access |
| components/CopyButton.tsx | New reusable component extracted from CopyField.tsx |
| components/CopyField.tsx | Refactored to use new CopyButton component |
| islands/ViewNote.tsx | Replaced inline SVG with CopyButton component |
| lib/rate-limiting/src/hashing.ts | Reformatted function signatures for consistency |
| tests/main_test.ts | Added ARC_SECRET environment variable setup |
| tests/arc-rate-limiter_test.ts | Added ARC_SECRET environment variable setup |
| deno.json | Updated dependency versions and reformatted configuration |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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
Copilot reviewed 13 out of 14 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>