# Process video in a NestJS app

Use @rendobar/nestjs to inject Rendobar's client into your services and run any job, from FFmpeg commands to captions and AI images. It verifies webhook signatures before your handler runs and keeps Rendobar's refusals out of your responses.

Official, built by Rendobar · v0.1.0 · MIT · NestJS 10 and 11, Node 22+

Page: https://rendobar.com/integrations/nestjs/ · View on npm: https://www.npmjs.com/package/@rendobar/nestjs · Read the docs: https://rendobar.com/docs/quickstart

```
npm install @rendobar/nestjs @rendobar/sdk
```

- Type: NestJS module
- Built by: Rendobar
- Package: `@rendobar/nestjs`
- Version: 0.1.0, MIT licence
- Runs on: NestJS 10 or 11 on Node 22 or later, Express adapter for webhooks
- Pricing: Free
- Category: Code

## Overview

Import `RendobarModule` once and inject `RendobarClient` wherever you need it. It is the [TypeScript SDK](https://rendobar.com/integrations/typescript-sdk/) client, so every job type is a typed call: [FFmpeg commands](https://rendobar.com/ffmpeg/), [timeline videos](https://rendobar.com/compose/), captions and AI images. A missing API key stops the app at startup instead of failing on the first request. `@RendobarWebhook()` verifies a delivery's signature against the raw body and passes your handler the typed event. A filter answers any Rendobar `ApiError` with a 502 and logs its request id, so a revoked key never reaches your users as your own 401.

## videos.service.ts

```ts
import { Injectable } from "@nestjs/common";
import { RendobarClient } from "@rendobar/nestjs";
import { outputUrl } from "@rendobar/sdk";

@Injectable()
export class VideosService {
  // Injected by type. RendobarModule provides the client.
  constructor(private readonly rb: RendobarClient) {}

  // Waits for the job. Throws JobFailedError if it fails.
  async scale(url: string): Promise<string | undefined> {
    const job = await this.rb.jobs.run({
      type: "ffmpeg",
      inputs: { "source.mp4": url },
      params: { command: "ffmpeg -i source.mp4 -vf scale=1280:-2 -c:v libx264 -crf 23 out.mp4" },
    });
    return outputUrl(job); // signed URL of out.mp4
  }
}
```

## Set up

1. **Install.** Add the module and the SDK, and put a [new API key](https://app.rendobar.com/api-keys?create=1&name=NestJS) in `RENDOBAR_API_KEY`.

```bash
npm install @rendobar/nestjs @rendobar/sdk
```

2. **Register the module.** Import `RendobarModule` in your root module. Use `forRootAsync` to read the key and secret from `ConfigService`.

```ts
const secret = process.env.RENDOBAR_WEBHOOK_SECRET;
if (!secret) throw new Error("Set RENDOBAR_WEBHOOK_SECRET");

@Module({ imports: [RendobarModule.forRoot({ webhooks: { secret } })] })
export class AppModule {}
```

3. **Inject the client.** Ask for `RendobarClient` in any constructor and call `jobs.run`, which waits for the job and throws if it fails.

```ts
constructor(private readonly rb: RendobarClient) {}
```

4. **Verify webhooks.** Create the app with `rawBody: true`, then put `@RendobarWebhook()` on the handler. A bad or stale signature gets a 401 before your code runs.

```ts
@Post("rendobar")
@HttpCode(204)
@RendobarWebhook()
handle(event: RendobarWebhookEvent) {
  if (isKnownWebhookEvent(event) && event.event === "job.completed") console.log(event.data.jobId);
}
```


## Reference

### Package

- @rendobar/nestjs 0.1.0, MIT
- Peers: @nestjs/common and @nestjs/core 10 or 11, @rendobar/sdk 5.18 or later
- Node 22 or later

### Module

- RendobarModule.forRoot({ client, webhooks, apiErrorFilter })
- RendobarModule.forRootAsync({ imports, inject, useFactory })
- client takes every createClient option of @rendobar/sdk except credentials and client

### Options

- client.apiKey defaults to RENDOBAR_API_KEY
- client.timeout 30000 ms, client.maxRetries 2
- webhooks.secret, webhooks.toleranceSec (300), webhooks.maxBodyBytes (102400)
- apiErrorFilter: false turns off the module-wide filter

### Exports

- RendobarClient, injected by type
- @RendobarWebhook(), RendobarWebhookEvent, isKnownWebhookEvent
- RendobarApiErrorFilter, for @UseFilters on one controller

## Questions

### Which NestJS versions does @rendobar/nestjs support?

NestJS 10 and 11 on Node 22 or later, with @rendobar/sdk 5.18 or later as a peer dependency. Webhook verification needs the Express adapter, Nest's default.

### Why does Rendobar webhook verification need rawBody in NestJS?

The signature covers the exact bytes Rendobar sent. Parsed and re-serialised JSON has different bytes, so `@RendobarWebhook()` reads the raw body and answers 500 naming the fix when `rawBody: true` is missing.

### Can a NestJS app receive Rendobar webhooks without an API key?

Yes. Pass `webhooks` and no `client` to `RendobarModule.forRoot`, and the app starts without a key. A call to the client is then refused with `MISSING_API_KEY` before any request.

### What do my users see when a Rendobar call fails?

The module's filter answers a Rendobar `ApiError` with a 502 and a generic body, and logs the error code and request id. Pass `apiErrorFilter: false` to handle those errors yourself.

## Resources

- [Docs](https://rendobar.com/docs/sdk): The SDK client the module injects: every method, option and error type.
- [npm](https://www.npmjs.com/package/@rendobar/nestjs): @rendobar/nestjs, the published package and its version history.
- [GitHub](https://github.com/rendobar/rendobar-typescript/tree/main/packages/nestjs): The source and the README with every module option. MIT licensed.
- [Example app](https://github.com/rendobar/rendobar-typescript/tree/main/examples/nestjs-app): A NestJS app with a probe endpoint and a verified webhook receiver.

## More

- [The TypeScript SDK](https://rendobar.com/integrations/typescript-sdk/)
- [Run FFmpeg from Node.js](https://rendobar.com/ffmpeg/nodejs/)