@zenweb/schedule 5.2.0 → 5.3.0
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/dist/register.d.ts +0 -4
- package/dist/register.js +14 -3
- package/package.json +2 -2
package/dist/register.d.ts
CHANGED
package/dist/register.js
CHANGED
|
@@ -10,8 +10,7 @@ const scheduleDecorator = makeMethodDecorator();
|
|
|
10
10
|
*/
|
|
11
11
|
export function schedule(opt) {
|
|
12
12
|
return scheduleDecorator.wrap(descriptor => {
|
|
13
|
-
|
|
14
|
-
return Object.assign({ path }, descriptor, opt);
|
|
13
|
+
return Object.assign({}, opt, descriptor);
|
|
15
14
|
});
|
|
16
15
|
}
|
|
17
16
|
export class ScheduleRegister {
|
|
@@ -33,7 +32,19 @@ export class ScheduleRegister {
|
|
|
33
32
|
const methods = scheduleDecorator.getMethods(target.prototype);
|
|
34
33
|
if (methods.length > 0) {
|
|
35
34
|
for (const item of methods) {
|
|
36
|
-
|
|
35
|
+
let apath = prefix ? path.join('/', prefix, item.handle.name) : item.handle.name;
|
|
36
|
+
// 重复定义自增
|
|
37
|
+
let i = 1;
|
|
38
|
+
let c = apath;
|
|
39
|
+
while (true) {
|
|
40
|
+
if (this.router.matchSelf(c, 'POST')) {
|
|
41
|
+
c = apath + i++;
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
apath = c;
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
37
48
|
// 添加到路由中
|
|
38
49
|
this.router.post(apath, ...(item.middleware ?
|
|
39
50
|
(Array.isArray(item.middleware) ? item.middleware : [item.middleware]) : []), async (ctx) => {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zenweb/schedule",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "5.
|
|
4
|
+
"version": "5.3.0",
|
|
5
5
|
"description": "Zenweb Schedule module",
|
|
6
6
|
"exports": "./dist/index.js",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"@types/node": "^22.19.15",
|
|
39
39
|
"@zenweb/core": "^5.2.1",
|
|
40
40
|
"@zenweb/inject": "^5.1.0",
|
|
41
|
-
"@zenweb/router": "^6.0
|
|
41
|
+
"@zenweb/router": "^6.4.0",
|
|
42
42
|
"rimraf": "^4.4.1",
|
|
43
43
|
"ts-node": "^10.9.2",
|
|
44
44
|
"typescript": "^5.9.3"
|