[add] first
This commit is contained in:
12
test/try/no-res-issue/client/index.ts
Normal file
12
test/try/no-res-issue/client/index.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import { TsrpcClient } from "../../..";
|
||||
import { serviceProto } from '../server/protocols/proto';
|
||||
|
||||
let client = new TsrpcClient({
|
||||
proto: serviceProto
|
||||
});
|
||||
|
||||
client.callApi('Test', { name: 'ssss' }).then(v => {
|
||||
console.log('then', v)
|
||||
}).catch(e => {
|
||||
console.log('catch', e)
|
||||
})
|
||||
10
test/try/no-res-issue/server/index.ts
Normal file
10
test/try/no-res-issue/server/index.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { TsrpcServer } from '../../../index';
|
||||
import { serviceProto } from './protocols/proto';
|
||||
|
||||
let server = new TsrpcServer({
|
||||
proto: serviceProto,
|
||||
});
|
||||
|
||||
server.autoImplementApi('src/api');
|
||||
|
||||
server.start();
|
||||
7
test/try/no-res-issue/server/protocols/PtlTest.ts
Normal file
7
test/try/no-res-issue/server/protocols/PtlTest.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
export interface ReqTest {
|
||||
name: string
|
||||
}
|
||||
|
||||
export interface ResTest {
|
||||
reply: string
|
||||
}
|
||||
52
test/try/no-res-issue/server/protocols/proto.ts
Normal file
52
test/try/no-res-issue/server/protocols/proto.ts
Normal file
@@ -0,0 +1,52 @@
|
||||
import { ServiceProto } from 'tsrpc-proto';
|
||||
import { ReqTest, ResTest } from './PtlTest'
|
||||
|
||||
export interface ServiceType {
|
||||
req: {
|
||||
"Test": ReqTest
|
||||
},
|
||||
res: {
|
||||
"Test": ResTest
|
||||
},
|
||||
msg: {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
export const serviceProto: ServiceProto<ServiceType> = {
|
||||
"services": [
|
||||
{
|
||||
"id": 0,
|
||||
"name": "Test",
|
||||
"type": "api",
|
||||
"req": "PtlTest/ReqTest",
|
||||
"res": "PtlTest/ResTest"
|
||||
}
|
||||
],
|
||||
"types": {
|
||||
"PtlTest/ReqTest": {
|
||||
"type": "Interface",
|
||||
"properties": [
|
||||
{
|
||||
"id": 0,
|
||||
"name": "name",
|
||||
"type": {
|
||||
"type": "String"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"PtlTest/ResTest": {
|
||||
"type": "Interface",
|
||||
"properties": [
|
||||
{
|
||||
"id": 0,
|
||||
"name": "reply",
|
||||
"type": {
|
||||
"type": "String"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
};
|
||||
18
test/try/no-res-issue/server/src/api/ApiTest.ts
Normal file
18
test/try/no-res-issue/server/src/api/ApiTest.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { ReqTest, ResTest } from "../../protocols/PtlTest";
|
||||
import { ApiCall } from "../../../../..";
|
||||
|
||||
export async function ApiTest(call: ApiCall<ReqTest, ResTest>) {
|
||||
await new Promise(rs => {
|
||||
let i = 5;
|
||||
call.logger.log(i);
|
||||
let interval = setInterval(() => {
|
||||
call.logger.log(--i);
|
||||
if (i === 0) {
|
||||
clearInterval(interval);
|
||||
rs();
|
||||
}
|
||||
}, 1000);
|
||||
});
|
||||
|
||||
call.error('asdfasdf', { a: 1, b: 2 })
|
||||
}
|
||||
Reference in New Issue
Block a user