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

gen-api-js

v1.0.6

Published

根据线上接口文档轻量化简易一键批量生成模块化 JavaScript/TypeScript API接口

Readme

gen-api-js

NPM Version Node Current NPM License

前言

为什么要开发这款工具? 传统前端每次和后端对接接口,如后端把接口文档放在线上文档,前端要去线上文档去复制接口的路径,然后又去前端的项目去写接口函数写注释这些,依次循环,如果后端的接口很多如二十、三十个这种, 你要复制二三十遍,这样不仅效率低而且还是个重复性乏味的劳动工作,为了解决这个问题 我开发了 了gen-api-js 它可以帮助你做这些事,对于大批量接口它可以给你很好的支持,但不过很遗憾的是 gen-api-js 它现在只支持 yapi,apifox,后续有需要将会支持更多的线上文档,敬请期待...

介绍

gen-api-js是一个代码生成工具,基于 puppeteerjs 开发, 它可以根据后端提供的线上接口文档然后批量模块化生成JavaScript/TypeScript前端代码接口函数

环境要求

首先得有 Node.js,并确保其版本 >= 14.15.0。

在线API网站文档的支持:


安装

选择你常用的包管理器将 gen-api-js 加入项目依赖即可:


# npm
npm i gen-api-js -g

# yarn
yarn add gen-api-js -g

# pnpm
pnpm add gen-api-js -g

使用

1.使用以下命令初始化配置文件你的项目根目录会生成一个文件名为api.config.js配置文件

// 初始化一个配置文件
 gen-api init

// 创建axios的文件
 gen-api init --axios filePath

2.使用以下命令运行gen-api:运行该命令生成完接口之后你的项目根目录会创建一个名为genApi.data.json的缓存文件,如你不要缓存你只需要在配置文件把 cache 设为 false 即可,但是我还是建议你开启缓存他可以检测你生成过的API不在去生成

 npx gen-api

3.使用以下命令自定义你的配置文件,gen-api 是从你的项目根目录查找你的配置文件:

 gen-api --c filaPath

4.使用以下命令运行你的自定义配置文件

 gen-api --p filaPath

api.config.js

  • 配置项

变更日志:

每个版本的详细变更记录在发行说明中。 发行说明

提问:

  • 使用明确、具体的标题描述问题。
  • 提供问题的详细描述,包括重现步骤、预期行为和实际行为。
  • 如果可能,附加屏幕截图或动画来说明问题。

贡献代码:

  • Fork项目到你的GitHub账户。
  • 编写代码时每个类需要继承Generator这个类,在项目src下core文件里面编写你的代码,文件名请和网站的名称一致,src/index.js 引入你的核心代码
  • 在本地开发和测试你的代码。
  • 提交Pull Request。

联系信息

如果你有任何问题或建议,请随时通过我的电子邮件([email protected])与我联系