npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

nestjs-deepl

v1.0.1

Published

DeepL module for Nest framework.

Readme

NestJS DeepL Module

npm version License: MIT

A NestJS module that provides seamless integration with the DeepL translation API. This module wraps the official DeepL Node.js client and makes it easy to use translation services in your NestJS applications.

Features

  • 🔧 Easy Integration: Simple module setup with NestJS dependency injection
  • 🌍 Translation Support: Full access to DeepL's translation capabilities
  • ⚙️ Configurable: Flexible configuration options for different environments
  • 🔒 Type Safe: Built with TypeScript for better development experience
  • 📦 Lightweight: Minimal overhead with clean architecture

Installation

npm install nestjs-deepl deepl-node
# or
yarn add nestjs-deepl deepl-node
# or
pnpm add nestjs-deepl deepl-node

Note: This module requires deepl-node as a peer dependency. Make sure to install it alongside nestjs-deepl.

Prerequisites

  • Node.js (v18 or higher)
  • NestJS framework
  • DeepL API key (Get one here)

Quick Start

1. Import the Module

import { Module } from '@nestjs/common';
import { DeepLModule } from 'nestjs-deepl';

@Module({
  imports: [
    DeepLModule.register({
      authKey: 'your-deepl-api-key',
    }),
  ],
})
export class AppModule {}

2. Use the DeepL Client

import { Injectable } from '@nestjs/common';
import { DeepLClient } from 'deepl-node';

@Injectable()
export class TranslationService {
  constructor(private readonly deepLClient: DeepLClient) {}

  async translateText(text: string, targetLang: string) {
    try {
      const result = await this.deepLClient.translateText(
        text,
        null,
        targetLang,
      );
      return result.text;
    } catch (error) {
      throw new Error(`Translation failed: ${error.message}`);
    }
  }
}

Configuration Options

The module accepts all configuration options from the official DeepL Node.js client:

DeepLModule.register({
  authKey: 'your-deepl-api-key',
  serverUrl: 'https://api-free.deepl.com', // Optional: for DeepL Free API
  // Other DeepL client options...
});

Global Module

To make the DeepL client available globally across your application:

DeepLModule.register({
  authKey: 'your-deepl-api-key',
  isGlobal: true,
});

Async Configuration

For dynamic configuration (e.g., from environment variables):

DeepLModule.registerAsync({
  useFactory: (configService: ConfigService) => ({
    authKey: configService.get('DEEPL_API_KEY'),
  }),
  inject: [ConfigService],
});

API Reference

DeepLModule

The main module class that provides the DeepL client.

Static Methods

  • register(options: DeepLModuleOptions): Configure the module with static options
  • registerAsync(options: DeepLModuleAsyncOptions): Configure the module with async options

DeepLModuleOptions

Extends the official DeepL client options:

interface DeepLModuleOptions extends DeepLClientOptions {
  authKey: string;
}

Examples

Basic Translation

@Injectable()
export class TranslationService {
  constructor(private readonly deepLClient: DeepLClient) {}

  async translateToGerman(text: string) {
    const result = await this.deepLClient.translateText(text, null, 'DE');
    return result.text;
  }
}

Document Translation

@Injectable()
export class DocumentService {
  constructor(private readonly deepLClient: DeepLClient) {}

  async translateDocument(filePath: string, targetLang: string) {
    const result = await this.deepLClient.translateDocument(
      filePath,
      targetLang,
    );
    return result;
  }
}

Usage Statistics

@Injectable()
export class UsageService {
  constructor(private readonly deepLClient: DeepLClient) {}

  async getUsage() {
    const usage = await this.deepLClient.getUsage();
    return usage;
  }
}

Environment Variables

It's recommended to use environment variables for your DeepL API key:

# .env
DEEPL_API_KEY=your-deepl-api-key
// app.module.ts
DeepLModule.register({
  authKey: process.env.DEEPL_API_KEY,
});

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Development Setup

  1. Clone the repository
  2. Install dependencies: pnpm install
  3. Run tests: pnpm test
  4. Run linting: pnpm lint
  5. Build the project: pnpm build

License

This project is licensed under the MIT License - see the LICENSE file for details.

Author

Xudong Huang

Related Links

Support

If you encounter any issues or have questions, please:

  1. Check the DeepL API documentation
  2. Search existing issues
  3. Create a new issue with detailed information

Made with ❤️ for the NestJS community