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

@faapi/faapi

v3.1.0

Published

函数即接口 - Function as API

Downloads

2,556

Readme

faapi

函数即接口 — Function as API

faapi 是一个 Node.js 框架,核心理念是"函数即接口"。编写普通 TypeScript 函数即可暴露为 HTTP / WebSocket 接口,类型校验由 TypeScript AST 自动生成,无需手写 schema。

安装

pnpm add @faapi/faapi
# 或
npm install @faapi/faapi

要求 Node.js >= 24。faapi 仅支持 ESM(type: "module"),不提供 CJS 产物。

快速开始

// api/user/handler.ts
export interface Query {
  page: number;
  pageSize: number;
}

export function GET(query: Query) {
  return { page: query.page, pageSize: query.pageSize };
}
# 启动 dev server
npx faapi

访问 http://localhost:3000/api/user?page=1&pageSize=10 即可。

# 生产部署
faapi build                # 编译 .ts → dist/,生成路由清单 + schema + dist/main.js
node dist/main             # 启动生产服务器

核心能力

  • 函数即接口:导出 GET/POST 等函数即声明路由
  • AST 类型校验:TypeScript Compiler API 自动生成运行时校验
  • 洋葱模型中间件:(ctx, next) => {}
  • 依赖注入:注入器按参数名匹配 handler 参数
  • WebSocket 路由:导出 WS 函数声明
  • SSE 流式响应:ctx.sse() 推送
  • 动态路由:[id] / [...slug] / (group)
  • MCP 集成:LLM 可查询路由 schema
  • 配置文件:faapi.config.ts 统一响应格式、全局错误处理、生命周期钩子、全局中间件/注入器
  • ESM only

文档

完整文档见 GitHub 仓库

许可证

MIT