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

koishi-plugin-pointmint

v0.0.8

Published

Points management system plugin

Readme

Koishi Plugin PointMint

npm License

模块化架构 | 高度可定制|可审计事务追踪|实时积分生态 - 基于双效校验机制的经济引擎

功能特性

核心能力

  • 双效校验机制:通过实现事务ID生成与验证,确保每笔积分操作的可追溯性
  • 实时积分系统:提供类实现完整的积分生命周期管理(增/删/查/改)
  • 审计追踪体系:通过记录全量操作日志,支持自定义日志保留策略

功能亮点

  • 用户积分排行榜(TopN 查询)
  • 自动用户名同步机制
  • 弹性积分初始化策略
  • 操作结果多状态码返回
  • 插件间调用追踪标识

开发者快速接入指南

[!NOTE]
正在撰写……

接口文档

基础数据结构

基础数据结构提供了必要的接口定义,用于实现插件间的交互。

[!WARNING]

  • 插件目前还在开发版本,下面的接口在接下来的版本中可能会有变动

  • 为了方便称呼,以下文档中有关于虚拟货币的称呼统一为“积分”,您可以设置您的货币为其他任意名称

  • 如果你在使用过程中遇到了问题,欢迎提交Issue

export interface ApiResponseNoData {
    code: number // 状态码
    msg: string // 状态信息
}

状态码表

| 状态码 | 状态信息 | 说明 | |---|---|---| | 200 | 成功 | 操作成功 | | 204 | 成功 | 操作成功,但是操作没有实质性改变数据 | | 400 | 错误 | 操作失败,参数有误 | | 403 | 错误 | 操作失败,用户没有足够的积分用于操作 | | 500 | 错误 | 操作失败,服务器内部错误,可能是配置项错误或bug |

1. 积分查询

  1. 设置积分
async set(
  userid: string, // 用户唯一标识符
  transactionId: string, // 事务id,见第二节
  points: number, // 积分值,必须 >= 0
  pluginName?: string // 插件名,用于追踪调用关系
): Promise<ApiResponseNoData>
  1. 增加积分
async add(
  userid: string,
  transactionId: string,
  points: number,
  pluginName?: string
): Promise<ApiResponseNoData>
  1. 扣除积分
async reduce(
  userid: string,
  transactionId: string,
  points: number,        // 必须 > 0
  pluginName?: string
): Promise<ApiResponseNoData>
  1. 获取积分排行
async getTopN(
  num: number  // 需要查询的排行榜名额数量,必须为正整数
): Promise<Array<{
  userid: string   // 用户唯一标识符
  username: string // 用户当前名称
  points: number   // 用户当前积分
}>>
// 返回示例
[
    { userid: '123456', username: 'Alice', points: 100},
    { userid: '654321', username: 'Bob', points: 90}
]

2. 获取事务id

事务id是用于操作积分的必要数值,对积分进行操作的方法都需要传入事务id。 你可以通过以下方法获取事务id:

async generateTransactionId(): Promise<string>

3. 其他方法

  1. 更新用户名
async updateUserName(
  userid: string,
  username: string,
  pluginName?: string
): Promise<ApiResponseNoData>
  1. 回写操作 回写操作是将某项操作回写。例如,你通过reduce方法后,所要提供的服务未能正常提供,可以通过该方法回退
async rollback(
  userid: string,
  transactionId: string,
  pluginName?: string
): Promise<ApiResponseNoData>