mirror of
https://github.com/kevin-DL/services.git
synced 2026-01-23 15:51:24 +00:00
Generate clients (#206)
This commit is contained in:
43
clients/ts/helloworld/index.ts
Executable file
43
clients/ts/helloworld/index.ts
Executable file
@@ -0,0 +1,43 @@
|
||||
import * as m3o from "@m3o/m3o-node";
|
||||
|
||||
export class HelloworldService {
|
||||
private client: m3o.Client;
|
||||
|
||||
constructor(token: string) {
|
||||
this.client = new m3o.Client({ token: token });
|
||||
}
|
||||
// Call returns a personalised "Hello $name" response
|
||||
call(request: CallRequest): Promise<CallResponse> {
|
||||
return this.client.call(
|
||||
"helloworld",
|
||||
"Call",
|
||||
request
|
||||
) as Promise<CallResponse>;
|
||||
}
|
||||
// Stream returns a stream of "Hello $name" responses
|
||||
stream(request: StreamRequest): Promise<StreamResponse> {
|
||||
return this.client.call(
|
||||
"helloworld",
|
||||
"Stream",
|
||||
request
|
||||
) as Promise<StreamResponse>;
|
||||
}
|
||||
}
|
||||
|
||||
export interface CallRequest {
|
||||
name?: string;
|
||||
}
|
||||
|
||||
export interface CallResponse {
|
||||
message?: string;
|
||||
}
|
||||
|
||||
export interface StreamRequest {
|
||||
// the number of messages to send back
|
||||
messages?: number;
|
||||
name?: string;
|
||||
}
|
||||
|
||||
export interface StreamResponse {
|
||||
message?: string;
|
||||
}
|
||||
Reference in New Issue
Block a user