@webpieces/http-routing 0.4.395 → 0.4.396

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.4.395",
3
+ "version": "0.4.396",
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.4.395",
26
- "@webpieces/core-util": "0.4.395",
27
- "@webpieces/gcp-identity": "0.4.395",
25
+ "@webpieces/core-context": "0.4.396",
26
+ "@webpieces/core-util": "0.4.396",
27
+ "@webpieces/gcp-identity": "0.4.396",
28
28
  "inversify": "7.10.4",
29
29
  "jsonwebtoken": "9.0.2",
30
30
  "minimatch": "10.0.1"
@@ -51,12 +51,14 @@ async function setupRuntime(options, appModules,
51
51
  /** A single DI module loaded LAST so tests can rebind bindings to mocks.
52
52
  * Or special case servers that want to override specific things */
53
53
  appOverrides) {
54
- // 0. This service must be NAMED. Both webpieces logging backends already read ServiceInfo in
55
- // their constructors, so a bunyan/winston app has failed before reaching here — but an app that
56
- // installs its OWN LoggerFactory touches neither, and would otherwise boot unnamed and stamp no
57
- // requestIdSource. Assert it HERE, the one startup every server runs, so the request path can
58
- // trust the name exists and never has to throw over it mid-traffic.
54
+ // 0. This service must be IDENTIFIED (name + build version). Both webpieces logging backends
55
+ // already read ServiceInfo in their constructors, so a bunyan/winston app has failed before
56
+ // reaching here — but an app that installs its OWN LoggerFactory touches neither, and would
57
+ // otherwise boot anonymous, stamp no requestIdSource, and ship logs that cannot say which build
58
+ // emitted them. Assert HERE, the one startup every server runs, so the request path can trust
59
+ // both exist and never has to throw over them mid-traffic.
59
60
  core_util_1.ServiceInfo.getName();
61
+ core_util_1.ServiceInfo.getVersion();
60
62
  // 1. Register the global HeaderRegistry FIRST (this service's own keys come from AppModules).
61
63
  core_util_1.HeaderRegistry.configure(appModules.getHeaders(), options.platformHeaders);
62
64
  // 2. Install the logging backend ONCE, before anything else logs.
@@ -1 +1 @@
1
- {"version":3,"file":"setupRuntime.js","sourceRoot":"","sources":["../../../../../packages/http/http-routing/src/setupRuntime.ts"],"names":[],"mappings":";;;AA2CA,oCAqCC;AA/ED,oDAAoH;AACpH,0DAAuE;AACvE,uDAAoD;AACpD,uDAA2D;AAI3D;;;;;;;;;GASG;AACH,MAAa,mBAAmB;IAGR;IAEA;IAEA;IANpB;IACI,0DAA0D;IAC1C,aAA4B;IAC5C,sDAAsD;IACtC,kBAA2B,IAAI;IAC/C,gFAAgF;IAChE,MAAwB;QAJxB,kBAAa,GAAb,aAAa,CAAe;QAE5B,oBAAe,GAAf,eAAe,CAAgB;QAE/B,WAAM,GAAN,MAAM,CAAkB;IACzC,CAAC;CACP;AATD,kDASC;AAED;;;;;;;;;;;;;GAaG;AACI,KAAK,UAAU,YAAY,CAC9B,OAA4B,EAC5B,UAAsB;AACtB;mEACmE;AACnE,YAA8B;IAE9B,6FAA6F;IAC7F,gGAAgG;IAChG,gGAAgG;IAChG,8FAA8F;IAC9F,oEAAoE;IACpE,uBAAW,CAAC,OAAO,EAAE,CAAC;IAEtB,8FAA8F;IAC9F,0BAAc,CAAC,SAAS,CAAC,UAAU,CAAC,UAAU,EAAE,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC;IAE3E,kEAAkE;IAClE,sBAAU,CAAC,UAAU,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;IAE7C,kGAAkG;IAClG,8FAA8F;IAC9F,kGAAkG;IAClG,gCAAoB,CAAC,OAAO,CAAC,IAAI,2CAA4B,EAAE,CAAC,CAAC;IAEjE,gDAAgD;IAChD,MAAM,MAAM,GAAG,MAAM,wCAAsB,CAAC,MAAM,CAAC;QAC/C,WAAW,EAAE,CAAC,GAAG,UAAU,CAAC,iBAAiB,EAAE,CAAC;QAChD,YAAY,EAAE,YAAY;QAC1B,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 { ApiCallContextHolder, HeaderRegistry, LoggerFactory, LogManager, ServiceInfo } from '@webpieces/core-util';\nimport { RequestContextApiCallContext } from '@webpieces/core-context';\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, whether to include the platform\n * default headers, and config. Data-only structure (a class, per the webpieces guidelines). The\n * app's own binding modules + route groups + headers come from the AppModules passed alongside;\n * the test-override module is the separate `appOverrides` param of {@link setupRuntime}.\n *\n * Headers: {@link HeaderRegistry.configure} registers the platform defaults (when\n * `platformHeaders` is true) plus AppModules.getHeaders() (by convention the company-wide set).\n */\nexport class RuntimeSetupOptions {\n constructor(\n /** Logging backend to install (LogManager.setFactory). */\n public readonly loggerFactory: LoggerFactory,\n /** Include the webpieces platform default headers. */\n public readonly platformHeaders: boolean = true,\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 /** A single DI module loaded LAST so tests can rebind bindings to mocks.\n * Or special case servers that want to override specific things */\n appOverrides?: ContainerModule,\n): Promise<ApiFactory> {\n // 0. This service must be NAMED. Both webpieces logging backends already read ServiceInfo in\n // their constructors, so a bunyan/winston app has failed before reaching here — but an app that\n // installs its OWN LoggerFactory touches neither, and would otherwise boot unnamed and stamp no\n // requestIdSource. Assert it HERE, the one startup every server runs, so the request path can\n // trust the name exists and never has to throw over it mid-traffic.\n ServiceInfo.getName();\n\n // 1. Register the global HeaderRegistry FIRST (this service's own keys come from AppModules).\n HeaderRegistry.configure(appModules.getHeaders(), options.platformHeaders);\n\n // 2. Install the logging backend ONCE, before anything else logs.\n LogManager.setFactory(options.loggerFactory);\n\n // 2b. Bind the SERVER ApiCallContext so LogApiCall (browser-safe core-util) stamps the structured\n // `api` tag into the real RequestContext. Installed here — the one startup that runs on EVERY\n // server — so both inbound (LogApiFilter) and outbound (clients) log lines carry jsonPayload.api.\n ApiCallContextHolder.install(new RequestContextApiCallContext());\n\n // 3. Build the node-only router + DI container.\n const router = await WebpiecesRouterFactory.create({\n appBindings: [...appModules.getBindingModules()],\n appOverrides: 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"]}
1
+ {"version":3,"file":"setupRuntime.js","sourceRoot":"","sources":["../../../../../packages/http/http-routing/src/setupRuntime.ts"],"names":[],"mappings":";;;AA2CA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,EAAE,CAAC;QACvD,WAAW,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAClC,CAAC;IACD,OAAO,MAAM,CAAC;AAClB,CAAC","sourcesContent":["import { ContainerModule } from 'inversify';\nimport { ApiCallContextHolder, HeaderRegistry, LoggerFactory, LogManager, ServiceInfo } from '@webpieces/core-util';\nimport { RequestContextApiCallContext } from '@webpieces/core-context';\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, whether to include the platform\n * default headers, and config. Data-only structure (a class, per the webpieces guidelines). The\n * app's own binding modules + route groups + headers come from the AppModules passed alongside;\n * the test-override module is the separate `appOverrides` param of {@link setupRuntime}.\n *\n * Headers: {@link HeaderRegistry.configure} registers the platform defaults (when\n * `platformHeaders` is true) plus AppModules.getHeaders() (by convention the company-wide set).\n */\nexport class RuntimeSetupOptions {\n constructor(\n /** Logging backend to install (LogManager.setFactory). */\n public readonly loggerFactory: LoggerFactory,\n /** Include the webpieces platform default headers. */\n public readonly platformHeaders: boolean = true,\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 /** A single DI module loaded LAST so tests can rebind bindings to mocks.\n * Or special case servers that want to override specific things */\n appOverrides?: ContainerModule,\n): Promise<ApiFactory> {\n // 0. This service must be IDENTIFIED (name + build version). Both webpieces logging backends\n // already read ServiceInfo in their constructors, so a bunyan/winston app has failed before\n // reaching here — but an app that installs its OWN LoggerFactory touches neither, and would\n // otherwise boot anonymous, stamp no requestIdSource, and ship logs that cannot say which build\n // emitted them. Assert HERE, the one startup every server runs, so the request path can trust\n // both exist and never has to throw over them mid-traffic.\n ServiceInfo.getName();\n ServiceInfo.getVersion();\n\n // 1. Register the global HeaderRegistry FIRST (this service's own keys come from AppModules).\n HeaderRegistry.configure(appModules.getHeaders(), options.platformHeaders);\n\n // 2. Install the logging backend ONCE, before anything else logs.\n LogManager.setFactory(options.loggerFactory);\n\n // 2b. Bind the SERVER ApiCallContext so LogApiCall (browser-safe core-util) stamps the structured\n // `api` tag into the real RequestContext. Installed here — the one startup that runs on EVERY\n // server — so both inbound (LogApiFilter) and outbound (clients) log lines carry jsonPayload.api.\n ApiCallContextHolder.install(new RequestContextApiCallContext());\n\n // 3. Build the node-only router + DI container.\n const router = await WebpiecesRouterFactory.create({\n appBindings: [...appModules.getBindingModules()],\n appOverrides: 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"]}