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

@wisemen/nestjs-auth

v0.5.0

Published

Shared NestJS auth helpers for public-route metadata and reusable HTTP basic auth.

Readme

@wisemen/nestjs-auth

Shared NestJS auth helpers for public-route metadata and reusable HTTP basic auth.

What it provides

  • Public() and isPublicContext(...) for public-route metadata
  • BasicAuthModule for registering shared basic auth definitions
  • @BasicAuth(name) for guarding controllers and handlers
  • createBasicAuthMiddleware(...) and createBasicAuthRequestHandler(...) for adapter-level protection
  • extractBearerToken(...) for parsing HTTP bearer authorization headers

Mark Public Routes

Use Public() on a controller or handler to mark it as public. Pass false to override public metadata inherited from a controller class.

import { Controller, Get } from '@nestjs/common'
import { Public } from '@wisemen/nestjs-auth'

@Controller('status')
export class StatusController {
  @Get()
  @Public()
  getStatus(): string {
    return 'ok'
  }

  @Get('internal')
  @Public(false)
  getInternalStatus(): string {
    return 'restricted'
  }
}

Use isPublicContext(...) inside guards or interceptors so the application does not need to depend on the metadata key directly.

Register And Use Basic Auth

Import BasicAuthModule.forRoot() once to initialize the shared registry, then register feature-local definitions close to the routes that use them.

import { Module } from '@nestjs/common'
import { BasicAuthModule } from '@wisemen/nestjs-auth'

@Module({
  imports: [BasicAuthModule.forRoot()]
})
export class AppModule {}
import { Module } from '@nestjs/common'
import { BasicAuthModule } from '@wisemen/nestjs-auth'

@Module({
  imports: [BasicAuthModule.forFeature({
    docs: {
      username: 'docs',
      password: 'secret'
    }
  })]
})
export class DocsAuthModule {}

Protect handlers with @BasicAuth(name) once the matching definition is registered.

import { Controller, Get } from '@nestjs/common'
import { BasicAuth } from '@wisemen/nestjs-auth'

@Controller('docs')
export class DocsController {
  @Get()
  @BasicAuth('docs')
  getDocs(): string {
    return 'private docs'
  }
}

Use forFeatureAsync(...) when credentials come from configuration or secrets. Definition names must stay unique unless they resolve to the same credentials.

Protect Adapter-Level Routes

Use createBasicAuthMiddleware(...) in Nest middleware or createBasicAuthRequestHandler(...) when attaching handlers directly to the HTTP adapter.

Parse Bearer Authorization Headers

Use extractBearerToken(...) to read a token from an Authorization header. It trims the extracted token, throws NoAuthorizationHeaderError when the header is absent, and throws InvalidAuthorizationHeaderFormatError when the header is not a bearer header.

import { extractBearerToken } from '@wisemen/nestjs-auth'

const token = extractBearerToken(request.headers.authorization)