whistle.pastekitlab 1.5.2 → 1.5.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +11 -10
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -139,13 +139,14 @@ function broadcast(type, data) {
139
139
  module.exports = (server, options) => {
140
140
  log('插件已启动(使用 request/response 钩子)');
141
141
  startWebSocketServer();
142
- // server.on('request', (req, res) => {
143
- // console.log('>>> [GLOBAL]', req.fullUrl);
144
- // });
142
+ server.on('request', (req, res) => {
143
+ console.log('>>> [GLOBAL]', req.fullUrl);
144
+ // 不拦截,让 whistle 默认处理
145
+ });
145
146
 
146
147
  return {
147
148
  // ✅ 监听请求
148
- request: (req, res) => {
149
+ request: (req, res, next) => {
149
150
  try {
150
151
  console.info("req:" + JSON.stringify(req))
151
152
  const url = req.fullUrl || req.url;
@@ -168,18 +169,18 @@ module.exports = (server, options) => {
168
169
  } catch (e) {
169
170
  log('request error: ' + e.message);
170
171
  }
171
- // next(); // ⚠️ 必须调用!
172
+ next(); // ⚠️ 必须调用,让 whistle 继续代理
172
173
  },
173
174
 
174
175
  // ✅ 监听响应
175
- response: (req, res) => {
176
+ response: (req, res, next) => {
176
177
  try {
177
178
  console.info("rsp:" + JSON.stringify(req))
178
179
 
179
180
  const url = req.fullUrl || req.url;
180
- // if (!shouldIntercept(url)) {
181
- // return next();
182
- // }
181
+ if (!shouldIntercept(url)) {
182
+ return next();
183
+ }
183
184
 
184
185
  const data = {
185
186
  eventId: generateId(),
@@ -197,7 +198,7 @@ module.exports = (server, options) => {
197
198
  } catch (e) {
198
199
  log('response error: ' + e.message);
199
200
  }
200
- // next(); // ⚠️ 必须调用!
201
+ next(); // ⚠️ 必须调用,继续后续处理
201
202
  }
202
203
  };
203
204
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "whistle.pastekitlab",
3
- "version": "1.5.2",
3
+ "version": "1.5.4",
4
4
  "description": "Whistle plugin for PasteKit Lab - Intercepts requests and sends them to requestlistviewer via WebSocket",
5
5
  "main": "index.js",
6
6
  "scripts": {