typespeed 2.6.1 → 2.6.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.
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,7 @@ typespeed 版本演进记录。本文件 2026-09-06 从 git 历史反推建立
|
|
|
4
4
|
|
|
5
5
|
## 2.6.x
|
|
6
6
|
|
|
7
|
+
- **2.6.2**:框架内建健康检查——新增 `HealthFactory`(abstract `ready()`)+ `HealthDefault`(默认恒就绪);`ExpressServer` 内建 `GET /health`(liveness)与 `GET /ready`(readiness,读 HealthFactory,200/503),路径可经 config 覆盖(2026-09-07)
|
|
7
8
|
- **2.6.1**:Node/TS 升级——TypeScript 4.9 → 5.9.3(legacy 装饰器零改动兼容,标准装饰器双轨同步验证);`@types/node` 对齐 22;声明 `engines`(node >=18)(2026-09-07)
|
|
8
9
|
|
|
9
10
|
## 2.5.x
|
|
@@ -22,6 +22,7 @@ const route_decorator_1 = require("../route.decorator");
|
|
|
22
22
|
const socket_io_class_1 = require("../default/socket-io.class");
|
|
23
23
|
const typespeed_1 = require("../typespeed");
|
|
24
24
|
const core_decorator_1 = require("../core.decorator");
|
|
25
|
+
const health_factory_class_1 = require("../factory/health-factory.class");
|
|
25
26
|
const redis_class_1 = require("./redis.class");
|
|
26
27
|
const authentication_factory_class_1 = require("../factory/authentication-factory.class");
|
|
27
28
|
class ExpressServer extends server_factory_class_1.default {
|
|
@@ -83,6 +84,23 @@ class ExpressServer extends server_factory_class_1.default {
|
|
|
83
84
|
}
|
|
84
85
|
(0, route_decorator_1.setRouter)(this.app);
|
|
85
86
|
this.app.use(this.authentication.afterCompletion);
|
|
87
|
+
// 健康检查(k8s liveness / readiness 探针)
|
|
88
|
+
const healthConfig = (0, typespeed_1.config)("health") || {};
|
|
89
|
+
const livenessPath = healthConfig["liveness"] || "/health";
|
|
90
|
+
const readinessPath = healthConfig["readiness"] || "/ready";
|
|
91
|
+
this.app.get(livenessPath, (req, res) => {
|
|
92
|
+
res.status(200).json({ status: "up" });
|
|
93
|
+
});
|
|
94
|
+
this.app.get(readinessPath, (req, res) => {
|
|
95
|
+
let ready = true;
|
|
96
|
+
try {
|
|
97
|
+
ready = (0, core_decorator_1.getBean)(health_factory_class_1.default).ready();
|
|
98
|
+
}
|
|
99
|
+
catch (e) {
|
|
100
|
+
ready = false;
|
|
101
|
+
}
|
|
102
|
+
res.status(ready ? 200 : 503).json({ status: ready ? "ready" : "not-ready" });
|
|
103
|
+
});
|
|
86
104
|
const errorPageDir = __dirname + "/pages";
|
|
87
105
|
this.app.use((req, res) => {
|
|
88
106
|
(0, core_decorator_1.error)("404 not found, for page: " + req.url);
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const core_decorator_1 = require("../core.decorator");
|
|
13
|
+
const health_factory_class_1 = require("../factory/health-factory.class");
|
|
14
|
+
/**
|
|
15
|
+
* 健康检查默认实现:恒为就绪。
|
|
16
|
+
* 应用继承 HealthFactory 并用 @bean 注册自定义实现,即可覆盖默认行为(如接入数据库/Redis 连通性检查)。
|
|
17
|
+
*/
|
|
18
|
+
class HealthDefault extends health_factory_class_1.default {
|
|
19
|
+
createHealth() {
|
|
20
|
+
return new HealthDefault();
|
|
21
|
+
}
|
|
22
|
+
ready() {
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.default = HealthDefault;
|
|
27
|
+
__decorate([
|
|
28
|
+
core_decorator_1.bean,
|
|
29
|
+
__metadata("design:type", Function),
|
|
30
|
+
__metadata("design:paramtypes", []),
|
|
31
|
+
__metadata("design:returntype", health_factory_class_1.default)
|
|
32
|
+
], HealthDefault.prototype, "createHealth", null);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/**
|
|
4
|
+
* 健康检查工厂(抽象)。
|
|
5
|
+
* 实现 ready() 自定义「就绪检查」(readiness)——如检查数据库/Redis/MQ 连通性。
|
|
6
|
+
* 应用继承此类并用 @bean 注册自定义实现;默认实现见 HealthDefault(恒就绪)。
|
|
7
|
+
*/
|
|
8
|
+
class HealthFactory {
|
|
9
|
+
}
|
|
10
|
+
exports.default = HealthFactory;
|
package/dist/typespeed.d.ts
CHANGED
|
@@ -280,6 +280,14 @@ declare abstract class AuthenticationFactory {
|
|
|
280
280
|
*/
|
|
281
281
|
afterCompletion(req: express.Request, res: express.Response, next: express.NextFunction): void;
|
|
282
282
|
}
|
|
283
|
+
/**健康检查工厂类,实现 ready() 自定义就绪检查(readiness) */
|
|
284
|
+
declare abstract class HealthFactory {
|
|
285
|
+
abstract ready(): boolean;
|
|
286
|
+
}
|
|
287
|
+
/**健康检查默认实现类,默认恒为就绪 */
|
|
288
|
+
declare class HealthDefault extends HealthFactory {
|
|
289
|
+
ready(): boolean;
|
|
290
|
+
}
|
|
283
291
|
/**Redis 操作类 */
|
|
284
292
|
declare class Redis extends IoRedis {
|
|
285
293
|
/**获取 Redis 实例 */
|
|
@@ -400,4 +408,4 @@ declare class SocketIo {
|
|
|
400
408
|
/**Socket IO 服务实现类 */
|
|
401
409
|
declare const io: IoServer;
|
|
402
410
|
|
|
403
|
-
export { ExpressServer, LogDefault, NodeCache, RabbitMQ, rabbitListener, redisSubscriber, ReadWriteDb, Redis, CacheFactory, DataSourceFactory, LogFactory, ServerFactory, AuthenticationFactory, next, reqBody, reqQuery, reqForm, reqParam, req, req as request, res, res as response, component, bean, resource, log, logx, app, before, after, value, error, config, autoware, getBean, getComponent, schedule, getMapping, postMapping, requestMapping, setRouter, upload, jwt, insert, update, remove, select, param, bind, resultType, cache, Model, SocketIo, io };
|
|
411
|
+
export { ExpressServer, LogDefault, NodeCache, RabbitMQ, rabbitListener, redisSubscriber, ReadWriteDb, Redis, CacheFactory, DataSourceFactory, LogFactory, ServerFactory, AuthenticationFactory, HealthFactory, HealthDefault, next, reqBody, reqQuery, reqForm, reqParam, req, req as request, res, res as response, component, bean, resource, log, logx, app, before, after, value, error, config, autoware, getBean, getComponent, schedule, getMapping, postMapping, requestMapping, setRouter, upload, jwt, insert, update, remove, select, param, bind, resultType, cache, Model, SocketIo, io };
|
package/dist/typespeed.js
CHANGED
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.ReadWriteDb = exports.redisSubscriber = exports.Redis = exports.NodeCache = exports.LogDefault = exports.ExpressServer = exports.AuthenticationFactory = exports.ServerFactory = exports.DataSourceFactory = exports.CacheFactory = exports.LogFactory = void 0;
|
|
17
|
+
exports.ReadWriteDb = exports.redisSubscriber = exports.Redis = exports.NodeCache = exports.HealthDefault = exports.LogDefault = exports.ExpressServer = exports.HealthFactory = exports.AuthenticationFactory = exports.ServerFactory = exports.DataSourceFactory = exports.CacheFactory = exports.LogFactory = void 0;
|
|
18
18
|
exports.app = app;
|
|
19
19
|
exports.value = value;
|
|
20
20
|
exports.config = config;
|
|
@@ -145,10 +145,14 @@ var server_factory_class_1 = require("./factory/server-factory.class");
|
|
|
145
145
|
Object.defineProperty(exports, "ServerFactory", { enumerable: true, get: function () { return server_factory_class_1.default; } });
|
|
146
146
|
var authentication_factory_class_1 = require("./factory/authentication-factory.class");
|
|
147
147
|
Object.defineProperty(exports, "AuthenticationFactory", { enumerable: true, get: function () { return authentication_factory_class_1.default; } });
|
|
148
|
+
var health_factory_class_1 = require("./factory/health-factory.class");
|
|
149
|
+
Object.defineProperty(exports, "HealthFactory", { enumerable: true, get: function () { return health_factory_class_1.default; } });
|
|
148
150
|
var express_server_class_1 = require("./default/express-server.class");
|
|
149
151
|
Object.defineProperty(exports, "ExpressServer", { enumerable: true, get: function () { return express_server_class_1.default; } });
|
|
150
152
|
var log_default_class_1 = require("./default/log-default.class");
|
|
151
153
|
Object.defineProperty(exports, "LogDefault", { enumerable: true, get: function () { return log_default_class_1.default; } });
|
|
154
|
+
var health_default_class_1 = require("./default/health-default.class");
|
|
155
|
+
Object.defineProperty(exports, "HealthDefault", { enumerable: true, get: function () { return health_default_class_1.default; } });
|
|
152
156
|
var node_cache_class_1 = require("./default/node-cache.class");
|
|
153
157
|
Object.defineProperty(exports, "NodeCache", { enumerable: true, get: function () { return node_cache_class_1.default; } });
|
|
154
158
|
var redis_class_1 = require("./default/redis.class");
|