typespeed 2.0.23 → 2.1.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/dist/route.decorator.js
CHANGED
|
@@ -15,9 +15,9 @@ const routerMiddleware = {};
|
|
|
15
15
|
function setRouter(app) {
|
|
16
16
|
["get", "post", "all"].forEach(method => {
|
|
17
17
|
for (let key in routerMapper[method]) {
|
|
18
|
-
|
|
18
|
+
const rounterFunction = routerMapper[method][key];
|
|
19
19
|
if (routerMiddleware[rounterFunction["name"]]) {
|
|
20
|
-
|
|
20
|
+
const args = [key, ...routerMiddleware[rounterFunction["name"]], rounterFunction["invoker"]];
|
|
21
21
|
app[method].apply(app, args);
|
|
22
22
|
}
|
|
23
23
|
else {
|
|
@@ -32,6 +32,8 @@ function mapperFunction(method, value) {
|
|
|
32
32
|
routerMapper[method][value] = {
|
|
33
33
|
"path": value,
|
|
34
34
|
"name": [target.constructor.name, propertyKey].toString(),
|
|
35
|
+
"target": target.constructor,
|
|
36
|
+
"propertyKey": propertyKey,
|
|
35
37
|
"invoker": async (req, res, next) => {
|
|
36
38
|
const routerBean = (0, core_decorator_1.getComponent)(target.constructor);
|
|
37
39
|
try {
|
|
@@ -39,7 +41,7 @@ function mapperFunction(method, value) {
|
|
|
39
41
|
if (routerParamsTotal[[target.constructor.name, propertyKey].toString()]) {
|
|
40
42
|
paramTotal = Math.max(paramTotal, routerParamsTotal[[target.constructor.name, propertyKey].toString()]);
|
|
41
43
|
}
|
|
42
|
-
|
|
44
|
+
const args = [req, res, next];
|
|
43
45
|
if (paramTotal > 0) {
|
|
44
46
|
for (let i = 0; i < paramTotal; i++) {
|
|
45
47
|
if (routerParams[[target.constructor.name, propertyKey, i].toString()]) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "typespeed",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.1",
|
|
4
4
|
"description": "A new Framework for TypeScript.",
|
|
5
5
|
"author": "speedphp",
|
|
6
6
|
"license": "MIT License",
|
|
@@ -52,6 +52,7 @@
|
|
|
52
52
|
"tracer": "^1.1.6",
|
|
53
53
|
"typescript": "^4.7.4",
|
|
54
54
|
"walk-sync": "^3.0.0",
|
|
55
|
-
"amqplib": "0.10.3"
|
|
55
|
+
"amqplib": "0.10.3",
|
|
56
|
+
"swagger-ui-express": "4.6.3"
|
|
56
57
|
}
|
|
57
58
|
}
|
|
@@ -54,12 +54,12 @@ export default class ExpressServer extends ServerFactory {
|
|
|
54
54
|
|
|
55
55
|
public start(port: number) {
|
|
56
56
|
this.app.use(this.authentication.afterCompletion);
|
|
57
|
-
|
|
58
57
|
this.middlewareList.forEach(middleware => {
|
|
59
58
|
this.app.use(middleware);
|
|
60
59
|
});
|
|
61
60
|
|
|
62
61
|
this.setDefaultMiddleware();
|
|
62
|
+
|
|
63
63
|
this.app.listen(port, () => {
|
|
64
64
|
log("server start at port: " + port);
|
|
65
65
|
});
|
package/src/route.decorator.ts
CHANGED
|
@@ -2,7 +2,6 @@ import * as express from "express";
|
|
|
2
2
|
import * as multiparty from "multiparty";
|
|
3
3
|
import { expressjwt } from "express-jwt";
|
|
4
4
|
import { getComponent } from "./core.decorator";
|
|
5
|
-
import { param } from "./database.decorator";
|
|
6
5
|
|
|
7
6
|
const routerMapper = {
|
|
8
7
|
"get": {},
|
|
@@ -15,9 +14,9 @@ const routerMiddleware = {};
|
|
|
15
14
|
function setRouter(app: express.Application) {
|
|
16
15
|
["get", "post", "all"].forEach(method => {
|
|
17
16
|
for (let key in routerMapper[method]) {
|
|
18
|
-
|
|
17
|
+
const rounterFunction = routerMapper[method][key];
|
|
19
18
|
if (routerMiddleware[rounterFunction["name"]]) {
|
|
20
|
-
|
|
19
|
+
const args: Array<any> = [key, ...routerMiddleware[rounterFunction["name"]], rounterFunction["invoker"]];
|
|
21
20
|
app[method].apply(app, args);
|
|
22
21
|
} else {
|
|
23
22
|
app[method](key, rounterFunction["invoker"]);
|
|
@@ -31,6 +30,8 @@ function mapperFunction(method: string, value: string) {
|
|
|
31
30
|
routerMapper[method][value] = {
|
|
32
31
|
"path": value,
|
|
33
32
|
"name": [target.constructor.name, propertyKey].toString(),
|
|
33
|
+
"target": target.constructor,
|
|
34
|
+
"propertyKey": propertyKey,
|
|
34
35
|
"invoker": async (req, res, next) => {
|
|
35
36
|
const routerBean = getComponent(target.constructor);
|
|
36
37
|
try {
|
|
@@ -38,7 +39,7 @@ function mapperFunction(method: string, value: string) {
|
|
|
38
39
|
if(routerParamsTotal[[target.constructor.name, propertyKey].toString()]){
|
|
39
40
|
paramTotal = Math.max(paramTotal, routerParamsTotal[[target.constructor.name, propertyKey].toString()]);
|
|
40
41
|
}
|
|
41
|
-
|
|
42
|
+
const args = [req, res, next];
|
|
42
43
|
if(paramTotal > 0) {
|
|
43
44
|
for(let i = 0; i < paramTotal; i++) {
|
|
44
45
|
if(routerParams[[target.constructor.name, propertyKey, i].toString()]){
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { component, getMapping, postMapping, log } from "../../";
|
|
2
|
-
import
|
|
1
|
+
import { component, getMapping, postMapping, log, req, res, reqQuery, reqBody, reqForm, reqParam } from "../../";
|
|
2
|
+
import MutilUsers from "./entities/mutil-users.class";
|
|
3
|
+
import UserDto from "./entities/user-dto.class";
|
|
3
4
|
|
|
4
5
|
|
|
5
6
|
@component
|
|
@@ -11,15 +12,15 @@ export default class TestRequest {
|
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
@getMapping("/request/query")
|
|
14
|
-
testQuery(req, res, @reqQuery("id") id: number) {
|
|
15
|
+
async testQuery(req, res, @reqQuery("id") id: number): Promise<MutilUsers> {
|
|
15
16
|
log("id: " + id);
|
|
16
|
-
|
|
17
|
+
return Promise.resolve(new MutilUsers("group", [new UserDto(1, "name"), new UserDto(2, "name")]));
|
|
17
18
|
}
|
|
18
19
|
|
|
19
20
|
@postMapping("/request/body")
|
|
20
|
-
testBody(@res res, @reqBody body: object) {
|
|
21
|
+
testBody(@res res, @reqBody body: object):MutilUsers {
|
|
21
22
|
log("body: " + JSON.stringify(body));
|
|
22
|
-
|
|
23
|
+
return new MutilUsers("group", [new UserDto(1, "name"), new UserDto(2, "name")]);
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
@postMapping("/request/form")
|