@carno.js/core 0.2.11 → 1.0.2
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/LICENSE +673 -673
- package/README.md +188 -0
- package/dist/Carno.js +272 -333
- package/dist/Carno.mjs +268 -0
- package/dist/DefaultRoutes.js +51 -0
- package/dist/DefaultRoutes.mjs +34 -0
- package/dist/bun/index.js +183 -0
- package/dist/bun/index.js.map +86 -0
- package/dist/cache/CacheDriver.js +13 -0
- package/dist/cache/CacheDriver.mjs +0 -0
- package/dist/cache/CacheService.js +113 -0
- package/dist/cache/CacheService.mjs +93 -0
- package/dist/cache/MemoryDriver.js +66 -0
- package/dist/cache/MemoryDriver.mjs +46 -0
- package/dist/cache/RedisDriver.js +81 -0
- package/dist/cache/RedisDriver.mjs +61 -0
- package/dist/compiler/JITCompiler.js +111 -0
- package/dist/compiler/JITCompiler.mjs +89 -0
- package/dist/container/Container.js +99 -0
- package/dist/container/Container.mjs +78 -0
- package/dist/context/Context.js +97 -0
- package/dist/context/Context.mjs +77 -0
- package/dist/cors/CorsHandler.js +90 -0
- package/dist/cors/CorsHandler.mjs +68 -0
- package/dist/decorators/Controller.js +42 -0
- package/dist/decorators/Controller.mjs +22 -0
- package/dist/decorators/Inject.js +30 -0
- package/dist/decorators/Inject.mjs +10 -0
- package/dist/decorators/Middleware.js +35 -0
- package/dist/decorators/Middleware.mjs +15 -0
- package/dist/decorators/Service.js +31 -0
- package/dist/decorators/Service.mjs +12 -0
- package/dist/decorators/methods.js +60 -0
- package/dist/decorators/methods.mjs +34 -0
- package/dist/decorators/params.js +63 -0
- package/dist/decorators/params.mjs +37 -0
- package/dist/events/Lifecycle.js +69 -0
- package/dist/events/Lifecycle.mjs +41 -0
- package/dist/exceptions/HttpException.js +112 -26
- package/dist/exceptions/HttpException.mjs +82 -0
- package/dist/index.js +129 -31
- package/dist/index.mjs +94 -0
- package/dist/metadata.js +34 -0
- package/dist/metadata.mjs +9 -0
- package/dist/middleware/CarnoMiddleware.js +13 -0
- package/dist/middleware/CarnoMiddleware.mjs +0 -0
- package/dist/router/RadixRouter.js +121 -0
- package/dist/router/RadixRouter.mjs +101 -0
- package/dist/testing/TestHarness.js +81 -0
- package/dist/testing/TestHarness.mjs +60 -0
- package/dist/utils/Metadata.js +53 -0
- package/dist/utils/Metadata.mjs +31 -0
- package/dist/validation/ValibotAdapter.js +67 -0
- package/dist/validation/ValibotAdapter.mjs +48 -0
- package/dist/validation/ValidatorAdapter.js +35 -19
- package/dist/validation/ValidatorAdapter.mjs +14 -0
- package/dist/validation/ZodAdapter.js +80 -0
- package/dist/validation/ZodAdapter.mjs +59 -0
- package/package.json +21 -63
- package/src/Carno.ts +605 -0
- package/src/DefaultRoutes.ts +34 -0
- package/src/cache/CacheDriver.ts +50 -0
- package/src/cache/CacheService.ts +139 -0
- package/src/cache/MemoryDriver.ts +104 -0
- package/src/cache/RedisDriver.ts +116 -0
- package/src/compiler/JITCompiler.ts +167 -0
- package/src/container/Container.ts +168 -0
- package/src/context/Context.ts +128 -0
- package/src/cors/CorsHandler.ts +145 -0
- package/src/decorators/Controller.ts +63 -0
- package/src/decorators/Inject.ts +16 -0
- package/src/decorators/Middleware.ts +22 -0
- package/src/decorators/Service.ts +18 -0
- package/src/decorators/methods.ts +58 -0
- package/src/decorators/params.ts +47 -0
- package/src/events/Lifecycle.ts +97 -0
- package/src/exceptions/HttpException.ts +99 -0
- package/src/index.ts +92 -0
- package/src/metadata.ts +46 -0
- package/src/middleware/CarnoMiddleware.ts +14 -0
- package/src/router/RadixRouter.ts +225 -0
- package/src/testing/TestHarness.ts +177 -0
- package/src/utils/Metadata.ts +43 -0
- package/src/validation/ValibotAdapter.ts +95 -0
- package/src/validation/ValidatorAdapter.ts +69 -0
- package/src/validation/ZodAdapter.ts +102 -0
- package/dist/Carno.d.ts +0 -75
- package/dist/cache/bento-cache.driver.d.ts +0 -13
- package/dist/cache/bento-cache.driver.js +0 -55
- package/dist/cache/cache.service.d.ts +0 -8
- package/dist/cache/cache.service.js +0 -6
- package/dist/commons/decorators/Injectable.decorator.d.ts +0 -20
- package/dist/commons/decorators/Injectable.decorator.js +0 -33
- package/dist/commons/decorators/controller.decorator.d.ts +0 -8
- package/dist/commons/decorators/controller.decorator.js +0 -22
- package/dist/commons/decorators/http.decorators.d.ts +0 -13
- package/dist/commons/decorators/http.decorators.js +0 -63
- package/dist/commons/decorators/index.d.ts +0 -6
- package/dist/commons/decorators/index.js +0 -22
- package/dist/commons/decorators/inject.decorator.d.ts +0 -1
- package/dist/commons/decorators/inject.decorator.js +0 -5
- package/dist/commons/decorators/middleware.decorator.d.ts +0 -2
- package/dist/commons/decorators/middleware.decorator.js +0 -30
- package/dist/commons/decorators/service.decorator.d.ts +0 -2
- package/dist/commons/decorators/service.decorator.js +0 -7
- package/dist/commons/decorators/validation.decorator.d.ts +0 -32
- package/dist/commons/decorators/validation.decorator.js +0 -40
- package/dist/commons/http-code.enum.d.ts +0 -50
- package/dist/commons/http-code.enum.js +0 -54
- package/dist/commons/index.d.ts +0 -3
- package/dist/commons/index.js +0 -19
- package/dist/commons/registries/ProviderControl.d.ts +0 -77
- package/dist/commons/registries/ProviderControl.js +0 -112
- package/dist/commons/registries/ProviderRegistry.d.ts +0 -7
- package/dist/commons/registries/ProviderRegistry.js +0 -20
- package/dist/constants.d.ts +0 -8
- package/dist/constants.js +0 -11
- package/dist/container/ContainerConfiguration.d.ts +0 -45
- package/dist/container/ContainerConfiguration.js +0 -121
- package/dist/container/DependencyResolver.d.ts +0 -20
- package/dist/container/DependencyResolver.js +0 -85
- package/dist/container/InjectorService.d.ts +0 -58
- package/dist/container/InjectorService.js +0 -286
- package/dist/container/MethodInvoker.d.ts +0 -21
- package/dist/container/MethodInvoker.js +0 -83
- package/dist/container/RouteResolver.d.ts +0 -27
- package/dist/container/RouteResolver.js +0 -173
- package/dist/container/container.d.ts +0 -41
- package/dist/container/container.js +0 -71
- package/dist/container/createContainer.d.ts +0 -3
- package/dist/container/createContainer.js +0 -12
- package/dist/container/createInjector.d.ts +0 -2
- package/dist/container/createInjector.js +0 -7
- package/dist/container/index.d.ts +0 -6
- package/dist/container/index.js +0 -22
- package/dist/container/middleware.resolver.d.ts +0 -9
- package/dist/container/middleware.resolver.js +0 -35
- package/dist/default-routes-carno.d.ts +0 -3
- package/dist/default-routes-carno.js +0 -29
- package/dist/domain/BaseContext.d.ts +0 -15
- package/dist/domain/BaseContext.js +0 -2
- package/dist/domain/CarnoClosure.d.ts +0 -1
- package/dist/domain/CarnoClosure.js +0 -2
- package/dist/domain/CarnoMiddleware.d.ts +0 -5
- package/dist/domain/CarnoMiddleware.js +0 -2
- package/dist/domain/Context.d.ts +0 -58
- package/dist/domain/Context.js +0 -188
- package/dist/domain/FastContext.d.ts +0 -34
- package/dist/domain/FastContext.js +0 -59
- package/dist/domain/LocalsContainer.d.ts +0 -4
- package/dist/domain/LocalsContainer.js +0 -10
- package/dist/domain/Metadata.d.ts +0 -449
- package/dist/domain/Metadata.js +0 -511
- package/dist/domain/cors-config.d.ts +0 -12
- package/dist/domain/cors-config.js +0 -18
- package/dist/domain/cors-headers-cache.d.ts +0 -17
- package/dist/domain/cors-headers-cache.js +0 -101
- package/dist/domain/http-method.d.ts +0 -7
- package/dist/domain/http-method.js +0 -11
- package/dist/domain/index.d.ts +0 -10
- package/dist/domain/index.js +0 -26
- package/dist/domain/provider-scope.d.ts +0 -5
- package/dist/domain/provider-scope.js +0 -9
- package/dist/domain/provider-type.d.ts +0 -6
- package/dist/domain/provider-type.js +0 -10
- package/dist/domain/provider.d.ts +0 -37
- package/dist/domain/provider.js +0 -70
- package/dist/events/hooks.decorator.d.ts +0 -3
- package/dist/events/hooks.decorator.js +0 -29
- package/dist/events/index.d.ts +0 -2
- package/dist/events/index.js +0 -18
- package/dist/events/on-event.d.ts +0 -13
- package/dist/events/on-event.js +0 -11
- package/dist/exceptions/HttpException.d.ts +0 -9
- package/dist/exceptions/index.d.ts +0 -1
- package/dist/exceptions/index.js +0 -17
- package/dist/index.d.ts +0 -16
- package/dist/route/CompiledRoute.d.ts +0 -23
- package/dist/route/CompiledRoute.js +0 -9
- package/dist/route/FastPathExecutor.d.ts +0 -12
- package/dist/route/FastPathExecutor.js +0 -50
- package/dist/route/JITCompiler.d.ts +0 -28
- package/dist/route/JITCompiler.js +0 -245
- package/dist/route/Matcher.d.ts +0 -11
- package/dist/route/Matcher.js +0 -48
- package/dist/route/ParamResolverFactory.d.ts +0 -14
- package/dist/route/ParamResolverFactory.js +0 -49
- package/dist/route/RouteCompiler.d.ts +0 -28
- package/dist/route/RouteCompiler.js +0 -157
- package/dist/route/RouteExecutor.d.ts +0 -12
- package/dist/route/RouteExecutor.js +0 -84
- package/dist/route/memoirist.d.ts +0 -31
- package/dist/route/memoirist.js +0 -373
- package/dist/services/logger.service.d.ts +0 -23
- package/dist/services/logger.service.js +0 -47
- package/dist/testing/core-testing.d.ts +0 -24
- package/dist/testing/core-testing.js +0 -102
- package/dist/testing/index.d.ts +0 -1
- package/dist/testing/index.js +0 -17
- package/dist/utils/ValidationCache.d.ts +0 -5
- package/dist/utils/ValidationCache.js +0 -35
- package/dist/utils/ancestorOf.d.ts +0 -2
- package/dist/utils/ancestorOf.js +0 -10
- package/dist/utils/ancestorsOf.d.ts +0 -6
- package/dist/utils/ancestorsOf.js +0 -20
- package/dist/utils/classOf.d.ts +0 -13
- package/dist/utils/classOf.js +0 -21
- package/dist/utils/cleanObject.d.ts +0 -6
- package/dist/utils/cleanObject.js +0 -22
- package/dist/utils/constructorOf.d.ts +0 -11
- package/dist/utils/constructorOf.js +0 -18
- package/dist/utils/createInstance.d.ts +0 -1
- package/dist/utils/createInstance.js +0 -7
- package/dist/utils/decoratorTypeOf.d.ts +0 -11
- package/dist/utils/decoratorTypeOf.js +0 -32
- package/dist/utils/deepClone.d.ts +0 -6
- package/dist/utils/deepClone.js +0 -63
- package/dist/utils/deepMerge.d.ts +0 -9
- package/dist/utils/deepMerge.js +0 -62
- package/dist/utils/descriptorOf.d.ts +0 -8
- package/dist/utils/descriptorOf.js +0 -16
- package/dist/utils/formatValidationErrors.d.ts +0 -5
- package/dist/utils/formatValidationErrors.js +0 -80
- package/dist/utils/getClassOrSymbol.d.ts +0 -1
- package/dist/utils/getClassOrSymbol.js +0 -8
- package/dist/utils/getConstructorArgNames.d.ts +0 -1
- package/dist/utils/getConstructorArgNames.js +0 -12
- package/dist/utils/getMethodArgTypes.d.ts +0 -1
- package/dist/utils/getMethodArgTypes.js +0 -9
- package/dist/utils/getValue.d.ts +0 -32
- package/dist/utils/getValue.js +0 -47
- package/dist/utils/hasJsonMethod.d.ts +0 -1
- package/dist/utils/hasJsonMethod.js +0 -6
- package/dist/utils/index.d.ts +0 -15
- package/dist/utils/index.js +0 -31
- package/dist/utils/isArray.d.ts +0 -13
- package/dist/utils/isArray.js +0 -21
- package/dist/utils/isArrowFn.d.ts +0 -1
- package/dist/utils/isArrowFn.js +0 -7
- package/dist/utils/isBoolean.d.ts +0 -7
- package/dist/utils/isBoolean.js +0 -15
- package/dist/utils/isBuffer.d.ts +0 -7
- package/dist/utils/isBuffer.js +0 -19
- package/dist/utils/isClass.d.ts +0 -1
- package/dist/utils/isClass.js +0 -26
- package/dist/utils/isCollection.d.ts +0 -6
- package/dist/utils/isCollection.js +0 -20
- package/dist/utils/isDate.d.ts +0 -6
- package/dist/utils/isDate.js +0 -11
- package/dist/utils/isEmpty.d.ts +0 -6
- package/dist/utils/isEmpty.js +0 -12
- package/dist/utils/isFunction.d.ts +0 -1
- package/dist/utils/isFunction.js +0 -6
- package/dist/utils/isInheritedFrom.d.ts +0 -1
- package/dist/utils/isInheritedFrom.js +0 -24
- package/dist/utils/isMomentObject.d.ts +0 -1
- package/dist/utils/isMomentObject.js +0 -6
- package/dist/utils/isMongooseObject.d.ts +0 -2
- package/dist/utils/isMongooseObject.js +0 -11
- package/dist/utils/isNil.d.ts +0 -1
- package/dist/utils/isNil.js +0 -6
- package/dist/utils/isNumber.d.ts +0 -7
- package/dist/utils/isNumber.js +0 -15
- package/dist/utils/isObject.d.ts +0 -1
- package/dist/utils/isObject.js +0 -6
- package/dist/utils/isObservable.d.ts +0 -1
- package/dist/utils/isObservable.js +0 -6
- package/dist/utils/isPlainObject.d.ts +0 -7
- package/dist/utils/isPlainObject.js +0 -16
- package/dist/utils/isPrimitive.d.ts +0 -14
- package/dist/utils/isPrimitive.js +0 -28
- package/dist/utils/isPrimitiveType.d.ts +0 -1
- package/dist/utils/isPrimitiveType.js +0 -11
- package/dist/utils/isPromise.d.ts +0 -7
- package/dist/utils/isPromise.js +0 -14
- package/dist/utils/isProtectedKey.d.ts +0 -5
- package/dist/utils/isProtectedKey.js +0 -10
- package/dist/utils/isRegExp.d.ts +0 -1
- package/dist/utils/isRegExp.js +0 -6
- package/dist/utils/isRequestScope.d.ts +0 -11
- package/dist/utils/isRequestScope.js +0 -23
- package/dist/utils/isSerializable.d.ts +0 -1
- package/dist/utils/isSerializable.js +0 -11
- package/dist/utils/isStream.d.ts +0 -1
- package/dist/utils/isStream.js +0 -6
- package/dist/utils/isString.d.ts +0 -6
- package/dist/utils/isString.js +0 -14
- package/dist/utils/isSymbol.d.ts +0 -6
- package/dist/utils/isSymbol.js +0 -14
- package/dist/utils/methodsOf.d.ts +0 -9
- package/dist/utils/methodsOf.js +0 -24
- package/dist/utils/nameOf.d.ts +0 -14
- package/dist/utils/nameOf.js +0 -31
- package/dist/utils/objectKeys.d.ts +0 -1
- package/dist/utils/objectKeys.js +0 -7
- package/dist/utils/primitiveOf.d.ts +0 -1
- package/dist/utils/primitiveOf.js +0 -18
- package/dist/utils/prototypeOf.d.ts +0 -6
- package/dist/utils/prototypeOf.js +0 -12
- package/dist/utils/setValue.d.ts +0 -1
- package/dist/utils/setValue.js +0 -32
- package/dist/utils/toMap.d.ts +0 -3
- package/dist/utils/toMap.js +0 -34
- package/dist/utils/toStringConstructor.d.ts +0 -1
- package/dist/utils/toStringConstructor.js +0 -10
- package/dist/validation/ValidatorAdapter.d.ts +0 -66
- package/dist/validation/adapters/ClassValidatorAdapter.d.ts +0 -23
- package/dist/validation/adapters/ClassValidatorAdapter.js +0 -47
- package/dist/validation/adapters/ZodAdapter.d.ts +0 -14
- package/dist/validation/adapters/ZodAdapter.js +0 -56
- package/dist/validation/adapters/index.d.ts +0 -4
- package/dist/validation/adapters/index.js +0 -7
- package/dist/validation/index.d.ts +0 -3
- package/dist/validation/index.js +0 -20
package/dist/domain/index.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./provider-scope"), exports);
|
|
18
|
-
__exportStar(require("./provider-type"), exports);
|
|
19
|
-
__exportStar(require("./Context"), exports);
|
|
20
|
-
__exportStar(require("./LocalsContainer"), exports);
|
|
21
|
-
__exportStar(require("./Metadata"), exports);
|
|
22
|
-
__exportStar(require("./provider"), exports);
|
|
23
|
-
__exportStar(require("./CarnoMiddleware"), exports);
|
|
24
|
-
__exportStar(require("./CarnoClosure"), exports);
|
|
25
|
-
__exportStar(require("./http-method"), exports);
|
|
26
|
-
__exportStar(require("./cors-config"), exports);
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ProviderScope = void 0;
|
|
4
|
-
var ProviderScope;
|
|
5
|
-
(function (ProviderScope) {
|
|
6
|
-
ProviderScope["REQUEST"] = "request";
|
|
7
|
-
ProviderScope["INSTANCE"] = "instance";
|
|
8
|
-
ProviderScope["SINGLETON"] = "singleton";
|
|
9
|
-
})(ProviderScope || (exports.ProviderScope = ProviderScope = {}));
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ProviderType = void 0;
|
|
4
|
-
var ProviderType;
|
|
5
|
-
(function (ProviderType) {
|
|
6
|
-
ProviderType["ROUTES"] = "routes";
|
|
7
|
-
ProviderType["SERVICE"] = "service";
|
|
8
|
-
ProviderType["PROVIDER"] = "provider";
|
|
9
|
-
ProviderType["CONTROLLER"] = "controller";
|
|
10
|
-
})(ProviderType || (exports.ProviderType = ProviderType = {}));
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { ProviderType } from "./provider-type";
|
|
2
|
-
import { ProviderScope } from "./provider-scope";
|
|
3
|
-
import { TokenProvider, Type } from "../commons/registries/ProviderControl";
|
|
4
|
-
export type ProviderHookCallback<T = any> = (instance: T, ...args: any[]) => Promise<void> | void;
|
|
5
|
-
export declare class Provider {
|
|
6
|
-
/**
|
|
7
|
-
* Token group provider to retrieve all provider from the same type
|
|
8
|
-
*/
|
|
9
|
-
type: TokenProvider | ProviderType;
|
|
10
|
-
deps: TokenProvider[];
|
|
11
|
-
instance: any;
|
|
12
|
-
private _provide;
|
|
13
|
-
private _useClass;
|
|
14
|
-
private _useValue?;
|
|
15
|
-
hooks?: Record<string, ProviderHookCallback>;
|
|
16
|
-
path?: string;
|
|
17
|
-
/**
|
|
18
|
-
* Scope used by the injector to build the provider.
|
|
19
|
-
*/
|
|
20
|
-
scope?: ProviderScope;
|
|
21
|
-
children?: any[];
|
|
22
|
-
parent?: Function;
|
|
23
|
-
constructor(token: TokenProvider, options?: Partial<Provider>);
|
|
24
|
-
get token(): any;
|
|
25
|
-
get useClass(): Type;
|
|
26
|
-
/**
|
|
27
|
-
* Create a new store if the given value is a class. Otherwise the value is ignored.
|
|
28
|
-
* @param value
|
|
29
|
-
*/
|
|
30
|
-
set useClass(value: Type);
|
|
31
|
-
get useValue(): () => any;
|
|
32
|
-
set useValue(value: () => any);
|
|
33
|
-
get provide(): TokenProvider;
|
|
34
|
-
set provide(value: TokenProvider);
|
|
35
|
-
clone(): Provider;
|
|
36
|
-
isChild(): boolean;
|
|
37
|
-
}
|
package/dist/domain/provider.js
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Provider = void 0;
|
|
4
|
-
const provider_type_1 = require("./provider-type");
|
|
5
|
-
const provider_scope_1 = require("./provider-scope");
|
|
6
|
-
const methodsOf_1 = require("../utils/methodsOf");
|
|
7
|
-
const utils_1 = require("../utils");
|
|
8
|
-
class Provider {
|
|
9
|
-
constructor(token, options = {}) {
|
|
10
|
-
/**
|
|
11
|
-
* Token group provider to retrieve all provider from the same type
|
|
12
|
-
*/
|
|
13
|
-
this.type = provider_type_1.ProviderType.PROVIDER;
|
|
14
|
-
this.deps = [];
|
|
15
|
-
/**
|
|
16
|
-
* Scope used by the injector to build the provider.
|
|
17
|
-
*/
|
|
18
|
-
this.scope = provider_scope_1.ProviderScope.SINGLETON;
|
|
19
|
-
this.children = [];
|
|
20
|
-
this.provide = token;
|
|
21
|
-
this.useClass = token;
|
|
22
|
-
Object.assign(this, options);
|
|
23
|
-
}
|
|
24
|
-
get token() {
|
|
25
|
-
return this._provide;
|
|
26
|
-
}
|
|
27
|
-
get useClass() {
|
|
28
|
-
return this._useClass;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Create a new store if the given value is a class. Otherwise the value is ignored.
|
|
32
|
-
* @param value
|
|
33
|
-
*/
|
|
34
|
-
set useClass(value) {
|
|
35
|
-
if ((0, utils_1.isClass)(value)) {
|
|
36
|
-
this._useClass = (0, utils_1.classOf)(value);
|
|
37
|
-
this.hooks = (0, methodsOf_1.methodsOf)(this._useClass).reduce((hooks, { propertyKey }) => {
|
|
38
|
-
if (String(propertyKey).startsWith("$")) {
|
|
39
|
-
return {
|
|
40
|
-
...hooks,
|
|
41
|
-
[propertyKey]: (instance, ...args) => instance[propertyKey](...args),
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
return hooks;
|
|
45
|
-
}, {});
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
get useValue() {
|
|
49
|
-
return this._useValue;
|
|
50
|
-
}
|
|
51
|
-
set useValue(value) {
|
|
52
|
-
this._useValue = value();
|
|
53
|
-
}
|
|
54
|
-
get provide() {
|
|
55
|
-
return this._provide;
|
|
56
|
-
}
|
|
57
|
-
set provide(value) {
|
|
58
|
-
if (!value) {
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
this._provide = value;
|
|
62
|
-
}
|
|
63
|
-
clone() {
|
|
64
|
-
return new ((0, utils_1.classOf)(this))(this._provide, this);
|
|
65
|
-
}
|
|
66
|
-
isChild() {
|
|
67
|
-
return !!this.parent;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
exports.Provider = Provider;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.OnApplicationInit = OnApplicationInit;
|
|
4
|
-
exports.OnApplicationShutdown = OnApplicationShutdown;
|
|
5
|
-
exports.OnApplicationBoot = OnApplicationBoot;
|
|
6
|
-
const constants_1 = require("../constants");
|
|
7
|
-
const Metadata_1 = require("../domain/Metadata");
|
|
8
|
-
const on_event_1 = require("./on-event");
|
|
9
|
-
function OnApplicationInit(priority = 0) {
|
|
10
|
-
return (target, propertyKey) => {
|
|
11
|
-
const anotherEvents = Metadata_1.Metadata.get(constants_1.CONTROLLER_EVENTS, Reflect) || [];
|
|
12
|
-
anotherEvents.push({ methodName: propertyKey, eventName: on_event_1.EventType.OnApplicationInit, target: target.constructor, priority });
|
|
13
|
-
Metadata_1.Metadata.set(constants_1.CONTROLLER_EVENTS, anotherEvents, Reflect);
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
function OnApplicationShutdown(priority = 0) {
|
|
17
|
-
return (target, propertyKey) => {
|
|
18
|
-
const anotherEvents = Metadata_1.Metadata.get(constants_1.CONTROLLER_EVENTS, Reflect) || [];
|
|
19
|
-
anotherEvents.push({ methodName: propertyKey, eventName: on_event_1.EventType.OnApplicationShutdown, target: target.constructor, priority });
|
|
20
|
-
Metadata_1.Metadata.set(constants_1.CONTROLLER_EVENTS, anotherEvents, Reflect);
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
function OnApplicationBoot(priority = 0) {
|
|
24
|
-
return (target, propertyKey) => {
|
|
25
|
-
const anotherEvents = Metadata_1.Metadata.get(constants_1.CONTROLLER_EVENTS, Reflect) || [];
|
|
26
|
-
anotherEvents.push({ methodName: propertyKey, eventName: on_event_1.EventType.OnApplicationBoot, target: target.constructor, priority });
|
|
27
|
-
Metadata_1.Metadata.set(constants_1.CONTROLLER_EVENTS, anotherEvents, Reflect);
|
|
28
|
-
};
|
|
29
|
-
}
|
package/dist/events/index.d.ts
DELETED
package/dist/events/index.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./on-event"), exports);
|
|
18
|
-
__exportStar(require("./hooks.decorator"), exports);
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export declare enum EventType {
|
|
2
|
-
OnApplicationBoot = "OnApplicationBoot",
|
|
3
|
-
OnApplicationInit = "OnApplicationInit",
|
|
4
|
-
OnApplicationShutdown = "OnApplicationShutdown",
|
|
5
|
-
OnRequest = "OnRequest",
|
|
6
|
-
OnResponse = "OnResponse"
|
|
7
|
-
}
|
|
8
|
-
export interface OnEvent {
|
|
9
|
-
methodName: string;
|
|
10
|
-
eventName: EventType;
|
|
11
|
-
target: Object;
|
|
12
|
-
priority: number;
|
|
13
|
-
}
|
package/dist/events/on-event.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.EventType = void 0;
|
|
4
|
-
var EventType;
|
|
5
|
-
(function (EventType) {
|
|
6
|
-
EventType["OnApplicationBoot"] = "OnApplicationBoot";
|
|
7
|
-
EventType["OnApplicationInit"] = "OnApplicationInit";
|
|
8
|
-
EventType["OnApplicationShutdown"] = "OnApplicationShutdown";
|
|
9
|
-
EventType["OnRequest"] = "OnRequest";
|
|
10
|
-
EventType["OnResponse"] = "OnResponse";
|
|
11
|
-
})(EventType || (exports.EventType = EventType = {}));
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './HttpException';
|
package/dist/exceptions/index.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./HttpException"), exports);
|
package/dist/index.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export * from "./commons";
|
|
2
|
-
export * from "./container";
|
|
3
|
-
export * from "./domain";
|
|
4
|
-
export * from "./route/Matcher";
|
|
5
|
-
export * from "./route/RouteExecutor";
|
|
6
|
-
export * from "./exceptions";
|
|
7
|
-
export * from "./Carno";
|
|
8
|
-
export * from "./events";
|
|
9
|
-
export * from "./constants";
|
|
10
|
-
export * from "./utils";
|
|
11
|
-
export * from "./default-routes-carno";
|
|
12
|
-
export * from "./services/logger.service";
|
|
13
|
-
export * from "./cache/cache.service";
|
|
14
|
-
export * from "./cache/bento-cache.driver";
|
|
15
|
-
export * from "./testing";
|
|
16
|
-
export * from "./validation";
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type { Context } from '../domain/Context';
|
|
2
|
-
import type { TokenRouteWithProvider } from '../container/ContainerConfiguration';
|
|
3
|
-
export declare enum RouteType {
|
|
4
|
-
SIMPLE = 0,
|
|
5
|
-
STANDARD = 1,
|
|
6
|
-
COMPLEX = 2
|
|
7
|
-
}
|
|
8
|
-
export type ParamResolver = (context: Context) => any;
|
|
9
|
-
export type AsyncParamResolver = (context: Context) => Promise<any>;
|
|
10
|
-
export type CompiledHandler = (context: Context) => any;
|
|
11
|
-
export type AsyncCompiledHandler = (context: Context) => Promise<any>;
|
|
12
|
-
export interface CompiledRoute {
|
|
13
|
-
routeType: RouteType;
|
|
14
|
-
controllerInstance: any | null;
|
|
15
|
-
boundHandler: CompiledHandler | AsyncCompiledHandler | null;
|
|
16
|
-
paramResolvers: (ParamResolver | AsyncParamResolver | null)[];
|
|
17
|
-
needsLocalsContainer: boolean;
|
|
18
|
-
hasMiddlewares: boolean;
|
|
19
|
-
hasValidation: boolean;
|
|
20
|
-
validationIndices: number[];
|
|
21
|
-
isAsync: boolean;
|
|
22
|
-
original: TokenRouteWithProvider;
|
|
23
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RouteType = void 0;
|
|
4
|
-
var RouteType;
|
|
5
|
-
(function (RouteType) {
|
|
6
|
-
RouteType[RouteType["SIMPLE"] = 0] = "SIMPLE";
|
|
7
|
-
RouteType[RouteType["STANDARD"] = 1] = "STANDARD";
|
|
8
|
-
RouteType[RouteType["COMPLEX"] = 2] = "COMPLEX";
|
|
9
|
-
})(RouteType || (exports.RouteType = RouteType = {}));
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { Context } from '../domain/Context';
|
|
2
|
-
import type { CompiledRoute } from './CompiledRoute';
|
|
3
|
-
/**
|
|
4
|
-
* Fast path executor completo - executa handler e monta response inline.
|
|
5
|
-
* Máximo 2 type checks no fast path.
|
|
6
|
-
*/
|
|
7
|
-
export declare function executeFastPath(compiled: CompiledRoute, context: Context): Promise<Response>;
|
|
8
|
-
/**
|
|
9
|
-
* Fast path executor síncrono - para handlers que não retornam Promise.
|
|
10
|
-
* Elimina overhead de async/await quando handler é síncrono.
|
|
11
|
-
*/
|
|
12
|
-
export declare function executeFastPathSync(compiled: CompiledRoute, context: Context): Response;
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.executeFastPath = executeFastPath;
|
|
4
|
-
exports.executeFastPathSync = executeFastPathSync;
|
|
5
|
-
/**
|
|
6
|
-
* Frozen header objects - V8 otimiza acesso a objetos frozen.
|
|
7
|
-
* Criados uma vez no startup, reutilizados em todas requests.
|
|
8
|
-
*/
|
|
9
|
-
const JSON_HEADERS = Object.freeze({
|
|
10
|
-
'Content-Type': 'application/json'
|
|
11
|
-
});
|
|
12
|
-
const TEXT_HEADERS = Object.freeze({
|
|
13
|
-
'Content-Type': 'text/html'
|
|
14
|
-
});
|
|
15
|
-
/**
|
|
16
|
-
* Fast path executor completo - executa handler e monta response inline.
|
|
17
|
-
* Máximo 2 type checks no fast path.
|
|
18
|
-
*/
|
|
19
|
-
async function executeFastPath(compiled, context) {
|
|
20
|
-
const result = await compiled.boundHandler(context);
|
|
21
|
-
const status = context.getResponseStatus() || 200;
|
|
22
|
-
if (typeof result === 'string') {
|
|
23
|
-
return new Response(result, { status, headers: TEXT_HEADERS });
|
|
24
|
-
}
|
|
25
|
-
if (result instanceof Response) {
|
|
26
|
-
return result;
|
|
27
|
-
}
|
|
28
|
-
if (result === null || result === undefined) {
|
|
29
|
-
return new Response('', { status, headers: TEXT_HEADERS });
|
|
30
|
-
}
|
|
31
|
-
return new Response(JSON.stringify(result), { status, headers: JSON_HEADERS });
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Fast path executor síncrono - para handlers que não retornam Promise.
|
|
35
|
-
* Elimina overhead de async/await quando handler é síncrono.
|
|
36
|
-
*/
|
|
37
|
-
function executeFastPathSync(compiled, context) {
|
|
38
|
-
const result = compiled.boundHandler(context);
|
|
39
|
-
const status = context.getResponseStatus() || 200;
|
|
40
|
-
if (typeof result === 'string') {
|
|
41
|
-
return new Response(result, { status, headers: TEXT_HEADERS });
|
|
42
|
-
}
|
|
43
|
-
if (result instanceof Response) {
|
|
44
|
-
return result;
|
|
45
|
-
}
|
|
46
|
-
if (result === null || result === undefined) {
|
|
47
|
-
return new Response('', { status, headers: TEXT_HEADERS });
|
|
48
|
-
}
|
|
49
|
-
return new Response(JSON.stringify(result), { status, headers: JSON_HEADERS });
|
|
50
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import type { ParamInfo } from './ParamResolverFactory';
|
|
2
|
-
import type { CompiledHandler, AsyncCompiledHandler } from './CompiledRoute';
|
|
3
|
-
/**
|
|
4
|
-
* Compila route handler em função otimizada.
|
|
5
|
-
*
|
|
6
|
-
* Estratégias de otimização:
|
|
7
|
-
* - Inline de acesso a parâmetros
|
|
8
|
-
* - Bind do handler no compile time
|
|
9
|
-
* - Código gerado monomórfico
|
|
10
|
-
* - Sem overhead de resolvers array
|
|
11
|
-
*/
|
|
12
|
-
/**
|
|
13
|
-
* Compila route handler em função otimizada que retorna Response inline.
|
|
14
|
-
*
|
|
15
|
-
* Estratégias de otimização:
|
|
16
|
-
* - Inline de acesso a parâmetros
|
|
17
|
-
* - Inline de response building (elimina executeFastPath)
|
|
18
|
-
* - Bind do handler no compile time
|
|
19
|
-
* - Código gerado monomórfico
|
|
20
|
-
* - Headers pré-frozen para otimização V8
|
|
21
|
-
*/
|
|
22
|
-
export declare function compileRouteHandler(instance: any, methodName: string, paramInfos: ParamInfo[]): CompiledHandler | AsyncCompiledHandler;
|
|
23
|
-
/**
|
|
24
|
-
* Compila handler com validação inline.
|
|
25
|
-
*/
|
|
26
|
-
export declare function compileValidatedHandler(instance: any, methodName: string, paramInfos: ParamInfo[], validatorAdapter: {
|
|
27
|
-
validateAndTransform: (token: any, value: any) => any;
|
|
28
|
-
}): CompiledHandler | AsyncCompiledHandler;
|