@pristine-ts/networking 0.0.162 → 0.0.166
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/lib/cjs/decorators/body.decorator.js +20 -1
- package/dist/lib/cjs/decorators/body.decorator.js.map +1 -1
- package/dist/lib/cjs/decorators/controller.decorator.js +13 -1
- package/dist/lib/cjs/decorators/controller.decorator.js.map +1 -1
- package/dist/lib/cjs/decorators/decorators.js +1 -1
- package/dist/lib/cjs/decorators/decorators.js.map +1 -1
- package/dist/lib/cjs/decorators/headers.decorator.js +20 -1
- package/dist/lib/cjs/decorators/headers.decorator.js.map +1 -1
- package/dist/lib/cjs/decorators/identity.decorator.js +20 -1
- package/dist/lib/cjs/decorators/identity.decorator.js.map +1 -1
- package/dist/lib/cjs/decorators/query-parameter.decorator.js +22 -1
- package/dist/lib/cjs/decorators/query-parameter.decorator.js.map +1 -1
- package/dist/lib/cjs/decorators/query-parameters.decorator.js +20 -1
- package/dist/lib/cjs/decorators/query-parameters.decorator.js.map +1 -1
- package/dist/lib/cjs/decorators/request.decorator.js +20 -1
- package/dist/lib/cjs/decorators/request.decorator.js.map +1 -1
- package/dist/lib/cjs/decorators/response-header.decorator.js +24 -2
- package/dist/lib/cjs/decorators/response-header.decorator.js.map +1 -1
- package/dist/lib/cjs/decorators/route-parameter.decorator.js +21 -1
- package/dist/lib/cjs/decorators/route-parameter.decorator.js.map +1 -1
- package/dist/lib/cjs/decorators/route.decorator.js +21 -1
- package/dist/lib/cjs/decorators/route.decorator.js.map +1 -1
- package/dist/lib/cjs/enrichers/router-response.enricher.js +4 -0
- package/dist/lib/cjs/enrichers/router-response.enricher.js.map +1 -1
- package/dist/lib/cjs/errors/errors.js +3 -1
- package/dist/lib/cjs/errors/errors.js.map +1 -1
- package/dist/lib/cjs/errors/http.error.js +1 -1
- package/dist/lib/cjs/errors/http.error.js.map +1 -1
- package/dist/lib/cjs/errors/method-router-adding.error.js +25 -0
- package/dist/lib/cjs/errors/method-router-adding.error.js.map +1 -0
- package/dist/lib/cjs/errors/path-router-adding.error.js +3 -2
- package/dist/lib/cjs/errors/path-router-adding.error.js.map +1 -1
- package/dist/lib/cjs/errors/path-router-instantiation.error.js +3 -2
- package/dist/lib/cjs/errors/path-router-instantiation.error.js.map +1 -1
- package/dist/lib/cjs/interfaces/interfaces.js +2 -2
- package/dist/lib/cjs/interfaces/interfaces.js.map +1 -1
- package/dist/lib/cjs/models/models.js +0 -1
- package/dist/lib/cjs/models/models.js.map +1 -1
- package/dist/lib/cjs/models/request.js +10 -4
- package/dist/lib/cjs/models/request.js.map +1 -1
- package/dist/lib/cjs/models/response.js +6 -0
- package/dist/lib/cjs/models/response.js.map +1 -1
- package/dist/lib/cjs/models/route.js +4 -0
- package/dist/lib/cjs/models/route.js.map +1 -1
- package/dist/lib/cjs/networking.module.js +0 -6
- package/dist/lib/cjs/networking.module.js.map +1 -1
- package/dist/lib/cjs/nodes/method-router.node.js +19 -4
- package/dist/lib/cjs/nodes/method-router.node.js.map +1 -1
- package/dist/lib/cjs/nodes/path-router.node.js +22 -12
- package/dist/lib/cjs/nodes/path-router.node.js.map +1 -1
- package/dist/lib/cjs/resolvers/body-parameter-decorator.resolver.js +18 -0
- package/dist/lib/cjs/resolvers/body-parameter-decorator.resolver.js.map +1 -1
- package/dist/lib/cjs/resolvers/controller-method-parameter-decorator.resolver.js +14 -0
- package/dist/lib/cjs/resolvers/controller-method-parameter-decorator.resolver.js.map +1 -1
- package/dist/lib/cjs/resolvers/headers-parameter-decorator.resolver.js +18 -0
- package/dist/lib/cjs/resolvers/headers-parameter-decorator.resolver.js.map +1 -1
- package/dist/lib/cjs/resolvers/identity-parameter-decorator.resolver.js +18 -0
- package/dist/lib/cjs/resolvers/identity-parameter-decorator.resolver.js.map +1 -1
- package/dist/lib/cjs/resolvers/query-parameter-decorator.resolver.js +19 -0
- package/dist/lib/cjs/resolvers/query-parameter-decorator.resolver.js.map +1 -1
- package/dist/lib/cjs/resolvers/query-parameters-decorator.resolver.js +18 -0
- package/dist/lib/cjs/resolvers/query-parameters-decorator.resolver.js.map +1 -1
- package/dist/lib/cjs/resolvers/request-parameter-decorator.resolver.js +18 -0
- package/dist/lib/cjs/resolvers/request-parameter-decorator.resolver.js.map +1 -1
- package/dist/lib/cjs/resolvers/route-parameter-decorator.resolver.js +18 -0
- package/dist/lib/cjs/resolvers/route-parameter-decorator.resolver.js.map +1 -1
- package/dist/lib/cjs/router.js +25 -10
- package/dist/lib/cjs/router.js.map +1 -1
- package/dist/lib/esm/decorators/body.decorator.js +20 -1
- package/dist/lib/esm/decorators/body.decorator.js.map +1 -1
- package/dist/lib/esm/decorators/controller.decorator.js +13 -1
- package/dist/lib/esm/decorators/controller.decorator.js.map +1 -1
- package/dist/lib/esm/decorators/decorators.js +1 -1
- package/dist/lib/esm/decorators/decorators.js.map +1 -1
- package/dist/lib/esm/decorators/headers.decorator.js +20 -1
- package/dist/lib/esm/decorators/headers.decorator.js.map +1 -1
- package/dist/lib/esm/decorators/identity.decorator.js +20 -1
- package/dist/lib/esm/decorators/identity.decorator.js.map +1 -1
- package/dist/lib/esm/decorators/query-parameter.decorator.js +22 -1
- package/dist/lib/esm/decorators/query-parameter.decorator.js.map +1 -1
- package/dist/lib/esm/decorators/query-parameters.decorator.js +20 -1
- package/dist/lib/esm/decorators/query-parameters.decorator.js.map +1 -1
- package/dist/lib/esm/decorators/request.decorator.js +20 -1
- package/dist/lib/esm/decorators/request.decorator.js.map +1 -1
- package/dist/lib/esm/decorators/response-header.decorator.js +24 -2
- package/dist/lib/esm/decorators/response-header.decorator.js.map +1 -1
- package/dist/lib/esm/decorators/route-parameter.decorator.js +21 -1
- package/dist/lib/esm/decorators/route-parameter.decorator.js.map +1 -1
- package/dist/lib/esm/decorators/route.decorator.js +21 -1
- package/dist/lib/esm/decorators/route.decorator.js.map +1 -1
- package/dist/lib/esm/enrichers/router-response.enricher.js +4 -0
- package/dist/lib/esm/enrichers/router-response.enricher.js.map +1 -1
- package/dist/lib/esm/errors/errors.js +3 -1
- package/dist/lib/esm/errors/errors.js.map +1 -1
- package/dist/lib/esm/errors/http.error.js +1 -1
- package/dist/lib/esm/errors/http.error.js.map +1 -1
- package/dist/lib/esm/errors/method-router-adding.error.js +21 -0
- package/dist/lib/esm/errors/method-router-adding.error.js.map +1 -0
- package/dist/lib/esm/errors/path-router-adding.error.js +3 -2
- package/dist/lib/esm/errors/path-router-adding.error.js.map +1 -1
- package/dist/lib/esm/errors/path-router-instantiation.error.js +3 -2
- package/dist/lib/esm/errors/path-router-instantiation.error.js.map +1 -1
- package/dist/lib/esm/interfaces/interfaces.js +2 -2
- package/dist/lib/esm/interfaces/interfaces.js.map +1 -1
- package/dist/lib/esm/models/models.js +0 -1
- package/dist/lib/esm/models/models.js.map +1 -1
- package/dist/lib/esm/models/request.js +10 -4
- package/dist/lib/esm/models/request.js.map +1 -1
- package/dist/lib/esm/models/response.js +6 -0
- package/dist/lib/esm/models/response.js.map +1 -1
- package/dist/lib/esm/models/route.js +4 -0
- package/dist/lib/esm/models/route.js.map +1 -1
- package/dist/lib/esm/networking.module.js +0 -6
- package/dist/lib/esm/networking.module.js.map +1 -1
- package/dist/lib/esm/nodes/method-router.node.js +19 -4
- package/dist/lib/esm/nodes/method-router.node.js.map +1 -1
- package/dist/lib/esm/nodes/path-router.node.js +22 -12
- package/dist/lib/esm/nodes/path-router.node.js.map +1 -1
- package/dist/lib/esm/resolvers/body-parameter-decorator.resolver.js +18 -0
- package/dist/lib/esm/resolvers/body-parameter-decorator.resolver.js.map +1 -1
- package/dist/lib/esm/resolvers/controller-method-parameter-decorator.resolver.js +14 -0
- package/dist/lib/esm/resolvers/controller-method-parameter-decorator.resolver.js.map +1 -1
- package/dist/lib/esm/resolvers/headers-parameter-decorator.resolver.js +18 -0
- package/dist/lib/esm/resolvers/headers-parameter-decorator.resolver.js.map +1 -1
- package/dist/lib/esm/resolvers/identity-parameter-decorator.resolver.js +18 -0
- package/dist/lib/esm/resolvers/identity-parameter-decorator.resolver.js.map +1 -1
- package/dist/lib/esm/resolvers/query-parameter-decorator.resolver.js +19 -0
- package/dist/lib/esm/resolvers/query-parameter-decorator.resolver.js.map +1 -1
- package/dist/lib/esm/resolvers/query-parameters-decorator.resolver.js +18 -0
- package/dist/lib/esm/resolvers/query-parameters-decorator.resolver.js.map +1 -1
- package/dist/lib/esm/resolvers/request-parameter-decorator.resolver.js +18 -0
- package/dist/lib/esm/resolvers/request-parameter-decorator.resolver.js.map +1 -1
- package/dist/lib/esm/resolvers/route-parameter-decorator.resolver.js +18 -0
- package/dist/lib/esm/resolvers/route-parameter-decorator.resolver.js.map +1 -1
- package/dist/lib/esm/router.js +25 -10
- package/dist/lib/esm/router.js.map +1 -1
- package/dist/types/decorators/body.decorator.d.ts +3 -0
- package/dist/types/decorators/controller.decorator.d.ts +4 -0
- package/dist/types/decorators/decorators.d.ts +1 -1
- package/dist/types/decorators/headers.decorator.d.ts +3 -0
- package/dist/types/decorators/identity.decorator.d.ts +3 -0
- package/dist/types/decorators/query-parameter.decorator.d.ts +4 -0
- package/dist/types/decorators/query-parameters.decorator.d.ts +3 -0
- package/dist/types/decorators/request.decorator.d.ts +3 -0
- package/dist/types/decorators/response-header.decorator.d.ts +7 -0
- package/dist/types/decorators/route-parameter.decorator.d.ts +4 -0
- package/dist/types/decorators/route.decorator.d.ts +6 -1
- package/dist/types/enrichers/router-response.enricher.d.ts +4 -0
- package/dist/types/errors/errors.d.ts +3 -1
- package/dist/types/errors/http.error.d.ts +1 -1
- package/dist/types/errors/method-router-adding.error.d.ts +10 -0
- package/dist/types/errors/path-router-adding.error.d.ts +4 -3
- package/dist/types/errors/path-router-instantiation.error.d.ts +4 -3
- package/dist/types/interfaces/controller-method-parameter-decorator-resolver.interface.d.ts +19 -2
- package/dist/types/interfaces/interfaces.d.ts +2 -2
- package/dist/types/interfaces/parameter-decorator.interface.d.ts +4 -0
- package/dist/types/interfaces/query-parameters-decorator.interface.d.ts +4 -0
- package/dist/types/interfaces/route-parameter-decorator.interface.d.ts +1 -1
- package/dist/types/interfaces/router.interface.d.ts +2 -2
- package/dist/types/models/models.d.ts +0 -1
- package/dist/types/models/request.d.ts +16 -4
- package/dist/types/models/response.d.ts +15 -0
- package/dist/types/models/route.d.ts +4 -0
- package/dist/types/nodes/method-router.node.d.ts +17 -4
- package/dist/types/nodes/path-router.node.d.ts +11 -7
- package/dist/types/nodes/router.node.d.ts +3 -3
- package/dist/types/resolvers/body-parameter-decorator.resolver.d.ts +22 -2
- package/dist/types/resolvers/controller-method-parameter-decorator.resolver.d.ts +14 -0
- package/dist/types/resolvers/headers-parameter-decorator.resolver.d.ts +22 -2
- package/dist/types/resolvers/identity-parameter-decorator.resolver.d.ts +22 -2
- package/dist/types/resolvers/query-parameter-decorator.resolver.d.ts +23 -2
- package/dist/types/resolvers/query-parameters-decorator.resolver.d.ts +22 -2
- package/dist/types/resolvers/request-parameter-decorator.resolver.d.ts +22 -2
- package/dist/types/resolvers/route-parameter-decorator.resolver.d.ts +22 -2
- package/dist/types/router.d.ts +13 -3
- package/package.json +5 -5
- package/dist/lib/cjs/enums/enums.js +0 -1
- package/dist/lib/cjs/enums/enums.js.map +0 -1
- package/dist/lib/cjs/models/error-response-body.js +0 -7
- package/dist/lib/cjs/models/error-response-body.js.map +0 -1
- package/dist/lib/esm/enums/enums.js +0 -1
- package/dist/lib/esm/enums/enums.js.map +0 -1
- package/dist/lib/esm/models/error-response-body.js +0 -3
- package/dist/lib/esm/models/error-response-body.js.map +0 -1
- package/dist/types/enums/enums.d.ts +0 -0
- package/dist/types/models/error-response-body.d.ts +0 -4
|
@@ -4,30 +4,42 @@ import { RequestInterface } from "@pristine-ts/common";
|
|
|
4
4
|
* This Request object represents the class used internally that represents a Request.
|
|
5
5
|
*/
|
|
6
6
|
export declare class Request implements RequestInterface {
|
|
7
|
+
/**
|
|
8
|
+
* The http method of the request.
|
|
9
|
+
*/
|
|
7
10
|
httpMethod: HttpMethod | string;
|
|
11
|
+
/**
|
|
12
|
+
* The url of the request.
|
|
13
|
+
*/
|
|
8
14
|
url: string;
|
|
15
|
+
/**
|
|
16
|
+
* The headers of the request.
|
|
17
|
+
*/
|
|
9
18
|
headers: {
|
|
10
19
|
[key: string]: string;
|
|
11
20
|
};
|
|
21
|
+
/**
|
|
22
|
+
* The body of the request.
|
|
23
|
+
*/
|
|
12
24
|
body: any;
|
|
13
25
|
constructor(requestInterface: RequestInterface);
|
|
14
26
|
/**
|
|
15
27
|
* This method sets a header parameter in the Request.
|
|
16
28
|
*
|
|
17
|
-
* @param name
|
|
18
|
-
* @param value
|
|
29
|
+
* @param name The name of the header.
|
|
30
|
+
* @param value The value of the header.
|
|
19
31
|
*/
|
|
20
32
|
setHeader(name: string, value: string): void;
|
|
21
33
|
/**
|
|
22
34
|
* This method returns whether or not the header exists in the Request.
|
|
23
35
|
*
|
|
24
|
-
* @param name
|
|
36
|
+
* @param name The name of the header.
|
|
25
37
|
*/
|
|
26
38
|
hasHeader(name: string): boolean;
|
|
27
39
|
/**
|
|
28
40
|
* This method returns the header corresponding to the name or undefined if it doesn't exist.
|
|
29
41
|
*
|
|
30
|
-
* @param name
|
|
42
|
+
* @param name The name of the header.
|
|
31
43
|
*/
|
|
32
44
|
getHeader(name: string): string | undefined;
|
|
33
45
|
}
|
|
@@ -1,9 +1,24 @@
|
|
|
1
1
|
import { RequestInterface } from "@pristine-ts/common";
|
|
2
|
+
/**
|
|
3
|
+
* This Response object represents the class used internally that represents a Response.
|
|
4
|
+
*/
|
|
2
5
|
export declare class Response {
|
|
6
|
+
/**
|
|
7
|
+
* The status code of the response. By default we return a 200.
|
|
8
|
+
*/
|
|
3
9
|
status: number;
|
|
10
|
+
/**
|
|
11
|
+
* The headers of the response.
|
|
12
|
+
*/
|
|
4
13
|
headers?: {
|
|
5
14
|
[key: string]: string;
|
|
6
15
|
};
|
|
16
|
+
/**
|
|
17
|
+
* The body of the response.
|
|
18
|
+
*/
|
|
7
19
|
body?: any;
|
|
20
|
+
/**
|
|
21
|
+
* The request that triggered this response.
|
|
22
|
+
*/
|
|
8
23
|
request?: RequestInterface;
|
|
9
24
|
}
|
|
@@ -13,5 +13,9 @@ export declare class Route {
|
|
|
13
13
|
* This contains the Route context for dynamic usage.
|
|
14
14
|
*/
|
|
15
15
|
context?: any;
|
|
16
|
+
/**
|
|
17
|
+
* @param controllerInstantiationToken The instantiation token of the controller. Usually this will be the controller's constructor name.
|
|
18
|
+
* @param methodPropertyKey The name of the method that corresponds to the route in the controller.
|
|
19
|
+
*/
|
|
16
20
|
constructor(controllerInstantiationToken: any, methodPropertyKey: string);
|
|
17
21
|
}
|
|
@@ -4,12 +4,24 @@ import { PathRouterNode } from "./path-router.node";
|
|
|
4
4
|
import { Route } from "../models/route";
|
|
5
5
|
/**
|
|
6
6
|
* This class represents the Leaf node of the RouteTree.
|
|
7
|
+
* It will always have a parent node that will be a PathRouterNode.
|
|
7
8
|
*/
|
|
8
9
|
export declare class MethodRouterNode extends RouterNode {
|
|
9
10
|
readonly method: HttpMethod | string;
|
|
10
11
|
readonly route: Route;
|
|
11
12
|
readonly levelFromRoot: number;
|
|
13
|
+
/**
|
|
14
|
+
* @param parent The parent node of the current node.
|
|
15
|
+
* @param method The http method of the current method node.
|
|
16
|
+
* @param route The route associated with the current node.
|
|
17
|
+
* @param levelFromRoot The depth level from the root node.
|
|
18
|
+
*/
|
|
12
19
|
constructor(parent: PathRouterNode, method: HttpMethod | string, route: Route, levelFromRoot: number);
|
|
20
|
+
/**
|
|
21
|
+
* Returns whether or not the node matches.
|
|
22
|
+
* This verification is made by verify the http method matches with the http method of the current node.
|
|
23
|
+
* @param method The http method to compare.
|
|
24
|
+
*/
|
|
13
25
|
matches(method: HttpMethod | string): boolean;
|
|
14
26
|
/**
|
|
15
27
|
* A MethodRouterNode is never a catch-all node.
|
|
@@ -17,19 +29,20 @@ export declare class MethodRouterNode extends RouterNode {
|
|
|
17
29
|
isCatchAll(): boolean;
|
|
18
30
|
/**
|
|
19
31
|
* This method adds all the required nodes to match the splitPaths and the method.
|
|
20
|
-
*
|
|
32
|
+
* Since a MethodRouterNode is a leaf node, you can't add anything after it, this method therefore doesn't do anything.
|
|
21
33
|
* @param splitPaths
|
|
22
34
|
* @param method
|
|
23
35
|
* @param route
|
|
24
36
|
*/
|
|
25
37
|
add(splitPaths: string[], method: HttpMethod | string, route: Route): void;
|
|
26
38
|
/**
|
|
27
|
-
* This method
|
|
39
|
+
* This method receives an array of path and recursively calls its children if this node matches
|
|
40
|
+
* the first splitPath. If the node is a MethodRouterNode, it checks to see if the method matches. If yes,
|
|
28
41
|
* it returns itself as the node found. This method should always return a MethodRouterNode. However, Typescript
|
|
29
42
|
* doesn't like these recursive imports so we return the base class
|
|
30
43
|
*
|
|
31
|
-
* @param splitPaths
|
|
32
|
-
* @param method
|
|
44
|
+
* @param splitPaths A list of all the parts of the paths spliced at the forward slashes.
|
|
45
|
+
* @param method The http method for which to find a node.
|
|
33
46
|
*/
|
|
34
47
|
find(splitPaths: string[], method: HttpMethod | string): RouterNode | null;
|
|
35
48
|
}
|
|
@@ -6,13 +6,17 @@ import { Route } from "../models/route";
|
|
|
6
6
|
*/
|
|
7
7
|
export declare class PathRouterNode extends RouterNode {
|
|
8
8
|
readonly path: string;
|
|
9
|
+
/**
|
|
10
|
+
* @param path The path associated with the current node.
|
|
11
|
+
* @param parent The parent node of the current node.
|
|
12
|
+
*/
|
|
9
13
|
constructor(path: string, parent?: PathRouterNode);
|
|
10
14
|
/**
|
|
11
15
|
* This method adds all the required nodes to match the splitPaths and the method.
|
|
12
16
|
*
|
|
13
|
-
* @param splitPaths
|
|
14
|
-
* @param method
|
|
15
|
-
* @param route
|
|
17
|
+
* @param splitPaths A list of all the parts of the paths spliced at the forward slashes.
|
|
18
|
+
* @param method The http method for this route.
|
|
19
|
+
* @param route The route.
|
|
16
20
|
*/
|
|
17
21
|
add(splitPaths: string[], method: HttpMethod | string, route: Route, levelFromRoot: number): void;
|
|
18
22
|
/**
|
|
@@ -21,14 +25,14 @@ export declare class PathRouterNode extends RouterNode {
|
|
|
21
25
|
* it returns itself as the node found. This method should always return a MethodRouterNode. However, Typescript
|
|
22
26
|
* doesn't like these recursive imports so we return the base class
|
|
23
27
|
*
|
|
24
|
-
* @param splitPaths
|
|
25
|
-
* @param method
|
|
28
|
+
* @param splitPaths A list of all the parts of the paths spliced at the forward slashes.
|
|
29
|
+
* @param method The http method for which to find a node.
|
|
26
30
|
*/
|
|
27
31
|
find(splitPaths: string[], method: HttpMethod | string): RouterNode | null;
|
|
28
32
|
/**
|
|
29
33
|
* This httpMethod navigates the tree upwards and returns all the routeParameters
|
|
30
34
|
*
|
|
31
|
-
* @param splitPaths
|
|
35
|
+
* @param splitPaths A list of all the parts of the paths spliced at the forward slashes.
|
|
32
36
|
*/
|
|
33
37
|
getRouteParameters(splitPaths: string[]): {
|
|
34
38
|
[key: string]: string;
|
|
@@ -38,7 +42,7 @@ export declare class PathRouterNode extends RouterNode {
|
|
|
38
42
|
*/
|
|
39
43
|
isCatchAll(): boolean;
|
|
40
44
|
/**
|
|
41
|
-
* This method returns whether or not this pathRouterNode represents a route parameter, e.g.: /{id} or
|
|
45
|
+
* This method returns whether or not this pathRouterNode represents a route parameter, e.g.: /{id} or /:id
|
|
42
46
|
*/
|
|
43
47
|
isRouteParameter(): boolean;
|
|
44
48
|
/**
|
|
@@ -20,7 +20,7 @@ export declare abstract class RouterNode {
|
|
|
20
20
|
/**
|
|
21
21
|
* This method adds all the required nodes to match the splitPaths and the method.
|
|
22
22
|
*
|
|
23
|
-
* @param splitPaths
|
|
23
|
+
* @param splitPaths A list of all the parts of the paths spliced at the forward slashes.
|
|
24
24
|
* @param method
|
|
25
25
|
* @param route
|
|
26
26
|
* @param levelFromRoot This parameter represents the number of level from the root. The root is at 0.
|
|
@@ -32,8 +32,8 @@ export declare abstract class RouterNode {
|
|
|
32
32
|
* it returns itself as the node found. This method should always return a MethodRouterNode. However, Typescript
|
|
33
33
|
* doesn't like these recursive imports so we return the base class
|
|
34
34
|
*
|
|
35
|
-
* @param splitPaths
|
|
36
|
-
* @param method
|
|
35
|
+
* @param splitPaths A list of all the parts of the paths spliced at the forward slashes.
|
|
36
|
+
* @param method The http method for which to find a node.
|
|
37
37
|
*/
|
|
38
38
|
abstract find(splitPaths: string[], method: HttpMethod | string): RouterNode | null;
|
|
39
39
|
/**
|
|
@@ -2,9 +2,29 @@ import "reflect-metadata";
|
|
|
2
2
|
import { ControllerMethodParameterDecoratorResolverInterface } from "../interfaces/controller-method-parameter-decorator-resolver.interface";
|
|
3
3
|
import { Request } from "../models/request";
|
|
4
4
|
import { IdentityInterface } from "@pristine-ts/common";
|
|
5
|
+
import { ParameterDecoratorInterface } from "../interfaces/parameter-decorator.interface";
|
|
6
|
+
import { BodyParameterDecoratorInterface } from "../interfaces/body-parameter-decorator.interface";
|
|
7
|
+
/**
|
|
8
|
+
* The BodyParameterDecoratorResolver resolves the value of the body of the request so that it can be injected it into the
|
|
9
|
+
* parameter of the route of the controller that was annotated with the @body decorator.
|
|
10
|
+
* It is tagged as an MethodParameterDecoratorResolver so it can be automatically injected with the all the other MethodParameterDecoratorResolvers.
|
|
11
|
+
*/
|
|
5
12
|
export declare class BodyParameterDecoratorResolver implements ControllerMethodParameterDecoratorResolverInterface {
|
|
6
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Resolves the value of the body of the request.
|
|
15
|
+
* The router than injects that value into the parameter of the controller method.
|
|
16
|
+
* @param methodArgument The method argument created by the decorator.
|
|
17
|
+
* @param request The request
|
|
18
|
+
* @param routeParameters The router parameters
|
|
19
|
+
* @param identity The identity making the request
|
|
20
|
+
*/
|
|
21
|
+
resolve(methodArgument: BodyParameterDecoratorInterface, request: Request, routeParameters: {
|
|
7
22
|
[p: string]: string;
|
|
8
23
|
}, identity?: IdentityInterface): Promise<any>;
|
|
9
|
-
|
|
24
|
+
/**
|
|
25
|
+
* Returns whether or not the resolver support such a method argument.
|
|
26
|
+
* Usually we will check the methodArgument.type field to determine if it is a supported type.
|
|
27
|
+
* @param methodArgument
|
|
28
|
+
*/
|
|
29
|
+
supports(methodArgument: ParameterDecoratorInterface): boolean;
|
|
10
30
|
}
|
|
@@ -2,9 +2,23 @@ import { IdentityInterface } from "@pristine-ts/common";
|
|
|
2
2
|
import { ControllerMethodParameterDecoratorResolverInterface } from "../interfaces/controller-method-parameter-decorator-resolver.interface";
|
|
3
3
|
import { Request } from "../models/request";
|
|
4
4
|
import { ParameterDecoratorInterface } from "../interfaces/parameter-decorator.interface";
|
|
5
|
+
/**
|
|
6
|
+
* This service calls the resolvers to resolve the value to be injected in the parameter of a method.
|
|
7
|
+
*/
|
|
5
8
|
export declare class ControllerMethodParameterDecoratorResolver {
|
|
6
9
|
private readonly methodParameterDecoratorResolvers;
|
|
10
|
+
/**
|
|
11
|
+
* This service calls the resolvers to resolve the value to be injected in the parameter of a method.
|
|
12
|
+
* @param methodParameterDecoratorResolvers The parameter decorator resolvers. All services with the tag ServiceDefinitionTagEnum.MethodParameterDecoratorResolver will be automatically injected here.
|
|
13
|
+
*/
|
|
7
14
|
constructor(methodParameterDecoratorResolvers: ControllerMethodParameterDecoratorResolverInterface[]);
|
|
15
|
+
/**
|
|
16
|
+
* This method calls the parameter decorator resolver that supports the type of the decorator and resolves the value to be injected in the parameter.
|
|
17
|
+
* @param methodArgument The method argument created by the decorator.
|
|
18
|
+
* @param request The request
|
|
19
|
+
* @param routeParameters The router parameters
|
|
20
|
+
* @param identity The identity making the request
|
|
21
|
+
*/
|
|
8
22
|
resolve(methodArgument: ParameterDecoratorInterface, request: Request, routeParameters: {
|
|
9
23
|
[key: string]: string;
|
|
10
24
|
}, identity?: IdentityInterface): Promise<any>;
|
|
@@ -2,9 +2,29 @@ import "reflect-metadata";
|
|
|
2
2
|
import { ControllerMethodParameterDecoratorResolverInterface } from "../interfaces/controller-method-parameter-decorator-resolver.interface";
|
|
3
3
|
import { Request } from "../models/request";
|
|
4
4
|
import { IdentityInterface } from "@pristine-ts/common";
|
|
5
|
+
import { ParameterDecoratorInterface } from "../interfaces/parameter-decorator.interface";
|
|
6
|
+
import { HeadersParameterDecoratorInterface } from "../interfaces/headers-parameter-decorator.interface";
|
|
7
|
+
/**
|
|
8
|
+
* The HeadersParameterDecoratorResolver resolves the value of the headers of the request so that it can be injected it into the
|
|
9
|
+
* parameter of the route of the controller that was annotated with the @headers decorator.
|
|
10
|
+
* It is tagged as an MethodParameterDecoratorResolver so it can be automatically injected with the all the other MethodParameterDecoratorResolvers.
|
|
11
|
+
*/
|
|
5
12
|
export declare class HeadersParameterDecoratorResolver implements ControllerMethodParameterDecoratorResolverInterface {
|
|
6
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Resolves the value of the headers of the request.
|
|
15
|
+
* The router than injects that value into the parameter of the controller method.
|
|
16
|
+
* @param methodArgument The method argument created by the decorator.
|
|
17
|
+
* @param request The request
|
|
18
|
+
* @param routeParameters The router parameters
|
|
19
|
+
* @param identity The identity making the request
|
|
20
|
+
*/
|
|
21
|
+
resolve(methodArgument: HeadersParameterDecoratorInterface, request: Request, routeParameters: {
|
|
7
22
|
[p: string]: string;
|
|
8
23
|
}, identity?: IdentityInterface): Promise<any>;
|
|
9
|
-
|
|
24
|
+
/**
|
|
25
|
+
* Returns whether or not the resolver support such a method argument.
|
|
26
|
+
* Usually we will check the methodArgument.type field to determine if it is a supported type.
|
|
27
|
+
* @param methodArgument
|
|
28
|
+
*/
|
|
29
|
+
supports(methodArgument: ParameterDecoratorInterface): boolean;
|
|
10
30
|
}
|
|
@@ -2,9 +2,29 @@ import "reflect-metadata";
|
|
|
2
2
|
import { ControllerMethodParameterDecoratorResolverInterface } from "../interfaces/controller-method-parameter-decorator-resolver.interface";
|
|
3
3
|
import { Request } from "../models/request";
|
|
4
4
|
import { IdentityInterface } from "@pristine-ts/common";
|
|
5
|
+
import { ParameterDecoratorInterface } from "../interfaces/parameter-decorator.interface";
|
|
6
|
+
import { IdentityParameterDecoratorInterface } from "../interfaces/identity-parameteter-decorator.interface";
|
|
7
|
+
/**
|
|
8
|
+
* The IdentityParameterDecoratorResolver resolves the value of the identity (parsed by the authenticator) of the request
|
|
9
|
+
* so that it can be injected it into the parameter of the route of the controller that was annotated with the @identity decorator.
|
|
10
|
+
* It is tagged as an MethodParameterDecoratorResolver so it can be automatically injected with the all the other MethodParameterDecoratorResolvers.
|
|
11
|
+
*/
|
|
5
12
|
export declare class IdentityParameterDecoratorResolver implements ControllerMethodParameterDecoratorResolverInterface {
|
|
6
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Resolves the value of the identity of the request.
|
|
15
|
+
* The router than injects that value into the parameter of the controller method.
|
|
16
|
+
* @param methodArgument The method argument created by the decorator.
|
|
17
|
+
* @param request The request
|
|
18
|
+
* @param routeParameters The router parameters
|
|
19
|
+
* @param identity The identity making the request
|
|
20
|
+
*/
|
|
21
|
+
resolve(methodArgument: IdentityParameterDecoratorInterface, request: Request, routeParameters: {
|
|
7
22
|
[p: string]: string;
|
|
8
23
|
}, identity?: IdentityInterface): Promise<any>;
|
|
9
|
-
|
|
24
|
+
/**
|
|
25
|
+
* Returns whether or not the resolver support such a method argument.
|
|
26
|
+
* Usually we will check the methodArgument.type field to determine if it is a supported type.
|
|
27
|
+
* @param methodArgument
|
|
28
|
+
*/
|
|
29
|
+
supports(methodArgument: ParameterDecoratorInterface): boolean;
|
|
10
30
|
}
|
|
@@ -1,9 +1,30 @@
|
|
|
1
1
|
import { ControllerMethodParameterDecoratorResolverInterface } from "../interfaces/controller-method-parameter-decorator-resolver.interface";
|
|
2
2
|
import { Request } from "../models/request";
|
|
3
3
|
import { IdentityInterface } from "@pristine-ts/common";
|
|
4
|
+
import { ParameterDecoratorInterface } from "../interfaces/parameter-decorator.interface";
|
|
5
|
+
import { QueryParameterDecoratorInterface } from "../interfaces/query-parameter-decorator.interface";
|
|
6
|
+
/**
|
|
7
|
+
* The QueryParameterDecoratorResolver resolves the value of the query parameter with the name passed to the decorator
|
|
8
|
+
* of the request so that it can be injected it into the parameter of the route of the controller that was annotated
|
|
9
|
+
* with the @queryParameter decorator.
|
|
10
|
+
* It is tagged as an MethodParameterDecoratorResolver so it can be automatically injected with the all the other MethodParameterDecoratorResolvers.
|
|
11
|
+
*/
|
|
4
12
|
export declare class QueryParameterDecoratorResolver implements ControllerMethodParameterDecoratorResolverInterface {
|
|
5
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Resolves the value of the query parameter with the specified name of the request.
|
|
15
|
+
* The router than injects that value into the parameter of the controller method.
|
|
16
|
+
* @param methodArgument The method argument created by the decorator including the query parameter name.
|
|
17
|
+
* @param request The request
|
|
18
|
+
* @param routeParameters The router parameters
|
|
19
|
+
* @param identity The identity making the request
|
|
20
|
+
*/
|
|
21
|
+
resolve(methodArgument: QueryParameterDecoratorInterface, request: Request, routeParameters: {
|
|
6
22
|
[p: string]: string;
|
|
7
23
|
}, identity?: IdentityInterface): Promise<any>;
|
|
8
|
-
|
|
24
|
+
/**
|
|
25
|
+
* Returns whether or not the resolver support such a method argument.
|
|
26
|
+
* Usually we will check the methodArgument.type field to determine if it is a supported type.
|
|
27
|
+
* @param methodArgument
|
|
28
|
+
*/
|
|
29
|
+
supports(methodArgument: ParameterDecoratorInterface): boolean;
|
|
9
30
|
}
|
|
@@ -1,9 +1,29 @@
|
|
|
1
1
|
import { ControllerMethodParameterDecoratorResolverInterface } from "../interfaces/controller-method-parameter-decorator-resolver.interface";
|
|
2
2
|
import { Request } from "../models/request";
|
|
3
3
|
import { IdentityInterface } from "@pristine-ts/common";
|
|
4
|
+
import { ParameterDecoratorInterface } from "../interfaces/parameter-decorator.interface";
|
|
5
|
+
import { QueryParametersDecoratorInterface } from "../interfaces/query-parameters-decorator.interface";
|
|
6
|
+
/**
|
|
7
|
+
* The QueryParametersDecoratorResolver resolves the value (a map) of the query parameters of the request so that it can be injected it into the
|
|
8
|
+
* parameter of the route of the controller that was annotated with the @queryParameters decorator.
|
|
9
|
+
* It is tagged as an MethodParameterDecoratorResolver so it can be automatically injected with the all the other MethodParameterDecoratorResolvers.
|
|
10
|
+
*/
|
|
4
11
|
export declare class QueryParametersDecoratorResolver implements ControllerMethodParameterDecoratorResolverInterface {
|
|
5
|
-
|
|
12
|
+
/**
|
|
13
|
+
* Resolves the value of all the query parameters of the request.
|
|
14
|
+
* The router than injects that value into the parameter of the controller method.
|
|
15
|
+
* @param methodArgument The method argument created by the decorator.
|
|
16
|
+
* @param request The request
|
|
17
|
+
* @param routeParameters The router parameters
|
|
18
|
+
* @param identity The identity making the request
|
|
19
|
+
*/
|
|
20
|
+
resolve(methodArgument: QueryParametersDecoratorInterface, request: Request, routeParameters: {
|
|
6
21
|
[p: string]: string;
|
|
7
22
|
}, identity?: IdentityInterface): Promise<any>;
|
|
8
|
-
|
|
23
|
+
/**
|
|
24
|
+
* Returns whether or not the resolver support such a method argument.
|
|
25
|
+
* Usually we will check the methodArgument.type field to determine if it is a supported type.
|
|
26
|
+
* @param methodArgument
|
|
27
|
+
*/
|
|
28
|
+
supports(methodArgument: ParameterDecoratorInterface): boolean;
|
|
9
29
|
}
|
|
@@ -2,9 +2,29 @@ import "reflect-metadata";
|
|
|
2
2
|
import { ControllerMethodParameterDecoratorResolverInterface } from "../interfaces/controller-method-parameter-decorator-resolver.interface";
|
|
3
3
|
import { Request } from "../models/request";
|
|
4
4
|
import { IdentityInterface } from "@pristine-ts/common";
|
|
5
|
+
import { RequestParameterDecoratorInterface } from "../interfaces/request-parameter-decorator.interface";
|
|
6
|
+
import { ParameterDecoratorInterface } from "../interfaces/parameter-decorator.interface";
|
|
7
|
+
/**
|
|
8
|
+
* The RequestParameterDecoratorResolver resolves the value of the whole request so that it can be injected it into the
|
|
9
|
+
* parameter of the route of the controller that was annotated with the @request decorator.
|
|
10
|
+
* It is tagged as an MethodParameterDecoratorResolver so it can be automatically injected with the all the other MethodParameterDecoratorResolvers.
|
|
11
|
+
*/
|
|
5
12
|
export declare class RequestParameterDecoratorResolver implements ControllerMethodParameterDecoratorResolverInterface {
|
|
6
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Resolves the value of the whole request.
|
|
15
|
+
* The router than injects that value into the parameter of the controller method.
|
|
16
|
+
* @param methodArgument The method argument created by the decorator.
|
|
17
|
+
* @param request The request
|
|
18
|
+
* @param routeParameters The router parameters
|
|
19
|
+
* @param identity The identity making the request
|
|
20
|
+
*/
|
|
21
|
+
resolve(methodArgument: RequestParameterDecoratorInterface, request: Request, routeParameters: {
|
|
7
22
|
[p: string]: string;
|
|
8
23
|
}, identity?: IdentityInterface): Promise<any>;
|
|
9
|
-
|
|
24
|
+
/**
|
|
25
|
+
* Returns whether or not the resolver support such a method argument.
|
|
26
|
+
* Usually we will check the methodArgument.type field to determine if it is a supported type.
|
|
27
|
+
* @param methodArgument
|
|
28
|
+
*/
|
|
29
|
+
supports(methodArgument: ParameterDecoratorInterface): boolean;
|
|
10
30
|
}
|
|
@@ -1,9 +1,29 @@
|
|
|
1
1
|
import { ControllerMethodParameterDecoratorResolverInterface } from "../interfaces/controller-method-parameter-decorator-resolver.interface";
|
|
2
2
|
import { Request } from "../models/request";
|
|
3
3
|
import { IdentityInterface } from "@pristine-ts/common";
|
|
4
|
+
import { RouteParameterDecoratorInterface } from "../interfaces/route-parameter-decorator.interface";
|
|
5
|
+
import { ParameterDecoratorInterface } from "../interfaces/parameter-decorator.interface";
|
|
6
|
+
/**
|
|
7
|
+
* The RouteParameterDecoratorResolver resolves the value of the route parameter specified of the request so that it can be injected it into the
|
|
8
|
+
* parameter of the route of the controller that was annotated with the @routeParameter decorator.
|
|
9
|
+
* It is tagged as an MethodParameterDecoratorResolver so it can be automatically injected with the all the other MethodParameterDecoratorResolvers.
|
|
10
|
+
*/
|
|
4
11
|
export declare class RouteParameterDecoratorResolver implements ControllerMethodParameterDecoratorResolverInterface {
|
|
5
|
-
|
|
12
|
+
/**
|
|
13
|
+
* Resolves the value of the the route parameter with the specified name of the request.
|
|
14
|
+
* The router than injects that value into the parameter of the controller method.
|
|
15
|
+
* @param methodArgument The method argument created by the decorator, including the name of the parameter to resolve.
|
|
16
|
+
* @param request The request
|
|
17
|
+
* @param routeParameters The router parameters
|
|
18
|
+
* @param identity The identity making the request
|
|
19
|
+
*/
|
|
20
|
+
resolve(methodArgument: RouteParameterDecoratorInterface, request: Request, routeParameters: {
|
|
6
21
|
[p: string]: string;
|
|
7
22
|
}, identity?: IdentityInterface): Promise<any>;
|
|
8
|
-
|
|
23
|
+
/**
|
|
24
|
+
* Returns whether or not the resolver support such a method argument.
|
|
25
|
+
* Usually we will check the methodArgument.type field to determine if it is a supported type.
|
|
26
|
+
* @param methodArgument
|
|
27
|
+
*/
|
|
28
|
+
supports(methodArgument: ParameterDecoratorInterface): boolean;
|
|
9
29
|
}
|
package/dist/types/router.d.ts
CHANGED
|
@@ -7,15 +7,25 @@ import { ControllerMethodParameterDecoratorResolver } from "./resolvers/controll
|
|
|
7
7
|
import { HttpMethod } from "@pristine-ts/common";
|
|
8
8
|
import { AuthenticationManagerInterface, AuthorizerManagerInterface } from "@pristine-ts/security";
|
|
9
9
|
import { LogHandlerInterface } from "@pristine-ts/logging";
|
|
10
|
-
|
|
10
|
+
/**
|
|
11
|
+
* The router service is the service that creates the routing tree from the controllers.
|
|
12
|
+
* It also executes a request properly by routing it to the intended controller and returns the response.
|
|
13
|
+
*/
|
|
11
14
|
export declare class Router implements RouterInterface {
|
|
12
15
|
private readonly loghandler;
|
|
13
16
|
private readonly controllerMethodParameterDecoratorResolver;
|
|
14
17
|
private readonly authorizerManager;
|
|
15
18
|
private readonly authenticationManager;
|
|
16
|
-
private readonly tracingManager;
|
|
17
19
|
private root;
|
|
18
|
-
|
|
20
|
+
/**
|
|
21
|
+
* The router service is the service that creates the routing tree from the controllers.
|
|
22
|
+
* It also executes a request properly by routing it to the intended controller and returns the response.
|
|
23
|
+
* @param loghandler The log handler
|
|
24
|
+
* @param controllerMethodParameterDecoratorResolver The controller method parameter decorator resolver used to resolve the values.
|
|
25
|
+
* @param authorizerManager The authorizer manager to validate authorization.
|
|
26
|
+
* @param authenticationManager The authentication manager to validate authentication.
|
|
27
|
+
*/
|
|
28
|
+
constructor(loghandler: LogHandlerInterface, controllerMethodParameterDecoratorResolver: ControllerMethodParameterDecoratorResolver, authorizerManager: AuthorizerManagerInterface, authenticationManager: AuthenticationManagerInterface);
|
|
19
29
|
/**
|
|
20
30
|
* This method registers a Route into the Route Tree maintained by the router.
|
|
21
31
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pristine-ts/networking",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.166",
|
|
4
4
|
"description": "",
|
|
5
5
|
"module": "dist/lib/esm/networking.module.js",
|
|
6
6
|
"main": "dist/lib/cjs/networking.module.js",
|
|
@@ -19,9 +19,9 @@
|
|
|
19
19
|
"access": "public"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@pristine-ts/common": "^0.0.
|
|
23
|
-
"@pristine-ts/security": "^0.0.
|
|
24
|
-
"@pristine-ts/telemetry": "^0.0.
|
|
22
|
+
"@pristine-ts/common": "^0.0.166",
|
|
23
|
+
"@pristine-ts/security": "^0.0.166",
|
|
24
|
+
"@pristine-ts/telemetry": "^0.0.166",
|
|
25
25
|
"url-parse": "^1.4.7"
|
|
26
26
|
},
|
|
27
27
|
"jest": {
|
|
@@ -58,5 +58,5 @@
|
|
|
58
58
|
"src/*.{js,ts}"
|
|
59
59
|
]
|
|
60
60
|
},
|
|
61
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "c452544a69d17814c83d6a99a4fd788fdaa0daff"
|
|
62
62
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=enums.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"enums.js","sourceRoot":"","sources":["../../../../src/enums/enums.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"error-response-body.js","sourceRoot":"","sources":["../../../../src/models/error-response-body.ts"],"names":[],"mappings":";;;AAAA,MAAa,iBAAiB;CAG7B;AAHD,8CAGC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=enums.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"enums.js","sourceRoot":"","sources":["../../../../src/enums/enums.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"error-response-body.js","sourceRoot":"","sources":["../../../../src/models/error-response-body.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,iBAAiB;CAG7B"}
|
|
File without changes
|