@carno.js/core 1.1.0 → 1.1.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 +21 -21
- package/README.md +188 -188
- package/dist/Carno.js +46 -26
- package/dist/Carno.mjs +46 -26
- package/dist/bun/index.js +4 -4
- package/dist/bun/index.js.map +29 -29
- package/package.json +2 -2
- package/src/Carno.ts +718 -673
- package/src/DefaultRoutes.ts +34 -34
- package/src/cache/CacheDriver.ts +50 -50
- package/src/cache/CacheService.ts +139 -139
- package/src/cache/MemoryDriver.ts +104 -104
- package/src/cache/RedisDriver.ts +116 -116
- package/src/compiler/JITCompiler.ts +167 -167
- package/src/container/Container.ts +168 -168
- package/src/context/Context.ts +130 -130
- package/src/cors/CorsHandler.ts +145 -145
- package/src/decorators/Controller.ts +63 -63
- package/src/decorators/Inject.ts +16 -16
- package/src/decorators/Middleware.ts +22 -22
- package/src/decorators/Service.ts +18 -18
- package/src/decorators/methods.ts +58 -58
- package/src/decorators/params.ts +47 -47
- package/src/events/Lifecycle.ts +97 -97
- package/src/exceptions/HttpException.ts +99 -99
- package/src/index.ts +95 -95
- package/src/metadata.ts +46 -46
- package/src/middleware/CarnoMiddleware.ts +14 -14
- package/src/router/RadixRouter.ts +225 -225
- package/src/testing/TestHarness.ts +185 -185
- package/src/utils/Metadata.ts +43 -43
- package/src/utils/parseQuery.ts +161 -161
- package/src/validation/ValibotAdapter.ts +95 -95
- package/src/validation/ValidatorAdapter.ts +69 -69
- package/src/validation/ZodAdapter.ts +102 -102
- package/dist/Carno.d.js +0 -14
- package/dist/Carno.d.mjs +0 -1
- package/dist/DefaultRoutes.d.js +0 -13
- package/dist/DefaultRoutes.d.mjs +0 -0
- package/dist/cache/CacheDriver.d.js +0 -13
- package/dist/cache/CacheDriver.d.mjs +0 -0
- package/dist/cache/CacheService.d.js +0 -13
- package/dist/cache/CacheService.d.mjs +0 -0
- package/dist/cache/MemoryDriver.d.js +0 -13
- package/dist/cache/MemoryDriver.d.mjs +0 -0
- package/dist/cache/RedisDriver.d.js +0 -13
- package/dist/cache/RedisDriver.d.mjs +0 -0
- package/dist/compiler/JITCompiler.d.js +0 -13
- package/dist/compiler/JITCompiler.d.mjs +0 -0
- package/dist/container/Container.d.js +0 -13
- package/dist/container/Container.d.mjs +0 -0
- package/dist/context/Context.d.js +0 -13
- package/dist/context/Context.d.mjs +0 -0
- package/dist/cors/CorsHandler.d.js +0 -13
- package/dist/cors/CorsHandler.d.mjs +0 -0
- package/dist/decorators/Controller.d.js +0 -13
- package/dist/decorators/Controller.d.mjs +0 -0
- package/dist/decorators/Inject.d.js +0 -13
- package/dist/decorators/Inject.d.mjs +0 -0
- package/dist/decorators/Middleware.d.js +0 -13
- package/dist/decorators/Middleware.d.mjs +0 -0
- package/dist/decorators/Service.d.js +0 -13
- package/dist/decorators/Service.d.mjs +0 -0
- package/dist/decorators/methods.d.js +0 -13
- package/dist/decorators/methods.d.mjs +0 -0
- package/dist/decorators/params.d.js +0 -13
- package/dist/decorators/params.d.mjs +0 -0
- package/dist/events/Lifecycle.d.js +0 -13
- package/dist/events/Lifecycle.d.mjs +0 -0
- package/dist/exceptions/HttpException.d.js +0 -13
- package/dist/exceptions/HttpException.d.mjs +0 -0
- package/dist/index.d.js +0 -130
- package/dist/index.d.mjs +0 -78
- package/dist/metadata.d.js +0 -13
- package/dist/metadata.d.mjs +0 -0
- package/dist/middleware/CarnoMiddleware.d.js +0 -13
- package/dist/middleware/CarnoMiddleware.d.mjs +0 -0
- package/dist/router/RadixRouter.d.js +0 -13
- package/dist/router/RadixRouter.d.mjs +0 -0
- package/dist/testing/TestHarness.d.js +0 -13
- package/dist/testing/TestHarness.d.mjs +0 -0
- package/dist/utils/Metadata.d.js +0 -13
- package/dist/utils/Metadata.d.mjs +0 -0
- package/dist/utils/parseQuery.d.js +0 -13
- package/dist/utils/parseQuery.d.mjs +0 -0
- package/dist/validation/ValibotAdapter.d.js +0 -13
- package/dist/validation/ValibotAdapter.d.mjs +0 -0
- package/dist/validation/ValidatorAdapter.d.js +0 -13
- package/dist/validation/ValidatorAdapter.d.mjs +0 -0
- package/dist/validation/ZodAdapter.d.js +0 -13
- package/dist/validation/ZodAdapter.d.mjs +0 -0
- package/src/Carno.d.ts +0 -135
- package/src/DefaultRoutes.d.ts +0 -19
- package/src/cache/CacheDriver.d.ts +0 -43
- package/src/cache/CacheService.d.ts +0 -89
- package/src/cache/MemoryDriver.d.ts +0 -32
- package/src/cache/RedisDriver.d.ts +0 -34
- package/src/compiler/JITCompiler.d.ts +0 -36
- package/src/container/Container.d.ts +0 -38
- package/src/context/Context.d.ts +0 -36
- package/src/cors/CorsHandler.d.ts +0 -47
- package/src/decorators/Controller.d.ts +0 -13
- package/src/decorators/Inject.d.ts +0 -6
- package/src/decorators/Middleware.d.ts +0 -5
- package/src/decorators/Service.d.ts +0 -9
- package/src/decorators/methods.d.ts +0 -7
- package/src/decorators/params.d.ts +0 -13
- package/src/events/Lifecycle.d.ts +0 -54
- package/src/exceptions/HttpException.d.ts +0 -43
- package/src/index.d.ts +0 -42
- package/src/metadata.d.ts +0 -41
- package/src/middleware/CarnoMiddleware.d.ts +0 -12
- package/src/router/RadixRouter.d.ts +0 -19
- package/src/testing/TestHarness.d.ts +0 -71
- package/src/utils/Metadata.d.ts +0 -20
- package/src/utils/parseQuery.d.ts +0 -23
- package/src/validation/ValibotAdapter.d.ts +0 -30
- package/src/validation/ValidatorAdapter.d.ts +0 -54
- package/src/validation/ZodAdapter.d.ts +0 -35
package/dist/index.d.mjs
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import "reflect-metadata";
|
|
2
|
-
import { Carno } from "./Carno.mjs";
|
|
3
|
-
import { Context } from "./context/Context.mjs";
|
|
4
|
-
import { Controller } from "./decorators/Controller.mjs";
|
|
5
|
-
import { Get, Post, Put, Delete, Patch, Head, Options } from "./decorators/methods.mjs";
|
|
6
|
-
import { Param, Query, Body, Header, Req, Ctx, Locals } from "./decorators/params.mjs";
|
|
7
|
-
import { Use, Use as Use2 } from "./decorators/Middleware.mjs";
|
|
8
|
-
import { Service } from "./decorators/Service.mjs";
|
|
9
|
-
import { Inject } from "./decorators/Inject.mjs";
|
|
10
|
-
import { Container, Scope } from "./container/Container.mjs";
|
|
11
|
-
import { RadixRouter } from "./router/RadixRouter.mjs";
|
|
12
|
-
import { CorsHandler } from "./cors/CorsHandler.mjs";
|
|
13
|
-
import { Schema, getSchema, VALIDATION_SCHEMA } from "./validation/ValidatorAdapter.mjs";
|
|
14
|
-
import { ZodAdapter, ValidationException } from "./validation/ZodAdapter.mjs";
|
|
15
|
-
import { ValibotAdapter } from "./validation/ValibotAdapter.mjs";
|
|
16
|
-
import { HttpException, BadRequestException, UnauthorizedException, ForbiddenException, NotFoundException, MethodNotAllowedException, ConflictException, UnprocessableEntityException, TooManyRequestsException, InternalServerErrorException, ServiceUnavailableException } from "./exceptions/HttpException.mjs";
|
|
17
|
-
import { EventType, OnApplicationInit, OnApplicationBoot, OnApplicationShutdown } from "./events/Lifecycle.mjs";
|
|
18
|
-
import { CacheService } from "./cache/CacheService.mjs";
|
|
19
|
-
import { MemoryDriver } from "./cache/MemoryDriver.mjs";
|
|
20
|
-
import { RedisDriver } from "./cache/RedisDriver.mjs";
|
|
21
|
-
import { createTestHarness, withTestApp } from "./testing/TestHarness.mjs";
|
|
22
|
-
import { Metadata, isObject, isString } from "./utils/Metadata.mjs";
|
|
23
|
-
export {
|
|
24
|
-
BadRequestException,
|
|
25
|
-
Body,
|
|
26
|
-
CacheService,
|
|
27
|
-
Carno,
|
|
28
|
-
ConflictException,
|
|
29
|
-
Container,
|
|
30
|
-
Context,
|
|
31
|
-
Controller,
|
|
32
|
-
CorsHandler,
|
|
33
|
-
Ctx,
|
|
34
|
-
Delete,
|
|
35
|
-
EventType,
|
|
36
|
-
ForbiddenException,
|
|
37
|
-
Get,
|
|
38
|
-
Head,
|
|
39
|
-
Header,
|
|
40
|
-
HttpException,
|
|
41
|
-
Inject,
|
|
42
|
-
InternalServerErrorException,
|
|
43
|
-
Locals,
|
|
44
|
-
MemoryDriver,
|
|
45
|
-
Metadata,
|
|
46
|
-
MethodNotAllowedException,
|
|
47
|
-
Use2 as Middleware,
|
|
48
|
-
NotFoundException,
|
|
49
|
-
OnApplicationBoot,
|
|
50
|
-
OnApplicationInit,
|
|
51
|
-
OnApplicationShutdown,
|
|
52
|
-
Options,
|
|
53
|
-
Param,
|
|
54
|
-
Patch,
|
|
55
|
-
Post,
|
|
56
|
-
Put,
|
|
57
|
-
Query,
|
|
58
|
-
RadixRouter,
|
|
59
|
-
RedisDriver,
|
|
60
|
-
Req,
|
|
61
|
-
Schema,
|
|
62
|
-
Scope,
|
|
63
|
-
Service,
|
|
64
|
-
ServiceUnavailableException,
|
|
65
|
-
TooManyRequestsException,
|
|
66
|
-
UnauthorizedException,
|
|
67
|
-
UnprocessableEntityException,
|
|
68
|
-
Use,
|
|
69
|
-
VALIDATION_SCHEMA,
|
|
70
|
-
ValibotAdapter,
|
|
71
|
-
ValidationException,
|
|
72
|
-
ZodAdapter,
|
|
73
|
-
createTestHarness,
|
|
74
|
-
getSchema,
|
|
75
|
-
isObject,
|
|
76
|
-
isString,
|
|
77
|
-
withTestApp
|
|
78
|
-
};
|
package/dist/metadata.d.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
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 metadata_d_exports = {};
|
|
13
|
-
module.exports = __toCommonJS(metadata_d_exports);
|
package/dist/metadata.d.mjs
DELETED
|
File without changes
|
|
@@ -1,13 +0,0 @@
|
|
|
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_d_exports = {};
|
|
13
|
-
module.exports = __toCommonJS(CarnoMiddleware_d_exports);
|
|
File without changes
|
|
@@ -1,13 +0,0 @@
|
|
|
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 RadixRouter_d_exports = {};
|
|
13
|
-
module.exports = __toCommonJS(RadixRouter_d_exports);
|
|
File without changes
|
|
@@ -1,13 +0,0 @@
|
|
|
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 TestHarness_d_exports = {};
|
|
13
|
-
module.exports = __toCommonJS(TestHarness_d_exports);
|
|
File without changes
|
package/dist/utils/Metadata.d.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
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 Metadata_d_exports = {};
|
|
13
|
-
module.exports = __toCommonJS(Metadata_d_exports);
|
|
File without changes
|
|
@@ -1,13 +0,0 @@
|
|
|
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 parseQuery_d_exports = {};
|
|
13
|
-
module.exports = __toCommonJS(parseQuery_d_exports);
|
|
File without changes
|
|
@@ -1,13 +0,0 @@
|
|
|
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 ValibotAdapter_d_exports = {};
|
|
13
|
-
module.exports = __toCommonJS(ValibotAdapter_d_exports);
|
|
File without changes
|
|
@@ -1,13 +0,0 @@
|
|
|
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 ValidatorAdapter_d_exports = {};
|
|
13
|
-
module.exports = __toCommonJS(ValidatorAdapter_d_exports);
|
|
File without changes
|
|
@@ -1,13 +0,0 @@
|
|
|
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 ZodAdapter_d_exports = {};
|
|
13
|
-
module.exports = __toCommonJS(ZodAdapter_d_exports);
|
|
File without changes
|
package/src/Carno.d.ts
DELETED
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import 'reflect-metadata';
|
|
2
|
-
import { Context } from './context/Context';
|
|
3
|
-
import type { Token, ProviderConfig } from './container/Container';
|
|
4
|
-
import { type CorsConfig } from './cors/CorsHandler';
|
|
5
|
-
import type { ValidatorAdapter } from './validation/ValidatorAdapter';
|
|
6
|
-
import type { CacheConfig } from './cache/CacheDriver';
|
|
7
|
-
export type MiddlewareHandler = (ctx: Context) => Response | void | Promise<Response | void>;
|
|
8
|
-
/**
|
|
9
|
-
* Carno plugin configuration.
|
|
10
|
-
*/
|
|
11
|
-
export interface CarnoConfig {
|
|
12
|
-
exports?: (Token | ProviderConfig)[];
|
|
13
|
-
globalMiddlewares?: MiddlewareHandler[];
|
|
14
|
-
disableStartupLog?: boolean;
|
|
15
|
-
cors?: CorsConfig;
|
|
16
|
-
validation?: ValidatorAdapter | boolean | (new (...args: any[]) => ValidatorAdapter);
|
|
17
|
-
cache?: CacheConfig | boolean;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Carno Application - Ultra-aggressive performance.
|
|
21
|
-
*
|
|
22
|
-
* ZERO runtime work in hot path:
|
|
23
|
-
* - All responses pre-created at startup
|
|
24
|
-
* - Direct Bun native routes - no fetch fallback needed
|
|
25
|
-
* - No function calls in hot path
|
|
26
|
-
*/
|
|
27
|
-
export declare class Carno {
|
|
28
|
-
config: CarnoConfig;
|
|
29
|
-
private _controllers;
|
|
30
|
-
private _services;
|
|
31
|
-
private _middlewares;
|
|
32
|
-
private routes;
|
|
33
|
-
private container;
|
|
34
|
-
private corsHandler;
|
|
35
|
-
private hasCors;
|
|
36
|
-
private validator;
|
|
37
|
-
private server;
|
|
38
|
-
private hasInitHooks;
|
|
39
|
-
private hasBootHooks;
|
|
40
|
-
private hasShutdownHooks;
|
|
41
|
-
constructor(config?: CarnoConfig);
|
|
42
|
-
/**
|
|
43
|
-
* Use a Carno plugin.
|
|
44
|
-
* Imports controllers, services, middlewares, and routes from another Carno instance.
|
|
45
|
-
*/
|
|
46
|
-
use(plugin: Carno): this;
|
|
47
|
-
private findServiceInPlugin;
|
|
48
|
-
private getServiceToken;
|
|
49
|
-
private shouldCloneService;
|
|
50
|
-
/**
|
|
51
|
-
* Register one or more services/providers.
|
|
52
|
-
*/
|
|
53
|
-
services(serviceClass: Token | ProviderConfig | (Token | ProviderConfig)[]): this;
|
|
54
|
-
/**
|
|
55
|
-
* Register one or more global middlewares.
|
|
56
|
-
*/
|
|
57
|
-
middlewares(handler: MiddlewareHandler | MiddlewareHandler[]): this;
|
|
58
|
-
/**
|
|
59
|
-
* Register one or more controllers.
|
|
60
|
-
*/
|
|
61
|
-
controllers(controllerClass: (new (...args: any[]) => any) | (new (...args: any[]) => any)[]): this;
|
|
62
|
-
/**
|
|
63
|
-
* Register a route programmatically.
|
|
64
|
-
* Useful for plugins that need to register routes without controllers.
|
|
65
|
-
*
|
|
66
|
-
* @example
|
|
67
|
-
* ```ts
|
|
68
|
-
* app.route('GET', '/health', () => ({ status: 'ok' }));
|
|
69
|
-
* app.route('POST', '/webhook', async (ctx) => {
|
|
70
|
-
* const data = await ctx.parseBody();
|
|
71
|
-
* return { received: true };
|
|
72
|
-
* });
|
|
73
|
-
* ```
|
|
74
|
-
*/
|
|
75
|
-
route(method: string, path: string, handler: Response | Function): this;
|
|
76
|
-
/**
|
|
77
|
-
* Bulk register multiple routes at once.
|
|
78
|
-
*
|
|
79
|
-
* @example
|
|
80
|
-
* ```ts
|
|
81
|
-
* app.addRoutes({
|
|
82
|
-
* '/api/users': {
|
|
83
|
-
* 'GET': () => ({ users: [] }),
|
|
84
|
-
* 'POST': (ctx) => ({ created: true })
|
|
85
|
-
* },
|
|
86
|
-
* '/api/health': {
|
|
87
|
-
* 'GET': () => ({ status: 'ok' })
|
|
88
|
-
* }
|
|
89
|
-
* });
|
|
90
|
-
* ```
|
|
91
|
-
*/
|
|
92
|
-
addRoutes(routes: Record<string, Record<string, Response | Function>>): this;
|
|
93
|
-
/**
|
|
94
|
-
* Get a service instance from the container.
|
|
95
|
-
*/
|
|
96
|
-
get<T>(token: Token<T>): T;
|
|
97
|
-
listen(port?: number): void;
|
|
98
|
-
private bootstrap;
|
|
99
|
-
private compileRoutes;
|
|
100
|
-
private compileController;
|
|
101
|
-
/**
|
|
102
|
-
* Register a route with Bun's native router format.
|
|
103
|
-
* Path: "/users/:id", Method: "GET", Handler: Function or Response
|
|
104
|
-
*/
|
|
105
|
-
private registerRoute;
|
|
106
|
-
private createStaticResponse;
|
|
107
|
-
private createHandler;
|
|
108
|
-
private resolveMiddleware;
|
|
109
|
-
/**
|
|
110
|
-
* Apply CORS headers to a response.
|
|
111
|
-
*/
|
|
112
|
-
private applyCors;
|
|
113
|
-
/**
|
|
114
|
-
* Fallback handler - only called for unmatched routes.
|
|
115
|
-
* All matched routes go through Bun's native router.
|
|
116
|
-
*/
|
|
117
|
-
private handleNotFound;
|
|
118
|
-
private buildResponse;
|
|
119
|
-
private normalizePath;
|
|
120
|
-
private hasParams;
|
|
121
|
-
stop(): void;
|
|
122
|
-
/**
|
|
123
|
-
* Error handler for Bun.serve.
|
|
124
|
-
* Converts exceptions to proper HTTP responses.
|
|
125
|
-
*/
|
|
126
|
-
private handleError;
|
|
127
|
-
/**
|
|
128
|
-
* Execute lifecycle hooks for a specific event type.
|
|
129
|
-
*/
|
|
130
|
-
private executeLifecycleHooks;
|
|
131
|
-
/**
|
|
132
|
-
* Register SIGTERM/SIGINT handlers for graceful shutdown.
|
|
133
|
-
*/
|
|
134
|
-
private registerShutdownHandlers;
|
|
135
|
-
}
|
package/src/DefaultRoutes.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Default routes controller.
|
|
3
|
-
* Auto-registered by Turbo for common endpoints.
|
|
4
|
-
*/
|
|
5
|
-
export declare class DefaultRoutes {
|
|
6
|
-
/**
|
|
7
|
-
* Favicon - returns empty response to prevent 404.
|
|
8
|
-
*/
|
|
9
|
-
favicon(): Response;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Pre-compiled static responses for maximum performance.
|
|
13
|
-
* Use these directly in Bun.serve static routes.
|
|
14
|
-
*/
|
|
15
|
-
export declare const DEFAULT_STATIC_ROUTES: {
|
|
16
|
-
'/health': Response;
|
|
17
|
-
'/ready': Response;
|
|
18
|
-
'/favicon.ico': Response;
|
|
19
|
-
};
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Cache Driver Interface.
|
|
3
|
-
* Implement this to add new cache backends (Redis, Memcached, etc.)
|
|
4
|
-
*/
|
|
5
|
-
export interface CacheDriver {
|
|
6
|
-
/**
|
|
7
|
-
* Driver name for debugging.
|
|
8
|
-
*/
|
|
9
|
-
readonly name: string;
|
|
10
|
-
/**
|
|
11
|
-
* Get a value from cache.
|
|
12
|
-
*/
|
|
13
|
-
get<T>(key: string): Promise<T | null>;
|
|
14
|
-
/**
|
|
15
|
-
* Set a value in cache.
|
|
16
|
-
* @param ttl Time to live in seconds (optional)
|
|
17
|
-
*/
|
|
18
|
-
set<T>(key: string, value: T, ttl?: number): Promise<boolean>;
|
|
19
|
-
/**
|
|
20
|
-
* Delete a value from cache.
|
|
21
|
-
*/
|
|
22
|
-
del(key: string): Promise<boolean>;
|
|
23
|
-
/**
|
|
24
|
-
* Check if key exists.
|
|
25
|
-
*/
|
|
26
|
-
has(key: string): Promise<boolean>;
|
|
27
|
-
/**
|
|
28
|
-
* Clear all cached values.
|
|
29
|
-
*/
|
|
30
|
-
clear(): Promise<void>;
|
|
31
|
-
/**
|
|
32
|
-
* Close connection (for Redis, etc.)
|
|
33
|
-
*/
|
|
34
|
-
close?(): Promise<void>;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Cache configuration.
|
|
38
|
-
*/
|
|
39
|
-
export interface CacheConfig {
|
|
40
|
-
driver?: CacheDriver;
|
|
41
|
-
prefix?: string;
|
|
42
|
-
defaultTtl?: number;
|
|
43
|
-
}
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import type { CacheDriver, CacheConfig } from './CacheDriver';
|
|
2
|
-
/**
|
|
3
|
-
* CacheService - High-performance caching with driver pattern.
|
|
4
|
-
*
|
|
5
|
-
* Features:
|
|
6
|
-
* - In-memory (default) or Redis backend
|
|
7
|
-
* - getOrSet for cache-aside pattern
|
|
8
|
-
* - Key prefixing for namespacing
|
|
9
|
-
* - Configurable default TTL
|
|
10
|
-
*
|
|
11
|
-
* Usage:
|
|
12
|
-
* ```typescript
|
|
13
|
-
* const cache = new CacheService();
|
|
14
|
-
*
|
|
15
|
-
* // Basic operations
|
|
16
|
-
* await cache.set('user:123', { name: 'John' }, 3600);
|
|
17
|
-
* const user = await cache.get<User>('user:123');
|
|
18
|
-
*
|
|
19
|
-
* // Cache-aside pattern
|
|
20
|
-
* const user = await cache.getOrSet('user:123',
|
|
21
|
-
* async () => db.findUser(123),
|
|
22
|
-
* 3600
|
|
23
|
-
* );
|
|
24
|
-
* ```
|
|
25
|
-
*/
|
|
26
|
-
export declare class CacheService {
|
|
27
|
-
private driver;
|
|
28
|
-
private prefix;
|
|
29
|
-
private defaultTtl;
|
|
30
|
-
constructor(config?: CacheConfig);
|
|
31
|
-
/**
|
|
32
|
-
* Get the full key with prefix.
|
|
33
|
-
*/
|
|
34
|
-
private key;
|
|
35
|
-
/**
|
|
36
|
-
* Get a value from cache.
|
|
37
|
-
*/
|
|
38
|
-
get<T>(key: string): Promise<T | null>;
|
|
39
|
-
/**
|
|
40
|
-
* Set a value in cache.
|
|
41
|
-
* @param ttl Time to live in seconds
|
|
42
|
-
*/
|
|
43
|
-
set<T>(key: string, value: T, ttl?: number): Promise<boolean>;
|
|
44
|
-
/**
|
|
45
|
-
* Delete a value from cache.
|
|
46
|
-
*/
|
|
47
|
-
del(key: string): Promise<boolean>;
|
|
48
|
-
/**
|
|
49
|
-
* Check if key exists.
|
|
50
|
-
*/
|
|
51
|
-
has(key: string): Promise<boolean>;
|
|
52
|
-
/**
|
|
53
|
-
* Clear all cached values.
|
|
54
|
-
*/
|
|
55
|
-
clear(): Promise<void>;
|
|
56
|
-
/**
|
|
57
|
-
* Get value from cache or compute and store it.
|
|
58
|
-
* This is the cache-aside pattern - most commonly used method.
|
|
59
|
-
*
|
|
60
|
-
* @param key Cache key
|
|
61
|
-
* @param cb Callback to compute value if not cached
|
|
62
|
-
* @param ttl Time to live in seconds
|
|
63
|
-
*/
|
|
64
|
-
getOrSet<T>(key: string, cb: () => Promise<T>, ttl?: number): Promise<T>;
|
|
65
|
-
/**
|
|
66
|
-
* Get multiple values at once.
|
|
67
|
-
*/
|
|
68
|
-
getMany<T>(keys: string[]): Promise<(T | null)[]>;
|
|
69
|
-
/**
|
|
70
|
-
* Set multiple values at once.
|
|
71
|
-
*/
|
|
72
|
-
setMany<T>(entries: Array<{
|
|
73
|
-
key: string;
|
|
74
|
-
value: T;
|
|
75
|
-
ttl?: number;
|
|
76
|
-
}>): Promise<boolean[]>;
|
|
77
|
-
/**
|
|
78
|
-
* Delete multiple values at once.
|
|
79
|
-
*/
|
|
80
|
-
delMany(keys: string[]): Promise<boolean[]>;
|
|
81
|
-
/**
|
|
82
|
-
* Close the cache driver connection.
|
|
83
|
-
*/
|
|
84
|
-
close(): Promise<void>;
|
|
85
|
-
/**
|
|
86
|
-
* Get the underlying driver (for advanced use).
|
|
87
|
-
*/
|
|
88
|
-
getDriver(): CacheDriver;
|
|
89
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import type { CacheDriver } from './CacheDriver';
|
|
2
|
-
/**
|
|
3
|
-
* In-Memory Cache Driver.
|
|
4
|
-
* Ultra-fast, perfect for single-instance applications.
|
|
5
|
-
*
|
|
6
|
-
* Features:
|
|
7
|
-
* - O(1) get/set/del operations
|
|
8
|
-
* - Lazy expiration (checked on access)
|
|
9
|
-
* - Periodic cleanup of expired entries
|
|
10
|
-
*/
|
|
11
|
-
export declare class MemoryDriver implements CacheDriver {
|
|
12
|
-
readonly name = "MemoryDriver";
|
|
13
|
-
private cache;
|
|
14
|
-
private cleanupInterval;
|
|
15
|
-
constructor(cleanupIntervalMs?: number);
|
|
16
|
-
get<T>(key: string): Promise<T | null>;
|
|
17
|
-
set<T>(key: string, value: T, ttl?: number): Promise<boolean>;
|
|
18
|
-
del(key: string): Promise<boolean>;
|
|
19
|
-
has(key: string): Promise<boolean>;
|
|
20
|
-
clear(): Promise<void>;
|
|
21
|
-
close(): Promise<void>;
|
|
22
|
-
/**
|
|
23
|
-
* Remove expired entries.
|
|
24
|
-
*/
|
|
25
|
-
private cleanup;
|
|
26
|
-
/**
|
|
27
|
-
* Get cache stats (for debugging).
|
|
28
|
-
*/
|
|
29
|
-
stats(): {
|
|
30
|
-
size: number;
|
|
31
|
-
};
|
|
32
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import type { CacheDriver } from './CacheDriver';
|
|
2
|
-
/**
|
|
3
|
-
* Redis Cache Driver Configuration.
|
|
4
|
-
*/
|
|
5
|
-
export interface RedisConfig {
|
|
6
|
-
host?: string;
|
|
7
|
-
port?: number;
|
|
8
|
-
password?: string;
|
|
9
|
-
db?: number;
|
|
10
|
-
url?: string;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Redis Cache Driver.
|
|
14
|
-
* For distributed caching in multi-instance deployments.
|
|
15
|
-
*
|
|
16
|
-
* Uses Bun's native Redis client for maximum performance.
|
|
17
|
-
*/
|
|
18
|
-
export declare class RedisDriver implements CacheDriver {
|
|
19
|
-
private config;
|
|
20
|
-
readonly name = "RedisDriver";
|
|
21
|
-
private client;
|
|
22
|
-
private connected;
|
|
23
|
-
constructor(config?: RedisConfig);
|
|
24
|
-
/**
|
|
25
|
-
* Connect to Redis (lazy - connects on first use).
|
|
26
|
-
*/
|
|
27
|
-
private ensureConnected;
|
|
28
|
-
get<T>(key: string): Promise<T | null>;
|
|
29
|
-
set<T>(key: string, value: T, ttl?: number): Promise<boolean>;
|
|
30
|
-
del(key: string): Promise<boolean>;
|
|
31
|
-
has(key: string): Promise<boolean>;
|
|
32
|
-
clear(): Promise<void>;
|
|
33
|
-
close(): Promise<void>;
|
|
34
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* JIT Compiler for Turbo.
|
|
3
|
-
*
|
|
4
|
-
* Aggressive AOT optimizations:
|
|
5
|
-
* - Detects async at compile time (not runtime)
|
|
6
|
-
* - Generates specialized handlers via new Function()
|
|
7
|
-
* - Inlines parameter access
|
|
8
|
-
* - Zero overhead for simple handlers
|
|
9
|
-
*/
|
|
10
|
-
import type { ParamType } from '../decorators/params';
|
|
11
|
-
export interface ParamInfo {
|
|
12
|
-
type: ParamType;
|
|
13
|
-
key?: string;
|
|
14
|
-
index: number;
|
|
15
|
-
}
|
|
16
|
-
export interface CompiledHandler {
|
|
17
|
-
fn: Function;
|
|
18
|
-
isAsync: boolean;
|
|
19
|
-
isStatic: boolean;
|
|
20
|
-
staticValue?: any;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Detects if function is async at compile time.
|
|
24
|
-
* Checks: async keyword, await usage, generators, .then()
|
|
25
|
-
*/
|
|
26
|
-
export declare function isAsyncFunction(fn: Function): boolean;
|
|
27
|
-
/**
|
|
28
|
-
* Detects if handler returns a static value.
|
|
29
|
-
* Static handlers can be pre-computed at startup.
|
|
30
|
-
*/
|
|
31
|
-
export declare function isStaticHandler(fn: Function): boolean;
|
|
32
|
-
/**
|
|
33
|
-
* Compiles handler with inlined parameter access.
|
|
34
|
-
* Uses new Function() for maximum V8 optimization.
|
|
35
|
-
*/
|
|
36
|
-
export declare function compileHandler(instance: any, methodName: string, params: ParamInfo[]): CompiledHandler;
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Lightweight DI Container for Turbo.
|
|
3
|
-
*
|
|
4
|
-
* Features:
|
|
5
|
-
* - Constructor injection via reflect-metadata
|
|
6
|
-
* - Singleton scope by default
|
|
7
|
-
* - Request scope support
|
|
8
|
-
* - Lazy instantiation
|
|
9
|
-
*/
|
|
10
|
-
export type Token<T = any> = new (...args: any[]) => T;
|
|
11
|
-
export declare enum Scope {
|
|
12
|
-
SINGLETON = "singleton",// Always the same instance
|
|
13
|
-
REQUEST = "request",// New instance per request
|
|
14
|
-
INSTANCE = "instance"
|
|
15
|
-
}
|
|
16
|
-
export interface ProviderConfig<T = any> {
|
|
17
|
-
token: Token<T>;
|
|
18
|
-
useClass?: Token<T>;
|
|
19
|
-
useValue?: T;
|
|
20
|
-
scope?: Scope;
|
|
21
|
-
}
|
|
22
|
-
export declare class Container {
|
|
23
|
-
private configs;
|
|
24
|
-
private instances;
|
|
25
|
-
private resolving;
|
|
26
|
-
register<T>(config: ProviderConfig<T> | Token<T>): this;
|
|
27
|
-
get<T>(token: Token<T>): T;
|
|
28
|
-
has(token: Token): boolean;
|
|
29
|
-
/**
|
|
30
|
-
* Resolves a token to return instance and its effective scope.
|
|
31
|
-
*/
|
|
32
|
-
private resolveInternal;
|
|
33
|
-
private createInstance;
|
|
34
|
-
private getDependencies;
|
|
35
|
-
private isPrimitive;
|
|
36
|
-
private normalizeConfig;
|
|
37
|
-
clear(): void;
|
|
38
|
-
}
|