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

rhine-base

v1.0.0

Published

Basic service for rhine-base-server

Readme

RHINE BASE

本项目专为 RHINE AI 公司内部使用,内置大量常用的通用功能与接口,主要用于与 rhine-base-server 公司基础服务端对接。

Install

bun add rhine-base

Network

网络请求层,基于 axios 封装,统一处理鉴权、错误码、请求/响应拦截。

Request

  • 基于 axios 的请求实例封装,统一 baseURL、超时、拦截器
  • 自动附加 Authorization header
  • 统一错误处理与响应格式化

Authorization

鉴权相关功能的网络接口封装函数。

  • login() — 登录,获取 token
  • logout() — 登出,清除 token
  • register() — 注册,包含登录
  • refreshToken() — 刷新 token
  • getProfile() — 获取当前用户信息
  • getToken() 持久化存储与自动刷新机制

File and Resource

文件与资源相关功能的网络接口封装函数。

  • uploadFile(file, containerId) — 上传文件到 OSS 并注册到服务端
  • deleteFile(fileId) — 删除文件
  • getResources(containerId) — 获取容器下的资源列表
  • getFileURL(fileId) — 获取文件访问地址(含签名)
  • createContainer(options) — 创建资源容器

Utils

通用常用工具包,纯函数,无副作用。

File and Resource

文件的处理工具,包含哈希、预览图生成、描述文本生成等。

  • getFileHash(file) — 计算文件哈希(用于去重/校验)
  • generateFilePreviewImages(file, options) — 生成预览图
  • generateFileDescription(file) — 生成文件描述文本
  • detectFileType(buffer) — 基于 file-type 检测文件 MIME 类型
  • formatFileSize(bytes) — 格式化文件大小显示

String

字符串处理工具。

Validation

通用校验工具。

  • isEmail(str) — 邮箱格式校验
  • isURL(str) — URL 格式校验
  • isPhone(str) — 手机号格式校验

React

React Hooks 与组件层,提供对 Network 和 Utils 的响应式封装。

Hooks

useAuth

const { user, isLoggedIn, login, logout } = useAuth()

鉴权状态管理,自动处理 token 持久化与刷新。

useResources

const { resources, isLoading, error, refresh } = useResources(containerId)

获取指定容器下的资源列表,自动请求与缓存。

useFileUpload

const { upload, progress, isUploading } = useFileUpload(containerId)

文件上传,支持进度回调。

Provider

import { RhineBaseProvider } from 'rhine-base/react'

function App() {
  return (
    <RhineBaseProvider config={{ baseURL: '...' }}>
      <YourApp />
    </RhineBaseProvider>
  )
}

通过 Context 向组件树注入全局配置与鉴权状态。


项目结构

src/
├── index.ts              # 主入口,导出所有公共 API
├── types.ts              # 公共类型定义
├── network/
│   ├── index.ts          # Network 模块入口
│   ├── request.ts        # axios 实例与拦截器
│   ├── auth.ts           # 鉴权相关接口
│   └── resource.ts       # 文件与资源相关接口
├── utils/
│   ├── index.ts          # Utils 模块入口
│   ├── math.ts           # 数学工具
│   ├── file.ts           # 文件处理工具
│   ├── string.ts         # 字符串工具
│   └── validation.ts     # 校验工具
└── react/
    ├── index.ts          # React 模块入口
    ├── provider.tsx      # RhineBaseProvider
    ├── use-auth.ts       # 鉴权 Hook
    └── use-resources.ts  # 资源列表 Hook
    └── use-files.ts      # 文件列表 Hook

构建与发布

# 构建
bun run build

构建产物输出到 dist/,包含 ESM 模块与类型声明文件。