@carno.js/core 1.0.4 → 1.0.6

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.
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Carno - Ultra-Fast HTTP Framework
3
+ *
4
+ * Design principles:
5
+ * 1. ZERO abstraction at runtime - everything compiled at startup
6
+ * 2. Direct Bun.serve() with native routes
7
+ * 3. JIT compiled handlers with AOT async detection
8
+ * 4. No intermediate layers in hot path
9
+ * 5. Radix tree router for dynamic routes
10
+ */
11
+ import 'reflect-metadata';
12
+ export { Carno } from './Carno';
13
+ export type { MiddlewareHandler, CarnoConfig } from './Carno';
14
+ export { Context } from './context/Context';
15
+ export { Controller } from './decorators/Controller';
16
+ export type { ControllerOptions } from './metadata';
17
+ export { Get, Post, Put, Delete, Patch, Head, Options } from './decorators/methods';
18
+ export { Param, Query, Body, Header, Req, Ctx, Locals } from './decorators/params';
19
+ export { Use, Use as Middleware } from './decorators/Middleware';
20
+ export type { CarnoMiddleware, CarnoClosure } from './middleware/CarnoMiddleware';
21
+ export { Service } from './decorators/Service';
22
+ export { Inject } from './decorators/Inject';
23
+ export { Container, Scope } from './container/Container';
24
+ export type { Token, ProviderConfig } from './container/Container';
25
+ export { RadixRouter } from './router/RadixRouter';
26
+ export type { RouteMatch } from './router/RadixRouter';
27
+ export { CorsHandler } from './cors/CorsHandler';
28
+ export type { CorsConfig, CorsOrigin } from './cors/CorsHandler';
29
+ export type { ValidatorAdapter, ValidationResult, ValidationError, ValidationConfig } from './validation/ValidatorAdapter';
30
+ export { Schema, getSchema, VALIDATION_SCHEMA } from './validation/ValidatorAdapter';
31
+ export { ZodAdapter, ValidationException } from './validation/ZodAdapter';
32
+ export { ValibotAdapter } from './validation/ValibotAdapter';
33
+ export { HttpException, BadRequestException, UnauthorizedException, ForbiddenException, NotFoundException, MethodNotAllowedException, ConflictException, UnprocessableEntityException, TooManyRequestsException, InternalServerErrorException, ServiceUnavailableException } from './exceptions/HttpException';
34
+ export { EventType, OnApplicationInit, OnApplicationBoot, OnApplicationShutdown } from './events/Lifecycle';
35
+ export { CacheService } from './cache/CacheService';
36
+ export { MemoryDriver } from './cache/MemoryDriver';
37
+ export { RedisDriver } from './cache/RedisDriver';
38
+ export type { RedisConfig } from './cache/RedisDriver';
39
+ export type { CacheDriver, CacheConfig } from './cache/CacheDriver';
40
+ export { createTestHarness, withTestApp } from './testing/TestHarness';
41
+ export type { TestHarness, TestOptions } from './testing/TestHarness';
42
+ export { Metadata, isObject, isString } from './utils/Metadata';
package/dist/index.js CHANGED
@@ -1,130 +1,106 @@
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 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
- });
1
+ "use strict";
2
+ /**
3
+ * Carno - Ultra-Fast HTTP Framework
4
+ *
5
+ * Design principles:
6
+ * 1. ZERO abstraction at runtime - everything compiled at startup
7
+ * 2. Direct Bun.serve() with native routes
8
+ * 3. JIT compiled handlers with AOT async detection
9
+ * 4. No intermediate layers in hot path
10
+ * 5. Radix tree router for dynamic routes
11
+ */
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.createTestHarness = exports.RedisDriver = exports.MemoryDriver = exports.CacheService = exports.OnApplicationShutdown = exports.OnApplicationBoot = exports.OnApplicationInit = exports.EventType = exports.ServiceUnavailableException = exports.InternalServerErrorException = exports.TooManyRequestsException = exports.UnprocessableEntityException = exports.ConflictException = exports.MethodNotAllowedException = exports.NotFoundException = exports.ForbiddenException = exports.UnauthorizedException = exports.BadRequestException = exports.HttpException = exports.ValibotAdapter = exports.ValidationException = exports.ZodAdapter = exports.VALIDATION_SCHEMA = exports.getSchema = exports.Schema = exports.CorsHandler = exports.RadixRouter = exports.Scope = exports.Container = exports.Inject = exports.Service = exports.Middleware = exports.Use = exports.Locals = exports.Ctx = exports.Req = exports.Header = exports.Body = exports.Query = exports.Param = exports.Options = exports.Head = exports.Patch = exports.Delete = exports.Put = exports.Post = exports.Get = exports.Controller = exports.Context = exports.Carno = void 0;
14
+ exports.isString = exports.isObject = exports.Metadata = exports.withTestApp = void 0;
15
+ // Import reflect-metadata globally for decorator support
16
+ require("reflect-metadata");
17
+ // Application
18
+ var Carno_1 = require("./Carno");
19
+ Object.defineProperty(exports, "Carno", { enumerable: true, get: function () { return Carno_1.Carno; } });
20
+ // Context
21
+ var Context_1 = require("./context/Context");
22
+ Object.defineProperty(exports, "Context", { enumerable: true, get: function () { return Context_1.Context; } });
23
+ // Decorators - Controller
24
+ var Controller_1 = require("./decorators/Controller");
25
+ Object.defineProperty(exports, "Controller", { enumerable: true, get: function () { return Controller_1.Controller; } });
26
+ // Decorators - HTTP Methods
27
+ var methods_1 = require("./decorators/methods");
28
+ Object.defineProperty(exports, "Get", { enumerable: true, get: function () { return methods_1.Get; } });
29
+ Object.defineProperty(exports, "Post", { enumerable: true, get: function () { return methods_1.Post; } });
30
+ Object.defineProperty(exports, "Put", { enumerable: true, get: function () { return methods_1.Put; } });
31
+ Object.defineProperty(exports, "Delete", { enumerable: true, get: function () { return methods_1.Delete; } });
32
+ Object.defineProperty(exports, "Patch", { enumerable: true, get: function () { return methods_1.Patch; } });
33
+ Object.defineProperty(exports, "Head", { enumerable: true, get: function () { return methods_1.Head; } });
34
+ Object.defineProperty(exports, "Options", { enumerable: true, get: function () { return methods_1.Options; } });
35
+ // Decorators - Parameters
36
+ var params_1 = require("./decorators/params");
37
+ Object.defineProperty(exports, "Param", { enumerable: true, get: function () { return params_1.Param; } });
38
+ Object.defineProperty(exports, "Query", { enumerable: true, get: function () { return params_1.Query; } });
39
+ Object.defineProperty(exports, "Body", { enumerable: true, get: function () { return params_1.Body; } });
40
+ Object.defineProperty(exports, "Header", { enumerable: true, get: function () { return params_1.Header; } });
41
+ Object.defineProperty(exports, "Req", { enumerable: true, get: function () { return params_1.Req; } });
42
+ Object.defineProperty(exports, "Ctx", { enumerable: true, get: function () { return params_1.Ctx; } });
43
+ Object.defineProperty(exports, "Locals", { enumerable: true, get: function () { return params_1.Locals; } });
44
+ // Decorators - Middleware
45
+ var Middleware_1 = require("./decorators/Middleware");
46
+ Object.defineProperty(exports, "Use", { enumerable: true, get: function () { return Middleware_1.Use; } });
47
+ Object.defineProperty(exports, "Middleware", { enumerable: true, get: function () { return Middleware_1.Use; } });
48
+ // Decorators - DI
49
+ var Service_1 = require("./decorators/Service");
50
+ Object.defineProperty(exports, "Service", { enumerable: true, get: function () { return Service_1.Service; } });
51
+ var Inject_1 = require("./decorators/Inject");
52
+ Object.defineProperty(exports, "Inject", { enumerable: true, get: function () { return Inject_1.Inject; } });
53
+ // Container
54
+ var Container_1 = require("./container/Container");
55
+ Object.defineProperty(exports, "Container", { enumerable: true, get: function () { return Container_1.Container; } });
56
+ Object.defineProperty(exports, "Scope", { enumerable: true, get: function () { return Container_1.Scope; } });
57
+ // Router
58
+ var RadixRouter_1 = require("./router/RadixRouter");
59
+ Object.defineProperty(exports, "RadixRouter", { enumerable: true, get: function () { return RadixRouter_1.RadixRouter; } });
60
+ // CORS
61
+ var CorsHandler_1 = require("./cors/CorsHandler");
62
+ Object.defineProperty(exports, "CorsHandler", { enumerable: true, get: function () { return CorsHandler_1.CorsHandler; } });
63
+ var ValidatorAdapter_1 = require("./validation/ValidatorAdapter");
64
+ Object.defineProperty(exports, "Schema", { enumerable: true, get: function () { return ValidatorAdapter_1.Schema; } });
65
+ Object.defineProperty(exports, "getSchema", { enumerable: true, get: function () { return ValidatorAdapter_1.getSchema; } });
66
+ Object.defineProperty(exports, "VALIDATION_SCHEMA", { enumerable: true, get: function () { return ValidatorAdapter_1.VALIDATION_SCHEMA; } });
67
+ var ZodAdapter_1 = require("./validation/ZodAdapter");
68
+ Object.defineProperty(exports, "ZodAdapter", { enumerable: true, get: function () { return ZodAdapter_1.ZodAdapter; } });
69
+ Object.defineProperty(exports, "ValidationException", { enumerable: true, get: function () { return ZodAdapter_1.ValidationException; } });
70
+ var ValibotAdapter_1 = require("./validation/ValibotAdapter");
71
+ Object.defineProperty(exports, "ValibotAdapter", { enumerable: true, get: function () { return ValibotAdapter_1.ValibotAdapter; } });
72
+ // Exceptions
73
+ var HttpException_1 = require("./exceptions/HttpException");
74
+ Object.defineProperty(exports, "HttpException", { enumerable: true, get: function () { return HttpException_1.HttpException; } });
75
+ Object.defineProperty(exports, "BadRequestException", { enumerable: true, get: function () { return HttpException_1.BadRequestException; } });
76
+ Object.defineProperty(exports, "UnauthorizedException", { enumerable: true, get: function () { return HttpException_1.UnauthorizedException; } });
77
+ Object.defineProperty(exports, "ForbiddenException", { enumerable: true, get: function () { return HttpException_1.ForbiddenException; } });
78
+ Object.defineProperty(exports, "NotFoundException", { enumerable: true, get: function () { return HttpException_1.NotFoundException; } });
79
+ Object.defineProperty(exports, "MethodNotAllowedException", { enumerable: true, get: function () { return HttpException_1.MethodNotAllowedException; } });
80
+ Object.defineProperty(exports, "ConflictException", { enumerable: true, get: function () { return HttpException_1.ConflictException; } });
81
+ Object.defineProperty(exports, "UnprocessableEntityException", { enumerable: true, get: function () { return HttpException_1.UnprocessableEntityException; } });
82
+ Object.defineProperty(exports, "TooManyRequestsException", { enumerable: true, get: function () { return HttpException_1.TooManyRequestsException; } });
83
+ Object.defineProperty(exports, "InternalServerErrorException", { enumerable: true, get: function () { return HttpException_1.InternalServerErrorException; } });
84
+ Object.defineProperty(exports, "ServiceUnavailableException", { enumerable: true, get: function () { return HttpException_1.ServiceUnavailableException; } });
85
+ // Lifecycle Events
86
+ var Lifecycle_1 = require("./events/Lifecycle");
87
+ Object.defineProperty(exports, "EventType", { enumerable: true, get: function () { return Lifecycle_1.EventType; } });
88
+ Object.defineProperty(exports, "OnApplicationInit", { enumerable: true, get: function () { return Lifecycle_1.OnApplicationInit; } });
89
+ Object.defineProperty(exports, "OnApplicationBoot", { enumerable: true, get: function () { return Lifecycle_1.OnApplicationBoot; } });
90
+ Object.defineProperty(exports, "OnApplicationShutdown", { enumerable: true, get: function () { return Lifecycle_1.OnApplicationShutdown; } });
91
+ // Cache
92
+ var CacheService_1 = require("./cache/CacheService");
93
+ Object.defineProperty(exports, "CacheService", { enumerable: true, get: function () { return CacheService_1.CacheService; } });
94
+ var MemoryDriver_1 = require("./cache/MemoryDriver");
95
+ Object.defineProperty(exports, "MemoryDriver", { enumerable: true, get: function () { return MemoryDriver_1.MemoryDriver; } });
96
+ var RedisDriver_1 = require("./cache/RedisDriver");
97
+ Object.defineProperty(exports, "RedisDriver", { enumerable: true, get: function () { return RedisDriver_1.RedisDriver; } });
98
+ // Testing
99
+ var TestHarness_1 = require("./testing/TestHarness");
100
+ Object.defineProperty(exports, "createTestHarness", { enumerable: true, get: function () { return TestHarness_1.createTestHarness; } });
101
+ Object.defineProperty(exports, "withTestApp", { enumerable: true, get: function () { return TestHarness_1.withTestApp; } });
102
+ // Utils
103
+ var Metadata_1 = require("./utils/Metadata");
104
+ Object.defineProperty(exports, "Metadata", { enumerable: true, get: function () { return Metadata_1.Metadata; } });
105
+ Object.defineProperty(exports, "isObject", { enumerable: true, get: function () { return Metadata_1.isObject; } });
106
+ Object.defineProperty(exports, "isString", { enumerable: true, get: function () { return Metadata_1.isString; } });
package/dist/index.mjs CHANGED
@@ -1,3 +1,4 @@
1
+ import "reflect-metadata";
1
2
  import { Carno } from "./Carno.mjs";
