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

@gidea/nest-common

v0.0.3

Published

Shared NestJS building blocks for WeChat mini-program backends

Readme

@gidea/nest-common

面向微信小程序后端的 NestJS 通用能力库,提供装饰器、守卫、过滤器、拦截器、日志、中间件等,可与 NestMiniappModule 一键接入。

安装

npm i @gidea/nest-common
# 或
pnpm add @gidea/nest-common

Peer 依赖:需在业务项目中安装 @nestjs/common@nestjs/core(>=10),以及 reflect-metadatarxjs。若使用 JWT 守卫,需安装 @nestjs/jwt

快速使用

在根模块中引入 NestMiniappModule,即可全局注册:

  • AppLogger:可注入的日志服务(TRANSIENT)
  • HttpExceptionFilter:统一 HTTP 异常与错误码响应
  • LoggingInterceptor:请求/响应日志
  • OpenIdGuard:基于 openid 的鉴权守卫(需配合小程序登录)
import { Module } from '@nestjs/common'
import { NestMiniappModule } from '@gidea/nest-common'

@Module({
  imports: [NestMiniappModule],
  // ...
})
export class AppModule {}

导出内容

模块

  • NestMiniappModule:一键注册上述全局能力

装饰器

  • @Public():标记接口无需鉴权(跳过 OpenIdGuard)
  • @OpenId():在 handler 参数上注入当前用户的 openid

守卫

  • OpenIdGuard:校验请求中的 openid(Header/Query),未通过返回 401
  • ApiKeyGuard:API Key 校验,可用于内部或管理接口
  • JwtGuard:JWT 鉴权(依赖 @nestjs/jwt,可选)

过滤器 / 拦截器 / 中间件

  • HttpExceptionFilter:将异常转为统一 { code, message, data } 响应
  • LoggingInterceptor:请求开始与结束的日志
  • RequestIdMiddleware:为请求注入 requestId(需自行注册)

常量

  • HTTP_STATUSERROR_CODEERROR_MSG:状态码与错误码
  • AUTH_HEADERAUTH_BEARER_PREFIXQUERY_TOKEN_KEY:鉴权相关常量

工具与类型

  • getBearerToken(request):从请求中解析 Bearer token
  • toNumber(value, default?):安全转数字
  • AppLogger:日志服务
  • IApiResultIApiErrorIRequestWithOpenId 等类型

脚本

pnpm run build      # 构建 ESM + CJS + 类型
pnpm run dev        # 监听源码变更并构建
pnpm run typecheck  # 仅类型检查

License

MIT