[add] first
This commit is contained in:
21
test/try/server/api/ApiTest.ts
Normal file
21
test/try/server/api/ApiTest.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { TsrpcError } from "tsrpc-proto";
|
||||
import { ApiCallHttp } from '../../../src/server/http/HttpCall';
|
||||
import { ReqTest } from "../../proto/PtlTest";
|
||||
import { ResTest } from '../../proto/a/b/c/PtlTest';
|
||||
|
||||
export async function ApiTest(call: ApiCallHttp<ReqTest, ResTest>) {
|
||||
if (Math.random() > 0.75) {
|
||||
call.succ({
|
||||
reply: 'Hello, ' + call.req.name
|
||||
})
|
||||
}
|
||||
else if (Math.random() > 0.5) {
|
||||
call.error('What the fuck??', { msg: '哈哈哈哈' })
|
||||
}
|
||||
else if (Math.random() > 0.25) {
|
||||
throw new Error('这应该是InternalERROR')
|
||||
}
|
||||
else {
|
||||
throw new TsrpcError('返回到前台的错误', 'ErrInfo');
|
||||
}
|
||||
}
|
||||
5
test/try/server/api/a/b/c/ApiTest.ts
Normal file
5
test/try/server/api/a/b/c/ApiTest.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
export async function ApiTest(call: any) {
|
||||
call.succ({
|
||||
reply: 'Api Test1 Succ'
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user