@lzpong/httpm 1.0.0 → 1.0.2

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 (3) hide show
  1. package/README.md +3 -3
  2. package/httpm.js +5 -5
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -18,7 +18,7 @@
18
18
  ## 安装
19
19
 
20
20
  ```bash
21
- npm install httpm
21
+ npm install @lzpong/httpm
22
22
  ```
23
23
 
24
24
  或直接拷贝 `httpm.js` 到项目中:
@@ -30,7 +30,7 @@ const httpm = require('./httpm');
30
30
  ## 快速开始
31
31
 
32
32
  ```javascript
33
- const httpm = require('httpm');
33
+ const httpm = require('@lzpong/httpm');
34
34
  const app = httpm({ rootPath: './public', svrPort: 3000 });
35
35
 
36
36
  // 全局中间件
@@ -275,7 +275,7 @@ app._logger.error('Something went wrong', err);
275
275
  ### 独立使用
276
276
 
277
277
  ```javascript
278
- const { Logger } = require('httpm');
278
+ const { Logger } = require('@lzpong/httpm');
279
279
 
280
280
  const logger = new Logger({ level: 'debug', logDir: './logs', name: 'myapp' });
281
281
  logger.debug('Debug message');
package/httpm.js CHANGED
@@ -915,12 +915,12 @@ class WebSocket {
915
915
  switch (opcode) {
916
916
  case 0x01: { // 文本帧
917
917
  const text = payload.toString('utf8');
918
- this._emit('message', text);
918
+ this._emit('message', { type: 'text', data: text });
919
919
  this._emit('text', text);
920
920
  break;
921
921
  }
922
922
  case 0x02: { // 二进制帧
923
- this._emit('message', payload);
923
+ this._emit('message', { type: 'binary', data: payload });
924
924
  this._emit('binary', payload);
925
925
  break;
926
926
  }
@@ -2026,9 +2026,9 @@ class Application extends Router {
2026
2026
  const sseInstance = res.sse();
2027
2027
  const cleanup = handler(sseInstance, req);
2028
2028
  // 连接关闭时执行清理
2029
- res._res.on('close', () => {
2030
- if (typeof cleanup === 'function') cleanup();
2031
- });
2029
+ if (typeof cleanup === 'function') {
2030
+ res._res.on('close', cleanup);
2031
+ }
2032
2032
  });
2033
2033
  }
2034
2034
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lzpong/httpm",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "基于 Node.js 原生模块的单文件、零依赖 HTTP 服务库,兼容 Express API",
5
5
  "main": "httpm.js",
6
6
  "files": [