@@ -26,7 +26,66 @@ TSW 2.0 是在 1.0 的基础上抽丝剥茧,辅以现代化的设计模式演
26
26
27
27
<h2 align =" center " >Quick Start</h2 >
28
28
29
- TODO
29
+ 首先,通过 npm 或者 yarn 安装 npm 包,` npm install --save @tswjs/tsw ` or ` yarn add @tswjs/tsw ` 。
30
+
31
+ 原本通过 ` node ./index.js ` 方式启动的应用,更换为 ` npx tsw ./index.js ` 。
32
+
33
+ ### Examples
34
+
35
+ 我们提供了一些示例项目以让大家尽快了解该项目。
36
+
37
+ 1 . ` cd ~ `
38
+ 2 . ` git clone https://github.com/Tencent/TSW.git `
39
+ 3 . ` cd TSW `
40
+
41
+ #### Native ` http.createServer `
42
+
43
+ 1 . ` cd examples/http-create-server `
44
+ 2 . ` npx tsw ./index.js `
45
+ 3 . ` curl -v localhost:4443/path/to/foo -X POST -d "hello, server" `
46
+
47
+ #### Koa
48
+
49
+ 1 . ` cd examples/koa `
50
+ 2 . ` yarn serve ` 或者 ` npm run serve `
51
+ 3 . ` curl -v localhost:4443/path/to/foo -X POST -d "hello, server" `
52
+
53
+ #### 使用 https://tswjs.org 开放平台
54
+
55
+ 在默认的情况下,TSW 只是会把所有的日志和抓包内容抓取到并且送到事件总线上,以供 [ 插件] ( #插件是什么? ) 消费。所以将日志和抓包内容落地查看一般需要用户自己编写插件以及提供存储,使用成本过于高昂。因此,TSW 官方提供了公共的服务平台,以供用户以更成本、更快、更方便地使用 TSW 的特性。使用方式如下:
56
+
57
+ 1 . 登录 https://tswjs.org 并在其上新建一个应用
58
+
59
+ ![ create-app] ( ./static/images/create-app.png )
60
+
61
+ 1 . 打开应用,获取 ` appid ` 和 ` appkey `
62
+
63
+ ![ appid-appkey] ( ./static/images/appid-appkey.png )
64
+
65
+ 1 . 在项目根目录下新增配置文件 ` tswconfig.json ` ,并将 ` appid ` 和 ` appkey ` 配置完成
66
+
67
+ ``` json
68
+ {
69
+ "appid" : " your-app-id" ,
70
+ "appkey" : " your-app-key" ,
71
+ "plugins" : [
72
+ " @tswjs/open-platform-plugin"
73
+ ]
74
+ }
75
+ ```
76
+
77
+ 1 . 向之前启动的 Koa 或者原生 http server 发送请求,并且在开放平台上查看对应的日志和抓包。查看地址为下方地址拼接而成 ` https://domain/log/view/demo `
78
+
79
+ ![ log-view] ( ./static/images/log-view.png )
80
+
81
+ ** 日志记录**
82
+
83
+ ![ log] ( ./static/images/log.png )
84
+
85
+ ** 在线查看抓包内容**
86
+
87
+ ![ capture] ( ./static/images/capture.png )
88
+
30
89
31
90
<h2 align =" center " >Plugins</h2 >
32
91
0 commit comments