@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.
- package/dist/bun/index.js +3 -3
- package/dist/bun/index.js.map +5 -4
- package/dist/index.d.ts +42 -0
- package/dist/index.js +106 -130
- package/dist/index.mjs +1 -0
- package/dist/testing/TestHarness.js +3 -0
- package/dist/testing/TestHarness.mjs +3 -0
- package/package.json +2 -2
- package/src/index.ts +3 -0
- package/src/testing/TestHarness.ts +8 -0
package/dist/index.d.ts
ADDED
|
@@ -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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
var
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
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
|
@@ -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.
|
|
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": "
|
|
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);
|