@carno.js/core 1.1.1 → 1.2.0
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 +45 -26
- package/dist/Carno.mjs +45 -26
- package/dist/bun/index.js +4 -4
- package/dist/bun/index.js.map +30 -29
- package/dist/compression/CompressionMiddleware.js +110 -0
- package/dist/compression/CompressionMiddleware.mjs +90 -0
- package/dist/index.js +3 -1
- package/dist/index.mjs +2 -0
- package/package.json +2 -2
- package/src/Carno.ts +728 -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/compression/CompressionMiddleware.ts +221 -0
- 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 +99 -95
- package/src/metadata.ts +46 -46
- package/src/middleware/CarnoMiddleware.ts +20 -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
|
@@ -1,99 +1,99 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Base HTTP Exception class.
|
|
3
|
-
* Throw this from handlers to return custom HTTP error responses.
|
|
4
|
-
*/
|
|
5
|
-
export class HttpException extends Error {
|
|
6
|
-
constructor(
|
|
7
|
-
public readonly statusCode: number,
|
|
8
|
-
message: string,
|
|
9
|
-
public readonly errors?: any[]
|
|
10
|
-
) {
|
|
11
|
-
super(message);
|
|
12
|
-
this.name = 'HttpException';
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Convert exception to Response.
|
|
17
|
-
*/
|
|
18
|
-
toResponse(): Response {
|
|
19
|
-
const body = {
|
|
20
|
-
statusCode: this.statusCode,
|
|
21
|
-
message: this.message,
|
|
22
|
-
...(this.errors && { errors: this.errors })
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
return Response.json(body, { status: this.statusCode });
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// Common HTTP Exceptions
|
|
30
|
-
|
|
31
|
-
export class BadRequestException extends HttpException {
|
|
32
|
-
constructor(message: string = 'Bad Request', errors?: any[]) {
|
|
33
|
-
super(400, message, errors);
|
|
34
|
-
this.name = 'BadRequestException';
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export class UnauthorizedException extends HttpException {
|
|
39
|
-
constructor(message: string = 'Unauthorized') {
|
|
40
|
-
super(401, message);
|
|
41
|
-
this.name = 'UnauthorizedException';
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export class ForbiddenException extends HttpException {
|
|
46
|
-
constructor(message: string = 'Forbidden') {
|
|
47
|
-
super(403, message);
|
|
48
|
-
this.name = 'ForbiddenException';
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export class NotFoundException extends HttpException {
|
|
53
|
-
constructor(message: string = 'Not Found') {
|
|
54
|
-
super(404, message);
|
|
55
|
-
this.name = 'NotFoundException';
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export class MethodNotAllowedException extends HttpException {
|
|
60
|
-
constructor(message: string = 'Method Not Allowed') {
|
|
61
|
-
super(405, message);
|
|
62
|
-
this.name = 'MethodNotAllowedException';
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export class ConflictException extends HttpException {
|
|
67
|
-
constructor(message: string = 'Conflict') {
|
|
68
|
-
super(409, message);
|
|
69
|
-
this.name = 'ConflictException';
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export class UnprocessableEntityException extends HttpException {
|
|
74
|
-
constructor(message: string = 'Unprocessable Entity', errors?: any[]) {
|
|
75
|
-
super(422, message, errors);
|
|
76
|
-
this.name = 'UnprocessableEntityException';
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
export class TooManyRequestsException extends HttpException {
|
|
81
|
-
constructor(message: string = 'Too Many Requests') {
|
|
82
|
-
super(429, message);
|
|
83
|
-
this.name = 'TooManyRequestsException';
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
export class InternalServerErrorException extends HttpException {
|
|
88
|
-
constructor(message: string = 'Internal Server Error') {
|
|
89
|
-
super(500, message);
|
|
90
|
-
this.name = 'InternalServerErrorException';
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
export class ServiceUnavailableException extends HttpException {
|
|
95
|
-
constructor(message: string = 'Service Unavailable') {
|
|
96
|
-
super(503, message);
|
|
97
|
-
this.name = 'ServiceUnavailableException';
|
|
98
|
-
}
|
|
99
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Base HTTP Exception class.
|
|
3
|
+
* Throw this from handlers to return custom HTTP error responses.
|
|
4
|
+
*/
|
|
5
|
+
export class HttpException extends Error {
|
|
6
|
+
constructor(
|
|
7
|
+
public readonly statusCode: number,
|
|
8
|
+
message: string,
|
|
9
|
+
public readonly errors?: any[]
|
|
10
|
+
) {
|
|
11
|
+
super(message);
|
|
12
|
+
this.name = 'HttpException';
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Convert exception to Response.
|
|
17
|
+
*/
|
|
18
|
+
toResponse(): Response {
|
|
19
|
+
const body = {
|
|
20
|
+
statusCode: this.statusCode,
|
|
21
|
+
message: this.message,
|
|
22
|
+
...(this.errors && { errors: this.errors })
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
return Response.json(body, { status: this.statusCode });
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Common HTTP Exceptions
|
|
30
|
+
|
|
31
|
+
export class BadRequestException extends HttpException {
|
|
32
|
+
constructor(message: string = 'Bad Request', errors?: any[]) {
|
|
33
|
+
super(400, message, errors);
|
|
34
|
+
this.name = 'BadRequestException';
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export class UnauthorizedException extends HttpException {
|
|
39
|
+
constructor(message: string = 'Unauthorized') {
|
|
40
|
+
super(401, message);
|
|
41
|
+
this.name = 'UnauthorizedException';
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export class ForbiddenException extends HttpException {
|
|
46
|
+
constructor(message: string = 'Forbidden') {
|
|
47
|
+
super(403, message);
|
|
48
|
+
this.name = 'ForbiddenException';
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export class NotFoundException extends HttpException {
|
|
53
|
+
constructor(message: string = 'Not Found') {
|
|
54
|
+
super(404, message);
|
|
55
|
+
this.name = 'NotFoundException';
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export class MethodNotAllowedException extends HttpException {
|
|
60
|
+
constructor(message: string = 'Method Not Allowed') {
|
|
61
|
+
super(405, message);
|
|
62
|
+
this.name = 'MethodNotAllowedException';
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export class ConflictException extends HttpException {
|
|
67
|
+
constructor(message: string = 'Conflict') {
|
|
68
|
+
super(409, message);
|
|
69
|
+
this.name = 'ConflictException';
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export class UnprocessableEntityException extends HttpException {
|
|
74
|
+
constructor(message: string = 'Unprocessable Entity', errors?: any[]) {
|
|
75
|
+
super(422, message, errors);
|
|
76
|
+
this.name = 'UnprocessableEntityException';
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export class TooManyRequestsException extends HttpException {
|
|
81
|
+
constructor(message: string = 'Too Many Requests') {
|
|
82
|
+
super(429, message);
|
|
83
|
+
this.name = 'TooManyRequestsException';
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export class InternalServerErrorException extends HttpException {
|
|
88
|
+
constructor(message: string = 'Internal Server Error') {
|
|
89
|
+
super(500, message);
|
|
90
|
+
this.name = 'InternalServerErrorException';
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export class ServiceUnavailableException extends HttpException {
|
|
95
|
+
constructor(message: string = 'Service Unavailable') {
|
|
96
|
+
super(503, message);
|
|
97
|
+
this.name = 'ServiceUnavailableException';
|
|
98
|
+
}
|
|
99
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,95 +1,99 @@
|
|
|
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
|
-
|
|
12
|
-
// Import reflect-metadata globally for decorator support
|
|
13
|
-
import 'reflect-metadata';
|
|
14
|
-
|
|
15
|
-
// Application
|
|
16
|
-
export { Carno } from './Carno';
|
|
17
|
-
export type { MiddlewareHandler, CarnoConfig } from './Carno';
|
|
18
|
-
|
|
19
|
-
// Context
|
|
20
|
-
export { Context } from './context/Context';
|
|
21
|
-
|
|
22
|
-
// Decorators - Controller
|
|
23
|
-
export { Controller } from './decorators/Controller';
|
|
24
|
-
export type { ControllerOptions } from './metadata';
|
|
25
|
-
|
|
26
|
-
// Decorators - HTTP Methods
|
|
27
|
-
export { Get, Post, Put, Delete, Patch, Head, Options } from './decorators/methods';
|
|
28
|
-
|
|
29
|
-
// Decorators - Parameters
|
|
30
|
-
export { Param, Query, Body, Header, Req, Ctx, Locals } from './decorators/params';
|
|
31
|
-
|
|
32
|
-
// Decorators - Middleware
|
|
33
|
-
export { Use, Use as Middleware } from './decorators/Middleware';
|
|
34
|
-
|
|
35
|
-
// Middleware Interface
|
|
36
|
-
export type { CarnoMiddleware, CarnoClosure } from './middleware/CarnoMiddleware';
|
|
37
|
-
|
|
38
|
-
// Decorators - DI
|
|
39
|
-
export { Service } from './decorators/Service';
|
|
40
|
-
export { Inject } from './decorators/Inject';
|
|
41
|
-
|
|
42
|
-
// Container
|
|
43
|
-
export { Container, Scope } from './container/Container';
|
|
44
|
-
export type { Token, ProviderConfig } from './container/Container';
|
|
45
|
-
|
|
46
|
-
// Router
|
|
47
|
-
export { RadixRouter } from './router/RadixRouter';
|
|
48
|
-
export type { RouteMatch } from './router/RadixRouter';
|
|
49
|
-
|
|
50
|
-
// CORS
|
|
51
|
-
export { CorsHandler } from './cors/CorsHandler';
|
|
52
|
-
export type { CorsConfig, CorsOrigin } from './cors/CorsHandler';
|
|
53
|
-
|
|
54
|
-
//
|
|
55
|
-
export
|
|
56
|
-
export {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
export {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
export
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
export {
|
|
92
|
-
export type {
|
|
93
|
-
|
|
94
|
-
//
|
|
95
|
-
export {
|
|
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
|
+
|
|
12
|
+
// Import reflect-metadata globally for decorator support
|
|
13
|
+
import 'reflect-metadata';
|
|
14
|
+
|
|
15
|
+
// Application
|
|
16
|
+
export { Carno } from './Carno';
|
|
17
|
+
export type { MiddlewareHandler, MiddlewareClass, MiddlewareEntry, CarnoConfig } from './Carno';
|
|
18
|
+
|
|
19
|
+
// Context
|
|
20
|
+
export { Context } from './context/Context';
|
|
21
|
+
|
|
22
|
+
// Decorators - Controller
|
|
23
|
+
export { Controller } from './decorators/Controller';
|
|
24
|
+
export type { ControllerOptions } from './metadata';
|
|
25
|
+
|
|
26
|
+
// Decorators - HTTP Methods
|
|
27
|
+
export { Get, Post, Put, Delete, Patch, Head, Options } from './decorators/methods';
|
|
28
|
+
|
|
29
|
+
// Decorators - Parameters
|
|
30
|
+
export { Param, Query, Body, Header, Req, Ctx, Locals } from './decorators/params';
|
|
31
|
+
|
|
32
|
+
// Decorators - Middleware
|
|
33
|
+
export { Use, Use as Middleware } from './decorators/Middleware';
|
|
34
|
+
|
|
35
|
+
// Middleware Interface
|
|
36
|
+
export type { CarnoMiddleware, CarnoClosure } from './middleware/CarnoMiddleware';
|
|
37
|
+
|
|
38
|
+
// Decorators - DI
|
|
39
|
+
export { Service } from './decorators/Service';
|
|
40
|
+
export { Inject } from './decorators/Inject';
|
|
41
|
+
|
|
42
|
+
// Container
|
|
43
|
+
export { Container, Scope } from './container/Container';
|
|
44
|
+
export type { Token, ProviderConfig } from './container/Container';
|
|
45
|
+
|
|
46
|
+
// Router
|
|
47
|
+
export { RadixRouter } from './router/RadixRouter';
|
|
48
|
+
export type { RouteMatch } from './router/RadixRouter';
|
|
49
|
+
|
|
50
|
+
// CORS
|
|
51
|
+
export { CorsHandler } from './cors/CorsHandler';
|
|
52
|
+
export type { CorsConfig, CorsOrigin } from './cors/CorsHandler';
|
|
53
|
+
|
|
54
|
+
// Compression
|
|
55
|
+
export { CompressionMiddleware } from './compression/CompressionMiddleware';
|
|
56
|
+
export type { CompressionConfig } from './compression/CompressionMiddleware';
|
|
57
|
+
|
|
58
|
+
// Validation
|
|
59
|
+
export type { ValidatorAdapter, ValidationResult, ValidationError, ValidationConfig } from './validation/ValidatorAdapter';
|
|
60
|
+
export { Schema, getSchema, VALIDATION_SCHEMA } from './validation/ValidatorAdapter';
|
|
61
|
+
export { ZodAdapter, ValidationException } from './validation/ZodAdapter';
|
|
62
|
+
export { ValibotAdapter } from './validation/ValibotAdapter';
|
|
63
|
+
|
|
64
|
+
// Exceptions
|
|
65
|
+
export {
|
|
66
|
+
HttpException,
|
|
67
|
+
BadRequestException,
|
|
68
|
+
UnauthorizedException,
|
|
69
|
+
ForbiddenException,
|
|
70
|
+
NotFoundException,
|
|
71
|
+
MethodNotAllowedException,
|
|
72
|
+
ConflictException,
|
|
73
|
+
UnprocessableEntityException,
|
|
74
|
+
TooManyRequestsException,
|
|
75
|
+
InternalServerErrorException,
|
|
76
|
+
ServiceUnavailableException
|
|
77
|
+
} from './exceptions/HttpException';
|
|
78
|
+
|
|
79
|
+
// Lifecycle Events
|
|
80
|
+
export {
|
|
81
|
+
EventType,
|
|
82
|
+
OnApplicationInit,
|
|
83
|
+
OnApplicationBoot,
|
|
84
|
+
OnApplicationShutdown
|
|
85
|
+
} from './events/Lifecycle';
|
|
86
|
+
|
|
87
|
+
// Cache
|
|
88
|
+
export { CacheService } from './cache/CacheService';
|
|
89
|
+
export { MemoryDriver } from './cache/MemoryDriver';
|
|
90
|
+
export { RedisDriver } from './cache/RedisDriver';
|
|
91
|
+
export type { RedisConfig } from './cache/RedisDriver';
|
|
92
|
+
export type { CacheDriver, CacheConfig } from './cache/CacheDriver';
|
|
93
|
+
|
|
94
|
+
// Testing
|
|
95
|
+
export { createTestHarness, withTestApp } from './testing/TestHarness';
|
|
96
|
+
export type { TestHarness, TestOptions } from './testing/TestHarness';
|
|
97
|
+
|
|
98
|
+
// Utils
|
|
99
|
+
export { Metadata, isObject, isString } from './utils/Metadata';
|
package/src/metadata.ts
CHANGED
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
import { Scope } from './container/Container';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Controller options for the @Controller decorator.
|
|
5
|
-
*/
|
|
6
|
-
export interface ControllerOptions {
|
|
7
|
-
path?: string;
|
|
8
|
-
scope?: Scope;
|
|
9
|
-
children?: any[];
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Controller metadata stored on controller classes.
|
|
14
|
-
*/
|
|
15
|
-
export interface ControllerMeta {
|
|
16
|
-
path: string;
|
|
17
|
-
scope?: Scope;
|
|
18
|
-
children?: any[];
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Route metadata stored on controllers.
|
|
23
|
-
*/
|
|
24
|
-
export interface RouteInfo {
|
|
25
|
-
method: 'get' | 'post' | 'put' | 'delete' | 'patch' | 'head' | 'options';
|
|
26
|
-
path: string;
|
|
27
|
-
handlerName: string;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Middleware metadata.
|
|
32
|
-
*/
|
|
33
|
-
export interface MiddlewareInfo {
|
|
34
|
-
handler: Function;
|
|
35
|
-
target?: string;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Metadata keys.
|
|
40
|
-
*/
|
|
41
|
-
export const CONTROLLER_META = Symbol('turbo:controller');
|
|
42
|
-
export const ROUTES_META = Symbol('turbo:routes');
|
|
43
|
-
export const PARAMS_META = Symbol('turbo:params');
|
|
44
|
-
export const MIDDLEWARE_META = Symbol('turbo:middleware');
|
|
45
|
-
export const SERVICE_META = Symbol('turbo:service');
|
|
46
|
-
export const INJECT_META = Symbol('turbo:inject');
|
|
1
|
+
import { Scope } from './container/Container';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Controller options for the @Controller decorator.
|
|
5
|
+
*/
|
|
6
|
+
export interface ControllerOptions {
|
|
7
|
+
path?: string;
|
|
8
|
+
scope?: Scope;
|
|
9
|
+
children?: any[];
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Controller metadata stored on controller classes.
|
|
14
|
+
*/
|
|
15
|
+
export interface ControllerMeta {
|
|
16
|
+
path: string;
|
|
17
|
+
scope?: Scope;
|
|
18
|
+
children?: any[];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Route metadata stored on controllers.
|
|
23
|
+
*/
|
|
24
|
+
export interface RouteInfo {
|
|
25
|
+
method: 'get' | 'post' | 'put' | 'delete' | 'patch' | 'head' | 'options';
|
|
26
|
+
path: string;
|
|
27
|
+
handlerName: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Middleware metadata.
|
|
32
|
+
*/
|
|
33
|
+
export interface MiddlewareInfo {
|
|
34
|
+
handler: Function;
|
|
35
|
+
target?: string;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Metadata keys.
|
|
40
|
+
*/
|
|
41
|
+
export const CONTROLLER_META = Symbol('turbo:controller');
|
|
42
|
+
export const ROUTES_META = Symbol('turbo:routes');
|
|
43
|
+
export const PARAMS_META = Symbol('turbo:params');
|
|
44
|
+
export const MIDDLEWARE_META = Symbol('turbo:middleware');
|
|
45
|
+
export const SERVICE_META = Symbol('turbo:service');
|
|
46
|
+
export const INJECT_META = Symbol('turbo:inject');
|
|
@@ -1,14 +1,20 @@
|
|
|
1
|
-
import type { Context } from '../context/Context';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Closure function to call the next middleware in the chain.
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
import type { Context } from '../context/Context';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Closure function to call the next middleware in the chain.
|
|
5
|
+
* Returns the Response produced by the next layer, allowing
|
|
6
|
+
* middlewares to inspect or transform it.
|
|
7
|
+
*/
|
|
8
|
+
export type CarnoClosure = () => Promise<Response>;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Interface for onion-style middleware.
|
|
12
|
+
* Middleware must call next() to continue the chain.
|
|
13
|
+
*
|
|
14
|
+
* Returning a Response from handle() replaces the response
|
|
15
|
+
* produced by the downstream chain (useful for response transformers
|
|
16
|
+
* like compression).
|
|
17
|
+
*/
|
|
18
|
+
export interface CarnoMiddleware {
|
|
19
|
+
handle(ctx: Context, next: CarnoClosure): void | Response | Promise<void | Response>;
|
|
20
|
+
}
|