@webpieces/http-server 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 ADDED
@@ -0,0 +1,19 @@
1
+ # @webpieces/http-server
2
+
3
+ > WebPieces server with filter chain and dependency injection
4
+
5
+ Part of the [WebPieces TypeScript](https://github.com/deanhiller/webpieces-ts) framework.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ npm install @webpieces/http-server
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,29 @@
1
+ {
2
+ "name": "@webpieces/http-server",
3
+ "version": "0.1.0",
4
+ "description": "WebPieces server with filter chain and dependency injection",
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/http/http-server"
14
+ },
15
+ "keywords": [
16
+ "webpieces",
17
+ "server",
18
+ "framework",
19
+ "microservices"
20
+ ],
21
+ "publishConfig": {
22
+ "access": "public"
23
+ },
24
+ "dependencies": {
25
+ "@webpieces/core-meta": "0.1.0",
26
+ "@webpieces/http-routing": "0.1.0",
27
+ "@webpieces/http-filters": "0.1.0"
28
+ }
29
+ }
@@ -0,0 +1,61 @@
1
+ import { Container } from 'inversify';
2
+ import { RouteBuilder, RouteDefinition, FilterDefinition } from '@webpieces/core-meta';
3
+ import { Filter } from '@webpieces/http-filters';
4
+ import { RouteMetadata } from "@webpieces/http-api";
5
+ /**
6
+ * Registered route entry in the route registry.
7
+ *
8
+ * We use unknown instead of any for better type safety:
9
+ * - unknown forces type checking at usage points
10
+ * - any allows unsafe operations without checks
11
+ *
12
+ * Each route has its own TResult type, but we can't store different
13
+ * generic types in the same Map, so we use unknown as a type-safe escape hatch.
14
+ */
15
+ export interface RegisteredRoute<TResult = unknown> extends RouteDefinition<TResult> {
16
+ routeMetadata?: RouteMetadata;
17
+ controllerClass?: any;
18
+ }
19
+ /**
20
+ * RouteBuilderImpl - Concrete implementation of RouteBuilder interface.
21
+ *
22
+ * Similar to Java WebPieces RouteBuilder, this class is responsible for:
23
+ * 1. Registering routes with their handlers
24
+ * 2. Registering filters with priority
25
+ *
26
+ * This class is explicit (not anonymous) to:
27
+ * - Improve traceability and debugging
28
+ * - Make the code easier to understand
29
+ * - Enable better IDE navigation (Cmd+Click on addRoute works!)
30
+ */
31
+ export declare class RouteBuilderImpl implements RouteBuilder {
32
+ private routes;
33
+ private filters;
34
+ private container;
35
+ /**
36
+ * Create a new RouteBuilder.
37
+ *
38
+ * @param routes - Map to store registered routes (keyed by "METHOD:path")
39
+ * @param filters - Array to store registered filters
40
+ * @param container - DI container for resolving filter instances
41
+ */
42
+ constructor(routes: Map<string, RegisteredRoute<unknown>>, filters: Filter[], container: Container);
43
+ /**
44
+ * Register a route with the router.
45
+ *
46
+ * The route is stored with a key of "METHOD:path" (e.g., "POST:/search/item").
47
+ * The TResult generic ensures type safety for the route's return type.
48
+ *
49
+ * @param route - Route definition with method, path, and handler
50
+ */
51
+ addRoute<TResult = unknown>(route: RouteDefinition<TResult>): void;
52
+ /**
53
+ * Register a filter with the filter chain.
54
+ *
55
+ * Filters are resolved from the DI container and added to the filter array.
56
+ * They will be executed in priority order (higher priority first).
57
+ *
58
+ * @param filterDef - Filter definition with priority and filter class
59
+ */
60
+ addFilter(filterDef: FilterDefinition): void;
61
+ }
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RouteBuilderImpl = void 0;
4
+ /**
5
+ * RouteBuilderImpl - Concrete implementation of RouteBuilder interface.
6
+ *
7
+ * Similar to Java WebPieces RouteBuilder, this class is responsible for:
8
+ * 1. Registering routes with their handlers
9
+ * 2. Registering filters with priority
10
+ *
11
+ * This class is explicit (not anonymous) to:
12
+ * - Improve traceability and debugging
13
+ * - Make the code easier to understand
14
+ * - Enable better IDE navigation (Cmd+Click on addRoute works!)
15
+ */
16
+ class RouteBuilderImpl {
17
+ /**
18
+ * Create a new RouteBuilder.
19
+ *
20
+ * @param routes - Map to store registered routes (keyed by "METHOD:path")
21
+ * @param filters - Array to store registered filters
22
+ * @param container - DI container for resolving filter instances
23
+ */
24
+ constructor(routes, filters, container) {
25
+ this.routes = routes;
26
+ this.filters = filters;
27
+ this.container = container;
28
+ }
29
+ /**
30
+ * Register a route with the router.
31
+ *
32
+ * The route is stored with a key of "METHOD:path" (e.g., "POST:/search/item").
33
+ * The TResult generic ensures type safety for the route's return type.
34
+ *
35
+ * @param route - Route definition with method, path, and handler
36
+ */
37
+ addRoute(route) {
38
+ const key = `${route.method}:${route.path}`;
39
+ // Store as RegisteredRoute<unknown> in the map
40
+ // Type safety is maintained through the generic on RouteDefinition
41
+ this.routes.set(key, route);
42
+ }
43
+ /**
44
+ * Register a filter with the filter chain.
45
+ *
46
+ * Filters are resolved from the DI container and added to the filter array.
47
+ * They will be executed in priority order (higher priority first).
48
+ *
49
+ * @param filterDef - Filter definition with priority and filter class
50
+ */
51
+ addFilter(filterDef) {
52
+ // Resolve filter instance from DI container
53
+ const filter = this.container.get(filterDef.filterClass);
54
+ // Set priority on the filter instance
55
+ filter.priority = filterDef.priority;
56
+ // Add to filters array (will be sorted by priority later)
57
+ this.filters.push(filter);
58
+ }
59
+ }
60
+ exports.RouteBuilderImpl = RouteBuilderImpl;
61
+ //# sourceMappingURL=RouteBuilderImpl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RouteBuilderImpl.js","sourceRoot":"","sources":["../../../../../packages/http/http-server/src/RouteBuilderImpl.ts"],"names":[],"mappings":";;;AAoBA;;;;;;;;;;;GAWG;AACH,MAAa,gBAAgB;IAK3B;;;;;;OAMG;IACH,YACE,MAA6C,EAC7C,OAAiB,EACjB,SAAoB;QAEpB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;IAED;;;;;;;OAOG;IACH,QAAQ,CAAoB,KAA+B;QACzD,MAAM,GAAG,GAAG,GAAG,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC;QAE5C,+CAA+C;QAC/C,mEAAmE;QACnE,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,KAAiC,CAAC,CAAC;IAC1D,CAAC;IAED;;;;;;;OAOG;IACH,SAAS,CAAC,SAA2B;QACnC,4CAA4C;QAC5C,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAS,SAAS,CAAC,WAAW,CAAC,CAAC;QAEjE,sCAAsC;QACtC,MAAM,CAAC,QAAQ,GAAG,SAAS,CAAC,QAAQ,CAAC;QAErC,0DAA0D;QAC1D,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC5B,CAAC;CACF;AAxDD,4CAwDC"}
@@ -0,0 +1,127 @@
1
+ import { Container } from 'inversify';
2
+ import { WebAppMeta } from '@webpieces/core-meta';
3
+ /**
4
+ * WebpiecesServer - Main bootstrap class for WebPieces applications.
5
+ *
6
+ * This class uses a two-container pattern similar to Java WebPieces:
7
+ * 1. webpiecesContainer: Core WebPieces framework bindings
8
+ * 2. appContainer: User's application bindings (child of webpiecesContainer)
9
+ *
10
+ * This separation allows:
11
+ * - Clean separation of concerns
12
+ * - Better testability
13
+ * - Ability to override framework bindings in tests
14
+ *
15
+ * The server:
16
+ * 1. Initializes both DI containers from WebAppMeta.getDIModules()
17
+ * 2. Registers routes using explicit RouteBuilderImpl
18
+ * 3. Creates filter chains
19
+ * 4. Supports both HTTP server mode and testing mode (no HTTP)
20
+ *
21
+ * Usage for testing (no HTTP):
22
+ * ```typescript
23
+ * const server = new WebpiecesServer(new ProdServerMeta());
24
+ * server.initialize();
25
+ * const saveApi = server.createApiClient<SaveApi>(SaveApiPrototype);
26
+ * const response = await saveApi.save(request);
27
+ * ```
28
+ *
29
+ * Usage for production (HTTP server):
30
+ * ```typescript
31
+ * const server = new WebpiecesServer(new ProdServerMeta());
32
+ * server.start(); // Starts Express server
33
+ * ```
34
+ */
35
+ export declare class WebpiecesServer {
36
+ private meta;
37
+ /**
38
+ * WebPieces container: Core WebPieces framework bindings.
39
+ * This includes framework-level services like filters, routing infrastructure,
40
+ * logging, metrics, etc. Similar to Java WebPieces platform container.
41
+ */
42
+ private webpiecesContainer;
43
+ /**
44
+ * Application container: User's application bindings.
45
+ * This is a child container of webpiecesContainer, so it can access
46
+ * framework bindings while keeping app bindings separate.
47
+ */
48
+ private appContainer;
49
+ /**
50
+ * Routes registry: Maps "METHOD:path" -> RegisteredRoute
51
+ * Example: "POST:/search/item" -> { method: "POST", path: "/search/item", handler: ... }
52
+ *
53
+ * We use unknown instead of any for type safety - each route has its own return type,
54
+ * but we can't have different generic types in the same Map.
55
+ */
56
+ private routes;
57
+ /**
58
+ * Registered filters, sorted by priority (higher priority first).
59
+ */
60
+ private filters;
61
+ private initialized;
62
+ private app?;
63
+ private server?;
64
+ private port;
65
+ constructor(meta: WebAppMeta);
66
+ /**
67
+ * Initialize the server (DI container, routes, filters).
68
+ * This is called automatically by start() or can be called manually for testing.
69
+ */
70
+ initialize(): void;
71
+ /**
72
+ * Load DI modules from WebAppMeta.
73
+ *
74
+ * Currently, all user modules are loaded into the application container.
75
+ * In the future, we could separate:
76
+ * - WebPieces framework modules -> webpiecesContainer
77
+ * - Application modules -> appContainer
78
+ *
79
+ * For now, everything goes into appContainer which has access to webpiecesContainer.
80
+ */
81
+ private loadDIModules;
82
+ /**
83
+ * Register routes from WebAppMeta.
84
+ *
85
+ * Creates an explicit RouteBuilderImpl instead of an anonymous object.
86
+ * This improves:
87
+ * - Traceability: Can Cmd+Click on addRoute to see implementation
88
+ * - Debugging: Explicit class shows up in stack traces
89
+ * - Understanding: Clear class name vs anonymous object
90
+ */
91
+ private registerRoutes;
92
+ /**
93
+ * Start the HTTP server with Express.
94
+ */
95
+ start(port?: number): void;
96
+ /**
97
+ * Register all routes with Express.
98
+ */
99
+ private registerExpressRoutes;
100
+ /**
101
+ * Stop the HTTP server.
102
+ */
103
+ stop(): void;
104
+ /**
105
+ * Create an API client proxy for testing (no HTTP).
106
+ *
107
+ * This creates a proxy object that implements the API interface
108
+ * and routes method calls through the full filter chain to the controller.
109
+ *
110
+ * @param apiMetaClass - The API interface class with decorators
111
+ * @returns Proxy object implementing the API interface
112
+ */
113
+ createApiClient<T>(apiMetaClass: any): T;
114
+ /**
115
+ * Invoke a route through the filter chain.
116
+ */
117
+ private invokeRoute;
118
+ /**
119
+ * Get the application DI container (for testing).
120
+ * Returns appContainer which has access to both app and framework bindings.
121
+ */
122
+ getContainer(): Container;
123
+ /**
124
+ * Get the WebPieces framework container (for advanced testing/debugging).
125
+ */
126
+ getWebpiecesContainer(): Container;
127
+ }
@@ -0,0 +1,310 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WebpiecesServer = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const express_1 = tslib_1.__importDefault(require("express"));
6
+ const inversify_1 = require("inversify");
7
+ const http_filters_1 = require("@webpieces/http-filters");
8
+ const http_routing_1 = require("@webpieces/http-routing");
9
+ const RouteBuilderImpl_1 = require("./RouteBuilderImpl");
10
+ /**
11
+ * WebpiecesServer - Main bootstrap class for WebPieces applications.
12
+ *
13
+ * This class uses a two-container pattern similar to Java WebPieces:
14
+ * 1. webpiecesContainer: Core WebPieces framework bindings
15
+ * 2. appContainer: User's application bindings (child of webpiecesContainer)
16
+ *
17
+ * This separation allows:
18
+ * - Clean separation of concerns
19
+ * - Better testability
20
+ * - Ability to override framework bindings in tests
21
+ *
22
+ * The server:
23
+ * 1. Initializes both DI containers from WebAppMeta.getDIModules()
24
+ * 2. Registers routes using explicit RouteBuilderImpl
25
+ * 3. Creates filter chains
26
+ * 4. Supports both HTTP server mode and testing mode (no HTTP)
27
+ *
28
+ * Usage for testing (no HTTP):
29
+ * ```typescript
30
+ * const server = new WebpiecesServer(new ProdServerMeta());
31
+ * server.initialize();
32
+ * const saveApi = server.createApiClient<SaveApi>(SaveApiPrototype);
33
+ * const response = await saveApi.save(request);
34
+ * ```
35
+ *
36
+ * Usage for production (HTTP server):
37
+ * ```typescript
38
+ * const server = new WebpiecesServer(new ProdServerMeta());
39
+ * server.start(); // Starts Express server
40
+ * ```
41
+ */
42
+ class WebpiecesServer {
43
+ constructor(meta) {
44
+ /**
45
+ * Routes registry: Maps "METHOD:path" -> RegisteredRoute
46
+ * Example: "POST:/search/item" -> { method: "POST", path: "/search/item", handler: ... }
47
+ *
48
+ * We use unknown instead of any for type safety - each route has its own return type,
49
+ * but we can't have different generic types in the same Map.
50
+ */
51
+ this.routes = new Map();
52
+ /**
53
+ * Registered filters, sorted by priority (higher priority first).
54
+ */
55
+ this.filters = [];
56
+ this.initialized = false;
57
+ this.port = 8080;
58
+ this.meta = meta;
59
+ // Create WebPieces container for framework-level bindings
60
+ this.webpiecesContainer = new inversify_1.Container();
61
+ // Create application container as a child of WebPieces container
62
+ // This allows app container to access framework bindings
63
+ this.appContainer = new inversify_1.Container();
64
+ this.appContainer.parent = this.webpiecesContainer;
65
+ }
66
+ /**
67
+ * Initialize the server (DI container, routes, filters).
68
+ * This is called automatically by start() or can be called manually for testing.
69
+ */
70
+ initialize() {
71
+ if (this.initialized) {
72
+ return;
73
+ }
74
+ // 1. Load DI modules
75
+ this.loadDIModules();
76
+ // 2. Register routes and filters
77
+ this.registerRoutes();
78
+ this.initialized = true;
79
+ }
80
+ /**
81
+ * Load DI modules from WebAppMeta.
82
+ *
83
+ * Currently, all user modules are loaded into the application container.
84
+ * In the future, we could separate:
85
+ * - WebPieces framework modules -> webpiecesContainer
86
+ * - Application modules -> appContainer
87
+ *
88
+ * For now, everything goes into appContainer which has access to webpiecesContainer.
89
+ */
90
+ loadDIModules() {
91
+ const modules = this.meta.getDIModules();
92
+ // Load all modules into application container
93
+ // (webpiecesContainer is currently empty, reserved for future framework bindings)
94
+ for (const module of modules) {
95
+ this.appContainer.load(module);
96
+ }
97
+ }
98
+ /**
99
+ * Register routes from WebAppMeta.
100
+ *
101
+ * Creates an explicit RouteBuilderImpl instead of an anonymous object.
102
+ * This improves:
103
+ * - Traceability: Can Cmd+Click on addRoute to see implementation
104
+ * - Debugging: Explicit class shows up in stack traces
105
+ * - Understanding: Clear class name vs anonymous object
106
+ */
107
+ registerRoutes() {
108
+ const routeConfigs = this.meta.getRoutes();
109
+ // Create explicit RouteBuilder implementation
110
+ // Filters are resolved from appContainer (which has access to platformContainer too)
111
+ const routeBuilder = new RouteBuilderImpl_1.RouteBuilderImpl(this.routes, this.filters, this.appContainer);
112
+ // Configure routes using the explicit RouteBuilder
113
+ for (const routeConfig of routeConfigs) {
114
+ routeConfig.configure(routeBuilder);
115
+ }
116
+ }
117
+ /**
118
+ * Start the HTTP server with Express.
119
+ */
120
+ start(port = 8080) {
121
+ this.port = port;
122
+ this.initialize();
123
+ // Create Express app
124
+ this.app = (0, express_1.default)();
125
+ // Middleware
126
+ this.app.use(express_1.default.json());
127
+ this.app.use(express_1.default.urlencoded({ extended: true }));
128
+ // Register routes
129
+ this.registerExpressRoutes();
130
+ // Start listening
131
+ this.server = this.app.listen(this.port, () => {
132
+ console.log(`[WebpiecesServer] Server listening on http://localhost:${this.port}`);
133
+ console.log(`[WebpiecesServer] Registered ${this.routes.size} routes`);
134
+ console.log(`[WebpiecesServer] Registered ${this.filters.length} filters`);
135
+ });
136
+ }
137
+ /**
138
+ * Register all routes with Express.
139
+ */
140
+ registerExpressRoutes() {
141
+ if (!this.app) {
142
+ throw new Error('Express app not initialized');
143
+ }
144
+ for (const [key, route] of this.routes.entries()) {
145
+ const method = route.method.toLowerCase();
146
+ const path = route.path;
147
+ console.log(`[WebpiecesServer] Registering route: ${method.toUpperCase()} ${path}`);
148
+ // Create Express route handler
149
+ const handler = async (req, res, next) => {
150
+ try {
151
+ // Create method metadata
152
+ const meta = {
153
+ httpMethod: route.method,
154
+ path: route.path,
155
+ methodName: key,
156
+ params: [req.body],
157
+ request: {
158
+ body: req.body,
159
+ query: req.query,
160
+ params: req.params,
161
+ headers: req.headers,
162
+ },
163
+ metadata: new Map(),
164
+ };
165
+ // Create filter chain
166
+ const filterChain = new http_filters_1.FilterChain(this.filters);
167
+ // Execute the filter chain
168
+ const action = await filterChain.execute(meta, async () => {
169
+ // Create typed route context
170
+ // Use appContainer which has access to both app and framework bindings
171
+ const routeContext = {
172
+ container: this.appContainer,
173
+ params: [req.body],
174
+ request: meta.request,
175
+ };
176
+ // Final handler: invoke the controller method via route handler
177
+ const result = await route.handler.execute(routeContext);
178
+ // Wrap result in a JSON action
179
+ return (0, http_filters_1.jsonAction)(result);
180
+ });
181
+ // Send response
182
+ if (action.type === 'json') {
183
+ res.json(action.data);
184
+ }
185
+ else if (action.type === 'error') {
186
+ res.status(500).json({ error: action.data });
187
+ }
188
+ }
189
+ catch (error) {
190
+ console.error('[WebpiecesServer] Error handling request:', error);
191
+ res.status(500).json({ error: error.message });
192
+ }
193
+ };
194
+ // Register with Express
195
+ switch (method) {
196
+ case 'get':
197
+ this.app.get(path, handler);
198
+ break;
199
+ case 'post':
200
+ this.app.post(path, handler);
201
+ break;
202
+ case 'put':
203
+ this.app.put(path, handler);
204
+ break;
205
+ case 'delete':
206
+ this.app.delete(path, handler);
207
+ break;
208
+ case 'patch':
209
+ this.app.patch(path, handler);
210
+ break;
211
+ default:
212
+ console.warn(`[WebpiecesServer] Unknown HTTP method: ${method}`);
213
+ }
214
+ }
215
+ }
216
+ /**
217
+ * Stop the HTTP server.
218
+ */
219
+ stop() {
220
+ if (this.server) {
221
+ this.server.close(() => {
222
+ console.log('[WebpiecesServer] Server stopped');
223
+ });
224
+ }
225
+ }
226
+ /**
227
+ * Create an API client proxy for testing (no HTTP).
228
+ *
229
+ * This creates a proxy object that implements the API interface
230
+ * and routes method calls through the full filter chain to the controller.
231
+ *
232
+ * @param apiMetaClass - The API interface class with decorators
233
+ * @returns Proxy object implementing the API interface
234
+ */
235
+ createApiClient(apiMetaClass) {
236
+ this.initialize();
237
+ // Get routes from the API metadata
238
+ const routes = (0, http_routing_1.getRoutes)(apiMetaClass);
239
+ // Create a proxy object
240
+ const proxy = {};
241
+ for (const route of routes) {
242
+ const methodName = route.methodName;
243
+ // Create a function that routes through the filter chain
244
+ proxy[methodName] = async (...args) => {
245
+ return this.invokeRoute(route, args);
246
+ };
247
+ }
248
+ return proxy;
249
+ }
250
+ /**
251
+ * Invoke a route through the filter chain.
252
+ */
253
+ async invokeRoute(route, args) {
254
+ // Find the registered route
255
+ const key = `${route.httpMethod}:${route.path}`;
256
+ const registeredRoute = this.routes.get(key);
257
+ if (!registeredRoute) {
258
+ throw new Error(`Route not found: ${key}`);
259
+ }
260
+ // Create method metadata
261
+ const meta = {
262
+ httpMethod: route.httpMethod,
263
+ path: route.path,
264
+ methodName: route.methodName,
265
+ params: [...args],
266
+ request: {
267
+ body: args[0], // Assume first arg is the request body
268
+ },
269
+ metadata: new Map(),
270
+ };
271
+ // Create filter chain
272
+ const filterChain = new http_filters_1.FilterChain(this.filters);
273
+ // Execute the filter chain
274
+ const action = await filterChain.execute(meta, async () => {
275
+ // Create typed route context
276
+ // Use appContainer which has access to both app and framework bindings
277
+ const routeContext = {
278
+ container: this.appContainer,
279
+ params: meta.params,
280
+ request: meta.request,
281
+ };
282
+ // Final handler: invoke the controller method via route handler
283
+ const result = await registeredRoute.handler.execute(routeContext);
284
+ // Wrap result in a JSON action
285
+ return (0, http_filters_1.jsonAction)(result);
286
+ });
287
+ // Return the data from the action
288
+ if (action.type === 'error') {
289
+ throw new Error(JSON.stringify(action.data));
290
+ }
291
+ return action.data;
292
+ }
293
+ /**
294
+ * Get the application DI container (for testing).
295
+ * Returns appContainer which has access to both app and framework bindings.
296
+ */
297
+ getContainer() {
298
+ this.initialize();
299
+ return this.appContainer;
300
+ }
301
+ /**
302
+ * Get the WebPieces framework container (for advanced testing/debugging).
303
+ */
304
+ getWebpiecesContainer() {
305
+ this.initialize();
306
+ return this.webpiecesContainer;
307
+ }
308
+ }
309
+ exports.WebpiecesServer = WebpiecesServer;
310
+ //# sourceMappingURL=WebpiecesServer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WebpiecesServer.js","sourceRoot":"","sources":["../../../../../packages/http/http-server/src/WebpiecesServer.ts"],"names":[],"mappings":";;;;AAAA,8DAA4E;AAC5E,yCAAsC;AAEtC,0DAAsF;AACtF,0DAAmE;AACnE,yDAAuE;AAEvE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAa,eAAe;IAoC1B,YAAY,IAAgB;QAnB5B;;;;;;WAMG;QACK,WAAM,GAA0C,IAAI,GAAG,EAAE,CAAC;QAElE;;WAEG;QACK,YAAO,GAAa,EAAE,CAAC;QAEvB,gBAAW,GAAG,KAAK,CAAC;QAGpB,SAAI,GAAW,IAAI,CAAC;QAG1B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QAEjB,0DAA0D;QAC1D,IAAI,CAAC,kBAAkB,GAAG,IAAI,qBAAS,EAAE,CAAC;QAE1C,iEAAiE;QACjE,yDAAyD;QACzD,IAAI,CAAC,YAAY,GAAG,IAAI,qBAAS,EAAE,CAAC;QACpC,IAAI,CAAC,YAAY,CAAC,MAAM,GAAG,IAAI,CAAC,kBAAkB,CAAC;IACrD,CAAC;IAED;;;OAGG;IACH,UAAU;QACR,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YACrB,OAAO;QACT,CAAC;QAED,qBAAqB;QACrB,IAAI,CAAC,aAAa,EAAE,CAAC;QAErB,iCAAiC;QACjC,IAAI,CAAC,cAAc,EAAE,CAAC;QAEtB,IAAI,CAAC,WAAW,G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,MAAM,eAAe,CAAC,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;YAEnE,+BAA+B;YAC/B,OAAO,IAAA,yBAAU,EAAC,MAAM,CAAC,CAAC;QAC5B,CAAC,CAAC,CAAC;QAEH,kCAAkC;QAClC,IAAI,MAAM,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;YAC5B,MAAM,IAAI,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;QAC/C,CAAC;QAED,OAAO,MAAM,CAAC,IAAI,CAAC;IACrB,CAAC;IAED;;;OAGG;IACH,YAAY;QACV,IAAI,CAAC,UAAU,EAAE,CAAC;QAClB,OAAO,IAAI,CAAC,YAAY,CAAC;IAC3B,CAAC;IAED;;OAEG;IACH,qBAAqB;QACnB,IAAI,CAAC,UAAU,EAAE,CAAC;QAClB,OAAO,IAAI,CAAC,kBAAkB,CAAC;IACjC,CAAC;CAGF;AA/UD,0CA+UC"}
package/src/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export { WebpiecesServer } from './WebpiecesServer';
2
+ export { RouteBuilderImpl, RegisteredRoute } from './RouteBuilderImpl';
package/src/index.js ADDED
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RouteBuilderImpl = exports.WebpiecesServer = void 0;
4
+ var WebpiecesServer_1 = require("./WebpiecesServer");
5
+ Object.defineProperty(exports, "WebpiecesServer", { enumerable: true, get: function () { return WebpiecesServer_1.WebpiecesServer; } });
6
+ var RouteBuilderImpl_1 = require("./RouteBuilderImpl");
7
+ Object.defineProperty(exports, "RouteBuilderImpl", { enumerable: true, get: function () { return RouteBuilderImpl_1.RouteBuilderImpl; } });
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/http/http-server/src/index.ts"],"names":[],"mappings":";;;AAAA,qDAAoD;AAA3C,kHAAA,eAAe,OAAA;AACxB,uDAAuE;AAA9D,oHAAA,gBAAgB,OAAA"}