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

@bestfulfill-inc/apifox-to-typescript

v0.2.8

Published

Apifox multi-project API generator CLI based on openapi-ts-request.

Readme

@bestfulfill-inc/apifox-to-typescript

安装

pnpm add -D @bestfulfill-inc/apifox-to-typescript

初始化配置

pnpm apifox init

该命令会创建 apifox.config.ts

import { defineConfig } from '@bestfulfill-inc/apifox-to-typescript';

export default defineConfig({
  apifoxToken: '',
  requestImport: "import { request } from '@/services/request'",
  outputBaseDir: 'src/services',
  projects: []
});

每个项目生成的文件会合并到同一个目录中:

src/services/
  projectId_<projectId>/
    request.ts
    types.ts
    mock.ts
    index.ts

生成 API

全量生成

pnpm apifox update

增量生成

pnpm apifox --p xx [--name <name>]
pnpm apifox --p xx --f xx [--name <name>]

--projectId / --folderId 仍兼容,但推荐用更短的 --p / --f

导出原始文档(不生成 TypeScript,二选一):

pnpm apifox --p xx --json
pnpm apifox --p xx --yaml

文档会写入项目输出目录,分别生成 openapi.jsonopenapi.yaml

其他配置

| 字段 | 类型 | 必填 | 说明 | | ---------------------- | ----------------------- | --- | --------------------------------------------------------------------------------------- | | apifoxToken | string | 否 | 共享的 Apifox API token;未配置时读取环境变量 APIFOX_ACCESS_TOKEN | | requestImport | string | 否 | 默认为 import { request } from '@/services/request';支持完整 import 语句,也支持模块路径,生成时会提取本地请求名 | | outputBaseDir | string | 否 | 默认为 src/services;生成项目目录的基础目录 | | projects | ApifoxProjectConfig[] | 否 | 项目生成列表;全量生成时为必填,仅使用 --p 增量生成时可为空 | | project.name | string | 否 | 本地项目标识,用于生成的输出目录名;默认值为 projectId_<id> | | project.projectId | string | 是 | Apifox 项目 ID | | selectedFolderIds | number[] | 否 | 导出时包含的 Apifox 接口分类/目录 ID。为空或省略时表示导出全部 | | isSplitTypesByFolder | boolean | 否 | 是否按 selectedFolderIds 自动拆分为 folderId_<id> 子目录,默认 false | | hook | ApifoxHookConfig | 否 | 支持函数名、类型名和请求调用表达式的定制 |

apifoxToken 外,顶层配置都可以放到项目级配置里覆盖。

Hook 扩展

hook 支持配置在顶层作为所有项目的默认值,也支持项目级覆盖。

import { defineConfig } from '@bestfulfill-inc/apifox-to-typescript';

export default defineConfig({
  apifoxToken: '',
  requestImport: "import { request } from '@/services/request'",
  outputBaseDir: 'src/services',
  hook: {
    customFunctionName(data, prefix) {
      return `${prefix ?? ''}${data.operationId ?? 'request'}`;
    },
    customTypeName(data) {
      return `${data.operationId ?? 'Request'}Result`;
    },
    customRequest({ method, url, params, responseType }, requestName) {
      return `${requestName}.${method}${responseType}(${url}${params ? `, ${params}` : ''})`;
    }
  },
  projects: []
});