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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@gotocva/nestjs-utils

v1.0.0

Published

Common utility functions for NestJS applications, including a lightweight in-memory event queue for managing asynchronous tasks efficiently without requiring Redis or any external dependencies. It supports job retries with customizable attempts and backof

Downloads

6

Readme

🚀 @gotocva/nestjs-utils

A reusable utility library for NestJS applications. This package includes cryptographic helpers, JWT handling, global exception filtering, response interceptors, and more.


📦 Features

  • 🔐 AES-256-CBC encryption/decryption
  • 🔑 JWT token generation, verification, and decoding
  • ⚠️ Global exception handler with MongoDB error awareness
  • 📦 Standardized API response formatting
  • 🧾 SHA-256 hashing utilities

📦 Installation

npm install @gotocva/nestjs-utils

Or via GitHub:

npm install git+https://github.com/your-org/nestjs-utils.git

Ensure you have @nestjs/jwt and @nestjs/common installed.


🔧 Usage

1. Crypto Utilities

import { createTransactionHash, createContractAddress, encrypt, decrypt } from '@gotocva/nestjs-utils';

// Hashing
const txHash = createTransactionHash({ sender: 'alice', amount: 100 });
const contractAddr = createContractAddress('SomeContractIdentifier');

// Encryption/Decryption
const key = crypto.randomBytes(32); // Or load from config
const encrypted = encrypt('my-secret-data', key);
const decrypted = decrypt(encrypted, key);

2. JWT Handler

import { JwtHandler } from '@gotocva/nestjs-utils';
import { JwtService } from '@nestjs/jwt';

const jwtHandler = new JwtHandler(new JwtService({ secret: process.env.JWT_SECRET }));

const token = jwtHandler.generateToken({ userId: 123 });
const verified = jwtHandler.verifyToken(token);
const decoded = jwtHandler.decodeToken(token);

3. Global Exception Filter

import { ExceptionHandler } from '@gotocva/nestjs-utils';
import { APP_FILTER } from '@nestjs/core';

@Module({
  providers: [
    {
      provide: APP_FILTER,
      useClass: ExceptionHandler,
    },
  ],
})
export class AppModule {}

Handles:

  • Mongoose validation errors
  • MongoDB error codes (duplicate key, validation, unauthorized, etc.)
  • Custom HttpException

4. Response Interceptor

import { ResponseInterceptor } from '@gotocva/nestjs-utils';
import { APP_INTERCEPTOR } from '@nestjs/core';

@Module({
  providers: [
    {
      provide: APP_INTERCEPTOR,
      useClass: ResponseInterceptor,
    },
  ],
})
export class AppModule {}

All HTTP responses will follow a consistent format:

{
  "message": "Success message",
  "status": true,
  "result": { /* your data */ },
  "error": null,
  "timestamps": "2025-05-11T00:00:00.000Z",
  "status_code": 200,
  "path": "/api/example"
}

🛠 Configuration

  • Set JWT_SECRET in your environment variables for the JwtHandler.
  • AES encryption keys must be 32 bytes for aes-256-cbc.

🧪 Testing

To test the utility functions independently:

npm run test

Add test coverage for each utility as needed.


🧑‍💻 Contributing

  1. Fork the repository
  2. Create your feature branch: git checkout -b feature/my-utils
  3. Commit your changes
  4. Push to the branch
  5. Open a Pull Request

📄 License

MIT License © Sivabharathy