From 9700c9ae84071c8ff8d327a288125932acf67f57 Mon Sep 17 00:00:00 2001 From: npmstudy Date: Mon, 6 Nov 2023 12:13:24 +0800 Subject: [PATCH] chore: refact --- packages/core2/README.md | 2 +- packages/core2/app.ts | 8 ++++++++ packages/core2/src/index.ts | 4 +++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/packages/core2/README.md b/packages/core2/README.md index 6d80dda..e857da1 100644 --- a/packages/core2/README.md +++ b/packages/core2/README.md @@ -73,7 +73,7 @@ rpc.add({ // rpc.mount(); -rpc.listen(3000); +rpc.start(3000); ``` diff --git a/packages/core2/app.ts b/packages/core2/app.ts index 275efab..3e73c4e 100644 --- a/packages/core2/app.ts +++ b/packages/core2/app.ts @@ -12,6 +12,14 @@ rpc['fn']('/a', function (a) { return { a: a }; }); +rpc['add']({ + c: (a: string) => { + return a; + }, + a: function (a: string, b: string) { + return `${this.path} , ${a} c2 ${b}`; + }, +}); // rpc.plugin(fn); // rpc.plugin(demo); diff --git a/packages/core2/src/index.ts b/packages/core2/src/index.ts index a70bc00..b6e0fe7 100644 --- a/packages/core2/src/index.ts +++ b/packages/core2/src/index.ts @@ -13,7 +13,9 @@ export function createServer(cfg?: any) { rpc['fn'] = function (key, fun) { fn.fn(key, fun); }; - // rpc['add'] = fn.add; + rpc['add'] = function (items) { + fn.add(items); + }; rpc.plugin(fn);