2
3
  import { Context } from "./context/Context.mjs";
3
4
  import { Controller } from "./decorators/Controller.mjs";
@@ -24,6 +24,9 @@ async function createTestHarness(options = {}) {
24
24
  ...options.config,
25
25
  disableStartupLog: !0
26
26
  }, app = new import_Carno.Carno(config);
27
+ if (options.plugins)
28
+ for (const plugin of options.plugins)
29
+ app.use(plugin);
27
30
  options.controllers && app.controllers(options.controllers), options.services && app.services(options.services);
28
31
  const port = resolvePort(options);
29
32
  let server;
@@ -4,6 +4,9 @@ async function createTestHarness(options = {}) {
4
4
  ...options.config,
5
5
  disableStartupLog: !0
6
6
  }, app = new Carno(config);
7
+ if (options.plugins)
8
+ for (const plugin of options.plugins)
9
+ app.use(plugin);
7
10
  options.controllers && app.controllers(options.controllers), options.services && app.services(options.services);
8
11
  const port = resolvePort(options);
9
12
  let server;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@carno.js/core",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "description": "Ultra-fast HTTP framework with aggressive AOT/JIT compilation",
5
5
  "main": "src/index.ts",
6
6
  "types": "src/index.ts",
@@ -21,5 +21,5 @@
21
21
  "esbuild-fix-imports-plugin": "^1.0.23",
