Skip to content

Express

Installation

Install the package using npm

Terminal window
npm install @latta/express

or using yarn

Terminal window
yarn add @latta/express

or using your favourite package manager

Quick start

Adding Latta to your Express application requires just one line of code

import { latta } from '@latta/express';
import express from 'express';
// Get your API key from the Latta dashboard or use environment variables
const LATTA_API_KEY = process.env.LATTA_API_KEY || "YOUR_API_KEY";
const app = express();
// Add Latta middleware
app.use(latta(LATTA_API_KEY));
// Your existing routes and middleware

Configuration

Client Initialization

The Latta client is implemented as Express middleware and accepts two parameters

import { latta } from '@latta/express';
const middleware = latta(
"API_KEY",
{
verbose: true // Enable detailed logging
}
);
app.use(middleware);

Options

interface LattaOptions {
verbose: boolean; // Enable/disable detailed logging
}

Debugging

To assist with troubleshooting, you can enable verbose logging

app.use(latta(LATTA_API_KEY, { verbose: true }));

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