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

@riaskov/nestjs-trace

v1.0.1

Published

Lightweight NestJS tracing (debug print) plugin for controllers and services

Readme

nestjs-trace

Lightweight NestJS tracing (debug print) plugin for controllers and services, supporting Express & Fastify, CJS & ESM.

npm version
Module type: MinNode Module type: MinNest

Installation

npm i @riaskov/nestjs-trace
# (Optional, for full decorator metadata support)
npm i -D @swc/core @swc/helpers

Usage

Import the Module

In your AppModule:

import { Module } from "@nestjs/common"
import { TraceModule } from "nestjs-trace"

@Module({
  imports: [TraceModule.forRoot()],
})
export class AppModule {}

Enable Tracing

By default, tracing is disabled. To enable it, set process env variable:

export ENABLE_METHOD_TRACING=true

Features

  • Method Tracing via @Trace() decorator (sync & async methods)
  • HTTP Tracing via a global interceptor (compatible with Express & Fastify)
  • Dual CJS & ESM bundles out of the box
  • Zero runtime dependencies beyond NestJS core

Examples

1. Method Tracing

Apply the @Trace() decorator to any class method:

import { Injectable } from "@nestjs/common"
import { Trace } from "nestjs-trace"

@Injectable()
export class MyService {
  @Trace()
  calculate(a: number, b: number): number {
    return a + b
  }

  @Trace()
  async fetchData(id: string): Promise<{ id: string; data: any }> {
    const data = await this.getFromDb(id)
    return { id, data }
  }

  private async getFromDb(id: string): Promise<any> {
    return { foo: 'bar' }
  }
}

With ENABLE_METHOD_TRACING=true, logs appear as:

[Trace] ▶ Enter MyService.calculate with args: [1,2]
[Trace] ◀ Exit MyService.calculate with result: 3

[Trace] ▶ Enter MyService.fetchData with args: ["abc"]
[Trace] ◀ Exit MyService.fetchData with result: {"id":"abc","data":{...}}

2. HTTP Tracing

Enable request/response tracing for all routes:

import { Controller, Get, Query } from "@nestjs/common"
import { Trace } from "nestjs-trace"
import { MyService } from "./my.service"

@Controller("items")
export class MyController {
  constructor(private readonly svc: MyService) {}

  @Get("sum")
  @Trace()
  sum(
    @Query("a") a: string,
    @Query("b") b: string,
  ): number {
    return this.svc.calculate(Number(a), Number(b))
  }

  @Get("data")
  async data(@Query("id") id: string) {
    return this.svc.fetchData(id)
  }
}

Logs for HTTP will look like:

[HTTP] ▶ GET /items/sum? a=3&b=5 — body={}, params={}, query={"a":"3","b":"5"}
[Trace] ▶ Enter MyController.sum with args: [3,5]
[Trace] ◀ Exit MyController.sum with result: 8
[HTTP] ◀ GET /items/sum 200 — 5ms

Development

git clone https://github.com/ARyaskov/nestjs-trace.git
cd nestjs-trace
npm i
npm run build

🤝 Contributing

  1. Fork this repo 🍴
  2. Create a feature branch (feat/awesome-graph)
  3. Commit your changes and open a Pull Request 🚀

📄 License

Released under the MIT License ❤️