Documentation•Reference
HazelJS Recipes
Every package documentation page includes a Recipes section at the bottom with 2–3 task-oriented, copy-paste-ready TypeScript examples. This page indexes all recipes by category for quick navigation.
Each recipe follows this format:
- Complete TypeScript with all imports
- File path comment (
// File: src/...) - No pseudo-code — every snippet is runnable
Core
| Recipe | Package |
|---|---|
| Build a CRUD REST API | @hazeljs/core |
| Add Validation to a POST Endpoint | @hazeljs/core |
| Add an Auth Guard | @hazeljs/core |
| Write a Unit Test | @hazeljs/core |
AI & Intelligence
Web & API
| Recipe | Package |
|---|---|
| Audit Business Events | @hazeljs/audit |
| Global HTTP Audit Logging | @hazeljs/audit |
| JWT-Protected CRUD Controller | @hazeljs/auth |
| Register and Login Endpoints | @hazeljs/auth |
| Record-Level Permission Check | @hazeljs/casl |
| Ability Factory for Roles | @hazeljs/casl |
| Google OAuth Login | @hazeljs/oauth |
| Stripe Checkout Session | @hazeljs/payment |
| Handle Stripe Webhooks | @hazeljs/payment |
| Add Swagger to Your App | @hazeljs/swagger |
| Document a Controller with Decorators | @hazeljs/swagger |
| Chat Room with WebSocket | @hazeljs/websocket |
| Authenticated WebSocket Gateway | @hazeljs/websocket |
| GraphQL Query and Mutation | @hazeljs/graphql |
| Register GraphQL Module | @hazeljs/graphql |
| gRPC Service and Client | @hazeljs/grpc |
Data & Storage
| Recipe | Package |
|---|---|
| CRUD Service with Prisma | @hazeljs/prisma |
| Transaction with Multiple Models | @hazeljs/prisma |
| Entity with Repository Pattern | @hazeljs/typeorm |
| Register TypeORM Module | @hazeljs/typeorm |
| Cache Database Queries | @hazeljs/cache |
| Cache AI Responses to Reduce Cost | @hazeljs/cache |
| Advanced Caching Strategies | Guide |
| ETL Pipeline for CSV Import | @hazeljs/data |
| Run a Pipeline from a Controller | @hazeljs/data |