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

@be-link/ecommerce-backend-bff-service-node-sdk

v0.1.74

Published

EcommerceBackendBffService Node.js SDK

Readme

开发

添加新服务

  1. 创建 types.ts 文件

    # 在对应平台和模块目录下创建 types.ts
    # 例如:src/bff/modules/miniprogram/product/types.ts
  2. 生成服务代码

    # ⚠️ 必须在 packages/sdk 目录下运行
    cd packages/sdk
    npm run generate miniprogram/product

EcommerceBackendBffService SDK

EcommerceBackendBffService Node.js SDK - 按平台分离的 SDK,支持 Pandora 管理后台和微信小程序

特性

  • 平台分离架构:PandoraSDK 和 MiniProgramSDK 独立,避免命名冲突
  • 统一命名空间结构:与后端 SDK 保持一致的类型定义
  • 自动生成 Swagger 文档:使用 tsoa 自动生成 OpenAPI 3.0 文档
  • 双模块格式支持:同时支持 ESM 和 CommonJS,兼容 Vite、Webpack 等现代构建工具
  • 编译时装饰器移除:使用 TypeScript transformer 在编译时移除 tsoa 装饰器,前端零依赖
  • 多平台支持:自动检测并适配 Web/H5 和微信小程序环境
  • 类型安全:完整的 TypeScript 类型定义
  • 标准响应格式:统一的 StandardResponse<T> 响应结构

安装

npm install @be-link/ecommerce-backend-bff-service-node-sdk

使用

💡 重要变更:SDK 现在按平台分离,请使用 PandoraSDKMiniProgramSDK。详见 平台 SDK 指南

Pandora 管理后台

import { PandoraSDK } from '@be-link/ecommerce-backend-bff-service-node-sdk'

const sdk = new PandoraSDK({
  getToken: async () => localStorage.getItem('token') || '',
  getUserId: async () => localStorage.getItem('userId') || '',
  getRoleId: async () => localStorage.getItem('roleId') || '',
  environment: 'production'
})

// 使用 Pandora 服务
const result = await sdk.example.getExampleData({ id: '123' })

微信小程序

import { MiniProgramSDK } from '@be-link/ecommerce-backend-bff-service-node-sdk'

const sdk = new MiniProgramSDK({
  getToken: async () => wx.getStorageSync('token') || '',
  getUserId: async () => wx.getStorageSync('userId') || '',
  getRoleId: async () => wx.getStorageSync('roleId') || '',
  environment: 'production'
})

// 使用小程序服务
const result = await sdk.demo.getDemoData({ page: 1 })

旧版本兼容(不推荐)

import { EcommerceBackendBffSDK } from '@be-link/ecommerce-backend-bff-service-node-sdk'

// ⚠️ 已废弃,请迁移到 PandoraSDK 或 MiniProgramSDK
const sdk = new EcommerceBackendBffSDK({
  getToken: async () => localStorage.getItem('token') || '',
  getUserId: async () => localStorage.getItem('userId') || '',
  getRoleId: async () => localStorage.getItem('roleId') || '',
  environment: 'production'
})

// 使用服务
const result = await sdk.demo.demoFunc({ demoParam: 'test' })
console.log(result.data)       // 业务数据
console.log(result.message)    // 响应消息
console.log(result.requestId)  // 请求 ID

微信小程序环境

import { EcommerceBackendBffSDK } from '@be-link/ecommerce-backend-bff-service-node-sdk'

const sdk = new EcommerceBackendBffSDK({
  getToken: async () => wx.getStorageSync('token') || '',
  getUserId: async () => wx.getStorageSync('userId') || '',
  getRoleId: async () => wx.getStorageSync('roleId') || '',
  environment: 'test'
})

// 使用服务
const result = await sdk.example.getUserProfile({ id: 'user123' })

使用类型定义

import { 
  EcommerceBackendBffSDK,
  DemoControllerTypes,
  ExampleServiceTypes 
} from '@be-link/ecommerce-backend-bff-service-node-sdk'

// 使用命名空间类型
type DemoRequest = DemoControllerTypes.Request.demoFunc
type DemoResponse = DemoControllerTypes.Response.demoFunc

type UserProfile = ExampleServiceTypes.Response.getUserProfile

开发

添加新服务

  1. 创建 types.ts 文件

    # 在对应平台和模块目录下创建 types.ts
    # 例如:src/bff/modules/miniprogram/product/types.ts
  2. 生成服务代码

    # ⚠️ 必须在 packages/sdk 目录下运行
    cd packages/sdk
    npm run generate miniprogram/product

其他命令

# 构建
npm run build

# 生成 Swagger 文档
npm run swagger

# 构建并生成文档
npm run build:swagger

# 运行测试
npm test

详细的生成器使用说明请查看:Generator README

文档

API 文档

生成的 Swagger 文档位于 dist/swagger.json,可以使用以下方式查看:

  1. Swagger UI
npm install -g swagger-ui-watcher
swagger-ui-watcher packages/sdk/dist/swagger.json
  1. 在线工具:访问 Swagger Editor 并导入 swagger.json

  2. VS Code 插件:安装 Swagger Viewer

添加新服务

查看 DIRECTORY_STRUCTURE.md 了解如何添加新的服务模块。

License

ISC