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

@websdr/nestjs-microservice

v0.5.3

Published

This is a NestJS microservice for WebSDR

Downloads

24

Readme

@websdr/nestjs-microservice

Reusable NestJS building blocks for the WebSDR backend.

This package is published as an npm module and is intended to be embedded into your NestJS app (import modules, reuse guards/services), not run as a standalone server by itself.

What’s inside

  • Auth (/auth): AuthModule, AuthService, JwtAuthGuard, DTOs and interfaces.
  • Users (/users): UsersModule and UsersService.
  • Common (/common): a small logging helper module (LoggingModule, createContextLogger) and LoggerLevelService/parseLogLevels.

Install

npm install @websdr/nestjs-microservice
pnpm add @websdr/nestjs-microservice
yarn add @websdr/nestjs-microservice

Importing

This package is published as ESM (see type: module).

Import from the root:

import { AuthModule, UsersModule, JwtAuthGuard } from '@websdr/nestjs-microservice';

Or use subpath exports:

import { AuthModule, JwtAuthGuard } from '@websdr/nestjs-microservice/auth';
import { UsersModule } from '@websdr/nestjs-microservice/users';
import { LoggingModule, LOGGER } from '@websdr/nestjs-microservice/common';

Usage

1) Import modules in your Nest app

import { Module } from '@nestjs/common';
import { AuthModule, UsersModule } from '@websdr/nestjs-microservice';

@Module({
  imports: [UsersModule, AuthModule],
})
export class AppModule {}

2) Protect controllers with JwtAuthGuard

JwtAuthGuard validates a JWT (Passport strategy) and also checks token revocation via AuthService.isRevoked(). It looks for the token in either:

  • req.cookies.jwt, or
  • Authorization: Bearer <token>
import { Controller, Get, UseGuards } from '@nestjs/common';
import { JwtAuthGuard } from '@websdr/nestjs-microservice/auth';

@Controller('private')
export class PrivateController {
  @UseGuards(JwtAuthGuard)
  @Get()
  getPrivateData() {
    return { ok: true };
  }
}

Accessing the authenticated user (req.user) with proper typing:

import { Controller, Get, Req, UseGuards } from '@nestjs/common';
import type { AuthRequest } from '@websdr/nestjs-microservice/auth';
import { JwtAuthGuard } from '@websdr/nestjs-microservice/auth';

@Controller('me')
export class MeController {
  @UseGuards(JwtAuthGuard)
  @Get()
  getMe(@Req() req: AuthRequest) {
    return req.user;
  }
}

3) Provide a logger instance via LoggingModule

LoggingModule.forRoot() registers a logger instance under the LOGGER token. createContextLogger() wraps a base logger and adds Nest-like context.

import { Module, Logger } from '@nestjs/common';
import { LoggingModule } from '@websdr/nestjs-microservice/common';

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

Injecting the base logger and creating a context-aware wrapper:

import { Inject, Injectable } from '@nestjs/common';
import type { LoggerService } from '@nestjs/common';
import { LOGGER, createContextLogger } from '@websdr/nestjs-microservice/common';

@Injectable()
export class DeviceService {
  private readonly logger: LoggerService;

  constructor(@Inject(LOGGER) base: any) {
    this.logger = createContextLogger(base, DeviceService.name);
  }

  open() {
    this.logger.log('opening device');
  }
}

4) Configure log levels

parseLogLevels() parses strings like "debug,warn,error", as well as "all"/"on" and "off"/"false".

import { Logger } from '@nestjs/common';
import { parseLogLevels } from '@websdr/nestjs-microservice/common';

Logger.overrideLogger(parseLogLevels(process.env.LOG_LEVELS));

If you prefer a service that can update levels at runtime:

import { NestFactory } from '@nestjs/core';
import { LoggerLevelService } from '@websdr/nestjs-microservice/common';
import { AppModule } from './app.module';

const app = await NestFactory.create(AppModule);
app.get(LoggerLevelService).setLevelsFromString(process.env.LOG_LEVELS);
await app.listen(3000);

Public API (summary)

  • @websdr/nestjs-microservice/auth:
    • AuthModule
    • JwtAuthGuard
    • DTOs: LoginDto
    • Types: AuthUser, AuthRequest
  • @websdr/nestjs-microservice/users:
    • UsersModule
  • @websdr/nestjs-microservice/common:
    • LoggingModule, LOGGER, createContextLogger
    • LoggerLevelService, parseLogLevels, LoggerLevels

Compatibility notes

  • NestJS: built against NestJS v11.
  • TypeScript: ships *.d.ts typings.
  • ESM: package is ESM. If your app is CommonJS, use a bundler/transpiler setup that supports ESM dependencies.

Development

From the repository root:

npm install

From this package folder:

Build

npm run build

Test

npm test

Source links

This package publishes dist/ to npm. Source is available in the GitHub repository:

  • Entry point: https://github.com/wavelet-lab/websdr/blob/main/packages/nestjs-microservice/src/index.ts
  • Auth exports: https://github.com/wavelet-lab/websdr/blob/main/packages/nestjs-microservice/src/auth/index.ts
  • Common exports: https://github.com/wavelet-lab/websdr/blob/main/packages/nestjs-microservice/src/common/index.ts
  • Users exports: https://github.com/wavelet-lab/websdr/blob/main/packages/nestjs-microservice/src/users/index.ts

Package folder (GitHub): https://github.com/wavelet-lab/websdr/tree/main/packages/nestjs-microservice

License

WebSDR is MIT licensed