@webpieces/http-routing 0.4.864 → 0.4.866
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 +6 -5
- package/src/Wiring.d.ts +17 -0
- package/src/{AppModules.js → Wiring.js} +1 -1
- package/src/Wiring.js.map +1 -0
- package/src/WiringCompileAssertions.d.ts +5 -0
- package/src/WiringCompileAssertions.js +16 -0
- package/src/WiringCompileAssertions.js.map +1 -0
- package/src/index.d.ts +2 -2
- package/src/index.js +5 -5
- package/src/index.js.map +1 -1
- package/src/setupRuntime.d.ts +5 -5
- package/src/setupRuntime.js +9 -6
- package/src/setupRuntime.js.map +1 -1
- package/src/AppModules.d.ts +0 -59
- package/src/AppModules.js.map +0 -1
- package/src/ServerWiring.d.ts +0 -13
- package/src/ServerWiring.js +0 -23
- package/src/ServerWiring.js.map +0 -1
- package/src/ServerWiringCompileAssertions.d.ts +0 -6
- package/src/ServerWiringCompileAssertions.js +0 -16
- package/src/ServerWiringCompileAssertions.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webpieces/http-routing",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.866",
|
|
4
4
|
"description": "Decorator-based routing with auto-wiring for WebPieces",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -22,11 +22,12 @@
|
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@inversifyjs/binding-decorators": "1.1.5",
|
|
25
|
-
"@webpieces/core-context": "0.4.
|
|
26
|
-
"@webpieces/core-util": "0.4.
|
|
27
|
-
"@webpieces/gcp-identity": "0.4.
|
|
25
|
+
"@webpieces/core-context": "0.4.866",
|
|
26
|
+
"@webpieces/core-util": "0.4.866",
|
|
27
|
+
"@webpieces/gcp-identity": "0.4.866",
|
|
28
28
|
"inversify": "7.10.4",
|
|
29
29
|
"jsonwebtoken": "9.0.2",
|
|
30
|
-
"minimatch": "10.0.1"
|
|
30
|
+
"minimatch": "10.0.1",
|
|
31
|
+
"@webpieces/http-client-core": "0.4.866"
|
|
31
32
|
}
|
|
32
33
|
}
|
package/src/Wiring.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ContainerModuleLoadOptions } from 'inversify';
|
|
2
|
+
import type { AnyContextKey } from '@webpieces/core-util';
|
|
3
|
+
import type { Wiring as Topology, AppWiring as AppTopology } from '@webpieces/http-client-core';
|
|
4
|
+
import type { WebpiecesRouter } from './WebpiecesRouter';
|
|
5
|
+
/** Named DI declaration, adapted internally while retaining the selected instance. */
|
|
6
|
+
export interface BindingModule {
|
|
7
|
+
configure(options: ContainerModuleLoadOptions): void | Promise<void>;
|
|
8
|
+
}
|
|
9
|
+
export interface RouteModule {
|
|
10
|
+
configure(router: WebpiecesRouter): void;
|
|
11
|
+
}
|
|
12
|
+
export interface Wiring extends Topology<BindingModule, RouteModule> {
|
|
13
|
+
}
|
|
14
|
+
/** Applications retain ownership of their server context headers. */
|
|
15
|
+
export interface AppWiring extends AppTopology<BindingModule, RouteModule> {
|
|
16
|
+
getHeaders(): AnyContextKey[];
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Wiring.js","sourceRoot":"","sources":["../../../../../packages/http/http-routing/src/Wiring.ts"],"names":[],"mappings":"","sourcesContent":["import type { ContainerModuleLoadOptions } from 'inversify';\nimport type { AnyContextKey } from '@webpieces/core-util';\nimport type { Wiring as Topology, AppWiring as AppTopology } from '@webpieces/http-client-core';\nimport type { WebpiecesRouter } from './WebpiecesRouter';\n\n/** Named DI declaration, adapted internally while retaining the selected instance. */\nexport interface BindingModule {\n configure(options: ContainerModuleLoadOptions): void | Promise<void>;\n}\n\nexport interface RouteModule {\n configure(router: WebpiecesRouter): void;\n}\n\nexport interface Wiring extends Topology<BindingModule, RouteModule> {}\n\n/** Applications retain ownership of their server context headers. */\nexport interface AppWiring extends AppTopology<BindingModule, RouteModule> {\n getHeaders(): AnyContextKey[];\n}\n"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WiringCompileAssertions = void 0;
|
|
4
|
+
/** Checked by tsc; module channels have distinct platform contracts. */
|
|
5
|
+
class WiringCompileAssertions {
|
|
6
|
+
check(binding, routing) {
|
|
7
|
+
// @ts-expect-error A routing module cannot configure an Inversify load.
|
|
8
|
+
const invalidBinding = routing;
|
|
9
|
+
// @ts-expect-error A binding module cannot configure a router.
|
|
10
|
+
const invalidRoute = binding;
|
|
11
|
+
void invalidBinding;
|
|
12
|
+
void invalidRoute;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.WiringCompileAssertions = WiringCompileAssertions;
|
|
16
|
+
//# sourceMappingURL=WiringCompileAssertions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WiringCompileAssertions.js","sourceRoot":"","sources":["../../../../../packages/http/http-routing/src/WiringCompileAssertions.ts"],"names":[],"mappings":";;;AAEA,wEAAwE;AACxE,MAAa,uBAAuB;IAChC,KAAK,CAAC,OAAsB,EAAE,OAAoB;QAC9C,wEAAwE;QACxE,MAAM,cAAc,GAAkB,OAAO,CAAC;QAC9C,+DAA+D;QAC/D,MAAM,YAAY,GAAgB,OAAO,CAAC;QAC1C,KAAK,cAAc,CAAC;QACpB,KAAK,YAAY,CAAC;IACtB,CAAC;CACJ;AATD,0DASC","sourcesContent":["import type { BindingModule, RouteModule } from './Wiring';\n\n/** Checked by tsc; module channels have distinct platform contracts. */\nexport class WiringCompileAssertions {\n check(binding: BindingModule, routing: RouteModule): void {\n // @ts-expect-error A routing module cannot configure an Inversify load.\n const invalidBinding: BindingModule = routing;\n // @ts-expect-error A binding module cannot configure a router.\n const invalidRoute: RouteModule = binding;\n void invalidBinding;\n void invalidRoute;\n }\n}\n"]}
|
package/src/index.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ export { MethodMeta } from './MethodMeta';
|
|
|
13
13
|
export { RouteHandler } from './RouteHandler';
|
|
14
14
|
export { LogApiFilter } from './filters/LogApiFilter';
|
|
15
15
|
export { FilterMatcher, HttpFilter } from './FilterMatcher';
|
|
16
|
-
export {
|
|
16
|
+
export type { Wiring, AppWiring, BindingModule, RouteModule } from './Wiring';
|
|
17
17
|
export { ApiFactory } from './ApiFactory';
|
|
18
18
|
export { ApiClient, ApiClientProxy } from './ApiClient';
|
|
19
19
|
export { AuthConfig, AUTH_CONFIG, AuthenticatedCaller, AuthenticatedMachineIdentity, AUTHENTICATED_CALLER_KEY, SharedSecrets, } from './AuthConfig';
|
|
@@ -23,7 +23,7 @@ export { DefaultJwtHook, DefaultJwtMintRequest } from './DefaultJwtHook';
|
|
|
23
23
|
export { WebpiecesRouter, WebpiecesRouterFactory, WebpiecesRouterOptions } from './WebpiecesRouter';
|
|
24
24
|
export { setupRuntime, RuntimeSetupOptions } from './setupRuntime';
|
|
25
25
|
export { WebpiecesConfig, WEBPIECES_CONFIG_TOKEN } from './WebpiecesConfig';
|
|
26
|
-
export { ServerWiring, ServerWiringOptions } from './ServerWiring';
|
|
27
26
|
export { AuthorizationHook, AuthorizationService, CanonicalUserRoles, AUTHORIZATION_HOOK, VERIFIED_MACHINE_CALLER, VerifiedMachineCaller } from './AuthorizationHook';
|
|
28
27
|
export { AuthorizedApiDocument } from './AuthorizedApiDocument';
|
|
29
28
|
export type { ApiDocumentObject, ApiDocumentValue } from './AuthorizedApiDocument';
|
|
29
|
+
export { WiringPolicy, ExternalContractUse } from '@webpieces/http-client-core';
|
package/src/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isDocumentDesign = exports.DocumentDesign = exports.EXTERNAL = exports.CRON = exports.CLOUDTASKS = exports.RPC = exports.WRITE = exports.WRITE_IDEMPOTENT = exports.READ = exports.POST = exports.GET = exports.METADATA_KEYS = exports.HttpContractMapper = exports.RouteMetadataFactory = exports.RouteMetadata = exports.AuthMeta = exports.getQueueName = exports.assertPubSubConventions = exports.assertApiKind = exports.getApiKind = exports.assertEveryEndpointHasAuthMode = exports.getAuthMeta = exports.isApiPath = exports.isRawBody = exports.isFormPost = exports.getHttpParameterDeclarations = exports.getEndpointOperation = exports.getEndpointHttpMethod = exports.getEndpointOptions = exports.getEndpoints = exports.getApiPath = exports.Queue = exports.PubSub = exports.Rpc = exports.getAuthorization = exports.AuthorizationType = exports.WpAuthorization = exports.apiKey = exports.webhook = exports.sharedSecret = exports.oidc = exports.jwt = exports.isLocalOnly = exports.WpLocalOnly = exports.WpAuth = exports.WpAuthPublic = exports.QueryParam = exports.PathParam = exports.Endpoint = exports.ApiPath = void 0;
|
|
4
|
-
exports.
|
|
5
|
-
exports.
|
|
4
|
+
exports.AuthorizedApiDocument = exports.VerifiedMachineCaller = exports.VERIFIED_MACHINE_CALLER = exports.AUTHORIZATION_HOOK = exports.CanonicalUserRoles = exports.AuthorizationService = exports.AuthorizationHook = exports.WEBPIECES_CONFIG_TOKEN = exports.WebpiecesConfig = exports.RuntimeSetupOptions = exports.setupRuntime = exports.WebpiecesRouterFactory = exports.WebpiecesRouter = exports.DefaultJwtMintRequest = exports.DefaultJwtHook = exports.DefaultOidcVerifier = exports.API_KEY_HOOK = exports.ApiKeyHook = exports.WEBHOOK_AUTH_CALLBACK = exports.WebhookAuthCallback = exports.OIDC_HOOK = exports.OidcHook = exports.JWT_HOOK = exports.MintedJwt = exports.JwtHook = exports.SharedSecrets = exports.AUTHENTICATED_CALLER_KEY = exports.AuthenticatedMachineIdentity = exports.AuthenticatedCaller = exports.AUTH_CONFIG = exports.AuthConfig = exports.ApiClient = exports.FilterMatcher = exports.LogApiFilter = exports.RouteHandler = exports.MethodMeta = exports.InvocationAuthentication = exports.AuthenticatedCallerContext = exports.WpResponse = exports.RawRequest = exports.HttpRequest = exports.FilterDefinition = exports.RouteDefinition = exports.ApiRoutingFactory = exports.buildFrameworkModule = exports.provideFrameworkSingletonDefaultForApi = exports.provideFrameworkSingleton = exports.provideSingletonDefaultForApi = exports.ROUTING_METADATA_KEYS = exports.SourceFile = void 0;
|
|
5
|
+
exports.ExternalContractUse = exports.WiringPolicy = void 0;
|
|
6
6
|
// Re-export API decorators from core-util for convenience
|
|
7
7
|
var core_util_1 = require("@webpieces/core-util");
|
|
8
8
|
Object.defineProperty(exports, "ApiPath", { enumerable: true, get: function () { return core_util_1.ApiPath; } });
|
|
@@ -146,9 +146,6 @@ Object.defineProperty(exports, "RuntimeSetupOptions", { enumerable: true, get: f
|
|
|
146
146
|
var WebpiecesConfig_1 = require("./WebpiecesConfig");
|
|
147
147
|
Object.defineProperty(exports, "WebpiecesConfig", { enumerable: true, get: function () { return WebpiecesConfig_1.WebpiecesConfig; } });
|
|
148
148
|
Object.defineProperty(exports, "WEBPIECES_CONFIG_TOKEN", { enumerable: true, get: function () { return WebpiecesConfig_1.WEBPIECES_CONFIG_TOKEN; } });
|
|
149
|
-
var ServerWiring_1 = require("./ServerWiring");
|
|
150
|
-
Object.defineProperty(exports, "ServerWiring", { enumerable: true, get: function () { return ServerWiring_1.ServerWiring; } });
|
|
151
|
-
Object.defineProperty(exports, "ServerWiringOptions", { enumerable: true, get: function () { return ServerWiring_1.ServerWiringOptions; } });
|
|
152
149
|
var AuthorizationHook_1 = require("./AuthorizationHook");
|
|
153
150
|
Object.defineProperty(exports, "AuthorizationHook", { enumerable: true, get: function () { return AuthorizationHook_1.AuthorizationHook; } });
|
|
154
151
|
Object.defineProperty(exports, "AuthorizationService", { enumerable: true, get: function () { return AuthorizationHook_1.AuthorizationService; } });
|
|
@@ -158,4 +155,7 @@ Object.defineProperty(exports, "VERIFIED_MACHINE_CALLER", { enumerable: true, ge
|
|
|
158
155
|
Object.defineProperty(exports, "VerifiedMachineCaller", { enumerable: true, get: function () { return AuthorizationHook_1.VerifiedMachineCaller; } });
|
|
159
156
|
var AuthorizedApiDocument_1 = require("./AuthorizedApiDocument");
|
|
160
157
|
Object.defineProperty(exports, "AuthorizedApiDocument", { enumerable: true, get: function () { return AuthorizedApiDocument_1.AuthorizedApiDocument; } });
|
|
158
|
+
var http_client_core_1 = require("@webpieces/http-client-core");
|
|
159
|
+
Object.defineProperty(exports, "WiringPolicy", { enumerable: true, get: function () { return http_client_core_1.WiringPolicy; } });
|
|
160
|
+
Object.defineProperty(exports, "ExternalContractUse", { enumerable: true, get: function () { return http_client_core_1.ExternalContractUse; } });
|
|
161
161
|
//# sourceMappingURL=index.js.map
|
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,kDA6C8B;AA5C1B,oGAAA,OAAO,OAAA;AACP,qGAAA,QAAQ,OAAA;AACR,sGAAA,SAAS,OAAA;AACT,uGAAA,UAAU,OAAA;AACV,yGAAA,YAAY,OAAA;AACZ,mGAAA,MAAM,OAAA;AAAE,wGAAA,WAAW,OAAA;AAAE,wGAAA,WAAW,OAAA;AAAE,gGAAA,GAAG,OAAA;AAAE,iGAAA,IAAI,OAAA;AAAE,yGAAA,YAAY,OAAA;AAAE,oGAAA,OAAO,OAAA;AAAE,mGAAA,MAAM,OAAA;AAC1E,4GAAA,eAAe,OAAA;AAAE,8GAAA,iBAAiB,OAAA;AAAE,6GAAA,gBAAgB,OAAA;AACpD,gGAAA,GAAG,OAAA;AACH,mGAAA,MAAM,OAAA;AACN,kGAAA,KAAK,OAAA;AACL,uGAAA,UAAU,OAAA;AACV,yGAAA,YAAY,OAAA;AACZ,+GAAA,kBAAkB,OAAA;AAClB,kHAAA,qBAAqB,OAAA;AACrB,iHAAA,oBAAoB,OAAA;AACpB,yHAAA,4BAA4B,OAAA;AAC5B,uGAAA,UAAU,OAA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CAOsB;AANlB,wGAAA,UAAU,OAAA;AACV,yGAAA,WAAW,OAAA;AACX,iHAAA,mBAAmB,OAAA;AACnB,0HAAA,4BAA4B,OAAA;AAC5B,sHAAA,wBAAwB,OAAA;AACxB,2GAAA,aAAa,OAAA;AAEjB,yCAUqB;AATjB,oGAAA,OAAO,OAAA;AACP,sGAAA,SAAS,OAAA;AACT,qGAAA,QAAQ,OAAA;AACR,qGAAA,QAAQ,OAAA;AACR,sGAAA,SAAS,OAAA;AACT,gHAAA,mBAAmB,OAAA;AACnB,kHAAA,qBAAqB,OAAA;AACrB,uGAAA,UAAU,OAAA;AACV,yGAAA,YAAY,OAAA;AAEhB,6DAA4D;AAAnD,0HAAA,mBAAmB,OAAA;AAC5B,0FAA0F;AAC1F,mDAAyE;AAAhE,gHAAA,cAAc,OAAA;AAAE,uHAAA,qBAAqB,OAAA;AAE9C,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;AAGhD,yDAAsK;AAA7J,sHAAA,iBAAiB,OAAA;AAAE,yHAAA,oBAAoB,OAAA;AAAE,uHAAA,kBAAkB,OAAA;AAAE,uHAAA,kBAAkB,OAAA;AAAE,4HAAA,uBAAuB,OAAA;AAAE,0HAAA,qBAAqB,OAAA;AACxI,iEAAgE;AAAvD,8HAAA,qBAAqB,OAAA;AAG9B,gEAAgF;AAAvE,gHAAA,YAAY,OAAA;AAAE,uHAAA,mBAAmB,OAAA","sourcesContent":["// Re-export API decorators from core-util for convenience\nexport {\n ApiPath,\n Endpoint,\n PathParam,\n QueryParam,\n WpAuthPublic,\n WpAuth, WpLocalOnly, isLocalOnly, jwt, oidc, sharedSecret, webhook, apiKey,\n WpAuthorization, AuthorizationType, getAuthorization,\n Rpc,\n PubSub,\n Queue,\n getApiPath,\n getEndpoints,\n getEndpointOptions,\n getEndpointHttpMethod,\n getEndpointOperation,\n getHttpParameterDeclarations,\n isFormPost,\n isRawBody,\n isApiPath,\n getAuthMeta,\n assertEveryEndpointHasAuthMode,\n getApiKind,\n assertApiKind,\n assertPubSubConventions,\n getQueueName,\n AuthMeta,\n RouteMetadata,\n RouteMetadataFactory,\n HttpContractMapper,\n METADATA_KEYS,\n ValidateImplementation,\n GET,\n POST,\n READ,\n WRITE_IDEMPOTENT,\n WRITE,\n RPC,\n CLOUDTASKS,\n CRON,\n EXTERNAL,\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 {\n AuthMode,\n ApiKind,\n HttpMethod,\n EndpointOperation,\n EndpointKind,\n EndpointOptions,\n EndpointResponseType,\n} from '@webpieces/core-util';\n\n// Server-side routing decorators and utilities\nexport { SourceFile, ROUTING_METADATA_KEYS } from './decorators';\n\n// DI provider decorators moved to core-context; re-exported here for back-compat\nexport { provideSingletonDefaultForApi } 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 { Routes, RouteBuilder, RouteDefinition, FilterDefinition } 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, RawHttpRequest, RawRequest } from '@webpieces/core-context';\n\n// The INBOUND chain's response type. `Filter`, `Service` and `FilterChain` are NOT re-exported\n// here: they moved to @webpieces/core-util so the outbound client chain is the SAME abstraction\n// rather than a second spelling of it. Import them from '@webpieces/core-util'.\nexport { WpResponse } from './WpResponse';\nexport { AuthenticatedCallerContext } from './AuthenticatedCallerContext';\nexport { InvocationAuthentication } from './InvocationAuthentication';\nexport { MethodMeta } from './MethodMeta';\nexport { RouteHandler } from './RouteHandler';\n\n// LogApiFilter: the fixed OUTERMOST framework filter (auto-installed at 1,000,000 above\n// AuthFilter). Exported for reference/testing only — apps must NOT install it themselves.\nexport { LogApiFilter } from './filters/LogApiFilter';\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 type { Wiring, AppWiring, BindingModule, RouteModule } from './Wiring';\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 (sharedSecret(...) values).\n// - JwtHook / OidcHook / WebhookAuthCallback / ApiKeyHook: OPTIONAL verification mechanisms\n// (bind only what you use; unbound means the matching endpoints 401, never open).\n// - DefaultOidcVerifier: the built-in Google OIDC verifier used when no OidcHook is bound.\nexport {\n AuthConfig,\n AUTH_CONFIG,\n AuthenticatedCaller,\n AuthenticatedMachineIdentity,\n AUTHENTICATED_CALLER_KEY,\n SharedSecrets,\n} from './AuthConfig';\nexport {\n JwtHook,\n MintedJwt,\n JWT_HOOK,\n OidcHook,\n OIDC_HOOK,\n WebhookAuthCallback,\n WEBHOOK_AUTH_CALLBACK,\n ApiKeyHook,\n API_KEY_HOOK,\n} from './AuthHooks';\nexport { DefaultOidcVerifier } from './DefaultOidcVerifier';\n// DefaultJwtHook: batteries-included HS256 JwtHook — `new DefaultJwtHook(secret)` and go.\nexport { DefaultJwtHook, DefaultJwtMintRequest } 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\n\nexport { AuthorizationHook, AuthorizationService, CanonicalUserRoles, AUTHORIZATION_HOOK, VERIFIED_MACHINE_CALLER, VerifiedMachineCaller } from './AuthorizationHook';\nexport { AuthorizedApiDocument } from './AuthorizedApiDocument';\nexport type { ApiDocumentObject, ApiDocumentValue } from './AuthorizedApiDocument';\n\nexport { WiringPolicy, ExternalContractUse } from '@webpieces/http-client-core';\n"]}
|
package/src/setupRuntime.d.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { ContainerModule } from 'inversify';
|
|
2
2
|
import { Locality, LoggerFactory } from '@webpieces/core-util';
|
|
3
3
|
import { WebpiecesConfig } from './WebpiecesConfig';
|
|
4
|
-
import {
|
|
4
|
+
import { AppWiring } from './Wiring';
|
|
5
5
|
import { ApiFactory } from './ApiFactory';
|
|
6
6
|
/**
|
|
7
7
|
* RuntimeSetupOptions - the environment/wiring inputs to {@link setupRuntime} (everything NOT
|
|
8
|
-
* declared by the app's {@link
|
|
8
|
+
* declared by the app's {@link AppWiring}): the logging backend, whether to include the platform
|
|
9
9
|
* default headers, and config. Data-only structure (a class, per the webpieces guidelines). The
|
|
10
|
-
* app's own binding modules + route groups + headers come from the
|
|
10
|
+
* app's own binding modules + route groups + headers come from the AppWiring passed alongside;
|
|
11
11
|
* the test-override module is the separate `appOverrides` param of {@link setupRuntime}.
|
|
12
12
|
*
|
|
13
13
|
* Headers: {@link HeaderRegistry.configure} registers the platform defaults (when
|
|
14
|
-
* `platformHeaders` is true) plus
|
|
14
|
+
* `platformHeaders` is true) plus AppWiring.getHeaders() (by convention the company-wide set).
|
|
15
15
|
*/
|
|
16
16
|
export declare class RuntimeSetupOptions {
|
|
17
17
|
/** This service's name — published to ServiceInfo. Names every log line and stamps
|
|
@@ -78,7 +78,7 @@ export declare class RuntimeSetupOptions {
|
|
|
78
78
|
* `createApiClient()` for in-process tests. There is NO express (or any transport) here; a
|
|
79
79
|
* transport adapter (e.g. WebpiecesExpressRouter in @webpieces/http-server) serves the result.
|
|
80
80
|
*/
|
|
81
|
-
export declare function setupRuntime(options: RuntimeSetupOptions, appModules:
|
|
81
|
+
export declare function setupRuntime(options: RuntimeSetupOptions, appModules: AppWiring,
|
|
82
82
|
/** A single DI module loaded LAST so tests can rebind bindings to mocks.
|
|
83
83
|
* Or special case servers that want to override specific things */
|
|
84
84
|
appOverrides?: ContainerModule): Promise<ApiFactory>;
|
package/src/setupRuntime.js
CHANGED
|
@@ -2,18 +2,20 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RuntimeSetupOptions = void 0;
|
|
4
4
|
exports.setupRuntime = setupRuntime;
|
|
5
|
+
const inversify_1 = require("inversify");
|
|
5
6
|
const core_util_1 = require("@webpieces/core-util");
|
|
6
7
|
const WebpiecesConfig_1 = require("./WebpiecesConfig");
|
|
7
8
|
const WebpiecesRouter_1 = require("./WebpiecesRouter");
|
|
9
|
+
const http_client_core_1 = require("@webpieces/http-client-core");
|
|
8
10
|
/**
|
|
9
11
|
* RuntimeSetupOptions - the environment/wiring inputs to {@link setupRuntime} (everything NOT
|
|
10
|
-
* declared by the app's {@link
|
|
12
|
+
* declared by the app's {@link AppWiring}): the logging backend, whether to include the platform
|
|
11
13
|
* default headers, and config. Data-only structure (a class, per the webpieces guidelines). The
|
|
12
|
-
* app's own binding modules + route groups + headers come from the
|
|
14
|
+
* app's own binding modules + route groups + headers come from the AppWiring passed alongside;
|
|
13
15
|
* the test-override module is the separate `appOverrides` param of {@link setupRuntime}.
|
|
14
16
|
*
|
|
15
17
|
* Headers: {@link HeaderRegistry.configure} registers the platform defaults (when
|
|
16
|
-
* `platformHeaders` is true) plus
|
|
18
|
+
* `platformHeaders` is true) plus AppWiring.getHeaders() (by convention the company-wide set).
|
|
17
19
|
*/
|
|
18
20
|
class RuntimeSetupOptions {
|
|
19
21
|
svcName;
|
|
@@ -85,18 +87,19 @@ appOverrides) {
|
|
|
85
87
|
// decide whether @WpLocalOnly routes are registered at all. Undeclared reads as DEPLOYED, so
|
|
86
88
|
// this call is what lets a local-only endpoint exist — never what hides one.
|
|
87
89
|
core_util_1.RuntimeLocality.declare(options.locality);
|
|
88
|
-
// 1. Register the global HeaderRegistry FIRST (this service's own keys come from
|
|
90
|
+
// 1. Register the global HeaderRegistry FIRST (this service's own keys come from AppWiring).
|
|
89
91
|
core_util_1.HeaderRegistry.configure(appModules.getHeaders(), options.platformHeaders);
|
|
90
92
|
// 2. Install the logging backend ONCE, before anything else logs.
|
|
91
93
|
core_util_1.LogManager.setFactory(options.loggerFactory);
|
|
92
94
|
// 3. Build the node-only router + DI container.
|
|
95
|
+
const modules = new http_client_core_1.WiringModules(appModules);
|
|
93
96
|
const router = await WebpiecesRouter_1.WebpiecesRouterFactory.create({
|
|
94
|
-
appBindings:
|
|
97
|
+
appBindings: modules.bindingModules.map((module) => new inversify_1.ContainerModule((load) => module.configure(load))),
|
|
95
98
|
appOverrides: appOverrides,
|
|
96
99
|
config: options.config ?? new WebpiecesConfig_1.WebpiecesConfig(),
|
|
97
100
|
});
|
|
98
101
|
// 4. Let each route group declare its routes + filters, then hand back the consumer surface.
|
|
99
|
-
for (const routeModule of
|
|
102
|
+
for (const routeModule of modules.routingModules) {
|
|
100
103
|
routeModule.configure(router);
|
|
101
104
|
}
|
|
102
105
|
return router;
|
package/src/setupRuntime.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setupRuntime.js","sourceRoot":"","sources":["../../../../../packages/http/http-routing/src/setupRuntime.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"setupRuntime.js","sourceRoot":"","sources":["../../../../../packages/http/http-routing/src/setupRuntime.ts"],"names":[],"mappings":";;;AAoEA,oCAyCC;AA7GD,yCAAwE;AACxE,oDAO8B;AAC9B,uDAAoD;AACpD,uDAA2D;AAE3D,kEAA4D;AAG5D;;;;;;;;;GASG;AACH,MAAa,mBAAmB;IAIR;IAIA;IAWA;IAEA;IAEA;IAEA;IAxBpB;IACI;iFAC6E;IAC7D,OAAe;IAC/B;;+DAE2D;IAC3C,UAAkB;IAClC;;;;;;;;;OASG;IACa,QAAkB;IAClC,0DAA0D;IAC1C,aAA4B;IAC5C,sDAAsD;IACtC,kBAA2B,IAAI;IAC/C,gFAAgF;IAChE,MAAwB;QArBxB,YAAO,GAAP,OAAO,CAAQ;QAIf,eAAU,GAAV,UAAU,CAAQ;QAWlB,aAAQ,GAAR,QAAQ,CAAU;QAElB,kBAAa,GAAb,aAAa,CAAe;QAE5B,oBAAe,GAAf,eAAe,CAAgB;QAE/B,WAAM,GAAN,MAAM,CAAkB;IACzC,CAAC;CACP;AA3BD,kDA2BC;AAED;;;;;;;;;;;;;GAaG;AACI,KAAK,UAAU,YAAY,CAC9B,OAA4B,EAC5B,UAAqB;AACrB;mEACmE;AACnE,YAA8B;IAE9B,gGAAgG;IAChG,6FAA6F;IAC7F,kGAAkG;IAClG,kGAAkG;IAClG,kGAAkG;IAClG,iCAAiC;IACjC,uBAAW,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;IAEzD,+FAA+F;IAC/F,6FAA6F;IAC7F,6EAA6E;IAC7E,2BAAe,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAE1C,6FAA6F;IAC7F,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,gDAAgD;IAChD,MAAM,OAAO,GAAG,IAAI,gCAAa,CAAC,UAAU,CAAC,CAAC;IAC9C,MAAM,MAAM,GAAG,MAAM,wCAAsB,CAAC,MAAM,CAAC;QAC/C,WAAW,EAAE,OAAO,CAAC,cAAc,CAAC,GAAG,CACnC,CAAC,MAAqB,EAAE,EAAE,CAAC,IAAI,2BAAe,CAAC,CAAC,IAAgC,EAAE,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAC/G;QACD,YAAY,EAAE,YAAY;QAC1B,MAAM,EAAE,OAAO,CAAC,MAAM,IAAI,IAAI,iCAAe,EAAE;KAClD,CAAC,CAAC;IAEH,6FAA6F;IAC7F,KAAK,MAAM,WAAW,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC;QAC/C,WAAW,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAClC,CAAC;IACD,OAAO,MAAM,CAAC;AAClB,CAAC","sourcesContent":["import { ContainerModule, ContainerModuleLoadOptions } from 'inversify';\nimport {\n HeaderRegistry,\n Locality,\n LoggerFactory,\n LogManager,\n RuntimeLocality,\n ServiceInfo,\n} from '@webpieces/core-util';\nimport { WebpiecesConfig } from './WebpiecesConfig';\nimport { WebpiecesRouterFactory } from './WebpiecesRouter';\nimport { AppWiring, BindingModule } from './Wiring';\nimport { WiringModules } from '@webpieces/http-client-core';\nimport { ApiFactory } from './ApiFactory';\n\n/**\n * RuntimeSetupOptions - the environment/wiring inputs to {@link setupRuntime} (everything NOT\n * declared by the app's {@link AppWiring}): 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 AppWiring 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 AppWiring.getHeaders() (by convention the company-wide set).\n */\nexport class RuntimeSetupOptions {\n constructor(\n /** This service's name — published to ServiceInfo. Names every log line and stamps\n * `requestIdSource` on request-ids this service mints. Must be non-blank. */\n public readonly svcName: string,\n /** This build's version — published to ServiceInfo alongside svcName. Opaque to webpieces\n * (a git SHA, a semver tag, a CI build number); it just has to identify THIS build so a log\n * line can say which one emitted it. Must be non-blank. */\n public readonly svcVersion: string,\n /**\n * WHERE this process runs — `'local'` (a developer's machine) or `'deployed'` (everything\n * else). Published to {@link RuntimeLocality}; the ONE input to `@WpLocalOnly` enforcement.\n *\n * REQUIRED and POSITIONAL on purpose, exactly like `@Endpoint(path, kind)`: only the app\n * knows how its platform is detected (Cloud Run's `K_SERVICE`, an ECS metadata URL, the\n * absence of both), the framework must not guess, and a defaulted field would mean \"forgot\n * to say\" and \"said deployed\" are the same line of code. Derive it at your startup, e.g.\n * `getServiceName() === 'local' ? 'local' : 'deployed'`.\n */\n public readonly locality: Locality,\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: AppWiring,\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. IDENTIFY this service (name + build version) FIRST, before anything logs. Name and version\n // are REQUIRED inputs to this call, so a build cannot boot anonymously — setInfo throws on a\n // blank value, which kills the deploy (the revision never goes healthy) rather than shipping logs\n // that cannot say which build emitted them. Reads of ServiceInfo elsewhere never throw (a missing\n // log field must never 500 live traffic); the \"say which build you are\" guarantee lives HERE, the\n // one startup every server runs.\n ServiceInfo.setInfo(options.svcName, options.svcVersion);\n\n // 0b. Declare WHERE we run, before any route is built: ApiRoutingFactory reads it in step 4 to\n // decide whether @WpLocalOnly routes are registered at all. Undeclared reads as DEPLOYED, so\n // this call is what lets a local-only endpoint exist — never what hides one.\n RuntimeLocality.declare(options.locality);\n\n // 1. Register the global HeaderRegistry FIRST (this service's own keys come from AppWiring).\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 // 3. Build the node-only router + DI container.\n const modules = new WiringModules(appModules);\n const router = await WebpiecesRouterFactory.create({\n appBindings: modules.bindingModules.map(\n (module: BindingModule) => new ContainerModule((load: ContainerModuleLoadOptions) => module.configure(load)),\n ),\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 modules.routingModules) {\n routeModule.configure(router);\n }\n return router;\n}\n"]}
|
package/src/AppModules.d.ts
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { ContainerModule } from 'inversify';
|
|
2
|
-
import { AnyContextKey } 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, MyFilter, '*')); // your own filters only
|
|
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(): AnyContextKey[] { return AppHeaders.ALL_HEADERS; }
|
|
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 company's own context keys(usually all keys across all servers),
|
|
57
|
-
* registered into the global HeaderRegistry at startup. */
|
|
58
|
-
getHeaders(): AnyContextKey[];
|
|
59
|
-
}
|
package/src/AppModules.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AppModules.js","sourceRoot":"","sources":["../../../../../packages/http/http-routing/src/AppModules.ts"],"names":[],"mappings":"","sourcesContent":["import { ContainerModule } from 'inversify';\nimport { ContextKey, AnyContextKey } 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, MyFilter, '*')); // your own filters only\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(): AnyContextKey[] { return AppHeaders.ALL_HEADERS; }\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 company's own context keys(usually all keys across all servers),\n * registered into the global HeaderRegistry at startup. */\n getHeaders(): AnyContextKey[];\n}\n"]}
|
package/src/ServerWiring.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { ContainerModule } from 'inversify';
|
|
2
|
-
import type { RouteModule } from './AppModules';
|
|
3
|
-
/** Separate lists are the actual ordered runtime composition, never a second topology inventory. */
|
|
4
|
-
export declare class ServerWiringOptions {
|
|
5
|
-
readonly bindingModules: ContainerModule[];
|
|
6
|
-
readonly routingModules: RouteModule[];
|
|
7
|
-
constructor(bindingModules: ContainerModule[], routingModules: RouteModule[]);
|
|
8
|
-
}
|
|
9
|
-
export declare class ServerWiring {
|
|
10
|
-
readonly host: string;
|
|
11
|
-
readonly options: ServerWiringOptions;
|
|
12
|
-
constructor(host: string, options: ServerWiringOptions);
|
|
13
|
-
}
|
package/src/ServerWiring.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ServerWiring = exports.ServerWiringOptions = void 0;
|
|
4
|
-
/** Separate lists are the actual ordered runtime composition, never a second topology inventory. */
|
|
5
|
-
class ServerWiringOptions {
|
|
6
|
-
bindingModules;
|
|
7
|
-
routingModules;
|
|
8
|
-
constructor(bindingModules, routingModules) {
|
|
9
|
-
this.bindingModules = bindingModules;
|
|
10
|
-
this.routingModules = routingModules;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
exports.ServerWiringOptions = ServerWiringOptions;
|
|
14
|
-
class ServerWiring {
|
|
15
|
-
host;
|
|
16
|
-
options;
|
|
17
|
-
constructor(host, options) {
|
|
18
|
-
this.host = host;
|
|
19
|
-
this.options = options;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
exports.ServerWiring = ServerWiring;
|
|
23
|
-
//# sourceMappingURL=ServerWiring.js.map
|
package/src/ServerWiring.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ServerWiring.js","sourceRoot":"","sources":["../../../../../packages/http/http-routing/src/ServerWiring.ts"],"names":[],"mappings":";;;AAGA,oGAAoG;AACpG,MAAa,mBAAmB;IAER;IACA;IAFpB,YACoB,cAAiC,EACjC,cAA6B;QAD7B,mBAAc,GAAd,cAAc,CAAmB;QACjC,mBAAc,GAAd,cAAc,CAAe;IAC9C,CAAC;CACP;AALD,kDAKC;AAED,MAAa,YAAY;IAED;IACA;IAFpB,YACoB,IAAY,EACZ,OAA4B;QAD5B,SAAI,GAAJ,IAAI,CAAQ;QACZ,YAAO,GAAP,OAAO,CAAqB;IAC7C,CAAC;CACP;AALD,oCAKC","sourcesContent":["import type { ContainerModule } from 'inversify';\nimport type { RouteModule } from './AppModules';\n\n/** Separate lists are the actual ordered runtime composition, never a second topology inventory. */\nexport class ServerWiringOptions {\n constructor(\n public readonly bindingModules: ContainerModule[],\n public readonly routingModules: RouteModule[],\n ) {}\n}\n\nexport class ServerWiring {\n constructor(\n public readonly host: string,\n public readonly options: ServerWiringOptions,\n ) {}\n}\n"]}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { ContainerModule } from 'inversify';
|
|
2
|
-
import type { RouteModule } from './AppModules';
|
|
3
|
-
/** Negative type assertions participate in the package build, never in runtime startup. */
|
|
4
|
-
export declare class ServerWiringCompileAssertions {
|
|
5
|
-
check(binding: ContainerModule, routing: RouteModule): void;
|
|
6
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ServerWiringCompileAssertions = void 0;
|
|
4
|
-
const ServerWiring_1 = require("./ServerWiring");
|
|
5
|
-
/** Negative type assertions participate in the package build, never in runtime startup. */
|
|
6
|
-
class ServerWiringCompileAssertions {
|
|
7
|
-
check(binding, routing) {
|
|
8
|
-
new ServerWiring_1.ServerWiringOptions([binding], [routing]);
|
|
9
|
-
// @ts-expect-error Route modules cannot be loaded into Inversify.
|
|
10
|
-
new ServerWiring_1.ServerWiringOptions([routing], []);
|
|
11
|
-
// @ts-expect-error Inversify modules cannot configure routes.
|
|
12
|
-
new ServerWiring_1.ServerWiringOptions([], [binding]);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
exports.ServerWiringCompileAssertions = ServerWiringCompileAssertions;
|
|
16
|
-
//# sourceMappingURL=ServerWiringCompileAssertions.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ServerWiringCompileAssertions.js","sourceRoot":"","sources":["../../../../../packages/http/http-routing/src/ServerWiringCompileAssertions.ts"],"names":[],"mappings":";;;AAEA,iDAAqD;AAErD,2FAA2F;AAC3F,MAAa,6BAA6B;IACtC,KAAK,CAAC,OAAwB,EAAE,OAAoB;QAChD,IAAI,kCAAmB,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;QAC9C,kEAAkE;QAClE,IAAI,kCAAmB,CAAC,CAAC,OAAO,CAAC,EAAE,EAAE,CAAC,CAAC;QACvC,8DAA8D;QAC9D,IAAI,kCAAmB,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IAC3C,CAAC;CACJ;AARD,sEAQC","sourcesContent":["import type { ContainerModule } from 'inversify';\nimport type { RouteModule } from './AppModules';\nimport { ServerWiringOptions } from './ServerWiring';\n\n/** Negative type assertions participate in the package build, never in runtime startup. */\nexport class ServerWiringCompileAssertions {\n check(binding: ContainerModule, routing: RouteModule): void {\n new ServerWiringOptions([binding], [routing]);\n // @ts-expect-error Route modules cannot be loaded into Inversify.\n new ServerWiringOptions([routing], []);\n // @ts-expect-error Inversify modules cannot configure routes.\n new ServerWiringOptions([], [binding]);\n }\n}\n"]}
|