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

nei-api

v2.0.6

Published

基于NEI生成前端所需要的接口文件和mock数据

Downloads

41

Readme

nei-api

基于 NEI 自动化生成 API 模拟数据和接口 SDK。只需一行命令,快速生成前端所需要的接口文件和 mock 数据!

安装

$ npm install nei-api -g

用法

同时生成接口文件和 mock 数据:

$ nei-api all

只生成 api 接口:

$ nei-api api

只生成 mock 数据:

$ nei-api mock

开启 mock 服务:

$ nei-api start

通过 AIGC 问答的方式修改指定路径下的 mock 数据:

$ nei-api ask /mock/xxx/xx.json "list返回10条不一样的数据"

配置

在项目的主目录下新建 nei.config.js 文件,配置内容如下

const cwdPath = process.cwd();
module.exports = {
  // 获取json文件的方式 1-本地获取 2-http获取
  TYPE: 1,
  // api.json文件本地路径
  API_FILE_PATH: `${cwdPath}/api.json`,
  // api 生成路径
  API_DIR_PATH: `${cwdPath}/src/services/`,
  // mock 生成路径
  MOCK_DIR_PATH: `${cwdPath}/mock/`,
  // api模板路径
  TPL_API_PATH: `${cwdPath}/tpl/@api/module.js`,
  // 自定义request本地路径
  REQUEST_PATH: "@/utils/request/request",
  // NEI数据源服务器
  NEI_SERVER: "https://nei.netease.com",
  // NEI项目ID(支持多项目配置)
  NEI_PID: "123,456",
  // NEI访问令牌
  PRIVATE_TOKEN: "xxxx",
  // 项目组的唯一标识 Key,在项目组的设置中查看
  PROGROUP_KEY: "xxxx",
  // OPENAI接口地址
  OPENAI_URL: "https://xxxx.com",
  // OPENAI官方提供的Api-key
  OPENAI_API_KEY: "xxxx",
  //由网易杭研内部系统提供的APP_ID,在console.openai.163.com中查看
  NETEASE_APP_ID: "xxxx",
  //由网易杭研内部系统提供的APP_KEY,在console.openai.163.com中查看
  NETEASE_API_KEY: "xxxx",
  // 项目关键词,可影响mock数据的生成(推荐用英文描述)
  PROMPTS: ["Contains information about the enterprise"],
};

配置参数说明

| 名称 | 类型 | 是否必需 | 说明 | | :-------------- | :----- | :------- | :------------------------------------------------------------------------------------------------------------------------------- | | TYPE | Int | 是 | 获取 json 文件的方式 1-本地获取 2-http 获 | | PRIVATE_TOKEN | String | 是 | NEI 访问令牌 | | PROGROUP_KEY | String | 是 | 项目的唯一标识 Key,在项目的设置中查看 | | REQUEST_PATH | String | 是 | 自定义 request 本地路径 | | NEI_PID | String | 是 | NEI 项目 ID(如果是多个,必须是同一个项目组里的) | | API_FILE_PATH | String | 否 | api.json 文件本地路径 | | API_DIR_PATH | String | 否 | api 生成路径 | | MOCK_DIR_PATH | Int | 否 | mock 生成路径 | | TPL_API_PATH | String | 否 | api 模板路径 | | NEI_SERVER | Int | 否 | NEI 数据源服务器 | | OPENAI_URL | String | 是 | OPENAI 接口地址,目前支持官方地址(需要填写 OPENAI_API_KEY)和网易杭研地址(需要填写 NETEASE_APP_ID 和 NETEASE_API_KEY)两种方式 | | OPENAI_API_KEY | String | 否 | OPENAI 官方后台提供的 Api-key | | NETEASE_APP_ID | String | 否 | 由网易杭研内部系统提供的 APP_ID,可在网易 AI 平台中查看 | | NETEASE_API_KEY | String | 否 | 由网易杭研内部系统提供的 APP_KEY,在网易 AI 平台中查看 | | PROMPTS | String | 否 | 项目关键词,可影响 mock 数据的生成(推荐用英文描述) |