Closed diegoalzate closed 1 month ago
@coderabbitai summary
This update introduces a comprehensive restructuring of the database access patterns across the application. It shifts from using a generalized db
module to a more specific schema
module, enhancing type safety and clarity in database interactions. Additionally, testing methodologies have been revised to utilize dedicated test databases, improving isolation and reliability. These changes collectively aim to streamline code organization, improve maintainability, and clarify the underlying data models used throughout the application.
Files | Change Summary |
---|---|
.github/workflows/test.yml , .gitignore , .nycrc |
Adjustments to testing environment setup, exclusions for test artifacts, and introduction of code coverage configurations for better test management. |
drizzle.config.js , src/db/create-db-connection.ts , src/db/index.ts , src/db/schema/index.ts , src/db/test.ts , src/handlers/* , src/routers/* , src/services/* |
Major refactor to replace db module usage with schema , updating all references and types for improved clarity and maintainability in database interactions. |
package.json |
Changes in test commands and dependencies, transitioning from Jest to NYC for coverage measurement and removing unnecessary Jest dependencies. |
scripts/db/seed.ts , src/db/seed.ts |
New database seeding functionality designed for structured data insertion and cleanup operations, enhancing development and testing efficiency. |
src/modules/*.spec.ts |
Transition to Node.js's native assert module for consistency in assertions, aligning with a more structured testing approach. |
sequenceDiagram
participant A as User
participant B as Router
participant C as Schema
participant D as Database
A->>B: Request data
B->>C: Query schema for data
C->>D: Fetch data from database
D-->>C: Return data
C-->>B: Return formatted data
B-->>A: Send response
π In fields of code where bunnies hop,
New schemas bloom, no need to stop.
With tests now spry and coverage bright,
We celebrate changes, oh what a sight!
Each line refined, each path made clear,
Hoppy coding days, let's give a cheer! π
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
overview
this will create an ephemeral database and will return a way to delete this database. allowing now tests to run concurrently without race conditions because each test will run in its own db.
performance
all ran on a m1 mac
with jest![CleanShot 2024-07-18 at 17 31 44@2x](https://github.com/user-attachments/assets/c840b310-a193-4a0c-a5de-fd389bb614b9)
with node:test![CleanShot 2024-07-18 at 17 25 11@2x](https://github.com/user-attachments/assets/0b1e841a-29cf-4e6e-96c4-11ea2cfd5295)
with node:test and ephemeral dbs![CleanShot 2024-07-18 at 17 39 15@2x](https://github.com/user-attachments/assets/9d803006-46f6-4bdc-a6b6-cb10c28f9c19)
Summary by CodeRabbit
New Features
.nycrc
configuration for code coverage tailored for TypeScript projects.Bug Fixes
Refactor
Tests
assert
module for improved consistency and clarity.Chores