typespeed 2.5.2 → 2.6.1
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 +4 -0
- package/dist/bind.decorator.js +2 -3
- package/dist/core.decorator.js +10 -11
- package/dist/database.decorator.js +8 -8
- package/dist/decorator-utils.js +2 -3
- package/dist/default/default-authentication.class.js +1 -1
- package/dist/default/express-server.class.js +1 -1
- package/dist/default/log-default.class.js +1 -1
- package/dist/default/node-cache.class.js +1 -1
- package/dist/default/rabbitmq.class.js +3 -3
- package/dist/default/read-write-db.class.js +1 -1
- package/dist/default/redis.class.js +3 -3
- package/dist/route.decorator.js +15 -15
- package/dist/typespeed.js +6 -7
- package/package.json +6 -3
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
typespeed 版本演进记录。本文件 2026-09-06 从 git 历史反推建立;git 最早提交 2022-09-18(ch01)。
|
|
4
4
|
|
|
5
|
+
## 2.6.x
|
|
6
|
+
|
|
7
|
+
- **2.6.1**:Node/TS 升级——TypeScript 4.9 → 5.9.3(legacy 装饰器零改动兼容,标准装饰器双轨同步验证);`@types/node` 对齐 22;声明 `engines`(node >=18)(2026-09-07)
|
|
8
|
+
|
|
5
9
|
## 2.5.x
|
|
6
10
|
|
|
7
11
|
- **2.5.2**:README 重写(专业丰富版:30+ 装饰器分类、书籍体系突出)+ 新增英文版 `README.en.md`(中英切换,默认中文)(2026-09-07)
|
package/dist/bind.decorator.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.bind = bind;
|
|
4
|
+
exports.getBindMapping = getBindMapping;
|
|
4
5
|
const decorator_utils_1 = require("./decorator-utils");
|
|
5
6
|
/**
|
|
6
7
|
* 方法级参数绑定注册表:key = `[className, methodName]`,value = 绑定声明。
|
|
@@ -42,9 +43,7 @@ function bind(mapping) {
|
|
|
42
43
|
bindParamMap.set([target.constructor.name, propertyKey].toString(), mapping);
|
|
43
44
|
};
|
|
44
45
|
}
|
|
45
|
-
exports.bind = bind;
|
|
46
46
|
/** 读取某方法上的 @bind 声明(route/database 内部使用) */
|
|
47
47
|
function getBindMapping(className, methodName) {
|
|
48
48
|
return bindParamMap.get([className, methodName].toString());
|
|
49
49
|
}
|
|
50
|
-
exports.getBindMapping = getBindMapping;
|
package/dist/core.decorator.js
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.component = component;
|
|
4
|
+
exports.bean = bean;
|
|
5
|
+
exports.resource = resource;
|
|
6
|
+
exports.log = log;
|
|
7
|
+
exports.logx = logx;
|
|
8
|
+
exports.error = error;
|
|
9
|
+
exports.autoware = autoware;
|
|
10
|
+
exports.getBean = getBean;
|
|
11
|
+
exports.getComponent = getComponent;
|
|
12
|
+
exports.schedule = schedule;
|
|
4
13
|
require("reflect-metadata");
|
|
5
14
|
const cron = require("cron");
|
|
6
15
|
const log_factory_class_1 = require("./factory/log-factory.class");
|
|
@@ -19,11 +28,9 @@ function component(...args) {
|
|
|
19
28
|
const constructorFunction = args[0];
|
|
20
29
|
objectMapper.set(constructorFunction.name, new constructorFunction());
|
|
21
30
|
}
|
|
22
|
-
exports.component = component;
|
|
23
31
|
function getComponent(constructorFunction) {
|
|
24
32
|
return objectMapper.get(constructorFunction.name);
|
|
25
33
|
}
|
|
26
|
-
exports.getComponent = getComponent;
|
|
27
34
|
function bean(...args) {
|
|
28
35
|
if (args.length >= 2) {
|
|
29
36
|
// 直接装饰器形式:@bean(无 token,走 legacy design:returntype)
|
|
@@ -32,7 +39,6 @@ function bean(...args) {
|
|
|
32
39
|
// 工厂形式:@bean(Token)(显式返回类型 token,标准模式必需)
|
|
33
40
|
return beanWithToken(args[0]);
|
|
34
41
|
}
|
|
35
|
-
exports.bean = bean;
|
|
36
42
|
function beanWithToken(token) {
|
|
37
43
|
return function (...args) {
|
|
38
44
|
if ((0, decorator_utils_1.isStd)(args)) {
|
|
@@ -59,7 +65,6 @@ function getBean(mappingClass) {
|
|
|
59
65
|
const bean = beanMapper.get(mappingClass.name);
|
|
60
66
|
return bean["factory"];
|
|
61
67
|
}
|
|
62
|
-
exports.getBean = getBean;
|
|
63
68
|
function autoware(...args) {
|
|
64
69
|
if (args.length >= 2) {
|
|
65
70
|
// 直接装饰器形式:@autoware(无 token,走 legacy design:type)
|
|
@@ -68,7 +73,6 @@ function autoware(...args) {
|
|
|
68
73
|
// 工厂形式:@autoware(Token)(显式 token,标准模式必需)
|
|
69
74
|
return autowareWithToken(args[0]);
|
|
70
75
|
}
|
|
71
|
-
exports.autoware = autoware;
|
|
72
76
|
function autowareWithToken(token) {
|
|
73
77
|
return function (...args) {
|
|
74
78
|
if ((0, decorator_utils_1.isStd)(args)) {
|
|
@@ -138,7 +142,6 @@ function resource(...args) {
|
|
|
138
142
|
});
|
|
139
143
|
};
|
|
140
144
|
}
|
|
141
|
-
exports.resource = resource;
|
|
142
145
|
function log(message, ...optionalParams) {
|
|
143
146
|
const logObject = beanMapper.get(log_factory_class_1.default.name);
|
|
144
147
|
if (logObject) {
|
|
@@ -148,7 +151,6 @@ function log(message, ...optionalParams) {
|
|
|
148
151
|
console.log(message, ...optionalParams);
|
|
149
152
|
}
|
|
150
153
|
}
|
|
151
|
-
exports.log = log;
|
|
152
154
|
function logx(message) {
|
|
153
155
|
message = JSON.stringify(message);
|
|
154
156
|
const logObject = beanMapper.get(log_factory_class_1.default.name);
|
|
@@ -159,7 +161,6 @@ function logx(message) {
|
|
|
159
161
|
console.log(message);
|
|
160
162
|
}
|
|
161
163
|
}
|
|
162
|
-
exports.logx = logx;
|
|
163
164
|
function error(message, ...optionalParams) {
|
|
164
165
|
const logObject = beanMapper.get(log_factory_class_1.default.name);
|
|
165
166
|
if (logObject) {
|
|
@@ -169,7 +170,6 @@ function error(message, ...optionalParams) {
|
|
|
169
170
|
console.error(message, ...optionalParams);
|
|
170
171
|
}
|
|
171
172
|
}
|
|
172
|
-
exports.error = error;
|
|
173
173
|
function schedule(cronTime) {
|
|
174
174
|
return (...args) => {
|
|
175
175
|
if ((0, decorator_utils_1.isStd)(args)) {
|
|
@@ -184,4 +184,3 @@ function schedule(cronTime) {
|
|
|
184
184
|
new cron.CronJob(cronTime, target[propertyKey]).start();
|
|
185
185
|
};
|
|
186
186
|
}
|
|
187
|
-
exports.schedule = schedule;
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Model =
|
|
3
|
+
exports.Model = void 0;
|
|
4
|
+
exports.insert = insert;
|
|
5
|
+
exports.update = update;
|
|
6
|
+
exports.remove = remove;
|
|
7
|
+
exports.select = select;
|
|
8
|
+
exports.param = param;
|
|
9
|
+
exports.resultType = resultType;
|
|
10
|
+
exports.cache = cache;
|
|
4
11
|
const core_decorator_1 = require("./core.decorator");
|
|
5
12
|
const decorator_utils_1 = require("./decorator-utils");
|
|
6
13
|
const bind_decorator_1 = require("./bind.decorator");
|
|
@@ -38,7 +45,6 @@ function insert(sql) {
|
|
|
38
45
|
};
|
|
39
46
|
};
|
|
40
47
|
}
|
|
41
|
-
exports.insert = insert;
|
|
42
48
|
function update(sql) {
|
|
43
49
|
return (...args) => {
|
|
44
50
|
if ((0, decorator_utils_1.isStd)(args)) {
|
|
@@ -66,7 +72,6 @@ function update(sql) {
|
|
|
66
72
|
};
|
|
67
73
|
};
|
|
68
74
|
}
|
|
69
|
-
exports.update = update;
|
|
70
75
|
function remove(sql) {
|
|
71
76
|
return (...args) => {
|
|
72
77
|
if ((0, decorator_utils_1.isStd)(args)) {
|
|
@@ -94,7 +99,6 @@ function remove(sql) {
|
|
|
94
99
|
};
|
|
95
100
|
};
|
|
96
101
|
}
|
|
97
|
-
exports.remove = remove;
|
|
98
102
|
function select(sql) {
|
|
99
103
|
return (...args) => {
|
|
100
104
|
if ((0, decorator_utils_1.isStd)(args)) {
|
|
@@ -144,7 +148,6 @@ function select(sql) {
|
|
|
144
148
|
};
|
|
145
149
|
};
|
|
146
150
|
}
|
|
147
|
-
exports.select = select;
|
|
148
151
|
function resultType(dataClass) {
|
|
149
152
|
return function (...args) {
|
|
150
153
|
if ((0, decorator_utils_1.isStd)(args)) {
|
|
@@ -160,7 +163,6 @@ function resultType(dataClass) {
|
|
|
160
163
|
//never return
|
|
161
164
|
};
|
|
162
165
|
}
|
|
163
|
-
exports.resultType = resultType;
|
|
164
166
|
function param(name) {
|
|
165
167
|
return function (target, propertyKey, parameterIndex) {
|
|
166
168
|
const existingParameters = Reflect.getOwnMetadata(paramMetadataKey, target, propertyKey) || [];
|
|
@@ -168,7 +170,6 @@ function param(name) {
|
|
|
168
170
|
Reflect.defineMetadata(paramMetadataKey, existingParameters, target, propertyKey);
|
|
169
171
|
};
|
|
170
172
|
}
|
|
171
|
-
exports.param = param;
|
|
172
173
|
async function queryForExecute(sql, args, target, propertyKey) {
|
|
173
174
|
const [newSql, sqlValues] = convertSQLParams(sql, target, propertyKey, args);
|
|
174
175
|
return actionExecute(newSql, sqlValues);
|
|
@@ -255,7 +256,6 @@ function cache(ttl) {
|
|
|
255
256
|
}
|
|
256
257
|
};
|
|
257
258
|
}
|
|
258
|
-
exports.cache = cache;
|
|
259
259
|
function getTableAndVersion(name, sql) {
|
|
260
260
|
const regExpMap = {
|
|
261
261
|
insert: /insert\sinto\s+([\w`\'\"]+)/i,
|
package/dist/decorator-utils.js
CHANGED
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
* 因此库可以单份源码、运行时按签名形态分流:legacy 分支逻辑与 2.4.x 逐字一致,标准分支为新增。
|
|
13
13
|
*/
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.
|
|
15
|
+
exports.isStd = isStd;
|
|
16
|
+
exports.getStdArgs = getStdArgs;
|
|
16
17
|
/**
|
|
17
18
|
* 判断装饰器收到的运行时参数是否为标准装饰器签名 (value, context)。
|
|
18
19
|
*
|
|
@@ -31,7 +32,6 @@ function isStd(args) {
|
|
|
31
32
|
&& args[1] !== null
|
|
32
33
|
&& typeof args[1].kind === "string";
|
|
33
34
|
}
|
|
34
|
-
exports.isStd = isStd;
|
|
35
35
|
/**
|
|
36
36
|
* 从标准装饰器参数中解出 (value, context)。
|
|
37
37
|
* 仅应在 isStd(args) 为 true 时调用。
|
|
@@ -39,4 +39,3 @@ exports.isStd = isStd;
|
|
|
39
39
|
function getStdArgs(args) {
|
|
40
40
|
return [args[0], args[1]];
|
|
41
41
|
}
|
|
42
|
-
exports.getStdArgs = getStdArgs;
|
|
@@ -16,10 +16,10 @@ class DefaultAuthentication extends authentication_factory_class_1.default {
|
|
|
16
16
|
return new DefaultAuthentication();
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
|
+
exports.default = DefaultAuthentication;
|
|
19
20
|
__decorate([
|
|
20
21
|
core_decorator_1.bean,
|
|
21
22
|
__metadata("design:type", Function),
|
|
22
23
|
__metadata("design:paramtypes", []),
|
|
23
24
|
__metadata("design:returntype", authentication_factory_class_1.default)
|
|
24
25
|
], DefaultAuthentication.prototype, "getAuthentication", null);
|
|
25
|
-
exports.default = DefaultAuthentication;
|
|
@@ -115,6 +115,7 @@ class ExpressServer extends server_factory_class_1.default {
|
|
|
115
115
|
});
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
|
+
exports.default = ExpressServer;
|
|
118
119
|
__decorate([
|
|
119
120
|
(0, typespeed_1.value)("view"),
|
|
120
121
|
__metadata("design:type", String)
|
|
@@ -165,4 +166,3 @@ __decorate([
|
|
|
165
166
|
__metadata("design:paramtypes", []),
|
|
166
167
|
__metadata("design:returntype", server_factory_class_1.default)
|
|
167
168
|
], ExpressServer.prototype, "getSever", null);
|
|
168
|
-
exports.default = ExpressServer;
|
|
@@ -16,10 +16,10 @@ class LogDefault extends log_factory_class_1.default {
|
|
|
16
16
|
return new LogDefault();
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
|
+
exports.default = LogDefault;
|
|
19
20
|
__decorate([
|
|
20
21
|
core_decorator_1.bean,
|
|
21
22
|
__metadata("design:type", Function),
|
|
22
23
|
__metadata("design:paramtypes", []),
|
|
23
24
|
__metadata("design:returntype", log_factory_class_1.default)
|
|
24
25
|
], LogDefault.prototype, "createLog", null);
|
|
25
|
-
exports.default = LogDefault;
|
|
@@ -38,6 +38,7 @@ class NodeCache extends cache_factory_class_1.default {
|
|
|
38
38
|
this.NodeCache.flushAll();
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
|
+
exports.default = NodeCache;
|
|
41
42
|
__decorate([
|
|
42
43
|
(0, typespeed_1.value)("cache"),
|
|
43
44
|
__metadata("design:type", Object)
|
|
@@ -48,4 +49,3 @@ __decorate([
|
|
|
48
49
|
__metadata("design:paramtypes", []),
|
|
49
50
|
__metadata("design:returntype", cache_factory_class_1.default)
|
|
50
51
|
], NodeCache.prototype, "getNodeCache", null);
|
|
51
|
-
exports.default = NodeCache;
|
|
@@ -9,7 +9,8 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
9
9
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.
|
|
12
|
+
exports.RabbitMQ = void 0;
|
|
13
|
+
exports.rabbitListener = rabbitListener;
|
|
13
14
|
const core_decorator_1 = require("../core.decorator");
|
|
14
15
|
const typespeed_1 = require("../typespeed");
|
|
15
16
|
const amqplib_1 = require("amqplib");
|
|
@@ -41,13 +42,13 @@ class RabbitMQ {
|
|
|
41
42
|
await this.sendMessageToQueue(queue, message);
|
|
42
43
|
}
|
|
43
44
|
}
|
|
45
|
+
exports.RabbitMQ = RabbitMQ;
|
|
44
46
|
__decorate([
|
|
45
47
|
core_decorator_1.bean,
|
|
46
48
|
__metadata("design:type", Function),
|
|
47
49
|
__metadata("design:paramtypes", []),
|
|
48
50
|
__metadata("design:returntype", RabbitMQ)
|
|
49
51
|
], RabbitMQ.prototype, "getRabbitMQ", null);
|
|
50
|
-
exports.RabbitMQ = RabbitMQ;
|
|
51
52
|
async function getChannel() {
|
|
52
53
|
if (rabbitConnection === null) {
|
|
53
54
|
rabbitConnection = await (0, amqplib_1.connect)((0, typespeed_1.config)("rabbitmq"));
|
|
@@ -84,4 +85,3 @@ function rabbitListener(queue) {
|
|
|
84
85
|
}());
|
|
85
86
|
};
|
|
86
87
|
}
|
|
87
|
-
exports.rabbitListener = rabbitListener;
|
|
@@ -57,10 +57,10 @@ class ReadWriteDb extends data_source_factory_class_1.default {
|
|
|
57
57
|
return this.writeSession;
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
|
+
exports.default = ReadWriteDb;
|
|
60
61
|
__decorate([
|
|
61
62
|
core_decorator_1.bean,
|
|
62
63
|
__metadata("design:type", Function),
|
|
63
64
|
__metadata("design:paramtypes", []),
|
|
64
65
|
__metadata("design:returntype", data_source_factory_class_1.default)
|
|
65
66
|
], ReadWriteDb.prototype, "getDataSource", null);
|
|
66
|
-
exports.default = ReadWriteDb;
|
|
@@ -9,7 +9,8 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
9
9
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.
|
|
12
|
+
exports.Redis = void 0;
|
|
13
|
+
exports.redisSubscriber = redisSubscriber;
|
|
13
14
|
const core_decorator_1 = require("../core.decorator");
|
|
14
15
|
const ioredis_1 = require("ioredis");
|
|
15
16
|
const typespeed_1 = require("../typespeed");
|
|
@@ -57,6 +58,7 @@ class Redis extends ioredis_1.default {
|
|
|
57
58
|
}
|
|
58
59
|
}
|
|
59
60
|
}
|
|
61
|
+
exports.Redis = Redis;
|
|
60
62
|
Redis.pubObj = null;
|
|
61
63
|
Redis.subObj = null;
|
|
62
64
|
__decorate([
|
|
@@ -65,7 +67,6 @@ __decorate([
|
|
|
65
67
|
__metadata("design:paramtypes", []),
|
|
66
68
|
__metadata("design:returntype", Redis)
|
|
67
69
|
], Redis.prototype, "getRedis", null);
|
|
68
|
-
exports.Redis = Redis;
|
|
69
70
|
function redisSubscriber(channel) {
|
|
70
71
|
if (!(0, typespeed_1.config)("redis"))
|
|
71
72
|
return function () {
|
|
@@ -95,7 +96,6 @@ function redisSubscriber(channel) {
|
|
|
95
96
|
};
|
|
96
97
|
};
|
|
97
98
|
}
|
|
98
|
-
exports.redisSubscriber = redisSubscriber;
|
|
99
99
|
if ((0, typespeed_1.config)("redis")) {
|
|
100
100
|
Redis.getInstanceOfRedis("sub").on("message", async function (channel, message) {
|
|
101
101
|
await (0, core_decorator_1.getComponent)(redisSubscribers[channel].target.constructor)[redisSubscribers[channel].propertyKey](message);
|
package/dist/route.decorator.js
CHANGED
|
@@ -1,6 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.requestMapping = exports.postMapping = exports.getMapping = void 0;
|
|
4
|
+
exports.next = next;
|
|
5
|
+
exports.reqBody = reqBody;
|
|
6
|
+
exports.reqQuery = reqQuery;
|
|
7
|
+
exports.reqForm = reqForm;
|
|
8
|
+
exports.reqParam = reqParam;
|
|
9
|
+
exports.req = req;
|
|
10
|
+
exports.request = req;
|
|
11
|
+
exports.res = res;
|
|
12
|
+
exports.response = res;
|
|
13
|
+
exports.before = before;
|
|
14
|
+
exports.after = after;
|
|
15
|
+
exports.setRouter = setRouter;
|
|
16
|
+
exports.upload = upload;
|
|
17
|
+
exports.jwt = jwt;
|
|
4
18
|
const multiparty = require("multiparty");
|
|
5
19
|
const express_jwt_1 = require("express-jwt");
|
|
6
20
|
const core_decorator_1 = require("./core.decorator");
|
|
@@ -28,7 +42,6 @@ function setRouter(app) {
|
|
|
28
42
|
}
|
|
29
43
|
});
|
|
30
44
|
}
|
|
31
|
-
exports.setRouter = setRouter;
|
|
32
45
|
function mapperFunction(method, value) {
|
|
33
46
|
return (...args) => {
|
|
34
47
|
if ((0, decorator_utils_1.isStd)(args)) {
|
|
@@ -137,7 +150,6 @@ function upload(...args) {
|
|
|
137
150
|
routerMiddleware[key] = [uploadMiddleware];
|
|
138
151
|
}
|
|
139
152
|
}
|
|
140
|
-
exports.upload = upload;
|
|
141
153
|
function uploadMiddleware(req, res, next) {
|
|
142
154
|
const form = new multiparty.Form();
|
|
143
155
|
form.parse(req, (err, fields, files) => {
|
|
@@ -171,7 +183,6 @@ function jwt(jwtConfig) {
|
|
|
171
183
|
}
|
|
172
184
|
};
|
|
173
185
|
}
|
|
174
|
-
exports.jwt = jwt;
|
|
175
186
|
function before(constructorFunction, methodName) {
|
|
176
187
|
const targetBean = (0, core_decorator_1.getComponent)(constructorFunction);
|
|
177
188
|
return function (...args) {
|
|
@@ -206,7 +217,6 @@ function before(constructorFunction, methodName) {
|
|
|
206
217
|
});
|
|
207
218
|
};
|
|
208
219
|
}
|
|
209
|
-
exports.before = before;
|
|
210
220
|
function after(constructorFunction, methodName) {
|
|
211
221
|
const targetBean = (0, core_decorator_1.getComponent)(constructorFunction);
|
|
212
222
|
return function (...args) {
|
|
@@ -243,35 +253,27 @@ function after(constructorFunction, methodName) {
|
|
|
243
253
|
});
|
|
244
254
|
};
|
|
245
255
|
}
|
|
246
|
-
exports.after = after;
|
|
247
256
|
function req(target, propertyKey, parameterIndex) {
|
|
248
257
|
const key = [target.constructor.name, propertyKey, parameterIndex].toString();
|
|
249
258
|
routerParams[key] = (req, res, next) => req;
|
|
250
259
|
}
|
|
251
|
-
exports.req = req;
|
|
252
|
-
exports.request = req;
|
|
253
260
|
function res(target, propertyKey, parameterIndex) {
|
|
254
261
|
const key = [target.constructor.name, propertyKey, parameterIndex].toString();
|
|
255
262
|
routerParams[key] = (req, res, next) => res;
|
|
256
263
|
}
|
|
257
|
-
exports.res = res;
|
|
258
|
-
exports.response = res;
|
|
259
264
|
function next(target, propertyKey, parameterIndex) {
|
|
260
265
|
const key = [target.constructor.name, propertyKey, parameterIndex].toString();
|
|
261
266
|
routerParams[key] = (req, res, next) => next;
|
|
262
267
|
}
|
|
263
|
-
exports.next = next;
|
|
264
268
|
function reqBody(target, propertyKey, parameterIndex) {
|
|
265
269
|
const key = [target.constructor.name, propertyKey, parameterIndex].toString();
|
|
266
270
|
routerParams[key] = (req, res, next) => req.body;
|
|
267
271
|
}
|
|
268
|
-
exports.reqBody = reqBody;
|
|
269
272
|
function reqParam(target, propertyKey, parameterIndex) {
|
|
270
273
|
const key = [target.constructor.name, propertyKey, parameterIndex].toString();
|
|
271
274
|
const paramName = getParamInFunction(target[propertyKey], parameterIndex);
|
|
272
275
|
routerParams[key] = (req, res, next) => req.params[paramName];
|
|
273
276
|
}
|
|
274
|
-
exports.reqParam = reqParam;
|
|
275
277
|
function getParamInFunction(fn, index) {
|
|
276
278
|
const code = fn.toString().replace(/((\/\/.*$)|(\/\*[\s\S]*?\*\/))/mg, '').replace(/=>.*$/mg, '').replace(/=[^,]+/mg, '');
|
|
277
279
|
const result = code.slice(code.indexOf('(') + 1, code.indexOf(')')).match(/([^\s,]+)/g);
|
|
@@ -330,14 +332,12 @@ function reqQuery(target, propertyKey, parameterIndex) {
|
|
|
330
332
|
const paramName = getParamInFunction(target[propertyKey], parameterIndex);
|
|
331
333
|
routerParams[key] = (req, res, next) => req.query[paramName];
|
|
332
334
|
}
|
|
333
|
-
exports.reqQuery = reqQuery;
|
|
334
335
|
function reqForm(paramName) {
|
|
335
336
|
return (target, propertyKey, parameterIndex) => {
|
|
336
337
|
const key = [target.constructor.name, propertyKey, parameterIndex].toString();
|
|
337
338
|
routerParams[key] = (req, res, next) => req.body[paramName];
|
|
338
339
|
};
|
|
339
340
|
}
|
|
340
|
-
exports.reqForm = reqForm;
|
|
341
341
|
const getMapping = (value) => mapperFunction("get", value);
|
|
342
342
|
exports.getMapping = getMapping;
|
|
343
343
|
const postMapping = (value) => mapperFunction("post", value);
|
package/dist/typespeed.js
CHANGED
|
@@ -14,7 +14,10 @@ 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 =
|
|
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;
|
|
18
|
+
exports.app = app;
|
|
19
|
+
exports.value = value;
|
|
20
|
+
exports.config = config;
|
|
18
21
|
require("reflect-metadata");
|
|
19
22
|
const fs = require("fs");
|
|
20
23
|
const path = require("path");
|
|
@@ -44,20 +47,18 @@ function app(...args) {
|
|
|
44
47
|
}
|
|
45
48
|
startApp(args[0]);
|
|
46
49
|
}
|
|
47
|
-
exports.app = app;
|
|
48
50
|
function startApp(constructor) {
|
|
49
51
|
const coreFiles = walkSync(corePath, { globs: ['**/*.ts'], ignore: ['**/*.d.ts', 'scaffold/**'] });
|
|
50
52
|
const mainFiles = walkSync(mainPath, { globs: ['**/*.ts'] });
|
|
51
53
|
(async function () {
|
|
52
|
-
var _a, _b;
|
|
53
54
|
try {
|
|
54
55
|
for (let p of coreFiles) {
|
|
55
56
|
let moduleName = p.replace(".d.ts", "").replace(".ts", "");
|
|
56
|
-
await (
|
|
57
|
+
await Promise.resolve(`${corePath + "/" + moduleName}`).then(s => require(s));
|
|
57
58
|
}
|
|
58
59
|
for (let p of mainFiles) {
|
|
59
60
|
let moduleName = p.replace(".d.ts", "").replace(".ts", "");
|
|
60
|
-
await (
|
|
61
|
+
await Promise.resolve(`${mainPath + "/" + moduleName}`).then(s => require(s));
|
|
61
62
|
}
|
|
62
63
|
}
|
|
63
64
|
catch (err) {
|
|
@@ -71,7 +72,6 @@ function startApp(constructor) {
|
|
|
71
72
|
function config(node) {
|
|
72
73
|
return globalConfig[node] || null;
|
|
73
74
|
}
|
|
74
|
-
exports.config = config;
|
|
75
75
|
function value(configPath) {
|
|
76
76
|
return function (...args) {
|
|
77
77
|
if ((0, decorator_utils_1.isStd)(args)) {
|
|
@@ -111,7 +111,6 @@ function value(configPath) {
|
|
|
111
111
|
}
|
|
112
112
|
};
|
|
113
113
|
}
|
|
114
|
-
exports.value = value;
|
|
115
114
|
function getRootPath(lines) {
|
|
116
115
|
// 兼容新旧 Node 栈帧(Node<22: "Function.Module._load" / Node22+: "Function._load")、
|
|
117
116
|
// mocha(ts-node) 下 "Context.<anonymous>" 与中间可能插入的 "wrapModuleLoad" 帧:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "typespeed",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.6.1",
|
|
4
4
|
"description": "A new Framework for TypeScript.",
|
|
5
5
|
"author": "speedphp",
|
|
6
6
|
"license": "MIT License",
|
|
@@ -13,6 +13,9 @@
|
|
|
13
13
|
"prebuild": "rm -rf dist"
|
|
14
14
|
},
|
|
15
15
|
"main": "dist/typespeed.js",
|
|
16
|
+
"engines": {
|
|
17
|
+
"node": ">=18"
|
|
18
|
+
},
|
|
16
19
|
"files": [
|
|
17
20
|
"dist",
|
|
18
21
|
"CHANGELOG.md",
|
|
@@ -62,13 +65,13 @@
|
|
|
62
65
|
"devDependencies": {
|
|
63
66
|
"@types/express": "^4.17.13",
|
|
64
67
|
"@types/mocha": "^10.0.1",
|
|
65
|
-
"@types/node": "^
|
|
68
|
+
"@types/node": "^22.0.0",
|
|
66
69
|
"chai": "4.3.7",
|
|
67
70
|
"chai-http": "^4.4.0",
|
|
68
71
|
"mocha": "10.2.0",
|
|
69
72
|
"nyc": "^15.1.0",
|
|
70
73
|
"socket.io-client": "4.7.1",
|
|
71
74
|
"ts-node": "^10.9.1",
|
|
72
|
-
"typescript": "^
|
|
75
|
+
"typescript": "^5.9.3"
|
|
73
76
|
}
|
|
74
77
|
}
|