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

@xm-fe/create-api

v1.0.7

Published

API快速导入

Downloads

9

Readme

⚡️ 简介

鲜沐科技 前端API生成工具

📌使用前须知

  1. 需要安装 Apifox 客户端
  2. 生成的所有的文件请勿手动修改,所有的改动请让后端修改文档后前端再重新导入
  3. 该工具生成的同名文件会覆盖
  4. 如果接口需要加前缀,比如 summerfarm-manage 请让后端在接口文档上直接生成(不是后端手动改文档)

❗❗❗因为所有的流程都是工具生成, 前后端对接口文档的操作请勿手动修改,以免后来的同学覆盖了原来手动修改的接口

更新日志

1.0.7

  • feat: 增加 summerfarm-inventory-center

🔧使用步骤

1. 安装

npm i @xm-fe/create-api -g

运行capi命令时,会读取当前项目根目下的的 capi.config.js文件,该文件中的配置会覆盖默认配置文件。

capi.config.js 具体配置及解释看文末

2. 配置

在项目根目录下新建 capi.config.js 文件

使用方式

运行命令后,生成的请求文件会生成到 apix/项目projectId对应的文件名/接口名

使用方式一 (推荐)

capi http://127.0.0.1:4523/export/openapi/5?version=3.0

直接使用导出的地址,无需再拼写 projectId

备注:此方法不适用于 全部导出,如需全部导出请使用 方式二 或 三

使用方式二

capi http://127.0.0.1:4523/export/openapi/9?version=3.0 954456

命令组成:capi apifox导出的URL projectId

使用方式三

capi

读取项目根目录配置文件 capi.config 中的 remotePath

默认项目配置

{
        954456: 'SAAS',
        1164722: 'summerfarm-manage',
        1164725: 'pms-service',
        1295278: 'summerfarm-crm',
        1409074: 'TMS',
        1965722: 'summerfarm-wms',
        2020406: 'OFC',
        2437205: 'saas-manage',
        2437206: 'saas-oms',
        2437207: 'saas-mall',
        2517920: 'summerfarm-wnc',
        2546551: 'saas-pms',
        2546569: 'SCP',
        2546585: 'SRM',
        2546600: 'bms-service',
        2737704: 'summerfarm-mall',
        3061191: 'common-service',
        3031557: 'xianmu-authentication',
        3464154: 'sf-mall-manage'
}

缺少的项目 请联系我加进去 禁止私自手动修改文件名

⚙️capi.config.js 配置,分为 javascript 和 typescript 两个版本

javascript项目中使用

module.exports = {
  remotePath: `http://127.0.0.1:4523/export/openapi/4?version=3.0&projectId=xxxx`,
  language: 'js',
  // 插入的模板代码
  getApiCodeTpl(api) {
    const pathParams = api.pathParams
      .map((param) => `${param.name},`)
      .join('\r\n')
    return `
import net from '@/libs/net'
/**
  * ${api.summary}
  */
export function ${api.fileName || api.name}(
  ${pathParams ? pathParams : ''}
  ${api.queryParams ? `params,` : ''}
  ${api.bodyParams ? `data,` : ''}
) {
  return net(
    {
      url: \`${api.url}\`,
      method: '${api.method}',
      ${api.queryParams ? `params,` : ''}
      ${api.bodyParams ? ` data` : ''}
    }
  )
}`
  }
}

typescript项目中使用

module.exports = {
  remotePath: `http://127.0.0.1:4523/export/openapi/4?version=3.0&projectId=xxxx`,
  language: 'ts', // 生成的语言的使用方式 默认 'ts', 可选值:'js' | 'ts'
  // 插入的模板代码
  getApiCodeTpl(api) {
    const pathParams = api.pathParams
      .map((param) => `${param.name}${param.required ? '' : '?'}: ${param._type},`)
      .join('\r\n')
    return `
  import net from '@/utils/net'
  import { NetConfig } from '@/interface/IAxiosConfig'
  /**
   * ${api.summary}
   */
export function ${api.fileName || api.name}(
    ${pathParams ? pathParams : ''}
    ${api.queryParams ? `params?: ${api.queryParams._name},` : ''}
    ${api.bodyParams ? `data?: ${api.bodyParams._name},` : ''}
    config?: NetConfig
  ): Promise<${api.resType}> {
    return net(
      {
        url: \`${api.url}\`,
        method: '${api.method}',
        ${api.isDownload ? `_download: true,` : ''}
        ${api.queryParams ? `params,` : ''}
        ${api.bodyParams ? ` data,` : ''}
      },
      config
    )
  }
  `
  }
}

版本

1.0.6

  • 增加 sf-mall-manage apifox工程

1.0.5

  • 增加 xianmu-authentication apifox工程

1.0.4

  • 对manage项目apix中已生成的接口进行接口响应兼容处理

1.0.2

  • 修复二维数组生成问题[[''], ['', '', '']]

0.0.5

  • 支持js版本
  • 优化体验

0.0.1

  • 初始化

🚀 开发


# 安装依赖
npm i
# 发布流程

# 编译
npm run build
# 本项目
npm link

# 引用调试的项目
npm link 包名

# 取消关联
npm unlink 包名

# 查看
npm ls -g