@ductape/nestjs
TypeScript only
@ductape/nestjs is a TypeScript/NestJS package. All code samples in this section are TypeScript — there are no Java, Go, or .NET tabs.
The @ductape/nestjs package wraps @ductape/sdk with NestJS modules, injectable handles, and decorators so you can call Ductape from controllers and services without manual SDK wiring.
What it provides
| Capability | NestJS surface |
|---|---|
| App actions | @Api, @ApiDispatch, @ApiConfig |
| Databases & storage | @Database, @Storage + feature modules |
| Webhooks | @Webhook.Register, @Webhook.Consumer, @Webhook.List |
| Messaging, workflows, jobs | @Messaging.*, @Workflow.*, @Job.Run, … |
| Agents, warehouse, sessions | @Agent.*, @Warehouse.Query, @Session.*, … |
| Resilience | @Health.*, @Quota.*, @Fallback.* |
| Workspace builders | @WebhookBuilder.Define, @ModelBuilder.Define, @AgentBuilder.Define |
| Context | @Product, @Env, @AccessTag, @InjectContext |
Install
npm install @ductape/nestjs @ductape/sdk @nestjs/common @nestjs/core reflect-metadata rxjs
Peer dependency: @ductape/sdk ≥ 0.1.12, NestJS 10 or 11.
Package status
@ductape/nestjs is at 0.1.0 in the monorepo. Install from the published package when available, or link locally from sdk/nestjs during development.
Architecture
- Decorators with runtime behavior (
@Api,@Webhook.Register, messaging, agents, sessions, and related decorators) are executed byDuctapeMethodInterceptor(orDuctapeBuilderInterceptorin workspace mode). - Injectable handles (
@Database('orders-db')) resolve throughDuctapeContextService, which respects@Product/@Envon the current HTTP request when set. - Use
ctx.sdkfrom@InjectContext()for SDK namespaces not yet wrapped (logs, cloud, …).
Auth modes
| Mode | Module helper | SDK auth | Typical use |
|---|---|---|---|
| Integration | DuctapeModule.forIntegration() | accessKey + default product / env | Customer apps, product integrators |
| Workspace | DuctapeModule.forWorkspace() | accessKey (workspace user context resolved by the SDK) | Admin tools, app/model/agent builders |
Integration mode covers @Api, @Database, @Storage, and @Webhook.Register.
Workspace mode is required for builder APIs (ductape.webhooks.create, ductape.app.*, model/agent admin).
Next steps
- Getting started — wire
DuctapeModuleand your first@Apihandler - Module setup —
forIntegration,forWorkspace, feature modules - Context & handles —
@Product,@Env,@InjectContext, multi-tenant patterns - Core decorators —
@Api,@Database,@Storage,@Webhook - Runtime decorators — messaging, workflows, agents, sessions, resilience
- Workspace builders — declarative webhook/model/agent definitions
- Interceptors — global vs per-controller registration