Nestjs Drizzle Multiple Schemas

screenshot of Nestjs Drizzle Multiple Schemas
drizzle-orm

Multiple schemas example using NestJS and Drizzle ORM

Overview

The NestJS with Drizzle ORM starter project is an innovative approach for developers looking to harness the power of the NestJS framework in combination with Drizzle ORM for efficient database interaction. This setup not only supports PostgreSQL but also incorporates multiple schemas, making it an excellent choice for testing and multi-tenant applications. With easy-to-use abstractions and an equipped environment, it streamlines the process of building and managing your application backend.

This stack includes handy features such as a custom logger system and automated migrations, ensuring developers can focus on building features instead of setting up repetitive tasks. It's designed for versatility and simplicity, allowing teams to test functionalities efficiently across different schemas, thus facilitating a more organized development process.

Features

  • Custom Logger: Utilizes pino with pino-pretty for better logging insights, including the ability to add request IDs to logs for easier tracking and debugging.
  • Environment Variable Management: Simplified loading and processing of environment variables to streamline configuration.
  • Testable with Vitest: Integrated testing suite that encourages developers to write and run tests efficiently, ensuring code quality and reliability.
  • Reusable DAO: Contains abstract.dao that allows for the reuse of common Drizzle ORM queries like getAll, getById, and getBySingleKey, enhancing code maintainability.
  • Multiple Schemas: Facilitates the creation of multiple schemas for testing purposes, enabling developers to isolate tests within distinct environments.
  • PostgreSQL Support: Full compatibility with PostgreSQL, providing a robust and reliable database solution for applications.
  • Quick Start API: Quick kickoff with easily accessible API endpoints, making it simple to start interacting with the application in no time.
  • Migration Support: Built-in support for database migrations, with a clear README to guide users through the setup process.
drizzle-orm
Drizzle ORM

Drizzle ORM is a TypeScript ORM for SQL databases designed with maximum type safety in mind. It comes with a drizzle-kit CLI companion for automatic SQL migrations generation. Drizzle ORM is meant to be a library, not a framework. It stays as an opt-in solution all the time at any levels.

eslint
Eslint

ESLint is a linter for JavaScript that analyzes code to detect and report on potential problems and errors, as well as enforce consistent code style and best practices, helping developers to write cleaner, more maintainable code.

typescript
Typescript

TypeScript is a superset of JavaScript, providing optional static typing, classes, interfaces, and other features that help developers write more maintainable and scalable code. TypeScript's static typing system can catch errors at compile-time, making it easier to build and maintain large applications.

zod
Zod

Zod is a TypeScript-first schema declaration and validation library. It allows you to define schemas that can validate data at runtime while providing excellent TypeScript inference, making it perfect for API validation, form validation, and type-safe data handling.