examples to new tsrpc-cli

This commit is contained in:
King Wang
2021-10-07 15:30:02 +08:00
parent c21445548e
commit 69a90884d5
86 changed files with 652 additions and 1697 deletions

View File

@@ -4,20 +4,20 @@
"main": "index.js",
"private": true,
"scripts": {
"proto": "tsrpc proto -i src/shared/protocols -o src/shared/protocols/serviceProto.ts",
"sync": "tsrpc sync --from src/shared --to ../frontend/src/shared",
"api": "tsrpc api -i src/shared/protocols/serviceProto.ts -o src/api",
"dev": "onchange \"src/**/*.ts\" -i -k -- ts-node \"src/index.ts\"",
"build": "tsrpc build"
"proto": "tsrpc proto --config tsrpc.config.ts",
"sync": "tsrpc sync --config tsrpc.config.ts",
"api": "tsrpc api --config tsrpc.config.ts",
"dev": "tsrpc dev --config tsrpc.config.ts",
"build": "tsrpc build --config tsrpc.config.ts"
},
"devDependencies": {
"@types/node": "^15.14.1",
"@types/node": "^15.14.9",
"onchange": "^7.1.0",
"ts-node": "^10.0.0",
"tsrpc-cli": "^2.0.3",
"typescript": "^4.3.5"
"ts-node": "^10.2.1",
"tsrpc-cli": "^2.0.8",
"typescript": "^4.4.3"
},
"dependencies": {
"tsrpc": "^3.0.4"
"tsrpc": "^3.0.9"
}
}

View File

@@ -0,0 +1,36 @@
import { TsrpcConfig } from 'tsrpc-cli';
const tsrpcConf: TsrpcConfig = {
// Generate ServiceProto
proto: [
{
ptlDir: 'src/shared/protocols', // Protocol dir
output: 'src/shared/protocols/serviceProto.ts', // Path for generated ServiceProto
apiDir: 'src/api' // API dir
}
],
// Sync shared code
sync: [
{
from: 'src/shared',
to: '../frontend/src/shared',
type: 'copy' // Change this to 'copy' if your environment not support symlink
}
],
// Dev server
dev: {
autoProto: true, // Auto regenerate proto
autoSync: true, // Auto sync when file changed
autoApi: true, // Auto create API when ServiceProto updated
watch: 'src', // Restart dev server when these files changed
entry: 'src/index.ts', // Dev server command: node -r ts-node/register {entry}
},
// Build config
build: {
autoProto: true, // Auto generate proto before build
autoSync: true, // Auto sync before build
autoApi: true, // Auto generate API before build
outDir: 'dist', // Clean this dir before build
}
}
export default tsrpcConf;

View File

@@ -7,17 +7,17 @@
"tsrpc-laya": "index.js"
},
"dependencies": {
"core-js": "^3.15.2",
"core-js": "^3.18.2",
"k8w-extend-native": "^1.4.5",
"k8w-linq-array": "^0.2.7",
"k8w-super-date": "^0.1.2",
"k8w-super-date": "^0.1.3",
"k8w-super-object": "^0.3.0",
"tsbuffer": "^2.0.4",
"tsbuffer-schema": "^2.0.2",
"tsbuffer-validator": "^2.0.4",
"tslib": "^2.3.0",
"tsrpc-base-client": "^1.0.6",
"tsrpc-browser": "^3.0.4",
"tslib": "^2.3.1",
"tsrpc-base-client": "^1.0.11",
"tsrpc-browser": "^3.0.7",
"tsrpc-proto": "^1.3.4"
},
"scripts": {