@webpieces/http-routing 0.3.145 → 0.3.147
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 +3 -3
- package/src/decorators.d.ts +14 -0
- package/src/decorators.js +16 -0
- package/src/decorators.js.map +1 -1
- package/src/index.d.ts +1 -1
- package/src/index.js +2 -1
- package/src/index.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webpieces/http-routing",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.147",
|
|
4
4
|
"description": "Decorator-based routing with auto-wiring for WebPieces",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
"access": "public"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@webpieces/http-api": "0.3.
|
|
25
|
-
"@webpieces/http-filters": "0.3.
|
|
24
|
+
"@webpieces/http-api": "0.3.147",
|
|
25
|
+
"@webpieces/http-filters": "0.3.147",
|
|
26
26
|
"inversify": "7.10.4",
|
|
27
27
|
"minimatch": "10.0.1"
|
|
28
28
|
}
|
package/src/decorators.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
|
+
import type { ServiceIdentifier } from 'inversify';
|
|
2
3
|
/**
|
|
3
4
|
* Metadata keys for server-side routing.
|
|
4
5
|
* These are specific to the routing package (server-side only).
|
|
@@ -55,6 +56,19 @@ export declare function SourceFile(filepath: string): ClassDecorator;
|
|
|
55
56
|
* ```
|
|
56
57
|
*/
|
|
57
58
|
export declare function provideSingleton(): (target: any) => any;
|
|
59
|
+
/**
|
|
60
|
+
* Provides a singleton-scoped dependency bound to a specific token (Symbol or abstract class).
|
|
61
|
+
* Use this in libraries/apis-external/** to bind an impl to the Symbol defined in libraries/apis/**.
|
|
62
|
+
*
|
|
63
|
+
* Usage:
|
|
64
|
+
* ```typescript
|
|
65
|
+
* import { SOME_API_TOKEN } from '@myorg/some-api';
|
|
66
|
+
*
|
|
67
|
+
* @provideSingletonAs(SOME_API_TOKEN)
|
|
68
|
+
* export class SomeApiImpl implements SomeApi { ... }
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
export declare function provideSingletonAs<T>(serviceIdentifier: ServiceIdentifier<T>): ClassDecorator;
|
|
58
72
|
/**
|
|
59
73
|
* Provides a transient-scoped dependency (new instance every time).
|
|
60
74
|
* When called without arguments, the decorated class binds to itself.
|
package/src/decorators.js
CHANGED
|
@@ -5,6 +5,7 @@ exports.Controller = Controller;
|
|
|
5
5
|
exports.isController = isController;
|
|
6
6
|
exports.SourceFile = SourceFile;
|
|
7
7
|
exports.provideSingleton = provideSingleton;
|
|
8
|
+
exports.provideSingletonAs = provideSingletonAs;
|
|
8
9
|
exports.provideTransient = provideTransient;
|
|
9
10
|
require("reflect-metadata");
|
|
10
11
|
const binding_decorators_1 = require("@inversifyjs/binding-decorators");
|
|
@@ -78,6 +79,21 @@ function provideSingleton() {
|
|
|
78
79
|
return (0, binding_decorators_1.provide)(target, (bind) => bind.inSingletonScope())(target);
|
|
79
80
|
};
|
|
80
81
|
}
|
|
82
|
+
/**
|
|
83
|
+
* Provides a singleton-scoped dependency bound to a specific token (Symbol or abstract class).
|
|
84
|
+
* Use this in libraries/apis-external/** to bind an impl to the Symbol defined in libraries/apis/**.
|
|
85
|
+
*
|
|
86
|
+
* Usage:
|
|
87
|
+
* ```typescript
|
|
88
|
+
* import { SOME_API_TOKEN } from '@myorg/some-api';
|
|
89
|
+
*
|
|
90
|
+
* @provideSingletonAs(SOME_API_TOKEN)
|
|
91
|
+
* export class SomeApiImpl implements SomeApi { ... }
|
|
92
|
+
* ```
|
|
93
|
+
*/
|
|
94
|
+
function provideSingletonAs(serviceIdentifier) {
|
|
95
|
+
return (0, binding_decorators_1.provide)(serviceIdentifier, (bind) => bind.inSingletonScope());
|
|
96
|
+
}
|
|
81
97
|
/**
|
|
82
98
|
* Provides a transient-scoped dependency (new instance every time).
|
|
83
99
|
* When called without arguments, the decorated class binds to itself.
|
package/src/decorators.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decorators.js","sourceRoot":"","sources":["../../../../../packages/http/http-routing/src/decorators.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"decorators.js","sourceRoot":"","sources":["../../../../../packages/http/http-routing/src/decorators.ts"],"names":[],"mappings":";;;AAyBA,gCAIC;AAMD,oCAEC;AAeD,gCAIC;AAiBD,4CAIC;AAcD,gDAEC;AAiBD,4CAIC;AAlHD,4BAA0B;AAC1B,wEAA0D;AAG1D;;;GAGG;AACU,QAAA,qBAAqB,GAAG;IACjC,UAAU,EAAE,sBAAsB;IAClC,eAAe,EAAE,2BAA2B;CAC/C,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,SAAgB,UAAU;IACtB,OAAO,CAAC,MAAW,EAAE,EAAE;QACnB,OAAO,CAAC,cAAc,CAAC,6BAAqB,CAAC,UAAU,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;IAC3E,CAAC,CAAC;AACN,CAAC;AAED;;;GAGG;AACH,SAAgB,YAAY,CAAC,eAAoB;IAC7C,OAAO,OAAO,CAAC,WAAW,CAAC,6BAAqB,CAAC,UAAU,EAAE,eAAe,CAAC,KAAK,IAAI,CAAC;AAC3F,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,SAAgB,UAAU,CAAC,QAAgB;IACvC,OAAO,CAAC,MAAW,EAAE,EAAE;QACnB,OAAO,CAAC,cAAc,CAAC,6BAAqB,CAAC,eAAe,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;IACpF,CAAC,CAAC;AACN,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,SAAgB,gBAAgB;IAC5B,OAAO,CAAC,MAAW,EAAE,EAAE;QACnB,OAAO,IAAA,4BAAO,EAAC,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,gBAAgB,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC;IACtE,CAAC,CAAC;AACN,CAAC;AAED;;;;;;;;;;;GAWG;AACH,SAAgB,kBAAkB,CAAI,iBAAuC;IACzE,OAAO,IAAA,4BAAO,EAAC,iBAAiB,EAAE,CAAC,IAAiC,EAAE,EAAE,CAAC,IAAI,CAAC,gBAAgB,EAAE,CAAC,CAAC;AACtG,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,SAAgB,gBAAgB;IAC5B,OAAO,CAAC,MAAW,EAAE,EAAE;QACnB,OAAO,IAAA,4BAAO,EAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC;IACnC,CAAC,CAAC;AACN,CAAC","sourcesContent":["import 'reflect-metadata';\nimport { provide } from '@inversifyjs/binding-decorators';\nimport type { BindInWhenOnFluentSyntax, ServiceIdentifier } from 'inversify';\n\n/**\n * Metadata keys for server-side routing.\n * These are specific to the routing package (server-side only).\n */\nexport const ROUTING_METADATA_KEYS = {\n CONTROLLER: 'webpieces:controller',\n SOURCE_FILEPATH: 'webpieces:source-filepath',\n};\n\n/**\n * @Controller decorator to mark a class as a controller.\n * This is a server-side only decorator.\n *\n * Usage:\n * ```typescript\n * @Controller()\n * export class SaveController implements SaveApi {\n * // ...\n * }\n * ```\n */\nexport function Controller(): ClassDecorator {\n return (target: any) => {\n Reflect.defineMetadata(ROUTING_METADATA_KEYS.CONTROLLER, true, target);\n };\n}\n\n/**\n * Helper function to check if a class is a controller.\n * Server-side only.\n */\nexport function isController(controllerClass: any): boolean {\n return Reflect.getMetadata(ROUTING_METADATA_KEYS.CONTROLLER, controllerClass) === true;\n}\n\n/**\n * SourceFile decorator to explicitly set the source filepath for a controller.\n * This is used by filter matching to determine which filters apply to the controller.\n *\n * If not specified, the system will use a heuristic based on class name.\n *\n * Usage:\n * @SourceFile('src/controllers/admin/UserController.ts')\n * @Controller()\n * export class UserController implements UserApi\n *\n * @param filepath - The source filepath of the controller\n */\nexport function SourceFile(filepath: string): ClassDecorator {\n return (target: any) => {\n Reflect.defineMetadata(ROUTING_METADATA_KEYS.SOURCE_FILEPATH, filepath, target);\n };\n}\n\n/**\n * Provides a singleton-scoped dependency.\n * When called without arguments, the decorated class binds to itself.\n *\n * Server-side only - registers classes in the DI container.\n *\n * Usage:\n * ```typescript\n * @provideSingleton()\n * @Controller()\n * export class SaveController {\n * // ...\n * }\n * ```\n */\nexport function provideSingleton() {\n return (target: any) => {\n return provide(target, (bind) => bind.inSingletonScope())(target);\n };\n}\n\n/**\n * Provides a singleton-scoped dependency bound to a specific token (Symbol or abstract class).\n * Use this in libraries/apis-external/** to bind an impl to the Symbol defined in libraries/apis/**.\n *\n * Usage:\n * ```typescript\n * import { SOME_API_TOKEN } from '@myorg/some-api';\n *\n * @provideSingletonAs(SOME_API_TOKEN)\n * export class SomeApiImpl implements SomeApi { ... }\n * ```\n */\nexport function provideSingletonAs<T>(serviceIdentifier: ServiceIdentifier<T>): ClassDecorator {\n return provide(serviceIdentifier, (bind: BindInWhenOnFluentSyntax<T>) => bind.inSingletonScope());\n}\n\n/**\n * Provides a transient-scoped dependency (new instance every time).\n * When called without arguments, the decorated class binds to itself.\n *\n * Server-side only - registers classes in the DI container.\n *\n * Usage:\n * ```typescript\n * @provideTransient()\n * @Controller()\n * export class TransientController {\n * // ...\n * }\n * ```\n */\nexport function provideTransient() {\n return (target: any) => {\n return provide(target)(target);\n };\n}\n"]}
|
package/src/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { ApiPath, Endpoint, Authentication, AuthenticationConfig, getApiPath, getEndpoints, isApiPath, getAuthMeta, AuthMeta, RouteMetadata, METADATA_KEYS, ValidateImplementation, } from '@webpieces/http-api';
|
|
2
|
-
export { Controller, isController, provideSingleton, provideTransient, ROUTING_METADATA_KEYS, } from './decorators';
|
|
2
|
+
export { Controller, isController, provideSingleton, provideSingletonAs, provideTransient, ROUTING_METADATA_KEYS, } from './decorators';
|
|
3
3
|
export { ApiRoutingFactory, ClassType } from './ApiRoutingFactory';
|
|
4
4
|
export { WebAppMeta, WEBAPP_META_TOKEN, Routes, RouteBuilder, RouteDefinition, FilterDefinition, } from './WebAppMeta';
|
|
5
5
|
export { MethodMeta } from './MethodMeta';
|
package/src/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.WEBPIECES_CONFIG_TOKEN = exports.WebpiecesConfig = exports.RequestContextReader = exports.FilterMatcher = exports.FilterWithMeta = exports.RouteHandlerWithMeta = exports.RouteBuilderImpl = exports.RouteHandler = exports.MethodMeta = exports.FilterDefinition = exports.RouteDefinition = exports.WEBAPP_META_TOKEN = exports.ApiRoutingFactory = exports.ROUTING_METADATA_KEYS = exports.provideTransient = exports.provideSingleton = exports.isController = exports.Controller = exports.METADATA_KEYS = exports.RouteMetadata = exports.AuthMeta = exports.getAuthMeta = exports.isApiPath = exports.getEndpoints = exports.getApiPath = exports.AuthenticationConfig = exports.Authentication = exports.Endpoint = exports.ApiPath = void 0;
|
|
3
|
+
exports.WEBPIECES_CONFIG_TOKEN = exports.WebpiecesConfig = exports.RequestContextReader = exports.FilterMatcher = exports.FilterWithMeta = exports.RouteHandlerWithMeta = exports.RouteBuilderImpl = exports.RouteHandler = exports.MethodMeta = exports.FilterDefinition = exports.RouteDefinition = exports.WEBAPP_META_TOKEN = exports.ApiRoutingFactory = exports.ROUTING_METADATA_KEYS = exports.provideTransient = exports.provideSingletonAs = exports.provideSingleton = exports.isController = exports.Controller = exports.METADATA_KEYS = exports.RouteMetadata = exports.AuthMeta = exports.getAuthMeta = exports.isApiPath = exports.getEndpoints = exports.getApiPath = exports.AuthenticationConfig = exports.Authentication = exports.Endpoint = exports.ApiPath = void 0;
|
|
4
4
|
// Re-export API decorators from http-api for convenience
|
|
5
5
|
var http_api_1 = require("@webpieces/http-api");
|
|
6
6
|
Object.defineProperty(exports, "ApiPath", { enumerable: true, get: function () { return http_api_1.ApiPath; } });
|
|
@@ -19,6 +19,7 @@ var decorators_1 = require("./decorators");
|
|
|
19
19
|
Object.defineProperty(exports, "Controller", { enumerable: true, get: function () { return decorators_1.Controller; } });
|
|
20
20
|
Object.defineProperty(exports, "isController", { enumerable: true, get: function () { return decorators_1.isController; } });
|
|
21
21
|
Object.defineProperty(exports, "provideSingleton", { enumerable: true, get: function () { return decorators_1.provideSingleton; } });
|
|
22
|
+
Object.defineProperty(exports, "provideSingletonAs", { enumerable: true, get: function () { return decorators_1.provideSingletonAs; } });
|
|
22
23
|
Object.defineProperty(exports, "provideTransient", { enumerable: true, get: function () { return decorators_1.provideTransient; } });
|
|
23
24
|
Object.defineProperty(exports, "ROUTING_METADATA_KEYS", { enumerable: true, get: function () { return decorators_1.ROUTING_METADATA_KEYS; } });
|
|
24
25
|
var ApiRoutingFactory_1 = require("./ApiRoutingFactory");
|
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,yDAAyD;AACzD,gDAa6B;AAZzB,mGAAA,OAAO,OAAA;AACP,oGAAA,QAAQ,OAAA;AACR,0GAAA,cAAc,OAAA;AACd,gHAAA,oBAAoB,OAAA;AACpB,sGAAA,UAAU,OAAA;AACV,wGAAA,YAAY,OAAA;AACZ,qGAAA,SAAS,OAAA;AACT,uGAAA,WAAW,OAAA;AACX,oGAAA,QAAQ,OAAA;AACR,yGAAA,aAAa,OAAA;AACb,yGAAA,aAAa,OAAA;AAIjB,+CAA+C;AAC/C,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/http/http-routing/src/index.ts"],"names":[],"mappings":";;;AAAA,yDAAyD;AACzD,gDAa6B;AAZzB,mGAAA,OAAO,OAAA;AACP,oGAAA,QAAQ,OAAA;AACR,0GAAA,cAAc,OAAA;AACd,gHAAA,oBAAoB,OAAA;AACpB,sGAAA,UAAU,OAAA;AACV,wGAAA,YAAY,OAAA;AACZ,qGAAA,SAAS,OAAA;AACT,uGAAA,WAAW,OAAA;AACX,oGAAA,QAAQ,OAAA;AACR,yGAAA,aAAa,OAAA;AACb,yGAAA,aAAa,OAAA;AAIjB,+CAA+C;AAC/C,2CAOsB;AANlB,wGAAA,UAAU,OAAA;AACV,0GAAA,YAAY,OAAA;AACZ,8GAAA,gBAAgB,OAAA;AAChB,gHAAA,kBAAkB,OAAA;AAClB,8GAAA,gBAAgB,OAAA;AAChB,mHAAA,qBAAqB,OAAA;AAGzB,yDAAmE;AAA1D,sHAAA,iBAAiB,OAAA;AAE1B,4CAA4C;AAC5C,2CAOsB;AALlB,+GAAA,iBAAiB,OAAA;AAGjB,6GAAA,eAAe,OAAA;AACf,8GAAA,gBAAgB,OAAA;AAGpB,oCAAoC;AACpC,2CAA0C;AAAjC,wGAAA,UAAU,OAAA;AACnB,+CAA8C;AAArC,4GAAA,YAAY,OAAA;AAErB,+BAA+B;AAC/B,uDAK4B;AAJxB,oHAAA,gBAAgB,OAAA;AAChB,wHAAA,oBAAoB,OAAA;AACpB,kHAAA,cAAc,OAAA;AAIlB,kBAAkB;AAClB,iDAA4D;AAAnD,8GAAA,aAAa,OAAA;AAEtB,iCAAiC;AACjC,+DAA8D;AAArD,4HAAA,oBAAoB,OAAA;AAE7B,uBAAuB;AACvB,qDAA4E;AAAnE,kHAAA,eAAe,OAAA;AAAE,yHAAA,sBAAsB,OAAA","sourcesContent":["// Re-export API decorators from http-api for convenience\nexport {\n ApiPath,\n Endpoint,\n Authentication,\n AuthenticationConfig,\n getApiPath,\n getEndpoints,\n isApiPath,\n getAuthMeta,\n AuthMeta,\n RouteMetadata,\n METADATA_KEYS,\n ValidateImplementation,\n} from '@webpieces/http-api';\n\n// Server-side routing decorators and utilities\nexport {\n Controller,\n isController,\n provideSingleton,\n provideSingletonAs,\n provideTransient,\n ROUTING_METADATA_KEYS,\n} from './decorators';\n\nexport { ApiRoutingFactory, ClassType } from './ApiRoutingFactory';\n\n// Core routing types (moved from core-meta)\nexport {\n WebAppMeta,\n WEBAPP_META_TOKEN,\n Routes,\n RouteBuilder,\n RouteDefinition,\n FilterDefinition,\n} from './WebAppMeta';\n\n// Method metadata and route handler\nexport { MethodMeta } from './MethodMeta';\nexport { RouteHandler } from './RouteHandler';\n\n// Route builder implementation\nexport {\n RouteBuilderImpl,\n RouteHandlerWithMeta,\n FilterWithMeta,\n ExpressRouteHandler,\n} from './RouteBuilderImpl';\n\n// Filter matching\nexport { FilterMatcher, HttpFilter } from './FilterMatcher';\n\n// Context readers (Node.js only)\nexport { RequestContextReader } from './RequestContextReader';\n\n// Server configuration\nexport { WebpiecesConfig, WEBPIECES_CONFIG_TOKEN } from './WebpiecesConfig';\n"]}
|