有赞云网关 SDK for Node 使用教程
open-sdk-node有赞云网关 SDK for Node项目地址:https://gitcode.com/gh_mirrors/op/open-sdk-node
1. 项目的目录结构及介绍
open-sdk-node/
├── adaptor/
├── client/
├── code-gen/
├── consts/
├── dispatcher/
├── doc/
├── http/
├── logger/
├── typings/
├── utils/
├── ws-client/
├── .eslintignore
├── .eslintrc.js
├── .gitignore
├── .prettierignore
├── .prettierrc.json
├── LICENSE
├── README.md
├── README.zh.md
├── index.ts
├── jest.config.ts
├── package.json
├── rollup.config.js
├── tsconfig.json
└── yarn.lock
目录结构介绍
adaptor/
: 适配器相关文件。client/
: 客户端相关文件。code-gen/
: 代码生成相关文件。consts/
: 常量定义文件。dispatcher/
: 分发器相关文件。doc/
: 文档文件。http/
: HTTP 相关文件。logger/
: 日志相关文件。typings/
: 类型定义文件。utils/
: 工具类文件。ws-client/
: WebSocket 客户端相关文件。.eslintignore
: ESLint 忽略配置文件。.eslintrc.js
: ESLint 配置文件。.gitignore
: Git 忽略配置文件。.prettierignore
: Prettier 忽略配置文件。.prettierrc.json
: Prettier 配置文件。LICENSE
: 项目许可证。README.md
: 项目英文介绍文档。README.zh.md
: 项目中文介绍文档。index.ts
: 项目入口文件。jest.config.ts
: Jest 测试配置文件。package.json
: 项目依赖和脚本配置文件。rollup.config.js
: Rollup 打包配置文件。tsconfig.json
: TypeScript 配置文件。yarn.lock
: Yarn 锁定文件。
2. 项目的启动文件介绍
项目的启动文件是 index.ts
。这个文件是整个项目的入口点,负责初始化和启动整个应用程序。
// index.ts
import { start } from './app';
start();
3. 项目的配置文件介绍
package.json
package.json
文件包含了项目的依赖、脚本和其他元数据。
{
"name": "open-sdk-node",
"version": "1.0.0",
"description": "有赞云网关 SDK for Node",
"main": "index.ts",
"scripts": {
"build": "rollup -c",
"test": "jest"
},
"dependencies": {
"axios": "^0.21.1",
"ws": "^7.4.5"
},
"devDependencies": {
"@types/jest": "^26.0.20",
"jest": "^26.6.3",
"rollup": "^2.38.5",
"typescript": "^4.1.3"
}
}
.eslintrc.js
.eslintrc.js
文件是 ESLint 的配置文件,用于定义代码风格和规则。
module.exports = {
root: true,
parser: '@typescript-eslint/parser',
plugins: [
'@typescript-eslint',
],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
],
};
tsconfig.json
tsconfig.json
文件是 TypeScript 的配置文件,用于定义 TypeScript 编译选项。
{
"compilerOptions": {
"target": "ES2020",
"module": "commonjs",
"outDir": "./dist",
"strict": true,
"esModuleInterop": true
},
"include": [
"src/**/*"
open-sdk-node有赞云网关 SDK for Node项目地址:https://gitcode.com/gh_mirrors/op/open-sdk-node