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

@xiao-ying/miniapp-xy-kit

v1.1.0

Published

Reusable kit for XiaoYing backend miniapps

Downloads

82

Readme

@xiao-ying/miniapp-xy-kit

面向小应后端小程序的通用业务套件,基于 miniapp SDK 与 UI 体系封装常用能力与高阶组件。

安装

pnpm add @xiao-ying/miniapp-xy-kit

包含内容

  • 认证守卫与登录拦截
  • 请求客户端中间件(错误提示/登录过期处理)
  • 选校相关工具、状态与 UI 组件
  • 直传上传辅助

API 概览

  • createAuthGuardLoader:路由级登录守卫(配合 react-router-dom loader)。
  • createLoginInterceptor:请求 401 处理(默认触发 xy.signIn)。
  • createErrorToastMiddleware / defaultErrorSchema:请求错误 toast 提示。
  • directXyUpload:直传上传(先取 token,再上传文件)。
  • SchoolSelectionProvider / useSchoolSelection:选校状态与数据加载。
  • SchoolSelectionGate / SchoolSelectPanel:选校 UI 组件。
  • useSelectedSchool:轻量选中学校 Hook(env / storage 双源)。

快速示例

认证守卫(React Router):

import { createAuthGuardLoader } from '@xiao-ying/miniapp-xy-kit'

export const loader = createAuthGuardLoader({
  redirectTo: '/login'
})

请求中间件(miniapp-request):

import { createXyRequestClient } from '@xiao-ying/miniapp-request'
import {
  createLoginInterceptor,
  createErrorToastMiddleware
} from '@xiao-ying/miniapp-xy-kit'

const client = createXyRequestClient()
client.use(createLoginInterceptor())
client.use(createErrorToastMiddleware())

直传上传:

import { directXyUpload } from '@xiao-ying/miniapp-xy-kit'

const res = await directXyUpload({
  client,
  tokenUrl: '/api/upload/token',
  filePath: '/tmp/demo.jpg'
})
console.log(res.url)

选校状态:

import { SchoolSelectionProvider, useSelectedSchool } from '@xiao-ying/miniapp-xy-kit'

const App = () => (
  <SchoolSelectionProvider>
    <YourRoutes />
  </SchoolSelectionProvider>
)

const { school, isLocked } = useSelectedSchool()

依赖说明

该套件通常与以下包搭配使用:

  • @xiao-ying/miniapp-sdk
  • @xiao-ying/miniapp-hooks
  • @xiao-ying/miniapp-request
  • @xiao-ying/miniapp-ui-pro