JsonRPC/templates/ts_service_base.ts

31 lines
599 B
TypeScript
Raw Permalink Normal View History

export const Logging = {
verbose: false,
log(...args: any[]) {
if (Logging.verbose) {
console.log(...args);
}
},
};
export enum ErrorCodes {
ParseError = -32700,
InvalidRequest = -32600,
MethodNotFound = -32601,
InvalidParams = -32602,
InternalError = -32603,
}
export interface RequestObject {
jsonrpc: "2.0";
method: string;
params?: any[] | { [key: string]: any };
id?: string | null;
}
export interface ResponseObject {
jsonrpc: "2.0";
result?: any;
error?: { code: ErrorCodes; message: string; data?: any };
id: string;
}