1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const constants_1 = require("../../constants");
|
4 | const request_method_enum_1 = require("../../enums/request-method.enum");
|
5 | const defaultMetadata = {
|
6 | [constants_1.PATH_METADATA]: '/',
|
7 | [constants_1.METHOD_METADATA]: request_method_enum_1.RequestMethod.GET,
|
8 | };
|
9 | exports.RequestMapping = (metadata = defaultMetadata) => {
|
10 | const pathMetadata = metadata[constants_1.PATH_METADATA];
|
11 | const path = pathMetadata && pathMetadata.length ? pathMetadata : '/';
|
12 | const requestMethod = metadata[constants_1.METHOD_METADATA] || request_method_enum_1.RequestMethod.GET;
|
13 | return (target, key, descriptor) => {
|
14 | Reflect.defineMetadata(constants_1.PATH_METADATA, path, descriptor.value);
|
15 | Reflect.defineMetadata(constants_1.METHOD_METADATA, requestMethod, descriptor.value);
|
16 | return descriptor;
|
17 | };
|
18 | };
|
19 | const createMappingDecorator = (method) => (path) => {
|
20 | return exports.RequestMapping({
|
21 | [constants_1.PATH_METADATA]: path,
|
22 | [constants_1.METHOD_METADATA]: method,
|
23 | });
|
24 | };
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 | exports.Post = createMappingDecorator(request_method_enum_1.RequestMethod.POST);
|
33 |
|
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 |
|
40 | exports.Get = createMappingDecorator(request_method_enum_1.RequestMethod.GET);
|
41 |
|
42 |
|
43 |
|
44 |
|
45 |
|
46 |
|
47 |
|
48 | exports.Delete = createMappingDecorator(request_method_enum_1.RequestMethod.DELETE);
|
49 |
|
50 |
|
51 |
|
52 |
|
53 |
|
54 |
|
55 |
|
56 | exports.Put = createMappingDecorator(request_method_enum_1.RequestMethod.PUT);
|
57 |
|
58 |
|
59 |
|
60 |
|
61 |
|
62 |
|
63 |
|
64 | exports.Patch = createMappingDecorator(request_method_enum_1.RequestMethod.PATCH);
|
65 |
|
66 |
|
67 |
|
68 |
|
69 |
|
70 |
|
71 |
|
72 | exports.Options = createMappingDecorator(request_method_enum_1.RequestMethod.OPTIONS);
|
73 |
|
74 |
|
75 |
|
76 |
|
77 |
|
78 |
|
79 |
|
80 | exports.Head = createMappingDecorator(request_method_enum_1.RequestMethod.HEAD);
|
81 |
|
82 |
|
83 |
|
84 |
|
85 |
|
86 |
|
87 |
|
88 | exports.All = createMappingDecorator(request_method_enum_1.RequestMethod.ALL);
|