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

yct

v1.0.0

Published

yapi 接口转化成ts 类型文件

Downloads

5

Readme

YCT

Yapi 生成 Typescript请求方法声明文件工具

插件安装

  1. 全局包:使用npm install -g yct全局安装即可

插件使用

概念说明

层级关系:分组项目模块接口

全局包使用方式

使用说明:

// 生成默认配置
$ yct -i
// 根据项目修改配置后
$ yct -g

完整功能列表:

$ yct --help
Options:
  -v, --version   获取当前版本
  -i, --init      初始化配置文件
  -g, --generate  生成接口文档
  • -v, --version:获取包的版本号
  • -i, --init:初始化配置文件,会放在项目当前执行目录下的yct.config.js
  • -g, --generate:根据配置生成接口文件,当没有配置时会初始化默认配置

配置文件

工具默认会去寻找当前工作区的yct.config.js文件,该文件默认导出一个对象

配置示例

module.exports = {
  // 账号
  account: '[email protected]',
  // 密码
  password: 'xxxxxx',
  // Yapi网址链接
  originUrl: 'https://yapi.xxxx.cn',
  // 输出目录
  outDir: './src/apis',
  // 项目跟请求方法映射
  projectMapping: {
  	// 项目跟请求方法映射(projectId为生成目录id)
  	// 参考url https://yapi.xxxx.cn/project/216/interface/api
  	// 其中216就是projectId,当未配置时y2t也会有相应的projectId提示
    216: {
      exportName: 'API',
      // 返回报文泛式
      // wrapper: '{ code: string, message: string, data: T }',
    },
  },
};

配置具体说明

  • account:账号
  • password:密码
  • originUrl:Yapi 网址地址
  • outDir:输出目录,相对于当前工作区的根目录
  • projectMapping:项目映射。在微服务盛行的现在一个工程中可能会有多个 api 地址,所以这里按照项目id进行了请求方法映射。
    • projectId:项目 ID,例如url:https://xxx.xxx.com/project/216/interface/api,其中216即为项目ID
    • exportName:请求方法名称,为了兼容不同的请求库,所以生成的代码中不会直接生成 ajax 请求方法,需要外部传入,这里的exportName一般就是你配置好了的axios实例