@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/index.js
CHANGED
|
@@ -1,32 +1,130 @@
|
|
|
1
|
-
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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);
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
8
|
+
}, __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from == "object" || typeof from == "function")
|
|
10
|
+
for (let key of __getOwnPropNames(from))
|
|
11
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
12
|
+
return to;
|
|
15
13
|
};
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
15
|
+
var index_exports = {};
|
|
16
|
+
__export(index_exports, {
|
|
17
|
+
BadRequestException: () => import_HttpException.BadRequestException,
|
|
18
|
+
Body: () => import_params.Body,
|
|
19
|
+
CacheService: () => import_CacheService.CacheService,
|
|
20
|
+
Carno: () => import_Carno.Carno,
|
|
21
|
+
ConflictException: () => import_HttpException.ConflictException,
|
|
22
|
+
Container: () => import_Container.Container,
|
|
23
|
+
Context: () => import_Context.Context,
|
|
24
|
+
Controller: () => import_Controller.Controller,
|
|
25
|
+
CorsHandler: () => import_CorsHandler.CorsHandler,
|
|
26
|
+
Ctx: () => import_params.Ctx,
|
|
27
|
+
Delete: () => import_methods.Delete,
|
|
28
|
+
EventType: () => import_Lifecycle.EventType,
|
|
29
|
+
ForbiddenException: () => import_HttpException.ForbiddenException,
|
|
30
|
+
Get: () => import_methods.Get,
|
|
31
|
+
Head: () => import_methods.Head,
|
|
32
|
+
Header: () => import_params.Header,
|
|
33
|
+
HttpException: () => import_HttpException.HttpException,
|
|
34
|
+
Inject: () => import_Inject.Inject,
|
|
35
|
+
InternalServerErrorException: () => import_HttpException.InternalServerErrorException,
|
|
36
|
+
Locals: () => import_params.Locals,
|
|
37
|
+
MemoryDriver: () => import_MemoryDriver.MemoryDriver,
|
|
38
|
+
Metadata: () => import_Metadata.Metadata,
|
|
39
|
+
MethodNotAllowedException: () => import_HttpException.MethodNotAllowedException,
|
|
40
|
+
Middleware: () => import_Middleware.Use,
|
|
41
|
+
NotFoundException: () => import_HttpException.NotFoundException,
|
|
42
|
+
OnApplicationBoot: () => import_Lifecycle.OnApplicationBoot,
|
|
43
|
+
OnApplicationInit: () => import_Lifecycle.OnApplicationInit,
|
|
44
|
+
OnApplicationShutdown: () => import_Lifecycle.OnApplicationShutdown,
|
|
45
|
+
Options: () => import_methods.Options,
|
|
46
|
+
Param: () => import_params.Param,
|
|
47
|
+
Patch: () => import_methods.Patch,
|
|
48
|
+
Post: () => import_methods.Post,
|
|
49
|
+
Put: () => import_methods.Put,
|
|
50
|
+
Query: () => import_params.Query,
|
|
51
|
+
RadixRouter: () => import_RadixRouter.RadixRouter,
|
|
52
|
+
RedisDriver: () => import_RedisDriver.RedisDriver,
|
|
53
|
+
Req: () => import_params.Req,
|
|
54
|
+
Schema: () => import_ValidatorAdapter.Schema,
|
|
55
|
+
Scope: () => import_Container.Scope,
|
|
56
|
+
Service: () => import_Service.Service,
|
|
57
|
+
ServiceUnavailableException: () => import_HttpException.ServiceUnavailableException,
|
|
58
|
+
TooManyRequestsException: () => import_HttpException.TooManyRequestsException,
|
|
59
|
+
UnauthorizedException: () => import_HttpException.UnauthorizedException,
|
|
60
|
+
UnprocessableEntityException: () => import_HttpException.UnprocessableEntityException,
|
|
61
|
+
Use: () => import_Middleware.Use,
|
|
62
|
+
VALIDATION_SCHEMA: () => import_ValidatorAdapter.VALIDATION_SCHEMA,
|
|
63
|
+
ValibotAdapter: () => import_ValibotAdapter.ValibotAdapter,
|
|
64
|
+
ValidationException: () => import_ZodAdapter.ValidationException,
|
|
65
|
+
ZodAdapter: () => import_ZodAdapter.ZodAdapter,
|
|
66
|
+
createTestHarness: () => import_TestHarness.createTestHarness,
|
|
67
|
+
getSchema: () => import_ValidatorAdapter.getSchema,
|
|
68
|
+
isObject: () => import_Metadata.isObject,
|
|
69
|
+
isString: () => import_Metadata.isString,
|
|
70
|
+
withTestApp: () => import_TestHarness.withTestApp
|
|
71
|
+
});
|
|
72
|
+
module.exports = __toCommonJS(index_exports);
|
|
73
|
+
var import_Carno = require('./Carno.js'), import_Context = require('./context/Context.js'), import_Controller = require('./decorators/Controller.js'), import_methods = require('./decorators/methods.js'), import_params = require('./decorators/params.js'), import_Middleware = require('./decorators/Middleware.js'), import_Service = require('./decorators/Service.js'), import_Inject = require('./decorators/Inject.js'), import_Container = require('./container/Container.js'), import_RadixRouter = require('./router/RadixRouter.js'), import_CorsHandler = require('./cors/CorsHandler.js'), import_ValidatorAdapter = require('./validation/ValidatorAdapter.js'), import_ZodAdapter = require('./validation/ZodAdapter.js'), import_ValibotAdapter = require('./validation/ValibotAdapter.js'), import_HttpException = require('./exceptions/HttpException.js'), import_Lifecycle = require('./events/Lifecycle.js'), import_CacheService = require('./cache/CacheService.js'), import_MemoryDriver = require('./cache/MemoryDriver.js'), import_RedisDriver = require('./cache/RedisDriver.js'), import_TestHarness = require('./testing/TestHarness.js'), import_Metadata = require('./utils/Metadata.js');
|
|
74
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
75
|
+
0 && (module.exports = {
|
|
76
|
+
BadRequestException,
|
|
77
|
+
Body,
|
|
78
|
+
CacheService,
|
|
79
|
+
Carno,
|
|
80
|
+
ConflictException,
|
|
81
|
+
Container,
|
|
82
|
+
Context,
|
|
83
|
+
Controller,
|
|
84
|
+
CorsHandler,
|
|
85
|
+
Ctx,
|
|
86
|
+
Delete,
|
|
87
|
+
EventType,
|
|
88
|
+
ForbiddenException,
|
|
89
|
+
Get,
|
|
90
|
+
Head,
|
|
91
|
+
Header,
|
|
92
|
+
HttpException,
|
|
93
|
+
Inject,
|
|
94
|
+
InternalServerErrorException,
|
|
95
|
+
Locals,
|
|
96
|
+
MemoryDriver,
|
|
97
|
+
Metadata,
|
|
98
|
+
MethodNotAllowedException,
|
|
99
|
+
Middleware,
|
|
100
|
+
NotFoundException,
|
|
101
|
+
OnApplicationBoot,
|
|
102
|
+
OnApplicationInit,
|
|
103
|
+
OnApplicationShutdown,
|
|
104
|
+
Options,
|
|
105
|
+
Param,
|
|
106
|
+
Patch,
|
|
107
|
+
Post,
|
|
108
|
+
Put,
|
|
109
|
+
Query,
|
|
110
|
+
RadixRouter,
|
|
111
|
+
RedisDriver,
|
|
112
|
+
Req,
|
|
113
|
+
Schema,
|
|
114
|
+
Scope,
|
|
115
|
+
Service,
|
|
116
|
+
ServiceUnavailableException,
|
|
117
|
+
TooManyRequestsException,
|
|
118
|
+
UnauthorizedException,
|
|
119
|
+
UnprocessableEntityException,
|
|
120
|
+
Use,
|
|
121
|
+
VALIDATION_SCHEMA,
|
|
122
|
+
ValibotAdapter,
|
|
123
|
+
ValidationException,
|
|
124
|
+
ZodAdapter,
|
|
125
|
+
createTestHarness,
|
|
126
|
+
getSchema,
|
|
127
|
+
isObject,
|
|
128
|
+
isString,
|
|
129
|
+
withTestApp
|
|
130
|
+
});
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { Carno } from "./Carno.mjs";
|
|
2
|
+
import { Context } from "./context/Context.mjs";
|
|
3
|
+
import { Controller } from "./decorators/Controller.mjs";
|
|
4
|
+
import { Get, Post, Put, Delete, Patch, Head, Options } from "./decorators/methods.mjs";
|
|
5
|
+
import { Param, Query, Body, Header, Req, Ctx, Locals } from "./decorators/params.mjs";
|
|
6
|
+
import { Use, Use as Use2 } from "./decorators/Middleware.mjs";
|
|
7
|
+
import { Service } from "./decorators/Service.mjs";
|
|
8
|
+
import { Inject } from "./decorators/Inject.mjs";
|
|
9
|
+
import { Container, Scope } from "./container/Container.mjs";
|
|
10
|
+
import { RadixRouter } from "./router/RadixRouter.mjs";
|
|
11
|
+
import { CorsHandler } from "./cors/CorsHandler.mjs";
|
|
12
|
+
import { Schema, getSchema, VALIDATION_SCHEMA } from "./validation/ValidatorAdapter.mjs";
|
|
13
|
+
import { ZodAdapter, ValidationException } from "./validation/ZodAdapter.mjs";
|
|
14
|
+
import { ValibotAdapter } from "./validation/ValibotAdapter.mjs";
|
|
15
|
+
import {
|
|
16
|
+
HttpException,
|
|
17
|
+
BadRequestException,
|
|
18
|
+
UnauthorizedException,
|
|
19
|
+
ForbiddenException,
|
|
20
|
+
NotFoundException,
|
|
21
|
+
MethodNotAllowedException,
|
|
22
|
+
ConflictException,
|
|
23
|
+
UnprocessableEntityException,
|
|
24
|
+
TooManyRequestsException,
|
|
25
|
+
InternalServerErrorException,
|
|
26
|
+
ServiceUnavailableException
|
|
27
|
+
} from "./exceptions/HttpException.mjs";
|
|
28
|
+
import {
|
|
29
|
+
EventType,
|
|
30
|
+
OnApplicationInit,
|
|
31
|
+
OnApplicationBoot,
|
|
32
|
+
OnApplicationShutdown
|
|
33
|
+
} from "./events/Lifecycle.mjs";
|
|
34
|
+
import { CacheService } from "./cache/CacheService.mjs";
|
|
35
|
+
import { MemoryDriver } from "./cache/MemoryDriver.mjs";
|
|
36
|
+
import { RedisDriver } from "./cache/RedisDriver.mjs";
|
|
37
|
+
import { createTestHarness, withTestApp } from "./testing/TestHarness.mjs";
|
|
38
|
+
import { Metadata, isObject, isString } from "./utils/Metadata.mjs";
|
|
39
|
+
export {
|
|
40
|
+
BadRequestException,
|
|
41
|
+
Body,
|
|
42
|
+
CacheService,
|
|
43
|
+
Carno,
|
|
44
|
+
ConflictException,
|
|
45
|
+
Container,
|
|
46
|
+
Context,
|
|
47
|
+
Controller,
|
|
48
|
+
CorsHandler,
|
|
49
|
+
Ctx,
|
|
50
|
+
Delete,
|
|
51
|
+
EventType,
|
|
52
|
+
ForbiddenException,
|
|
53
|
+
Get,
|
|
54
|
+
Head,
|
|
55
|
+
Header,
|
|
56
|
+
HttpException,
|
|
57
|
+
Inject,
|
|
58
|
+
InternalServerErrorException,
|
|
59
|
+
Locals,
|
|
60
|
+
MemoryDriver,
|
|
61
|
+
Metadata,
|
|
62
|
+
MethodNotAllowedException,
|
|
63
|
+
Use2 as Middleware,
|
|
64
|
+
NotFoundException,
|
|
65
|
+
OnApplicationBoot,
|
|
66
|
+
OnApplicationInit,
|
|
67
|
+
OnApplicationShutdown,
|
|
68
|
+
Options,
|
|
69
|
+
Param,
|
|
70
|
+
Patch,
|
|
71
|
+
Post,
|
|
72
|
+
Put,
|
|
73
|
+
Query,
|
|
74
|
+
RadixRouter,
|
|
75
|
+
RedisDriver,
|
|
76
|
+
Req,
|
|
77
|
+
Schema,
|
|
78
|
+
Scope,
|
|
79
|
+
Service,
|
|
80
|
+
ServiceUnavailableException,
|
|
81
|
+
TooManyRequestsException,
|
|
82
|
+
UnauthorizedException,
|
|
83
|
+
UnprocessableEntityException,
|
|
84
|
+
Use,
|
|
85
|
+
VALIDATION_SCHEMA,
|
|
86
|
+
ValibotAdapter,
|
|
87
|
+
ValidationException,
|
|
88
|
+
ZodAdapter,
|
|
89
|
+
createTestHarness,
|
|
90
|
+
getSchema,
|
|
91
|
+
isObject,
|
|
92
|
+
isString,
|
|
93
|
+
withTestApp
|
|
94
|
+
};
|
package/dist/metadata.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
8
|
+
}, __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from == "object" || typeof from == "function")
|
|
10
|
+
for (let key of __getOwnPropNames(from))
|
|
11
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
15
|
+
var metadata_exports = {};
|
|
16
|
+
__export(metadata_exports, {
|
|
17
|
+
CONTROLLER_META: () => CONTROLLER_META,
|
|
18
|
+
INJECT_META: () => INJECT_META,
|
|
19
|
+
MIDDLEWARE_META: () => MIDDLEWARE_META,
|
|
20
|
+
PARAMS_META: () => PARAMS_META,
|
|
21
|
+
ROUTES_META: () => ROUTES_META,
|
|
22
|
+
SERVICE_META: () => SERVICE_META
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(metadata_exports);
|
|
25
|
+
const CONTROLLER_META = /* @__PURE__ */ Symbol("turbo:controller"), ROUTES_META = /* @__PURE__ */ Symbol("turbo:routes"), PARAMS_META = /* @__PURE__ */ Symbol("turbo:params"), MIDDLEWARE_META = /* @__PURE__ */ Symbol("turbo:middleware"), SERVICE_META = /* @__PURE__ */ Symbol("turbo:service"), INJECT_META = /* @__PURE__ */ Symbol("turbo:inject");
|
|
26
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
27
|
+
0 && (module.exports = {
|
|
28
|
+
CONTROLLER_META,
|
|
29
|
+
INJECT_META,
|
|
30
|
+
MIDDLEWARE_META,
|
|
31
|
+
PARAMS_META,
|
|
32
|
+
ROUTES_META,
|
|
33
|
+
SERVICE_META
|
|
34
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
const CONTROLLER_META = /* @__PURE__ */ Symbol("turbo:controller"), ROUTES_META = /* @__PURE__ */ Symbol("turbo:routes"), PARAMS_META = /* @__PURE__ */ Symbol("turbo:params"), MIDDLEWARE_META = /* @__PURE__ */ Symbol("turbo:middleware"), SERVICE_META = /* @__PURE__ */ Symbol("turbo:service"), INJECT_META = /* @__PURE__ */ Symbol("turbo:inject");
|
|
2
|
+
export {
|
|
3
|
+
CONTROLLER_META,
|
|
4
|
+
INJECT_META,
|
|
5
|
+
MIDDLEWARE_META,
|
|
6
|
+
PARAMS_META,
|
|
7
|
+
ROUTES_META,
|
|
8
|
+
SERVICE_META
|
|
9
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from == "object" || typeof from == "function")
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
9
|
+
return to;
|
|
10
|
+
};
|
|
11
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
12
|
+
var CarnoMiddleware_exports = {};
|
|
13
|
+
module.exports = __toCommonJS(CarnoMiddleware_exports);
|
|
File without changes
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
8
|
+
}, __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from == "object" || typeof from == "function")
|
|
10
|
+
for (let key of __getOwnPropNames(from))
|
|
11
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
15
|
+
var RadixRouter_exports = {};
|
|
16
|
+
__export(RadixRouter_exports, {
|
|
17
|
+
RadixRouter: () => RadixRouter
|
|
18
|
+
});
|
|
19
|
+
module.exports = __toCommonJS(RadixRouter_exports);
|
|
20
|
+
const EMPTY_PARAMS = Object.freeze({});
|
|
21
|
+
function createNode(part) {
|
|
22
|
+
return {
|
|
23
|
+
part,
|
|
24
|
+
store: null,
|
|
25
|
+
children: null,
|
|
26
|
+
paramChild: null,
|
|
27
|
+
wildcardStore: null
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
class RadixRouter {
|
|
31
|
+
constructor() {
|
|
32
|
+
this.roots = {};
|
|
33
|
+
}
|
|
34
|
+
add(method, path, store) {
|
|
35
|
+
path === "" && (path = "/"), path[0] !== "/" && (path = "/" + path);
|
|
36
|
+
const isWildcard = path.endsWith("*");
|
|
37
|
+
isWildcard && (path = path.slice(0, -1));
|
|
38
|
+
let node = this.roots[method];
|
|
39
|
+
node || (node = this.roots[method] = createNode("/"));
|
|
40
|
+
let i = 0;
|
|
41
|
+
const len = path.length;
|
|
42
|
+
for (; i < len; ) {
|
|
43
|
+
if (path.charCodeAt(i) === 58) {
|
|
44
|
+
const paramStart = i + 1;
|
|
45
|
+
let paramEnd = paramStart;
|
|
46
|
+
for (; paramEnd < len && path.charCodeAt(paramEnd) !== 47; )
|
|
47
|
+
paramEnd++;
|
|
48
|
+
const paramName = path.slice(paramStart, paramEnd);
|
|
49
|
+
if (node.paramChild || (node.paramChild = { name: paramName, store: null, child: null }), paramEnd >= len) {
|
|
50
|
+
node.paramChild.store = store;
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
node.paramChild.child || (node.paramChild.child = createNode(path.slice(paramEnd))), node = node.paramChild.child, i = paramEnd;
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
let segmentEnd = i;
|
|
57
|
+
for (; segmentEnd < len && path.charCodeAt(segmentEnd) !== 47 && path.charCodeAt(segmentEnd) !== 58; )
|
|
58
|
+
segmentEnd++;
|
|
59
|
+
segmentEnd < len && path.charCodeAt(segmentEnd) === 47 && segmentEnd++;
|
|
60
|
+
const segment = path.slice(i, segmentEnd);
|
|
61
|
+
if (segment === node.part) {
|
|
62
|
+
i = segmentEnd;
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
node.children || (node.children = /* @__PURE__ */ new Map());
|
|
66
|
+
const firstChar = segment.charCodeAt(0);
|
|
67
|
+
let child = node.children.get(firstChar);
|
|
68
|
+
child || (child = createNode(segment), node.children.set(firstChar, child)), node = child, i = segmentEnd;
|
|
69
|
+
}
|
|
70
|
+
isWildcard ? node.wildcardStore = store : node.store = store;
|
|
71
|
+
}
|
|
72
|
+
find(method, path) {
|
|
73
|
+
const root = this.roots[method];
|
|
74
|
+
return root ? this.matchPath(root, path, 0, path.length) : null;
|
|
75
|
+
}
|
|
76
|
+
matchPath(node, path, start, len) {
|
|
77
|
+
const partLen = node.part.length, end = start + partLen;
|
|
78
|
+
if (partLen > 1) {
|
|
79
|
+
if (end > len) return null;
|
|
80
|
+
for (let i = 1, j = start + 1; i < partLen; i++, j++)
|
|
81
|
+
if (node.part.charCodeAt(i) !== path.charCodeAt(j))
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
if (end === len)
|
|
85
|
+
return node.store !== null ? { store: node.store, params: EMPTY_PARAMS } : node.wildcardStore !== null ? { store: node.wildcardStore, params: { "*": "" } } : null;
|
|
86
|
+
if (node.children) {
|
|
87
|
+
const child = node.children.get(path.charCodeAt(end));
|
|
88
|
+
if (child) {
|
|
89
|
+
const result = this.matchPath(child, path, end, len);
|
|
90
|
+
if (result) return result;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
if (node.paramChild) {
|
|
94
|
+
const param = node.paramChild;
|
|
95
|
+
let paramEnd = end;
|
|
96
|
+
for (; paramEnd < len && path.charCodeAt(paramEnd) !== 47; )
|
|
97
|
+
paramEnd++;
|
|
98
|
+
if (paramEnd === end) return null;
|
|
99
|
+
const paramValue = path.slice(end, paramEnd);
|
|
100
|
+
if (paramEnd >= len) {
|
|
101
|
+
if (param.store !== null)
|
|
102
|
+
return {
|
|
103
|
+
store: param.store,
|
|
104
|
+
params: { [param.name]: paramValue }
|
|
105
|
+
};
|
|
106
|
+
} else if (param.child) {
|
|
107
|
+
const result = this.matchPath(param.child, path, paramEnd, len);
|
|
108
|
+
if (result)
|
|
109
|
+
return result.params === EMPTY_PARAMS ? result.params = { [param.name]: paramValue } : result.params[param.name] = paramValue, result;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return node.wildcardStore !== null ? {
|
|
113
|
+
store: node.wildcardStore,
|
|
114
|
+
params: { "*": path.slice(end) }
|
|
115
|
+
} : null;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
119
|
+
0 && (module.exports = {
|
|
120
|
+
RadixRouter
|
|
121
|
+
});
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
const EMPTY_PARAMS = Object.freeze({});
|
|
2
|
+
function createNode(part) {
|
|
3
|
+
return {
|
|
4
|
+
part,
|
|
5
|
+
store: null,
|
|
6
|
+
children: null,
|
|
7
|
+
paramChild: null,
|
|
8
|
+
wildcardStore: null
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
class RadixRouter {
|
|
12
|
+
constructor() {
|
|
13
|
+
this.roots = {};
|
|
14
|
+
}
|
|
15
|
+
add(method, path, store) {
|
|
16
|
+
path === "" && (path = "/"), path[0] !== "/" && (path = "/" + path);
|
|
17
|
+
const isWildcard = path.endsWith("*");
|
|
18
|
+
isWildcard && (path = path.slice(0, -1));
|
|
19
|
+
let node = this.roots[method];
|
|
20
|
+
node || (node = this.roots[method] = createNode("/"));
|
|
21
|
+
let i = 0;
|
|
22
|
+
const len = path.length;
|
|
23
|
+
for (; i < len; ) {
|
|
24
|
+
if (path.charCodeAt(i) === 58) {
|
|
25
|
+
const paramStart = i + 1;
|
|
26
|
+
let paramEnd = paramStart;
|
|
27
|
+
for (; paramEnd < len && path.charCodeAt(paramEnd) !== 47; )
|
|
28
|
+
paramEnd++;
|
|
29
|
+
const paramName = path.slice(paramStart, paramEnd);
|
|
30
|
+
if (node.paramChild || (node.paramChild = { name: paramName, store: null, child: null }), paramEnd >= len) {
|
|
31
|
+
node.paramChild.store = store;
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
node.paramChild.child || (node.paramChild.child = createNode(path.slice(paramEnd))), node = node.paramChild.child, i = paramEnd;
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
let segmentEnd = i;
|
|
38
|
+
for (; segmentEnd < len && path.charCodeAt(segmentEnd) !== 47 && path.charCodeAt(segmentEnd) !== 58; )
|
|
39
|
+
segmentEnd++;
|
|
40
|
+
segmentEnd < len && path.charCodeAt(segmentEnd) === 47 && segmentEnd++;
|
|
41
|
+
const segment = path.slice(i, segmentEnd);
|
|
42
|
+
if (segment === node.part) {
|
|
43
|
+
i = segmentEnd;
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
node.children || (node.children = /* @__PURE__ */ new Map());
|
|
47
|
+
const firstChar = segment.charCodeAt(0);
|
|
48
|
+
let child = node.children.get(firstChar);
|
|
49
|
+
child || (child = createNode(segment), node.children.set(firstChar, child)), node = child, i = segmentEnd;
|
|
50
|
+
}
|
|
51
|
+
isWildcard ? node.wildcardStore = store : node.store = store;
|
|
52
|
+
}
|
|
53
|
+
find(method, path) {
|
|
54
|
+
const root = this.roots[method];
|
|
55
|
+
return root ? this.matchPath(root, path, 0, path.length) : null;
|
|
56
|
+
}
|
|
57
|
+
matchPath(node, path, start, len) {
|
|
58
|
+
const partLen = node.part.length, end = start + partLen;
|
|
59
|
+
if (partLen > 1) {
|
|
60
|
+
if (end > len) return null;
|
|
61
|
+
for (let i = 1, j = start + 1; i < partLen; i++, j++)
|
|
62
|
+
if (node.part.charCodeAt(i) !== path.charCodeAt(j))
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
if (end === len)
|
|
66
|
+
return node.store !== null ? { store: node.store, params: EMPTY_PARAMS } : node.wildcardStore !== null ? { store: node.wildcardStore, params: { "*": "" } } : null;
|
|
67
|
+
if (node.children) {
|
|
68
|
+
const child = node.children.get(path.charCodeAt(end));
|
|
69
|
+
if (child) {
|
|
70
|
+
const result = this.matchPath(child, path, end, len);
|
|
71
|
+
if (result) return result;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
if (node.paramChild) {
|
|
75
|
+
const param = node.paramChild;
|
|
76
|
+
let paramEnd = end;
|
|
77
|
+
for (; paramEnd < len && path.charCodeAt(paramEnd) !== 47; )
|
|
78
|
+
paramEnd++;
|
|
79
|
+
if (paramEnd === end) return null;
|
|
80
|
+
const paramValue = path.slice(end, paramEnd);
|
|
81
|
+
if (paramEnd >= len) {
|
|
82
|
+
if (param.store !== null)
|
|
83
|
+
return {
|
|
84
|
+
store: param.store,
|
|
85
|
+
params: { [param.name]: paramValue }
|
|
86
|
+
};
|
|
87
|
+
} else if (param.child) {
|
|
88
|
+
const result = this.matchPath(param.child, path, paramEnd, len);
|
|
89
|
+
if (result)
|
|
90
|
+
return result.params === EMPTY_PARAMS ? result.params = { [param.name]: paramValue } : result.params[param.name] = paramValue, result;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return node.wildcardStore !== null ? {
|
|
94
|
+
store: node.wildcardStore,
|
|
95
|
+
params: { "*": path.slice(end) }
|
|
96
|
+
} : null;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
export {
|
|
100
|
+
RadixRouter
|
|
101
|
+
};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
8
|
+
}, __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from == "object" || typeof from == "function")
|
|
10
|
+
for (let key of __getOwnPropNames(from))
|
|
11
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
15
|
+
var TestHarness_exports = {};
|
|
16
|
+
__export(TestHarness_exports, {
|
|
17
|
+
createTestHarness: () => createTestHarness,
|
|
18
|
+
withTestApp: () => withTestApp
|
|
19
|
+
});
|
|
20
|
+
module.exports = __toCommonJS(TestHarness_exports);
|
|
21
|
+
var import_Carno = require('../Carno.js');
|
|
22
|
+
async function createTestHarness(options = {}) {
|
|
23
|
+
const config = {
|
|
24
|
+
...options.config,
|
|
25
|
+
disableStartupLog: !0
|
|
26
|
+
}, app = new import_Carno.Carno(config);
|
|
27
|
+
options.controllers && app.controllers(options.controllers), options.services && app.services(options.services);
|
|
28
|
+
const port = resolvePort(options);
|
|
29
|
+
let server;
|
|
30
|
+
shouldListen(options.listen) && (app.listen(port), server = app.server);
|
|
31
|
+
const actualPort = server?.port ?? port, container = app.container, baseUrl = `http://127.0.0.1:${actualPort}`, request = async (path, init) => {
|
|
32
|
+
if (!server)
|
|
33
|
+
throw new Error("Server not running. Set listen: true in options.");
|
|
34
|
+
const url = path.startsWith("http") ? path : `${baseUrl}${path.startsWith("/") ? path : "/" + path}`;
|
|
35
|
+
return fetch(url, init);
|
|
36
|
+
};
|
|
37
|
+
return {
|
|
38
|
+
app,
|
|
39
|
+
container,
|
|
40
|
+
server,
|
|
41
|
+
port: actualPort,
|
|
42
|
+
resolve: (token) => container.get(token),
|
|
43
|
+
request,
|
|
44
|
+
get: (path, init) => request(path, { ...init, method: "GET" }),
|
|
45
|
+
post: (path, body, init) => request(path, {
|
|
46
|
+
...init,
|
|
47
|
+
method: "POST",
|
|
48
|
+
body: body ? JSON.stringify(body) : void 0,
|
|
49
|
+
headers: { "Content-Type": "application/json", ...init?.headers }
|
|
50
|
+
}),
|
|
51
|
+
put: (path, body, init) => request(path, {
|
|
52
|
+
...init,
|
|
53
|
+
method: "PUT",
|
|
54
|
+
body: body ? JSON.stringify(body) : void 0,
|
|
55
|
+
headers: { "Content-Type": "application/json", ...init?.headers }
|
|
56
|
+
}),
|
|
57
|
+
delete: (path, init) => request(path, { ...init, method: "DELETE" }),
|
|
58
|
+
close: async () => {
|
|
59
|
+
app.stop();
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
async function withTestApp(routine, options = {}) {
|
|
64
|
+
const harness = await createTestHarness(options);
|
|
65
|
+
try {
|
|
66
|
+
await routine(harness);
|
|
67
|
+
} finally {
|
|
68
|
+
await harness.close();
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
function shouldListen(value) {
|
|
72
|
+
return typeof value == "number" || !!value;
|
|
73
|
+
}
|
|
74
|
+
function resolvePort(options) {
|
|
75
|
+
return typeof options.listen == "number" ? options.listen : typeof options.port == "number" ? options.port : 0;
|
|
76
|
+
}
|
|
77
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
78
|
+
0 && (module.exports = {
|
|
79
|
+
createTestHarness,
|
|
80
|
+
withTestApp
|
|
81
|
+
});
|