From 9ac9deaa8fb45999e2fd669eb6c491467ef52567 Mon Sep 17 00:00:00 2001 From: kingecg Date: Wed, 1 Mar 2023 21:50:09 +0800 Subject: [PATCH] add design --- README.md | 31 +++++++++++++++++++++++++++++++ model/def.ts | 9 +++++++++ package.json | 16 ++++++++++++++++ 3 files changed, 56 insertions(+) create mode 100644 model/def.ts create mode 100644 package.json diff --git a/README.md b/README.md index cc23e4b..a09d748 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,33 @@ # http-gateway +a lib for create gateway between and other protocol + +interface + +- create 创建http服务器app +- registryHandlerFactory 注册protocol处理器工厂 +- app.registryPath + +## HandlerFactory + +一个函数或者拥有静态createHandler方法的class + +工厂函数/createHandler方法签名 + +```typescript +interface HandlerFn { + (options: any): (req:Request,resp: Response)=>void +} + +interface HandlerClass { + createHandler: HandlerFn +} + +type HandlerFactory = HandlerFn | HandlerClass +``` + +## registryHandlerFactory + +```typescript +registryHandlerFactory(type:string, HandlerFactory) +``` \ No newline at end of file diff --git a/model/def.ts b/model/def.ts new file mode 100644 index 0000000..8d87c78 --- /dev/null +++ b/model/def.ts @@ -0,0 +1,9 @@ +interface HandlerFn { + (options: any): (req:Request,resp: Response)=>void +} + +interface HandlerClass { + createHandler: HandlerFn +} + +type HandlerFactory = HandlerFn | HandlerClass \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..9671607 --- /dev/null +++ b/package.json @@ -0,0 +1,16 @@ +{ + "name": "http-gateway", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "ssh://git@git.pyer.club:2222/kingecg/http-gateway.git" + }, + "keywords": [], + "author": "", + "license": "ISC" +}