@maiyunnet/kebab 3.2.23 → 3.2.24

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.
package/index.d.ts CHANGED
@@ -5,7 +5,7 @@
5
5
  * --- 本文件用来定义每个目录实体地址的常量 ---
6
6
  */
7
7
  /** --- 当前系统版本号 --- */
8
- export declare const VER = "3.2.23";
8
+ export declare const VER = "3.2.24";
9
9
  /** --- 框架根目录,以 / 结尾 --- */
10
10
  export declare const ROOT_PATH: string;
11
11
  export declare const LIB_PATH: string;
package/index.js CHANGED
@@ -6,7 +6,7 @@
6
6
  * --- 本文件用来定义每个目录实体地址的常量 ---
7
7
  */
8
8
  /** --- 当前系统版本号 --- */
9
- export const VER = '3.2.23';
9
+ export const VER = '3.2.24';
10
10
  // --- 服务端用的路径 ---
11
11
  const imu = decodeURIComponent(import.meta.url).replace('file://', '').replace(/^\/(\w:)/, '$1');
12
12
  /** --- /xxx/xxx --- */
package/lib/kv.d.ts CHANGED
@@ -301,6 +301,7 @@ export declare class Connection {
301
301
  * --- 获取字符串 ---
302
302
  * @param key
303
303
  * @param etc
304
+ * @returns 字符串或 null(即使存入时是 number,这个方法也只会返回字符串)
304
305
  */
305
306
  get(key: string, etc: kebab.IConfigKv): Promise<string | null>;
306
307
  /**
package/lib/kv.js CHANGED
@@ -823,6 +823,7 @@ end`;
823
823
  * --- 获取字符串 ---
824
824
  * @param key
825
825
  * @param etc
826
+ * @returns 字符串或 null(即使存入时是 number,这个方法也只会返回字符串)
826
827
  */
827
828
  async get(key, etc) {
828
829
  this.refreshLast();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@maiyunnet/kebab",
3
- "version": "3.2.23",
3
+ "version": "3.2.24",
4
4
  "description": "Simple, easy-to-use, and fully-featured Node.js framework that is ready-to-use out of the box.",
5
5
  "type": "module",
6
6
  "keywords": [
package/sys/child.js CHANGED
@@ -90,7 +90,7 @@ async function run() {
90
90
  const host = (req.headers[':authority'] ?? req.headers['host'] ?? '');
91
91
  if (!host) {
92
92
  lCore.writeHead(res, 403);
93
- res.end();
93
+ res.end('403 Forbidden');
94
94
  return;
95
95
  }
96
96
  const key = host + req.url;
@@ -141,6 +141,7 @@ async function run() {
141
141
  httpServer = http.createServer(function (req, res) {
142
142
  const host = (req.headers['host'] ?? '');
143
143
  if (!host) {
144
+ res.setHeader('x-kebab-error', '0');
144
145
  lCore.writeHead(res, 403);
145
146
  res.end();
146
147
  return;
@@ -233,6 +234,7 @@ async function requestHandler(req, res, https) {
233
234
  /** --- 当前的 vhost 配置文件 --- */
234
235
  const vhost = await getVhostByHostname(uri.hostname ?? '');
235
236
  if (!vhost) {
237
+ res.setHeader('x-kebab-error', '1');
236
238
  lCore.writeHead(res, 403);
237
239
  res.end();
238
240
  return;
@@ -553,7 +555,7 @@ process.on('message', function (msg) {
553
555
  for (const key in linkCount) {
554
556
  str.push(key + ':' + linkCount[key].toString());
555
557
  }
556
- lCore.display(`[CHILD] Worker ${process.pid} busy: ${str.join(',')}.`);
558
+ lCore.debug(`[CHILD] Worker ${process.pid} busy: ${str.join(',')}.`);
557
559
  lCore.log({}, `[CHILD] Worker ${process.pid} busy: ${str.join(',')}.`, '-warning');
558
560
  await lCore.sleep(30_000);
559
561
  waiting += 30_000;
package/sys/mod.d.ts CHANGED
@@ -342,6 +342,10 @@ export default class Mod {
342
342
  * --- 根据当前条件,筛选出当前条目该有的数据条数 ---
343
343
  */
344
344
  count(): Promise<number>;
345
+ /**
346
+ * --- 获取当前条件下的 count 的 SQL 语句 ---
347
+ */
348
+ countSql(): string;
345
349
  /**
346
350
  * @param f 表名
347
351
  * @param s ON 信息
package/sys/mod.js CHANGED
@@ -1184,7 +1184,7 @@ class Mod {
1184
1184
  * --- 根据当前条件,筛选出当前条目该有的数据条数 ---
1185
1185
  */
1186
1186
  async count() {
1187
- const sql = this._sql.getSql().replace(/SELECT .+? FROM/, 'SELECT COUNT(*) AS `count` FROM');
1187
+ const sql = this._sql.getSql().replace(/SELECT .+? FROM/, 'SELECT COUNT(0) AS `count` FROM');
1188
1188
  const r = await this._db.query(sql, this._sql.getData());
1189
1189
  if (r.rows === null) {
1190
1190
  lCore.log(this._ctr ?? {}, '[count, mod] ' + lText.stringifyJson(r.error?.message ?? '').slice(1, -1).replace(/"/g, '""'), '-error');
@@ -1196,6 +1196,13 @@ class Mod {
1196
1196
  }
1197
1197
  return count;
1198
1198
  }
1199
+ /**
1200
+ * --- 获取当前条件下的 count 的 SQL 语句 ---
1201
+ */
1202
+ countSql() {
1203
+ const sql = this._sql.getSql().replace(/SELECT .+? FROM/, 'SELECT COUNT(0) AS `count` FROM');
1204
+ return this._sql.format(sql, this._sql.getData());
1205
+ }
1199
1206
  /**
1200
1207
  * @param f 表名
1201
1208
  * @param s ON 信息
package/sys/route.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Project: Kebab, User: JianSuoQiYue
3
3
  * Date: 2019-4-15 13:40
4
- * Last: 2020-4-14 13:52:00, 2022-09-07 01:43:31, 2023-12-29 17:24:03, 2024-2-7 00:28:50, 2024-6-6 15:15:54, 2025-6-13 19:23:53, 2025-9-22 15:48:53, 2025-9-23 11:26:50
4
+ * Last: 2020-4-14 13:52:00, 2022-09-07 01:43:31, 2023-12-29 17:24:03, 2024-2-7 00:28:50, 2024-6-6 15:15:54, 2025-6-13 19:23:53, 2025-9-22 15:48:53, 2025-9-23 11:26:50, 2025-10-30 17:44:41
5
5
  */
6
6
  import * as http from 'http';
7
7
  import * as http2 from 'http2';
package/sys/route.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Project: Kebab, User: JianSuoQiYue
3
3
  * Date: 2019-4-15 13:40
4
- * Last: 2020-4-14 13:52:00, 2022-09-07 01:43:31, 2023-12-29 17:24:03, 2024-2-7 00:28:50, 2024-6-6 15:15:54, 2025-6-13 19:23:53, 2025-9-22 15:48:53, 2025-9-23 11:26:50
4
+ * Last: 2020-4-14 13:52:00, 2022-09-07 01:43:31, 2023-12-29 17:24:03, 2024-2-7 00:28:50, 2024-6-6 15:15:54, 2025-6-13 19:23:53, 2025-9-22 15:48:53, 2025-9-23 11:26:50, 2025-10-30 17:44:41
5
5
  */
6
6
  import * as http from 'http';
7
7
  import * as stream from 'stream';
@@ -12,7 +12,6 @@ import * as lFs from '#kebab/lib/fs.js';
12
12
  import * as lZlib from '#kebab/lib/zlib.js';
13
13
  import * as lCore from '#kebab/lib/core.js';
14
14
  import * as lText from '#kebab/lib/text.js';
15
- import * as lTime from '#kebab/lib/time.js';
16
15
  import * as lResponse from '#kebab/lib/net/response.js';
17
16
  import * as lWs from '#kebab/lib/ws.js';
18
17
  import * as lLang from '#kebab/lib/lang.js';
@@ -567,7 +566,7 @@ export async function run(data) {
567
566
  }
568
567
  // --- 设置缓存 ---
569
568
  if (!data.res.headersSent && (cacheTTL > 0)) {
570
- data.res.setHeader('expires', lTime.format(0, 'D, d M Y H:i:s', Date.now() + cacheTTL * 1000) + ' GMT');
569
+ data.res.setHeader('expires', new Date(Date.now() + cacheTTL * 1_000).toUTCString());
571
570
  data.res.setHeader('cache-control', 'max-age=' + cacheTTL.toString());
572
571
  }
573
572
  // --- 设置自定义 hcode ---