Node.jsExpressTypeScriptPrismaOOP

Prexress

Prexress is designed to eliminate boilerplate in Express.js applications. It provides high-level abstractions for routing, controllers, and services, promoting a standardized OOP-based architecture for rapid and scalable API development.

A scalable, modular TypeScript backend framework powered by Drizzle ORM.

๐Ÿง  Overview

Prexress is a backend framework built in TypeScript, designed with modularity and scalability in mind. It integrates with Drizzle ORM, embraces clean architecture principles, and leverages package separation to isolate core functionalities and database access.


๐Ÿ› ๏ธ Installation

Install the CLI tool globally via pnpm:

pnpm add -g @prexress/cli

Verify the installation:

pxr --help

๐Ÿ“ฆ Project Initialization

To create a new Prexress project:

pxr init

This sets up the initial project structure with a basic configuration, default modules, and dependencies.


Start Working

  • Install required dependencies
pnpm install
  • Generate migration for database schema
pnpm run db:generate
  • Push migration to database
pnpm run db:migrate

Prexress CLI

You will find proper cli documentation over here. @prexress/cli


๐Ÿ›๏ธ Architectural Highlights

1. Modular Folder Architecture

Prexress promotes a feature-first structure, where each domain (e.g., user, post) is treated as an isolated module.

src/
โ”œโ”€โ”€ modules/
โ”‚   โ””โ”€โ”€ user/
โ”‚       โ”œโ”€โ”€ user.controller.ts
โ”‚       โ”œโ”€โ”€ user.service.ts
โ”‚       โ”œโ”€โ”€ user.schema.ts
โ”‚       โ”œโ”€โ”€ user.repository.ts
โ”‚       โ””โ”€โ”€ user.middleware.ts
โ”œโ”€โ”€ middlewares/
โ”œโ”€โ”€ registry.ts
โ””โ”€โ”€ app.ts

๐Ÿ“ฆ Package Separation

Core Package (`@prexress/core`)

  • Base classes for controllers, services, selectors, and repositories
  • Common decorators
  • Dependency Injection and utility helpers

DB Package (`@prexress/db`)

  • Drizzle ORM setup and configuration
  • Connection pool management

Helpers (planned)

  • Authorization (RBAC)
  • JWT + Passport strategies

๐Ÿ” Features

  • โš™๏ธ Drizzle ORM Integration: Lightweight, type-safe database access layer
  • ๐Ÿงฉ Modular Design: Each domain is self-contained for better testability
  • ๐Ÿงฑ Repository Pattern: Abstracts persistence layer from business logic
  • ๐Ÿ’‰ Dependency Injection: Powered by tsyringe for service registration
  • ๐Ÿงผ Decorators for Routing: Clean and declarative routing with decorators
  • ๐Ÿงต Selector Layer: Efficient response shaping and security via field filtering
  • ๐Ÿ” Middleware Support: Built-in support for global, controller, and route-level middleware
  • ๐Ÿš€ Automatic Route Discovery: Controllers are registered dynamically
  • ๐Ÿ”ฅ Prexress CLI: An interactive cli to generate project files

๐Ÿง  Usage Philosophy

Repository

Encapsulates data access using Drizzle's db.select, db.insert, etc.

export class UserRepository extends BaseRepository {
  async findByEmail(email: string) {
    return this.db.query.users.findFirst({ where: eq(users.email, email) });
  }
}

Service

Contains validation and orchestrates domain logic.

export class UserService extends BaseService {
  async register(data: CreateUserDTO) {
    if (!this.isEmailValid(data.email)) throw new ValidationError();
    return this.create(data);
  }
}

Controller

Maps routes to service methods using expressive decorators.

@autoInjectable()
@Controller("/api/v1/users")
export class UserController {
  constructor(readonly userService: UserService) {}

  @POST("/")
  async create(req: Request, res: Response) {
    const user = await this.userService.create(req.body);
    return res.status(201).json(user);
  }
}

๐Ÿ” Middleware & Error Handling

Supports multi-layer middleware:

  • Global (e.g., logging, auth)
  • Controller-level
  • Route-specific
Example:
@Use(authMiddleware)
@POST("/")
@Use(validateUserMiddleware)

Global error handler is included for graceful failures.


๐Ÿ”ฎ Future Scope

  • Plugin system for auth, logging, metrics
  • GraphQL integration
  • Multi-tenancy support
  • Multi-DB adapters

๐Ÿ“„ License

MIT License โ€” see LICENSE file for details.