@atlantjs/backend 11.0.5 → 11.0.6
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.
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export declare
|
|
7
|
-
export declare const
|
|
1
|
+
import { ControllerOptions } from "routing-controllers/types/decorator-options/ControllerOptions";
|
|
2
|
+
interface UnifiedControllerOptions extends ControllerOptions {
|
|
3
|
+
route: string;
|
|
4
|
+
method: "get" | "post" | "put" | "patch" | "delete";
|
|
5
|
+
}
|
|
6
|
+
export declare function UnifiedController(options: UnifiedControllerOptions): ClassDecorator;
|
|
7
|
+
export declare const Get: (route: string) => ClassDecorator;
|
|
8
|
+
export declare const Post: (route: string) => ClassDecorator;
|
|
9
|
+
export declare const Put: (route: string) => ClassDecorator;
|
|
10
|
+
export declare const Patch: (route: string) => ClassDecorator;
|
|
11
|
+
export declare const Delete: (route: string) => ClassDecorator;
|
|
12
|
+
export {};
|
|
@@ -1,33 +1,67 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
// import { HttpContentTypePoint } from "./http-content-type.point";
|
|
3
|
+
// import { HttpMethodPoint } from "./http-method.point";
|
|
4
|
+
// import "reflect-metadata";
|
|
5
|
+
// import { getMetadataArgsStorage } from "routing-controllers";
|
|
2
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
7
|
exports.Delete = exports.Patch = exports.Put = exports.Post = exports.Get = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
8
|
+
exports.UnifiedController = UnifiedController;
|
|
9
|
+
// function HttpMethod(httpMethod: HttpMethodPoint) {
|
|
10
|
+
// return (
|
|
11
|
+
// route: string,
|
|
12
|
+
// contentType = HttpContentTypePoint.JSON,
|
|
13
|
+
// ): ClassDecorator => {
|
|
14
|
+
// return (target) => {
|
|
15
|
+
// getMetadataArgsStorage().actions.push({
|
|
16
|
+
// type: httpMethod,
|
|
17
|
+
// target: target.constructor,
|
|
18
|
+
// method: "apply",
|
|
19
|
+
// route,
|
|
20
|
+
// options: {},
|
|
21
|
+
// });
|
|
22
|
+
// if (contentType === HttpContentTypePoint.JSON) {
|
|
23
|
+
// getMetadataArgsStorage().controllers.push({
|
|
24
|
+
// type: "json",
|
|
25
|
+
// target: target,
|
|
26
|
+
// route,
|
|
27
|
+
// options: {},
|
|
28
|
+
// });
|
|
29
|
+
// }
|
|
30
|
+
// };
|
|
31
|
+
// };
|
|
32
|
+
// }
|
|
33
|
+
// export const Get = HttpMethod(HttpMethodPoint.GET);
|
|
34
|
+
// export const Post = HttpMethod(HttpMethodPoint.POST);
|
|
35
|
+
// export const Put = HttpMethod(HttpMethodPoint.PUT);
|
|
36
|
+
// export const Patch = HttpMethod(HttpMethodPoint.PATCH);
|
|
37
|
+
// export const Delete = HttpMethod(HttpMethodPoint.DELETE);
|
|
7
38
|
const routing_controllers_1 = require("routing-controllers");
|
|
8
|
-
function
|
|
9
|
-
return (
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
};
|
|
39
|
+
function UnifiedController(options) {
|
|
40
|
+
return (target) => {
|
|
41
|
+
// Registra o controller como JSON
|
|
42
|
+
(0, routing_controllers_1.getMetadataArgsStorage)().controllers.push({
|
|
43
|
+
type: "json", // ou options.type se quiser customizar
|
|
44
|
+
target,
|
|
45
|
+
route: options.route,
|
|
46
|
+
options,
|
|
47
|
+
});
|
|
48
|
+
// Registra a action sempre como método 'apply'
|
|
49
|
+
(0, routing_controllers_1.getMetadataArgsStorage)().actions.push({
|
|
50
|
+
type: options.method,
|
|
51
|
+
target,
|
|
52
|
+
method: "apply",
|
|
53
|
+
route: options.route,
|
|
54
|
+
options: {},
|
|
55
|
+
});
|
|
27
56
|
};
|
|
28
57
|
}
|
|
29
|
-
|
|
30
|
-
exports.
|
|
31
|
-
|
|
32
|
-
exports.
|
|
33
|
-
|
|
58
|
+
const Get = (route) => UnifiedController({ method: "get", route });
|
|
59
|
+
exports.Get = Get;
|
|
60
|
+
const Post = (route) => UnifiedController({ method: "post", route });
|
|
61
|
+
exports.Post = Post;
|
|
62
|
+
const Put = (route) => UnifiedController({ method: "put", route });
|
|
63
|
+
exports.Put = Put;
|
|
64
|
+
const Patch = (route) => UnifiedController({ method: "patch", route });
|
|
65
|
+
exports.Patch = Patch;
|
|
66
|
+
const Delete = (route) => UnifiedController({ method: "delete", route });
|
|
67
|
+
exports.Delete = Delete;
|