Adding parameter and response validation.
Adding prettier formatting support. Add warning when no targets are selected.
This commit is contained in:
@ -1,18 +1,18 @@
|
||||
export const Logging = {
|
||||
export const Logging = {
|
||||
verbose: false,
|
||||
log(...args: any[]) {
|
||||
if(Logging.verbose) {
|
||||
console.log(...args)
|
||||
if (Logging.verbose) {
|
||||
console.log(...args);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
export enum ErrorCodes {
|
||||
ParseError=-32700,
|
||||
InvalidRequest=-32700,
|
||||
MethodNotFound=-32700,
|
||||
InvalidParams=-32700,
|
||||
InternalError=-32700,
|
||||
ParseError = -32700,
|
||||
InvalidRequest = -32700,
|
||||
MethodNotFound = -32700,
|
||||
InvalidParams = -32700,
|
||||
InternalError = -32700,
|
||||
}
|
||||
|
||||
export interface RequestObject {
|
||||
@ -25,6 +25,24 @@ export interface RequestObject {
|
||||
export interface ResponseObject {
|
||||
jsonrpc: "2.0";
|
||||
result?: any;
|
||||
error?: { code: ErrorCodes, message:string, data?: any}
|
||||
error?: { code: ErrorCodes; message: string; data?: any };
|
||||
id: string;
|
||||
}
|
||||
|
||||
export function verify_number(data: any) {
|
||||
if (typeof data !== "number") return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
export function verify_string(data: any) {
|
||||
if (typeof data !== "string") return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
export function verify_boolean(data: any) {
|
||||
if (typeof data !== "boolean") return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -34,7 +34,13 @@ export class ServiceProvider {
|
||||
} else {
|
||||
Logging.log("CLIENT: Determined type is Notification");
|
||||
//Notification. Send to Notification handler
|
||||
//TODO: Implement
|
||||
const [srvName, fncName] = msg.method.split(".");
|
||||
let service = this.services.get(srvName)
|
||||
if(!service) {
|
||||
Logging.log("CLIENT: Did not find Service wanted by Notification!", srvName);
|
||||
} else {
|
||||
//TODO: Implement Event thingy (or so :))
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Logging.log("CLIENT: Determined type is Response");
|
||||
|
Reference in New Issue
Block a user