Skip to content

Latest commit

 

History

History
73 lines (60 loc) · 2.07 KB

README.zh-CN.md

File metadata and controls

73 lines (60 loc) · 2.07 KB

English Document

nest-canddy

nest-canddy 是一个无侵入代码的CLI工具,它可以快速生成前端可用的TypeScript SDK代码,用于发起http请求。同时,它还提供一个可视化的web ui界面,用于简单的展示项目模块结构。

功能

  • 快速生成前端用于发起RESTful请求的TypeScript SDK代码
  • 提供Web UI可视化界面

安装

你可以通过npm或yarn安装nest-canddy

yarn add -g nest-canddy
//or
npm install -g nest-canddy

作为服务端

如果你当前的角色是使用nestjs框架的服务器开发人员:

  1. 在nestjs的项目根目录下新增nestcanddy.config.js
module.exports = {
    server:{
		port: 13270,//作为提供SDK拉取服务的端口号
		outputPath:'./output',//生成SDK的保存目录
	},
}

2.接下来,你可以生成前端Typescript SDK代码。

nests generate
//or
nests g

nest-canddy-demo-3 3.你也可以使用Web UI来查看和生成生成前端Typescript SDK代码。

nests server
//or
nests s

nest-canddy-demo-3

作为客户端

如果你当前的角色是使用Typescript开发任何项目的前端开发人员:

  1. 在nestjs的项目根目录下新增nestcanddy.config.cjs
module.exports = {
	client:{
		host: 'localhost:13270',//后端提供的SDK服务地址
		outputPath:'./output',//SDK输出到当前项目的相对路径
		httpAdapterPath:'axios',//发起http请求的适配器引用路径
		httpAdapterName:'axios',//发起http请求的适配器引用名称
		responseWrapperType:'{AxiosResponse}',//返回类型包裹类型
		responseWrapperTypePath:'axios',//返回类型包裹类型路径
	}
}

2.接下来,你可以拉取前端Typescript SDK代码。

nestc get
//or
nestc g

nest-canddy-demo-3