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

@knowai/core

v0.1.0

Published

Knowai核心库,提供API服务、客户端、装饰器、类型定义等。

Readme

KnowAI Core

KnowAI Core 是前端核心库,提供完整的API服务、HTTP客户端、装饰器系统和类型定义,专注于后端通信和数据处理。

核心功能

API 服务

  • 装饰器驱动:基于TS5+装饰器实现的声明式API调用
  • 模块化设计:按功能域划分API服务(用户、帖子、聊天、模型、上传)
  • 统一错误处理:标准化的错误响应和类型定义
  • 路径参数支持:内置支持:param格式的动态路径参数

客户端实现

  • 基于Axios:高性能HTTP客户端封装
  • 统一请求配置:标准化的请求/响应接口
  • 错误转换:自动将Axios错误转换为应用错误类型
  • 类型安全:完整的TypeScript泛型支持

装饰器系统

  • HTTP方法装饰器:支持GET、POST、PUT、DELETE、PATCH
  • 请求执行装饰器:自动处理API调用逻辑
  • 客户端注入装饰器:自动注入HTTP客户端实例
  • TS5+ Stage 3:遵循最新的装饰器规范

类型系统

  • 完整类型定义:覆盖所有API请求/响应类型
  • 业务实体类型:用户、帖子、聊天、模型等核心实体类型
  • 模块化组织:按功能域分类管理类型定义

目录结构

knowai-core/
├── api/           # API服务模块
├── client/        # HTTP客户端实现
├── decorators/    # 装饰器系统
├── types/         # TypeScript类型定义
├── utils/         # 工具函数
├── index.ts       # 主入口文件
├── package.json   # 项目配置
└── tsconfig.json  # TypeScript配置

使用方式

安装

# 使用 npm
npm install @knowai/core

# 使用 pnpm
pnpm add @knowai/core

导入API服务

import { api } from '@knowai/core';

// 调用API方法
const posts = await api.post.getPosts({ page: 1, pageSize: 10 });

设计原则

  • 声明式API:使用装饰器提供简洁的API定义方式
  • 类型安全:全面利用TypeScript确保代码质量
  • 模块化:高内聚低耦合的模块化设计
  • 可扩展性:易于添加新的API服务和功能
  • 错误统一:标准化的错误处理机制

更新日志

2025-11-30

  • 用装饰器全部重构了一遍,迭代版本为0.1.0
  • 减少了百分之六十到八十的代码量
  • 先发布0.1.0版本