diff --git a/package.json b/package.json index 78e6790..d40c780 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rpclibrary", - "version": "1.0.4", + "version": "1.1.0", "description": "", "main": "./js/Index.js", "scripts": { diff --git a/src/Backend.ts b/src/Backend.ts index a78d38d..8e62028 100644 --- a/src/Backend.ts +++ b/src/Backend.ts @@ -46,7 +46,7 @@ export class RPCServer< if(badRPC = exporters.flatMap(ex => ex.exportRPCs()).find(rpc => !rpc.name)) throw new Error(` RPC did not provide a name. - \nUse funtion name(..){ .. } syntax instead. + \nUse 'funtion name(..){ .. }' syntax instead. \n \n<------------OFFENDING RPC: \n`+badRPC.toString()+` diff --git a/src/Types.ts b/src/Types.ts index f7010e9..2603b34 100644 --- a/src/Types.ts +++ b/src/Types.ts @@ -48,7 +48,7 @@ export type BaseInfo = { export type HookInfo = BaseInfo & { type: 'Hook', - generator: (socket) => HookFunction + generator: (socket?:I.Socket) => HookFunction } export type CallInfo = BaseInfo & { @@ -61,6 +61,6 @@ export type ExtendedRpcInfo = RpcInfo & { uniqueName: string } export type OnFunction = (type: 'error' | 'close', f: (e?:any)=>void) => I.Socket export type HookCloseFunction = (res:SubscriptionResponse, rpc:HookRPC) => any -export type HookFunction = (...args:[any, ...any[]]) => Promise | ErrorResponse> -export type AsyncFunction = (...args:any[]) => Promise -export type CallbackFunction = (...args:any[]) => void \ No newline at end of file +export type HookFunction = (...args:any) => Promise | ErrorResponse> +export type AsyncFunction = (...args:any) => Promise +export type CallbackFunction = (...args:any) => void \ No newline at end of file diff --git a/src/Utils.ts b/src/Utils.ts index 32b9e50..0f292cf 100644 --- a/src/Utils.ts +++ b/src/Utils.ts @@ -28,7 +28,7 @@ export const rpcToRpcinfo = (rpc : T.RPC, owner: T.Owner) case "function": if(!rpc.name) throw new Error(` RPC did not provide a name. -\nUse funtion name(..){ .. } syntax instead. +\nUse 'funtion name(..){ .. }' syntax instead. \n \n<------------OFFENDING RPC: \n`+rpc.toString()+` diff --git a/test/TestBackend.ts b/test/TestBackend.ts index 6975b25..44edaa2 100644 --- a/test/TestBackend.ts +++ b/test/TestBackend.ts @@ -24,18 +24,18 @@ new RPCServer(20000, [{ subcallback = callback return makeSubResponse() }, - onClose: (res:SubscriptionResponse, rpc:HookRPC) => { + onClose: (res, rpc) => { console.log("Specific close handler for", rpc.name, res) subcallback = null }, - onCallback: (...args:any) => { console.log.apply(console, args) } + onCallback: (...args) => { console.log.apply(console, args) } }, function add(...args:number[]):number {return args.reduce((a,b)=>a+b, 0)}, function triggerCallback(...messages:any[]):number {return subcallback.apply({}, messages)}, ] }]) -new RPCServer<{ topic: string}>(20001, [{ +new RPCServer<{ topic: string }>(20001, [{ name: "HelloWorldRPCGroup", exportRPCs: () => [ {