@void-snippets/nestjs
defineResource() config + generated Controller/Service/Repository for a full REST resource.
#What defineResource replaces
Without this package, a single CRUD resource in NestJS usually means three hand-written classes: a repository (talks to the database), a service (business logic, calls the repository), and a controller (HTTP routes, calls the service). Multiply that by every resource in your app — contacts, invoices, tickets — and most of it is the same shape every time.
@void-snippets/nestjs generates all three from one config object:
import { defineResource } from '@void-snippets/nestjs';
import { forTypeOrmResource } from '@void-snippets/nestjs/typeorm';
import { Contact } from './contact.entity';
@Module({ imports: [forTypeOrmResource(Contact)] })
export class ContactsModule {}Nothing else. That's a full ContactsController, ContactsService, and ContactsRepository — generated, wired together, and registered with Nest's dependency injection.
#When you outgrow the generated classes
You don't have to choose between "the package does everything" and "I write everything by hand." When a resource needs a side effect (send a welcome email after create), an extra endpoint (GET /contacts/recent), or custom validation, you extends the generated base classes instead of using the one-liner. See Adding Custom Logic.
#The four pieces
| Page | What it covers |
|---|---|
| Setup | Installing the package and configuring app-wide defaults once |
| defineResource | The full reference — every option the config object accepts |
| Mongoose | Registering a resource backed by a Mongoose schema |
| TypeORM | Registering a resource backed by a TypeORM entity |