22
22
  "tsup": "^8.5.1"
23
23
  },
24
- "gitHead": "8aba0ef37b8be1b9b5441feb9a29a8d686821561"
24
+ "gitHead": "deae35f92bcb54cc74dcc02054e87987dd6edb5e"
25
25
  }
package/src/index.ts CHANGED
@@ -9,6 +9,9 @@
9
9
  * 5. Radix tree router for dynamic routes
10
10
  */
11
11
 
12
+ // Import reflect-metadata globally for decorator support
13
+ import 'reflect-metadata';
14
+
12
15
  // Application
13
16
  export { Carno } from './Carno';
14
17
  export type { MiddlewareHandler, CarnoConfig } from './Carno';
@@ -11,6 +11,7 @@ export interface TestOptions {
11
11
  port?: number;
12
12
  controllers?: (new (...args: any[]) => any)[];
13
13
  services?: (Token | any)[];
14
+ plugins?: Carno[];
14
15
  }
15
16
 
16
17
  /**
@@ -76,6 +77,13 @@ export async function createTestHarness(options: TestOptions = {}): Promise<Test
76
77
 
77
78
  const app = new Carno(config);
78
79
 
80
+ // Register plugins
81
+ if (options.plugins) {
82
+ for (const plugin of options.plugins) {
83
+ app.use(plugin);
84
+ }
85
+ }
86
+
79
87
  // Register controllers
80
88
  if (options.controllers) {
81
89
  app.controllers(options.controllers);