@webpieces/core-meta 0.1.0
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/README.md +19 -0
- package/package.json +23 -0
- package/src/WebAppMeta.d.ts +98 -0
- package/src/WebAppMeta.js +20 -0
- package/src/WebAppMeta.js.map +1 -0
- package/src/index.d.ts +1 -0
- package/src/index.js +6 -0
- package/src/index.js.map +1 -0
package/README.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# @webpieces/core-meta
|
|
2
|
+
|
|
3
|
+
> Core metadata interfaces for WebPieces framework
|
|
4
|
+
|
|
5
|
+
Part of the [WebPieces TypeScript](https://github.com/deanhiller/webpieces-ts) framework.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @webpieces/core-meta
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Documentation
|
|
14
|
+
|
|
15
|
+
See the main [WebPieces README](https://github.com/deanhiller/webpieces-ts#readme) for complete documentation and examples.
|
|
16
|
+
|
|
17
|
+
## License
|
|
18
|
+
|
|
19
|
+
Apache-2.0
|
package/package.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@webpieces/core-meta",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Core metadata interfaces for WebPieces framework",
|
|
5
|
+
"type": "commonjs",
|
|
6
|
+
"main": "./src/index.js",
|
|
7
|
+
"types": "./src/index.d.ts",
|
|
8
|
+
"author": "Dean Hiller",
|
|
9
|
+
"license": "Apache-2.0",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/deanhiller/webpieces-ts.git",
|
|
13
|
+
"directory": "packages/core/core-meta"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"webpieces",
|
|
17
|
+
"framework",
|
|
18
|
+
"metadata"
|
|
19
|
+
],
|
|
20
|
+
"publishConfig": {
|
|
21
|
+
"access": "public"
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { ContainerModule, Container } from 'inversify';
|
|
2
|
+
/**
|
|
3
|
+
* Represents a route configuration that can be registered with the router.
|
|
4
|
+
* Similar to Java WebPieces Routes interface.
|
|
5
|
+
*/
|
|
6
|
+
export interface Routes {
|
|
7
|
+
/**
|
|
8
|
+
* Configure routes using the provided RouteBuilder.
|
|
9
|
+
*/
|
|
10
|
+
configure(routeBuilder: RouteBuilder): void;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Builder for registering routes.
|
|
14
|
+
* Will be implemented in http-routing package.
|
|
15
|
+
*/
|
|
16
|
+
export interface RouteBuilder {
|
|
17
|
+
addRoute<TResult = unknown>(route: RouteDefinition<TResult>): void;
|
|
18
|
+
addFilter(filter: FilterDefinition): void;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Definition of a single route.
|
|
22
|
+
*
|
|
23
|
+
* Generic type parameter TResult represents the return type of the route handler.
|
|
24
|
+
* This provides type safety for the entire request/response cycle.
|
|
25
|
+
*/
|
|
26
|
+
export interface RouteDefinition<TResult = unknown> {
|
|
27
|
+
method: string;
|
|
28
|
+
path: string;
|
|
29
|
+
handler: RouteHandler<TResult>;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Definition of a filter with priority.
|
|
33
|
+
*/
|
|
34
|
+
export interface FilterDefinition {
|
|
35
|
+
priority: number;
|
|
36
|
+
filterClass: any;
|
|
37
|
+
packageRegex?: RegExp;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Request data passed to route handlers.
|
|
41
|
+
*/
|
|
42
|
+
export interface RouteRequest {
|
|
43
|
+
body?: any;
|
|
44
|
+
query?: Record<string, any>;
|
|
45
|
+
params?: Record<string, any>;
|
|
46
|
+
headers?: Record<string, any>;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Context passed to route handlers.
|
|
50
|
+
* Contains DI container, request data, and extracted parameters.
|
|
51
|
+
*/
|
|
52
|
+
export interface RouteContext {
|
|
53
|
+
/** DI container for resolving dependencies */
|
|
54
|
+
container: Container;
|
|
55
|
+
/** Extracted parameters (e.g., from request body, path params) */
|
|
56
|
+
params: any[];
|
|
57
|
+
/** Original request data */
|
|
58
|
+
request?: RouteRequest;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Handler class for routes.
|
|
62
|
+
* Takes a RouteContext and returns the controller method result.
|
|
63
|
+
*
|
|
64
|
+
* Generic type parameter TResult represents the return type of the controller method.
|
|
65
|
+
* Example: RouteHandler<SaveResponse> for a method that returns Promise<SaveResponse>
|
|
66
|
+
*
|
|
67
|
+
* Using unknown as default instead of any forces type safety - consumers must
|
|
68
|
+
* handle the result appropriately rather than assuming any type.
|
|
69
|
+
*
|
|
70
|
+
* This is a class instead of a function type to make it easier to trace
|
|
71
|
+
* who is calling what in the debugger/IDE.
|
|
72
|
+
*/
|
|
73
|
+
export declare abstract class RouteHandler<TResult = unknown> {
|
|
74
|
+
/**
|
|
75
|
+
* Execute the route handler.
|
|
76
|
+
* @param context - The route context containing DI container, params, and request
|
|
77
|
+
* @returns Promise of the controller method result
|
|
78
|
+
*/
|
|
79
|
+
abstract execute(context: RouteContext): Promise<TResult>;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Main application metadata interface.
|
|
83
|
+
* Similar to Java WebPieces WebAppMeta.
|
|
84
|
+
*
|
|
85
|
+
* This is the entry point that WebpiecesServer calls to configure your application.
|
|
86
|
+
*/
|
|
87
|
+
export interface WebAppMeta {
|
|
88
|
+
/**
|
|
89
|
+
* Returns the list of Inversify container modules for dependency injection.
|
|
90
|
+
* Similar to getGuiceModules() in Java.
|
|
91
|
+
*/
|
|
92
|
+
getDIModules(): ContainerModule[];
|
|
93
|
+
/**
|
|
94
|
+
* Returns the list of route configurations.
|
|
95
|
+
* Similar to getRouteModules() in Java.
|
|
96
|
+
*/
|
|
97
|
+
getRoutes(): Routes[];
|
|
98
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RouteHandler = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Handler class for routes.
|
|
6
|
+
* Takes a RouteContext and returns the controller method result.
|
|
7
|
+
*
|
|
8
|
+
* Generic type parameter TResult represents the return type of the controller method.
|
|
9
|
+
* Example: RouteHandler<SaveResponse> for a method that returns Promise<SaveResponse>
|
|
10
|
+
*
|
|
11
|
+
* Using unknown as default instead of any forces type safety - consumers must
|
|
12
|
+
* handle the result appropriately rather than assuming any type.
|
|
13
|
+
*
|
|
14
|
+
* This is a class instead of a function type to make it easier to trace
|
|
15
|
+
* who is calling what in the debugger/IDE.
|
|
16
|
+
*/
|
|
17
|
+
class RouteHandler {
|
|
18
|
+
}
|
|
19
|
+
exports.RouteHandler = RouteHandler;
|
|
20
|
+
//# sourceMappingURL=WebAppMeta.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WebAppMeta.js","sourceRoot":"","sources":["../../../../../packages/core/core-meta/src/WebAppMeta.ts"],"names":[],"mappings":";;;AAkEA;;;;;;;;;;;;GAYG;AACH,MAAsB,YAAY;CAOjC;AAPD,oCAOC"}
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { WebAppMeta, Routes, RouteBuilder, RouteDefinition, FilterDefinition, RouteHandler, RouteContext, RouteRequest, } from './WebAppMeta';
|
package/src/index.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RouteHandler = void 0;
|
|
4
|
+
var WebAppMeta_1 = require("./WebAppMeta");
|
|
5
|
+
Object.defineProperty(exports, "RouteHandler", { enumerable: true, get: function () { return WebAppMeta_1.RouteHandler; } });
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/core/core-meta/src/index.ts"],"names":[],"mappings":";;;AAAA,2CASsB;AAHpB,0GAAA,YAAY,OAAA"}
|