Generate clients (#206)

This commit is contained in:
Janos Dobronszki
2021-09-16 12:52:36 +01:00
committed by GitHub
parent 552c321dd7
commit d4d9c1c176
334 changed files with 9334 additions and 45 deletions

39
clients/ts/id/index.ts Executable file
View File

@@ -0,0 +1,39 @@
import * as m3o from "@m3o/m3o-node";
export class IdService {
private client: m3o.Client;
constructor(token: string) {
this.client = new m3o.Client({ token: token });
}
// Generate a unique ID. Defaults to uuid.
generate(request: GenerateRequest): Promise<GenerateResponse> {
return this.client.call(
"id",
"Generate",
request
) as Promise<GenerateResponse>;
}
// List the types of IDs available. No query params needed.
types(request: TypesRequest): Promise<TypesResponse> {
return this.client.call("id", "Types", request) as Promise<TypesResponse>;
}
}
export interface GenerateRequest {
// type of id e.g uuid, shortid, snowflake (64 bit), bigflake (128 bit)
type?: string;
}
export interface GenerateResponse {
// the unique id generated
id?: string;
// the type of id generated
type?: string;
}
export interface TypesRequest {}
export interface TypesResponse {
types?: string[];
}