Skip to content

NestJS

Installation

Install the package using npm

Terminal window
npm install @latta/nestjs

or using yarn

Terminal window
yarn add @latta/nestjs

or using your favourite package manager

Quick start

Adding Latta to your NestJS application requires just one line of code in your bootstrap function

import { NestFactory } from '@nestjs/core';
import { LattaInterceptor } from '@latta/nestjs';
import { AppModule } from './app.module';
async function bootstrap() {
const app = await NestFactory.create(AppModule);
// Add Latta interceptor
app.useGlobalInterceptors(new LattaInterceptor(process.env.LATTA_API_KEY));
await app.listen(3000);
}
bootstrap();

Configuration

Client Initialization

The Latta interceptor can be configured with options

import { LattaInterceptor } from '@latta/nestjs';
const interceptor = new LattaInterceptor(
process.env.LATTA_API_KEY,
{
verbose: true // Enable detailed logging
}
);
app.useGlobalInterceptors(interceptor);

Options

OptionTypeDefaultDescription
verbosebooleanfalseWhen enabled, Latta will log detailed information to the console
interface LattaOptions {
verbose: boolean; // Enable/disable detailed logging
}

Debugging

For debugging purposes, you can enable verbose logging

const interceptor = new LattaInterceptor(process.env.LATTA_API_KEY, { verbose: true });

This will output detailed information about Latta’s operation to the console.