@nestia/core 1.1.2-dev.20230503 → 1.1.2-dev.20230503-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.
|
@@ -33,7 +33,7 @@ var common_1 = require("@nestjs/common");
|
|
|
33
33
|
* @author Jeongho Nam - https://github.com/samchon
|
|
34
34
|
*/
|
|
35
35
|
function TypedParam(name, type, nullable) {
|
|
36
|
-
var
|
|
36
|
+
var TypedParam = function (_a, ctx) {
|
|
37
37
|
var request = ctx.switchToHttp().getRequest();
|
|
38
38
|
var str = request.params[name];
|
|
39
39
|
if (nullable === true && str === "null")
|
|
@@ -59,10 +59,10 @@ function TypedParam(name, type, nullable) {
|
|
|
59
59
|
}
|
|
60
60
|
else
|
|
61
61
|
return str;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
return
|
|
62
|
+
};
|
|
63
|
+
TypedParam.nullable = !!nullable;
|
|
64
|
+
TypedParam.type = type;
|
|
65
|
+
return (0, common_1.createParamDecorator)(TypedParam)(name);
|
|
66
66
|
}
|
|
67
67
|
exports.TypedParam = TypedParam;
|
|
68
68
|
var UUID_PATTERN = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TypedParam.js","sourceRoot":"","sources":["../../src/decorators/TypedParam.ts"],"names":[],"mappings":";;;AAAA,yCAIwB;AAGxB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,SAAgB,UAAU,CACtB,IAAY,EACZ,IAA+C,EAC/C,QAAuB;IAEvB,IAAM,
|
|
1
|
+
{"version":3,"file":"TypedParam.js","sourceRoot":"","sources":["../../src/decorators/TypedParam.ts"],"names":[],"mappings":";;;AAAA,yCAIwB;AAGxB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA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C,CAAC;AAClD,CAAC;AApCD,gCAoCC;AAED,IAAM,YAAY,GACd,qHAAqH,CAAC"}
|
package/package.json
CHANGED
|
@@ -40,10 +40,7 @@ export function TypedParam(
|
|
|
40
40
|
type?: "boolean" | "number" | "string" | "uuid",
|
|
41
41
|
nullable?: false | true,
|
|
42
42
|
): ParameterDecorator {
|
|
43
|
-
const
|
|
44
|
-
{}: any,
|
|
45
|
-
ctx: ExecutionContext,
|
|
46
|
-
) {
|
|
43
|
+
const TypedParam = ({}: any, ctx: ExecutionContext) => {
|
|
47
44
|
const request: express.Request = ctx.switchToHttp().getRequest();
|
|
48
45
|
const str: string = request.params[name];
|
|
49
46
|
|
|
@@ -69,10 +66,11 @@ export function TypedParam(
|
|
|
69
66
|
);
|
|
70
67
|
return str;
|
|
71
68
|
} else return str;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
(
|
|
75
|
-
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
(TypedParam as any).nullable = !!nullable;
|
|
72
|
+
(TypedParam as any).type = type;
|
|
73
|
+
return createParamDecorator(TypedParam)(name);
|
|
76
74
|
}
|
|
77
75
|
|
|
78
76
|
const UUID_PATTERN =
|