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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@yhclt/apifox-cli

v1.0.5

Published

apifox转换成apifox-interface.ts和api接口函数

Downloads

186

Readme

apifox-cli

基于 APIFOX 平台,帮助开发者快速生成前端项目中的 API 请求代码和 TypeScript 类型定义。

安装与配置

  1. 全局安装
# 使用 npm 进行全局安装:
npm i @yhclt/apifox-cli -g

# 全局移除
npm uninstall -g @yhclt/apifox-cli
  1. 初始化配置
// 在项目根目录运行 apifox-cli init 命令来生成配置文件 apifox.config.cjs
module.exports = {
  module: 'web', // web | wx
  projectId: 0000000, // 访问https://app.apifox.com/main 查看你的项目id
  output: 'src/api', // 输出目录
  importHttp: `import { http } from '@/utils/http'`,
  // 访问https://app.apifox.com/main从某个接口的请求头里面copy
  Authorization: 'Bearer XXXXXX',
}

生成代码

# 更新所有接口
apifox-cli create --type=all

# 按文件夹模块更新接口
apifox-cli create --type=module

# 按文件夹模块更新接口 --prefixPath参数可以给接口path增加统一的前缀
apifox-cli create --type=module --prefixPath=testPrefix

# 按api接口精确更新
apifox-cli create --type=api

查看帮助

// 执行:apifox-cli help 查看帮助文档
// 在项目中配置 eslint 忽略文件
// ignorePatterns 与 rules 一个级别的 (不推荐,建议使用项目中的格式化保存)
"ignorePatterns": [ "src/apis/**/*.ts" ],

注意事项

  • 确保在 apifox.config.cjs 中填写正确的 projectId,这通常可以在 APIFOX 平台上找到。
  • 如果接口文档中有授权信息,需要在配置文件中正确设置 Authorization 字段。
  • 使用 --prefixPath 参数可以为生成的接口路径添加统一的前缀,这在某些项目结构中可能很有用。

补充