DocumentationReference

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.

End-to-end app: Support Agent combines modules, RAG ingest, and chat memory — use it when you need a full project layout rather than a single-package recipe.


Core

RecipePackage
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

RecipePackage
Chat Endpoint with Streaming@hazeljs/​ai
Multi-Provider Fallback@hazeljs/​ai
AI-Powered DTO Validation@hazeljs/​ai
Parallel AI Pipeline with HCEL@hazeljs/​ai
Customer Support Agent with Tools@hazeljs/​agent
Multi-Agent Pipeline with AgentGraph@hazeljs/​agent
Agent with RAG Context@hazeljs/​agent
Ingest Documents and Search@hazeljs/​rag
RAG-Powered Q&A Endpoint@hazeljs/​rag
Hybrid Search with Reranking@hazeljs/​rag
Run a golden dataset with a custom runner@hazeljs/​eval
Retrieval metrics only@hazeljs/​eval
Fail CI when evals do not pass@hazeljs/​eval
Agent OS lifecycle (loop, policies, DNA)@hazeljs/​agent
describeAgent regression suite@hazeljs/​testing
Agent benchmarks across commits@hazeljs/​benchmark
Agent SSE timeline@hazeljs/​inspector
Store and Retrieve User Preferences@hazeljs/​memory
Conversation Memory with RAG Adapter@hazeljs/​memory
Versioned Prompt with Variables@hazeljs/​prompts
A/B Test Prompts@hazeljs/​prompts
Order Processing Workflow@hazeljs/​flow
Start a Flow from a Controller@hazeljs/​flow
Start Flow Runtime Programmatically@hazeljs/​flow-runtime
Trigger a Flow via REST from Another Service@hazeljs/​flow-runtime
Voice AI WebSocket Gateway@hazeljs/​realtime
Text-to-Speech Endpoint@hazeljs/​realtime
Expose a Database Query as an MCP Tool@hazeljs/​mcp
MCP Server with Multiple Tools@hazeljs/​mcp
Block Prompt Injection on a Chat Endpoint@hazeljs/​guardrails
Redact PII from LLM Output@hazeljs/​guardrails
Sentiment Analysis Model@hazeljs/​ml
Serve ML Predictions via REST@hazeljs/​ml
Feature Store with Online/Offline Access@hazeljs/​ml
Trigger Incident Response from a Controller@hazeljs/​ops-agent
Configure Ops Agent with Jira and Slack@hazeljs/​ops-agent
Convert a PDF to Audio via REST@hazeljs/​pdf-to-audio
Background PDF Conversion with Queue@hazeljs/​pdf-to-audio

Web & API

RecipePackage
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

RecipePackage
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 StrategiesGuide
ETL Pipeline for CSV Import@hazeljs/​data
Run a Pipeline from a Controller@hazeljs/​data

Infrastructure

RecipePackage
Typed Configuration with Validation@hazeljs/​config
Inject Config in a Service@hazeljs/​config
Feature-Flagged Route@hazeljs/​feature-toggle
Branch Logic with Feature Flags@hazeljs/​feature-toggle
Enable Inspector Dashboard@hazeljs/​inspector
Custom Inspector Metadata@hazeljs/​inspector
Scaffold a New Project@hazeljs/​cli
Generate Components@hazeljs/​cli
Golden dataset smoke check@hazeljs/​cli
Localized REST API Responses@hazeljs/​i18n
Register i18n Module with JSON Translations@hazeljs/​i18n
AWS Lambda Handler@hazeljs/​serverless
Google Cloud Function Handler@hazeljs/​serverless
Scheduled Database Cleanup@hazeljs/​cron
Register Cron Module@hazeljs/​cron
Email Queue with Processor@hazeljs/​queue
Register Queue Module with Redis@hazeljs/​queue
Offload Image Processing to a Worker@hazeljs/​worker
API Gateway with Route Versioning@hazeljs/​gateway
Canary Deployment via Gateway@hazeljs/​gateway
Circuit Breaker on an External API Call@hazeljs/​resilience
Rate Limiter on a Controller@hazeljs/​resilience
Register and Discover Services@hazeljs/​discovery
Emit and Listen to Domain Events@hazeljs/​event-emitter
Cache Invalidation via Events@hazeljs/​event-emitter
Kafka Producer and Consumer@hazeljs/​kafka
Register Kafka Module@hazeljs/​kafka
Slack Bot with AI Responses@hazeljs/​messaging
Multi-Channel Bot Registration@hazeljs/​messaging