@webpieces/http-routing 0.3.364 → 0.3.366

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webpieces/http-routing",
3
- "version": "0.3.364",
3
+ "version": "0.3.366",
4
4
  "description": "Decorator-based routing with auto-wiring for WebPieces",
5
5
  "type": "commonjs",
6
6
  "main": "./src/index.js",
@@ -22,9 +22,9 @@
22
22
  },
23
23
  "dependencies": {
24
24
  "@inversifyjs/binding-decorators": "1.1.5",
25
- "@webpieces/core-context": "0.3.364",
26
- "@webpieces/core-util": "0.3.364",
27
- "@webpieces/gcp-identity": "0.3.364",
25
+ "@webpieces/core-context": "0.3.366",
26
+ "@webpieces/core-util": "0.3.366",
27
+ "@webpieces/gcp-identity": "0.3.366",
28
28
  "inversify": "7.10.4",
29
29
  "jsonwebtoken": "9.0.2",
30
30
  "minimatch": "10.0.1"
@@ -0,0 +1,58 @@
1
+ import { ContainerModule } from 'inversify';
2
+ import { ContextKey } from '@webpieces/core-util';
3
+ import { WebpiecesRouter } from './WebpiecesRouter';
4
+ /**
5
+ * RouteModule - a reusable, named group of routes + filters, configured onto the
6
+ * {@link WebpiecesRouter}. This is the TypeScript analog of a Java WebPieces "RouteModule":
7
+ * instead of one anonymous `(router) => { ... }` block, each cohesive group of routes/filters
8
+ * lives in its own named class, and an app composes several of them.
9
+ *
10
+ * A RouteModule holds business logic (it configures the router), so it is an interface — the
11
+ * same category as {@link Routes} / {@link Filter}, NOT a data-only class (per the webpieces
12
+ * guidelines).
13
+ *
14
+ * ```ts
15
+ * export class AuthRoutes implements RouteModule {
16
+ * configure(router: WebpiecesRouter): void {
17
+ * router.addFilter(new FilterDefinition(1800, LogApiFilter, '*'));
18
+ * router.addRoutes(AuthApi, AuthController);
19
+ * }
20
+ * }
21
+ * ```
22
+ */
23
+ export interface RouteModule {
24
+ /** Declare this group's routes + filters via {@link WebpiecesRouter.addRoutes} / addFilter. */
25
+ configure(router: WebpiecesRouter): void;
26
+ }
27
+ /**
28
+ * AppModules - an app's COMPLETE server-surface declaration in one object: its DI binding modules,
29
+ * its route groups, and its own context-key headers. It replaces the old split of a
30
+ * `ContainerModule[]` + a `ContextKey[]` + an inline `(router) => void` callback threaded through
31
+ * the bootstrap in separate arguments.
32
+ *
33
+ * Apps implement this on a class with a static `create()` factory, so the real server AND its
34
+ * tests build the SAME object (tests then tweak it / pass a test override module):
35
+ *
36
+ * ```ts
37
+ * export class MyAppModules implements AppModules {
38
+ * static create(): MyAppModules { return new MyAppModules(); }
39
+ * getBindingModules(): ContainerModule[] { return [InversifyModule]; }
40
+ * getRoutingModules(): RouteModule[] { return [new AppRoutes()]; }
41
+ * getHeaders(): ContextKey[] { return AppHeaders.getAllHeaders(); }
42
+ * }
43
+ *
44
+ * // server.ts
45
+ * await bootstrapServer(new BootstrapOptions(8200, 'my-svr'), MyAppModules.create());
46
+ * ```
47
+ *
48
+ * AppModules is a provider interface (it hands back the app's pieces), the same category as the
49
+ * former WebAppMeta — hence an interface, not a data-only class.
50
+ */
51
+ export interface AppModules {
52
+ /** App-specific DI ContainerModules (beyond the standard company/framework set). */
53
+ getBindingModules(): ContainerModule[];
54
+ /** The route groups to configure onto the router, in order. */
55
+ getRoutingModules(): RouteModule[];
56
+ /** This app's own context keys, registered into the global HeaderRegistry at startup. */
57
+ getHeaders(): ContextKey[];
58
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=AppModules.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AppModules.js","sourceRoot":"","sources":["../../../../../packages/http/http-routing/src/AppModules.ts"],"names":[],"mappings":"","sourcesContent":["import { ContainerModule } from 'inversify';\nimport { ContextKey } from '@webpieces/core-util';\nimport { WebpiecesRouter } from './WebpiecesRouter';\n\n/**\n * RouteModule - a reusable, named group of routes + filters, configured onto the\n * {@link WebpiecesRouter}. This is the TypeScript analog of a Java WebPieces \"RouteModule\":\n * instead of one anonymous `(router) => { ... }` block, each cohesive group of routes/filters\n * lives in its own named class, and an app composes several of them.\n *\n * A RouteModule holds business logic (it configures the router), so it is an interface — the\n * same category as {@link Routes} / {@link Filter}, NOT a data-only class (per the webpieces\n * guidelines).\n *\n * ```ts\n * export class AuthRoutes implements RouteModule {\n * configure(router: WebpiecesRouter): void {\n * router.addFilter(new FilterDefinition(1800, LogApiFilter, '*'));\n * router.addRoutes(AuthApi, AuthController);\n * }\n * }\n * ```\n */\nexport interface RouteModule {\n /** Declare this group's routes + filters via {@link WebpiecesRouter.addRoutes} / addFilter. */\n configure(router: WebpiecesRouter): void;\n}\n\n/**\n * AppModules - an app's COMPLETE server-surface declaration in one object: its DI binding modules,\n * its route groups, and its own context-key headers. It replaces the old split of a\n * `ContainerModule[]` + a `ContextKey[]` + an inline `(router) => void` callback threaded through\n * the bootstrap in separate arguments.\n *\n * Apps implement this on a class with a static `create()` factory, so the real server AND its\n * tests build the SAME object (tests then tweak it / pass a test override module):\n *\n * ```ts\n * export class MyAppModules implements AppModules {\n * static create(): MyAppModules { return new MyAppModules(); }\n * getBindingModules(): ContainerModule[] { return [InversifyModule]; }\n * getRoutingModules(): RouteModule[] { return [new AppRoutes()]; }\n * getHeaders(): ContextKey[] { return AppHeaders.getAllHeaders(); }\n * }\n *\n * // server.ts\n * await bootstrapServer(new BootstrapOptions(8200, 'my-svr'), MyAppModules.create());\n * ```\n *\n * AppModules is a provider interface (it hands back the app's pieces), the same category as the\n * former WebAppMeta — hence an interface, not a data-only class.\n */\nexport interface AppModules {\n /** App-specific DI ContainerModules (beyond the standard company/framework set). */\n getBindingModules(): ContainerModule[];\n /** The route groups to configure onto the router, in order. */\n getRoutingModules(): RouteModule[];\n /** This app's own context keys, registered into the global HeaderRegistry at startup. */\n getHeaders(): ContextKey[];\n}\n"]}
package/src/index.d.ts CHANGED
@@ -11,6 +11,7 @@ export { FilterChain } from './FilterChain';
11
11
  export { MethodMeta } from './MethodMeta';
12
12
  export { RouteHandler } from './RouteHandler';
13
13
  export { FilterMatcher, HttpFilter } from './FilterMatcher';
14
+ export { AppModules, RouteModule } from './AppModules';
14
15
  export { ApiFactory } from './ApiFactory';
15
16
  export { ApiClient, ApiClientProxy } from './ApiClient';
16
17
  export { AuthConfig, AuthValues, SharedSecrets } from './AuthConfig';
package/src/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/http/http-routing/src/index.ts"],"names":[],"mappings":";;;;AAAA,0DAA0D;AAC1D,kDA8B8B;AA7B1B,oGAAA,OAAO,OAAA;AACP,qGAAA,QAAQ,OAAA;AACR,2GAAA,cAAc,OAAA;AACd,iHAAA,oBAAoB,OAAA;AACpB,mGAAA,MAAM,OAAA;AACN,oGAAA,OAAO,OAAA;AACP,qGAAA,QAAQ,OAAA;AACR,6GAAA,gBAAgB,OAAA;AAChB,gGAAA,GAAG,OAAA;AACH,mGAAA,MAAM,OAAA;AACN,kGAAA,KAAK,OAAA;AACL,uGAAA,UAAU,OAAA;AACV,yGAAA,YAAY,OAAA;AACZ,sGAAA,SAAS,OAAA;AACT,wGAAA,WAAW,OAAA;AACX,wGAAA,WAAW,OAAA;AACX,2HAAA,8BAA8B,OAAA;AAC9B,uGAAA,UAAU,OAAA;AACV,0GAAA,aAAa,OAAA;AACb,oHAAA,uBAAuB,OAAA;AACvB,yGAAA,YAAY,OAAA;AACZ,qGAAA,QAAQ,OAAA;AACR,0GAAA,aAAa,OAAA;AACb,0GAAA,aAAa,OAAA;AAEb,2EAA2E;AAC3E,oCAAoC;AACpC,2GAAA,cAAc,OAAA;AACd,6GAAA,gBAAgB,OAAA;AAIpB,+CAA+C;AAC/C,2CAGsB;AAFlB,wGAAA,UAAU,OAAA;AACV,mHAAA,qBAAqB,OAAA;AAGzB,iFAAiF;AACjF,wDAA4G;AAAnG,gHAAA,gBAAgB,OAAA;AAAE,6HAAA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DAA4E;AAAnE,kHAAA,eAAe,OAAA;AAAE,yHAAA,sBAAsB,OAAA","sourcesContent":["// Re-export API decorators from core-util for convenience\nexport {\n ApiPath,\n Endpoint,\n Authentication,\n AuthenticationConfig,\n Public,\n AuthJwt,\n AuthOidc,\n AuthSharedSecret,\n Rpc,\n PubSub,\n Queue,\n getApiPath,\n getEndpoints,\n isApiPath,\n getAuthMeta,\n getAuthMode,\n assertEveryEndpointHasAuthMode,\n getApiKind,\n assertApiKind,\n assertPubSubConventions,\n getQueueName,\n AuthMeta,\n RouteMetadata,\n METADATA_KEYS,\n ValidateImplementation,\n // @DocumentDesign moved to core-util (design-root marker, browser + Node);\n // re-exported here for back-compat.\n DocumentDesign,\n isDocumentDesign,\n} from '@webpieces/core-util';\nexport type { AuthMode, ApiKind } from '@webpieces/core-util';\n\n// Server-side routing decorators and utilities\nexport {\n SourceFile,\n ROUTING_METADATA_KEYS,\n} from './decorators';\n\n// DI provider decorators moved to core-context; re-exported here for back-compat\nexport { provideSingleton, provideSingletonDefaultForApi, provideTransient } from '@webpieces/core-context';\n// Framework-only DI registry (packages/** framework classes use these; see frameworkProvide.ts)\nexport {\n provideFrameworkSingleton,\n provideFrameworkSingletonDefaultForApi,\n buildFrameworkModule,\n} from '@webpieces/core-context';\n\nexport { ApiRoutingFactory, ClassType } from './ApiRoutingFactory';\n\n// Core routing types\nexport {\n Routes,\n RouteBuilder,\n RouteDefinition,\n FilterDefinition,\n} from './WebAppMeta';\n\n// The transport-neutral request type (defined in core-context; this is http-routing's\n// public request — a transport adapter builds one and the chain reads it from RequestContext).\nexport { HttpRequest } from '@webpieces/core-context';\n\n// Filter-chain primitives (absorbed from the former @webpieces/http-filters package)\nexport { Filter, WpResponse, Service } from './Filter';\nexport { FilterChain } from './FilterChain';\nexport { MethodMeta } from './MethodMeta';\nexport { RouteHandler } from './RouteHandler';\n\n// RouteBuilderImpl (the route table + chain composer) is now INTERNAL — it is never\n// handed to upper layers. The express layer consumes ApiFactory.apiClients() instead.\n\n// Filter matching\nexport { FilterMatcher, HttpFilter } from './FilterMatcher';\n\n// The public API-surface abstraction: declare routes/filters, get them back as ApiClient[].\nexport { ApiFactory } from './ApiFactory';\nexport { ApiClient, ApiClientProxy } from './ApiClient';\n\n// Auth: the app-provided, container-bound pieces the framework AuthFilter injects.\n// - AuthConfig: shared-secret STATE (@AuthSharedSecret values).\n// - JwtHook / OidcHook: OPTIONAL verification mechanisms (bind only what you use).\n// - DefaultOidcVerifier: the built-in Google OIDC verifier used when no OidcHook is bound.\nexport { AuthConfig, AuthValues, SharedSecrets } from './AuthConfig';\nexport { JwtHook, OidcHook } from './AuthHooks';\nexport { DefaultOidcVerifier } from './DefaultOidcVerifier';\n// DefaultJwtHook: batteries-included HS256 JwtHook — `new DefaultJwtHook(secret)` and go.\nexport { DefaultJwtHook } from './DefaultJwtHook';\n\n// Above-boundary context setup shared by every transport adapter.\n\n// Node-only router (the express-free heart: container + filter chain + in-process client)\nexport { WebpiecesRouter, WebpiecesRouterFactory, WebpiecesRouterOptions } from './WebpiecesRouter';\n\n// The ONE transport-free startup sequence (headers → logging → router → routes) → ApiFactory.\n// Reusable by any company/app and any framework adapter; a company wraps it with its own headers.\nexport { setupRuntime, RuntimeSetupOptions } from './setupRuntime';\n\n// Server configuration\nexport { WebpiecesConfig, WEBPIECES_CONFIG_TOKEN } from './WebpiecesConfig';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/http/http-routing/src/index.ts"],"names":[],"mappings":";;;;AAAA,0DAA0D;AAC1D,kDA8B8B;AA7B1B,oGAAA,OAAO,OAAA;AACP,qGAAA,QAAQ,OAAA;AACR,2GAAA,cAAc,OAAA;AACd,iHAAA,oBAAoB,OAAA;AACpB,mGAAA,MAAM,OAAA;AACN,oGAAA,OAAO,OAAA;AACP,qGAAA,QAAQ,OAAA;AACR,6GAAA,gBAAgB,OAAA;AAChB,gGAAA,GAAG,OAAA;AACH,mGAAA,MAAM,OAAA;AACN,kGA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yCAAwD;AAA/C,sGAAA,SAAS,OAAA;AAElB,mFAAmF;AACnF,iEAAiE;AACjE,oFAAoF;AACpF,4FAA4F;AAC5F,2CAAqE;AAA5D,wGAAA,UAAU,OAAA;AAAE,wGAAA,UAAU,OAAA;AAAE,2GAAA,aAAa,OAAA;AAC9C,yCAAgD;AAAvC,oGAAA,OAAO,OAAA;AAAE,qGAAA,QAAQ,OAAA;AAC1B,6DAA4D;AAAnD,0HAAA,mBAAmB,OAAA;AAC5B,0FAA0F;AAC1F,mDAAkD;AAAzC,gHAAA,cAAc,OAAA;AAEvB,kEAAkE;AAElE,0FAA0F;AAC1F,qDAAoG;AAA3F,kHAAA,eAAe,OAAA;AAAE,yHAAA,sBAAsB,OAAA;AAEhD,8FAA8F;AAC9F,kGAAkG;AAClG,+CAAmE;AAA1D,4GAAA,YAAY,OAAA;AAAE,mHAAA,mBAAmB,OAAA;AAE1C,uBAAuB;AACvB,qDAA4E;AAAnE,kHAAA,eAAe,OAAA;AAAE,yHAAA,sBAAsB,OAAA","sourcesContent":["// Re-export API decorators from core-util for convenience\nexport {\n ApiPath,\n Endpoint,\n Authentication,\n AuthenticationConfig,\n Public,\n AuthJwt,\n AuthOidc,\n AuthSharedSecret,\n Rpc,\n PubSub,\n Queue,\n getApiPath,\n getEndpoints,\n isApiPath,\n getAuthMeta,\n getAuthMode,\n assertEveryEndpointHasAuthMode,\n getApiKind,\n assertApiKind,\n assertPubSubConventions,\n getQueueName,\n AuthMeta,\n RouteMetadata,\n METADATA_KEYS,\n ValidateImplementation,\n // @DocumentDesign moved to core-util (design-root marker, browser + Node);\n // re-exported here for back-compat.\n DocumentDesign,\n isDocumentDesign,\n} from '@webpieces/core-util';\nexport type { AuthMode, ApiKind } from '@webpieces/core-util';\n\n// Server-side routing decorators and utilities\nexport {\n SourceFile,\n ROUTING_METADATA_KEYS,\n} from './decorators';\n\n// DI provider decorators moved to core-context; re-exported here for back-compat\nexport { provideSingleton, provideSingletonDefaultForApi, provideTransient } from '@webpieces/core-context';\n// Framework-only DI registry (packages/** framework classes use these; see frameworkProvide.ts)\nexport {\n provideFrameworkSingleton,\n provideFrameworkSingletonDefaultForApi,\n buildFrameworkModule,\n} from '@webpieces/core-context';\n\nexport { ApiRoutingFactory, ClassType } from './ApiRoutingFactory';\n\n// Core routing types\nexport {\n Routes,\n RouteBuilder,\n RouteDefinition,\n FilterDefinition,\n} from './WebAppMeta';\n\n// The transport-neutral request type (defined in core-context; this is http-routing's\n// public request — a transport adapter builds one and the chain reads it from RequestContext).\nexport { HttpRequest } from '@webpieces/core-context';\n\n// Filter-chain primitives (absorbed from the former @webpieces/http-filters package)\nexport { Filter, WpResponse, Service } from './Filter';\nexport { FilterChain } from './FilterChain';\nexport { MethodMeta } from './MethodMeta';\nexport { RouteHandler } from './RouteHandler';\n\n// RouteBuilderImpl (the route table + chain composer) is now INTERNAL — it is never\n// handed to upper layers. The express layer consumes ApiFactory.apiClients() instead.\n\n// Filter matching\nexport { FilterMatcher, HttpFilter } from './FilterMatcher';\n\n// The app's server-surface declaration: DI binding modules + route groups + headers.\nexport { AppModules, RouteModule } from './AppModules';\n\n// The public API-surface abstraction: declare routes/filters, get them back as ApiClient[].\nexport { ApiFactory } from './ApiFactory';\nexport { ApiClient, ApiClientProxy } from './ApiClient';\n\n// Auth: the app-provided, container-bound pieces the framework AuthFilter injects.\n// - AuthConfig: shared-secret STATE (@AuthSharedSecret values).\n// - JwtHook / OidcHook: OPTIONAL verification mechanisms (bind only what you use).\n// - DefaultOidcVerifier: the built-in Google OIDC verifier used when no OidcHook is bound.\nexport { AuthConfig, AuthValues, SharedSecrets } from './AuthConfig';\nexport { JwtHook, OidcHook } from './AuthHooks';\nexport { DefaultOidcVerifier } from './DefaultOidcVerifier';\n// DefaultJwtHook: batteries-included HS256 JwtHook — `new DefaultJwtHook(secret)` and go.\nexport { DefaultJwtHook } from './DefaultJwtHook';\n\n// Above-boundary context setup shared by every transport adapter.\n\n// Node-only router (the express-free heart: container + filter chain + in-process client)\nexport { WebpiecesRouter, WebpiecesRouterFactory, WebpiecesRouterOptions } from './WebpiecesRouter';\n\n// The ONE transport-free startup sequence (headers → logging → router → routes) → ApiFactory.\n// Reusable by any company/app and any framework adapter; a company wraps it with its own headers.\nexport { setupRuntime, RuntimeSetupOptions } from './setupRuntime';\n\n// Server configuration\nexport { WebpiecesConfig, WEBPIECES_CONFIG_TOKEN } from './WebpiecesConfig';\n"]}
@@ -1,27 +1,25 @@
1
1
  import { ContainerModule } from 'inversify';
2
2
  import { ContextKey, LoggerFactory } from '@webpieces/core-util';
3
3
  import { WebpiecesConfig } from './WebpiecesConfig';
4
- import { WebpiecesRouter } from './WebpiecesRouter';
4
+ import { AppModules } from './AppModules';
5
5
  import { ApiFactory } from './ApiFactory';
6
6
  /**
7
- * RuntimeSetupOptions - inputs to {@link setupRuntime}. Data-only structure (a class, per the
8
- * webpieces guidelines). A company/app layer supplies its own header tiers + logger + modules;
9
- * the framework runs the canonical startup sequence and hands back a transport-free ApiFactory.
7
+ * RuntimeSetupOptions - the environment/wiring inputs to {@link setupRuntime} (everything NOT
8
+ * declared by the app's {@link AppModules}): the logging backend, the company/platform header
9
+ * tiers, the test-override module, and config. Data-only structure (a class, per the webpieces
10
+ * guidelines). The app's own binding modules + route groups + headers come from the AppModules
11
+ * passed alongside.
10
12
  *
11
13
  * Header tiers mirror {@link HeaderRegistry.configure}: platform defaults + org/company keys +
12
- * this-service keys.
14
+ * this-service keys (the this-service keys are AppModules.getHeaders()).
13
15
  */
14
16
  export declare class RuntimeSetupOptions {
15
17
  /** Logging backend to install (LogManager.setFactory). */
16
18
  readonly loggerFactory: LoggerFactory;
17
- /** This service's own context keys. */
18
- readonly svrHeaders: ContextKey[];
19
19
  /** Org/company-wide shared context keys (the company layer passes these in). */
20
20
  readonly companyHeaders: ContextKey[];
21
21
  /** Include the webpieces platform default headers. */
22
22
  readonly platformHeaders: boolean;
23
- /** App DI ContainerModules to load. */
24
- readonly modules: ContainerModule[];
25
23
  /** A single DI module loaded LAST so tests can rebind bindings to mocks. */
26
24
  readonly appOverrides?: ContainerModule | undefined;
27
25
  /** Optional WebpiecesConfig (e.g. recording flags); defaults to a fresh one. */
@@ -29,14 +27,10 @@ export declare class RuntimeSetupOptions {
29
27
  constructor(
30
28
  /** Logging backend to install (LogManager.setFactory). */
31
29
  loggerFactory: LoggerFactory,
32
- /** This service's own context keys. */
33
- svrHeaders?: ContextKey[],
34
30
  /** Org/company-wide shared context keys (the company layer passes these in). */
35
31
  companyHeaders?: ContextKey[],
36
32
  /** Include the webpieces platform default headers. */
37
33
  platformHeaders?: boolean,
38
- /** App DI ContainerModules to load. */
39
- modules?: ContainerModule[],
40
34
  /** A single DI module loaded LAST so tests can rebind bindings to mocks. */
41
35
  appOverrides?: ContainerModule | undefined,
42
36
  /** Optional WebpiecesConfig (e.g. recording flags); defaults to a fresh one. */
@@ -49,11 +43,11 @@ export declare class RuntimeSetupOptions {
49
43
  *
50
44
  * 1. HeaderRegistry.configure (filters read it at construction; logging masks off it)
51
45
  * 2. LogManager.setFactory (fails fast unless the registry is configured first)
52
- * 3. build the router + DI container
53
- * 4. run the caller's `configureRoutes(router)` block (addRoutes/addFilter)
46
+ * 3. build the router + DI container (from appModules.getBindingModules())
47
+ * 4. configure each appModules.getRoutingModules() onto the router (addRoutes/addFilter)
54
48
  *
55
49
  * and returns the built {@link ApiFactory} — `apiClients()` for a transport to bind, or
56
50
  * `createApiClient()` for in-process tests. There is NO express (or any transport) here; a
57
51
  * transport adapter (e.g. WebpiecesExpressRouter in @webpieces/http-server) serves the result.
58
52
  */
59
- export declare function setupRuntime(options: RuntimeSetupOptions, configureRoutes: (router: WebpiecesRouter) => void): Promise<ApiFactory>;
53
+ export declare function setupRuntime(options: RuntimeSetupOptions, appModules: AppModules): Promise<ApiFactory>;
@@ -6,41 +6,35 @@ const core_util_1 = require("@webpieces/core-util");
6
6
  const WebpiecesConfig_1 = require("./WebpiecesConfig");
7
7
  const WebpiecesRouter_1 = require("./WebpiecesRouter");
8
8
  /**
9
- * RuntimeSetupOptions - inputs to {@link setupRuntime}. Data-only structure (a class, per the
10
- * webpieces guidelines). A company/app layer supplies its own header tiers + logger + modules;
11
- * the framework runs the canonical startup sequence and hands back a transport-free ApiFactory.
9
+ * RuntimeSetupOptions - the environment/wiring inputs to {@link setupRuntime} (everything NOT
10
+ * declared by the app's {@link AppModules}): the logging backend, the company/platform header
11
+ * tiers, the test-override module, and config. Data-only structure (a class, per the webpieces
12
+ * guidelines). The app's own binding modules + route groups + headers come from the AppModules
13
+ * passed alongside.
12
14
  *
13
15
  * Header tiers mirror {@link HeaderRegistry.configure}: platform defaults + org/company keys +
14
- * this-service keys.
16
+ * this-service keys (the this-service keys are AppModules.getHeaders()).
15
17
  */
16
18
  class RuntimeSetupOptions {
17
19
  loggerFactory;
18
- svrHeaders;
19
20
  companyHeaders;
20
21
  platformHeaders;
21
- modules;
22
22
  appOverrides;
23
23
  config;
24
24
  constructor(
25
25
  /** Logging backend to install (LogManager.setFactory). */
26
26
  loggerFactory,
27
- /** This service's own context keys. */
28
- svrHeaders = [],
29
27
  /** Org/company-wide shared context keys (the company layer passes these in). */
30
28
  companyHeaders = [],
31
29
  /** Include the webpieces platform default headers. */
32
30
  platformHeaders = true,
33
- /** App DI ContainerModules to load. */
34
- modules = [],
35
31
  /** A single DI module loaded LAST so tests can rebind bindings to mocks. */
36
32
  appOverrides,
37
33
  /** Optional WebpiecesConfig (e.g. recording flags); defaults to a fresh one. */
38
34
  config) {
39
35
  this.loggerFactory = loggerFactory;
40
- this.svrHeaders = svrHeaders;
41
36
  this.companyHeaders = companyHeaders;
42
37
  this.platformHeaders = platformHeaders;
43
- this.modules = modules;
44
38
  this.appOverrides = appOverrides;
45
39
  this.config = config;
46
40
  }
@@ -53,26 +47,28 @@ exports.RuntimeSetupOptions = RuntimeSetupOptions;
53
47
  *
54
48
  * 1. HeaderRegistry.configure (filters read it at construction; logging masks off it)
55
49
  * 2. LogManager.setFactory (fails fast unless the registry is configured first)
56
- * 3. build the router + DI container
57
- * 4. run the caller's `configureRoutes(router)` block (addRoutes/addFilter)
50
+ * 3. build the router + DI container (from appModules.getBindingModules())
51
+ * 4. configure each appModules.getRoutingModules() onto the router (addRoutes/addFilter)
58
52
  *
59
53
  * and returns the built {@link ApiFactory} — `apiClients()` for a transport to bind, or
60
54
  * `createApiClient()` for in-process tests. There is NO express (or any transport) here; a
61
55
  * transport adapter (e.g. WebpiecesExpressRouter in @webpieces/http-server) serves the result.
62
56
  */
63
- async function setupRuntime(options, configureRoutes) {
64
- // 1. Register the global HeaderRegistry FIRST.
65
- core_util_1.HeaderRegistry.configure(options.svrHeaders, options.companyHeaders, options.platformHeaders);
57
+ async function setupRuntime(options, appModules) {
58
+ // 1. Register the global HeaderRegistry FIRST (this service's own keys come from AppModules).
59
+ core_util_1.HeaderRegistry.configure(appModules.getHeaders(), options.companyHeaders, options.platformHeaders);
66
60
  // 2. Install the logging backend ONCE, before anything else logs.
67
61
  core_util_1.LogManager.setFactory(options.loggerFactory);
68
62
  // 3. Build the node-only router + DI container.
69
63
  const router = await WebpiecesRouter_1.WebpiecesRouterFactory.create({
70
- appBindings: [...options.modules],
64
+ appBindings: [...appModules.getBindingModules()],
71
65
  appOverrides: options.appOverrides,
72
66
  config: options.config ?? new WebpiecesConfig_1.WebpiecesConfig(),
73
67
  });
74
- // 4. Let the caller declare its routes + filters, then hand back the consumer surface.
75
- configureRoutes(router);
68
+ // 4. Let each route group declare its routes + filters, then hand back the consumer surface.
69
+ for (const routeModule of appModules.getRoutingModules()) {
70
+ routeModule.configure(router);
71
+ }
76
72
  return router;
77
73
  }
78
74
  //# sourceMappingURL=setupRuntime.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"setupRuntime.js","sourceRoot":"","sources":["../../../../../packages/http/http-routing/src/setupRuntime.ts"],"names":[],"mappings":";;;AA+CA,oCAoBC;AAlED,oDAA6F;AAC7F,uDAAoD;AACpD,uDAA4E;AAG5E;;;;;;;GAOG;AACH,M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from '@webpieces/core-util';\nimport { WebpiecesConfig } from './WebpiecesConfig';\nimport { WebpiecesRouter, WebpiecesRouterFactory } from './WebpiecesRouter';\nimport { ApiFactory } from './ApiFactory';\n\n/**\n * RuntimeSetupOptions - inputs to {@link setupRuntime}. Data-only structure (a class, per the\n * webpieces guidelines). A company/app layer supplies its own header tiers + logger + modules;\n * the framework runs the canonical startup sequence and hands back a transport-free ApiFactory.\n *\n * Header tiers mirror {@link HeaderRegistry.configure}: platform defaults + org/company keys +\n * this-service keys.\n */\nexport class RuntimeSetupOptions {\n constructor(\n /** Logging backend to install (LogManager.setFactory). */\n public readonly loggerFactory: LoggerFactory,\n /** This service's own context keys. */\n public readonly svrHeaders: ContextKey[] = [],\n /** Org/company-wide shared context keys (the company layer passes these in). */\n public readonly companyHeaders: ContextKey[] = [],\n /** Include the webpieces platform default headers. */\n public readonly platformHeaders: boolean = true,\n /** App DI ContainerModules to load. */\n public readonly modules: ContainerModule[] = [],\n /** A single DI module loaded LAST so tests can rebind bindings to mocks. */\n public readonly appOverrides?: ContainerModule,\n /** Optional WebpiecesConfig (e.g. recording flags); defaults to a fresh one. */\n public readonly config?: WebpiecesConfig,\n ) {}\n}\n\n/**\n * setupRuntime - the ONE canonical, TRANSPORT-FREE startup sequence, reusable by any company/app\n * AND any framework adapter (express, fastify, a serverless handler, ...). It runs, in the correct\n * fail-fast order:\n *\n * 1. HeaderRegistry.configure (filters read it at construction; logging masks off it)\n * 2. LogManager.setFactory (fails fast unless the registry is configured first)\n * 3. build the router + DI container\n * 4. run the caller's `configureRoutes(router)` block (addRoutes/addFilter)\n *\n * and returns the built {@link ApiFactory} — `apiClients()` for a transport to bind, or\n * `createApiClient()` for in-process tests. There is NO express (or any transport) here; a\n * transport adapter (e.g. WebpiecesExpressRouter in @webpieces/http-server) serves the result.\n */\nexport async function setupRuntime(\n options: RuntimeSetupOptions,\n configureRoutes: (router: WebpiecesRouter) => void,\n): Promise<ApiFactory> {\n // 1. Register the global HeaderRegistry FIRST.\n HeaderRegistry.configure(options.svrHeaders, options.companyHeaders, options.platformHeaders);\n\n // 2. Install the logging backend ONCE, before anything else logs.\n LogManager.setFactory(options.loggerFactory);\n\n // 3. Build the node-only router + DI container.\n const router = await WebpiecesRouterFactory.create({\n appBindings: [...options.modules],\n appOverrides: options.appOverrides,\n config: options.config ?? new WebpiecesConfig(),\n });\n\n // 4. Let the caller declare its routes + filters, then hand back the consumer surface.\n configureRoutes(router);\n return router;\n}\n"]}
1
+ {"version":3,"file":"setupRuntime.js","sourceRoot":"","sources":["../../../../../packages/http/http-routing/src/setupRuntime.ts"],"names":[],"mappings":";;;AA8CA,oCAsBC;AAnED,oDAA6F;AAC7F,uDAAoD;AACpD,uDAA2D;AAI3D;;;;;;;;;GASG;AACH,MAAa,mBAAmB;IAGR;IAEA;IAEA;IAEA;IAEA;IAVpB;IACI,0DAA0D;IAC1C,aAA4B;IAC5C,gFAAgF;IAChE,iBAA+B,EAAE;IACjD,sDAAsD;IACtC,kBAA2B,IAAI;IAC/C,4EAA4E;IAC5D,YAA8B;IAC9C,gFAAgF;IAChE,MAAwB;QARxB,kBAAa,GAAb,aAAa,CAAe;QAE5B,mBAAc,GAAd,cAAc,CAAmB;QAEjC,oBAAe,GAAf,eAAe,CAAgB;QAE/B,iBAAY,GAAZ,YAAY,CAAkB;QAE9B,WAAM,GAAN,MAAM,CAAkB;IACzC,CAAC;CACP;AAbD,kDAaC;AAED;;;;;;;;;;;;;GAaG;AACI,KAAK,UAAU,YAAY,CAC9B,OAA4B,EAC5B,UAAsB;IAEtB,8FAA8F;IAC9F,0BAAc,CAAC,SAAS,CAAC,UAAU,CAAC,UAAU,EAAE,EAAE,OAAO,CAAC,cAAc,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC;IAEnG,kEAAkE;IAClE,sBAAU,CAAC,UAAU,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;IAE7C,gDAAgD;IAChD,MAAM,MAAM,GAAG,MAAM,wCAAsB,CAAC,MAAM,CAAC;QAC/C,WAAW,EAAE,CAAC,GAAG,UAAU,CAAC,iBAAiB,EAAE,CAAC;QAChD,YAAY,EAAE,OAAO,CAAC,YAAY;QAClC,MAAM,EAAE,OAAO,CAAC,MAAM,IAAI,IAAI,iCAAe,EAAE;KAClD,CAAC,CAAC;IAEH,6FAA6F;IAC7F,KAAK,MAAM,WAAW,IAAI,UAAU,CAAC,iBAAiB,EAAE,EAAE,CAAC;QACvD,WAAW,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAClC,CAAC;IACD,OAAO,MAAM,CAAC;AAClB,CAAC","sourcesContent":["import { ContainerModule } from 'inversify';\nimport { ContextKey, HeaderRegistry, LoggerFactory, LogManager } from '@webpieces/core-util';\nimport { WebpiecesConfig } from './WebpiecesConfig';\nimport { WebpiecesRouterFactory } from './WebpiecesRouter';\nimport { AppModules } from './AppModules';\nimport { ApiFactory } from './ApiFactory';\n\n/**\n * RuntimeSetupOptions - the environment/wiring inputs to {@link setupRuntime} (everything NOT\n * declared by the app's {@link AppModules}): the logging backend, the company/platform header\n * tiers, the test-override module, and config. Data-only structure (a class, per the webpieces\n * guidelines). The app's own binding modules + route groups + headers come from the AppModules\n * passed alongside.\n *\n * Header tiers mirror {@link HeaderRegistry.configure}: platform defaults + org/company keys +\n * this-service keys (the this-service keys are AppModules.getHeaders()).\n */\nexport class RuntimeSetupOptions {\n constructor(\n /** Logging backend to install (LogManager.setFactory). */\n public readonly loggerFactory: LoggerFactory,\n /** Org/company-wide shared context keys (the company layer passes these in). */\n public readonly companyHeaders: ContextKey[] = [],\n /** Include the webpieces platform default headers. */\n public readonly platformHeaders: boolean = true,\n /** A single DI module loaded LAST so tests can rebind bindings to mocks. */\n public readonly appOverrides?: ContainerModule,\n /** Optional WebpiecesConfig (e.g. recording flags); defaults to a fresh one. */\n public readonly config?: WebpiecesConfig,\n ) {}\n}\n\n/**\n * setupRuntime - the ONE canonical, TRANSPORT-FREE startup sequence, reusable by any company/app\n * AND any framework adapter (express, fastify, a serverless handler, ...). It runs, in the correct\n * fail-fast order:\n *\n * 1. HeaderRegistry.configure (filters read it at construction; logging masks off it)\n * 2. LogManager.setFactory (fails fast unless the registry is configured first)\n * 3. build the router + DI container (from appModules.getBindingModules())\n * 4. configure each appModules.getRoutingModules() onto the router (addRoutes/addFilter)\n *\n * and returns the built {@link ApiFactory} — `apiClients()` for a transport to bind, or\n * `createApiClient()` for in-process tests. There is NO express (or any transport) here; a\n * transport adapter (e.g. WebpiecesExpressRouter in @webpieces/http-server) serves the result.\n */\nexport async function setupRuntime(\n options: RuntimeSetupOptions,\n appModules: AppModules,\n): Promise<ApiFactory> {\n // 1. Register the global HeaderRegistry FIRST (this service's own keys come from AppModules).\n HeaderRegistry.configure(appModules.getHeaders(), options.companyHeaders, options.platformHeaders);\n\n // 2. Install the logging backend ONCE, before anything else logs.\n LogManager.setFactory(options.loggerFactory);\n\n // 3. Build the node-only router + DI container.\n const router = await WebpiecesRouterFactory.create({\n appBindings: [...appModules.getBindingModules()],\n appOverrides: options.appOverrides,\n config: options.config ?? new WebpiecesConfig(),\n });\n\n // 4. Let each route group declare its routes + filters, then hand back the consumer surface.\n for (const routeModule of appModules.getRoutingModules()) {\n routeModule.configure(router);\n }\n return router;\n}\n"]}