@cosmneo/onion-lasagna 0.1.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/dist/backend/core/global.cjs +283 -0
- package/dist/backend/core/global.cjs.map +1 -0
- package/dist/backend/core/global.d.cts +294 -0
- package/dist/backend/core/global.d.ts +294 -0
- package/dist/backend/core/global.js +39 -0
- package/dist/backend/core/global.js.map +1 -0
- package/dist/backend/core/onion-layers.cjs +2302 -0
- package/dist/backend/core/onion-layers.cjs.map +1 -0
- package/dist/backend/core/onion-layers.d.cts +1675 -0
- package/dist/backend/core/onion-layers.d.ts +1675 -0
- package/dist/backend/core/onion-layers.js +1158 -0
- package/dist/backend/core/onion-layers.js.map +1 -0
- package/dist/backend/core/presentation.cjs +573 -0
- package/dist/backend/core/presentation.cjs.map +1 -0
- package/dist/backend/core/presentation.d.cts +5 -0
- package/dist/backend/core/presentation.d.ts +5 -0
- package/dist/backend/core/presentation.js +28 -0
- package/dist/backend/core/presentation.js.map +1 -0
- package/dist/backend/core/validators/arktype.cjs +947 -0
- package/dist/backend/core/validators/arktype.cjs.map +1 -0
- package/dist/backend/core/validators/arktype.d.cts +188 -0
- package/dist/backend/core/validators/arktype.d.ts +188 -0
- package/dist/backend/core/validators/arktype.js +287 -0
- package/dist/backend/core/validators/arktype.js.map +1 -0
- package/dist/backend/core/validators/typebox.cjs +939 -0
- package/dist/backend/core/validators/typebox.cjs.map +1 -0
- package/dist/backend/core/validators/typebox.d.cts +189 -0
- package/dist/backend/core/validators/typebox.d.ts +189 -0
- package/dist/backend/core/validators/typebox.js +281 -0
- package/dist/backend/core/validators/typebox.js.map +1 -0
- package/dist/backend/core/validators/valibot.cjs +942 -0
- package/dist/backend/core/validators/valibot.cjs.map +1 -0
- package/dist/backend/core/validators/valibot.d.cts +160 -0
- package/dist/backend/core/validators/valibot.d.ts +160 -0
- package/dist/backend/core/validators/valibot.js +294 -0
- package/dist/backend/core/validators/valibot.js.map +1 -0
- package/dist/backend/core/validators/zod.cjs +934 -0
- package/dist/backend/core/validators/zod.cjs.map +1 -0
- package/dist/backend/core/validators/zod.d.cts +188 -0
- package/dist/backend/core/validators/zod.d.ts +188 -0
- package/dist/backend/core/validators/zod.js +278 -0
- package/dist/backend/core/validators/zod.js.map +1 -0
- package/dist/backend/frameworks/elysia.cjs +715 -0
- package/dist/backend/frameworks/elysia.cjs.map +1 -0
- package/dist/backend/frameworks/elysia.d.cts +208 -0
- package/dist/backend/frameworks/elysia.d.ts +208 -0
- package/dist/backend/frameworks/elysia.js +251 -0
- package/dist/backend/frameworks/elysia.js.map +1 -0
- package/dist/backend/frameworks/fastify.cjs +677 -0
- package/dist/backend/frameworks/fastify.cjs.map +1 -0
- package/dist/backend/frameworks/fastify.d.cts +201 -0
- package/dist/backend/frameworks/fastify.d.ts +201 -0
- package/dist/backend/frameworks/fastify.js +213 -0
- package/dist/backend/frameworks/fastify.js.map +1 -0
- package/dist/backend/frameworks/hono.cjs +715 -0
- package/dist/backend/frameworks/hono.cjs.map +1 -0
- package/dist/backend/frameworks/hono.d.cts +163 -0
- package/dist/backend/frameworks/hono.d.ts +163 -0
- package/dist/backend/frameworks/hono.js +249 -0
- package/dist/backend/frameworks/hono.js.map +1 -0
- package/dist/backend/frameworks/nestjs.cjs +260 -0
- package/dist/backend/frameworks/nestjs.cjs.map +1 -0
- package/dist/backend/frameworks/nestjs.d.cts +168 -0
- package/dist/backend/frameworks/nestjs.d.ts +168 -0
- package/dist/backend/frameworks/nestjs.js +193 -0
- package/dist/backend/frameworks/nestjs.js.map +1 -0
- package/dist/base-dto.class-D7W9iqoU.d.cts +146 -0
- package/dist/base-dto.class-D7W9iqoU.d.ts +146 -0
- package/dist/base-uuid-v7.vo-BPGEIWLM.d.ts +799 -0
- package/dist/base-uuid-v7.vo-BjqKX44G.d.cts +799 -0
- package/dist/chunk-74IKUOSE.js +116 -0
- package/dist/chunk-74IKUOSE.js.map +1 -0
- package/dist/chunk-BKZOLGQW.js +29 -0
- package/dist/chunk-BKZOLGQW.js.map +1 -0
- package/dist/chunk-CGZBV6BD.js +54 -0
- package/dist/chunk-CGZBV6BD.js.map +1 -0
- package/dist/chunk-DDAHJZVK.js +258 -0
- package/dist/chunk-DDAHJZVK.js.map +1 -0
- package/dist/chunk-MQD5GXMT.js +171 -0
- package/dist/chunk-MQD5GXMT.js.map +1 -0
- package/dist/chunk-OKFXZHBC.js +43 -0
- package/dist/chunk-OKFXZHBC.js.map +1 -0
- package/dist/chunk-RLLWYFPI.js +168 -0
- package/dist/chunk-RLLWYFPI.js.map +1 -0
- package/dist/chunk-VCHFXT5W.js +425 -0
- package/dist/chunk-VCHFXT5W.js.map +1 -0
- package/dist/chunk-ZWLYNGO3.js +40 -0
- package/dist/chunk-ZWLYNGO3.js.map +1 -0
- package/dist/http-response-BAhi8lF4.d.cts +124 -0
- package/dist/http-response-BAhi8lF4.d.ts +124 -0
- package/dist/index-DingXh7B.d.cts +1187 -0
- package/dist/index-tOH7XBa3.d.ts +1187 -0
- package/dist/routing.type-DB4pt-d9.d.ts +184 -0
- package/dist/routing.type-DF2BIL7x.d.cts +184 -0
- package/dist/validation-error.type-kD4_qNZ9.d.cts +199 -0
- package/dist/validation-error.type-kD4_qNZ9.d.ts +199 -0
- package/package.json +191 -0
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base controller interface for the presentation layer.
|
|
3
|
+
*
|
|
4
|
+
* All controllers must implement this interface. The {@link BaseController} class
|
|
5
|
+
* provides a standard request/response pipeline implementation.
|
|
6
|
+
*
|
|
7
|
+
* @typeParam TInput - The input type the controller accepts
|
|
8
|
+
* @typeParam TOutput - The output type the controller returns
|
|
9
|
+
*
|
|
10
|
+
* @example Using BaseController (recommended)
|
|
11
|
+
* ```typescript
|
|
12
|
+
* const controller = BaseController.create({
|
|
13
|
+
* requestMapper: (req) => CreateUserInputDto.create(req.body),
|
|
14
|
+
* useCase: createUserUseCase,
|
|
15
|
+
* responseMapper: (output) => ({ statusCode: 201, body: output.value }),
|
|
16
|
+
* });
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* @example Custom implementation
|
|
20
|
+
* ```typescript
|
|
21
|
+
* class MyController implements Controller<MyInput, MyOutput> {
|
|
22
|
+
* async execute(input: MyInput): Promise<MyOutput> {
|
|
23
|
+
* // custom logic
|
|
24
|
+
* }
|
|
25
|
+
* }
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
interface Controller<TInput = unknown, TOutput = unknown> {
|
|
29
|
+
/**
|
|
30
|
+
* Executes the controller with the given input.
|
|
31
|
+
*
|
|
32
|
+
* @param input - The input to process
|
|
33
|
+
* @returns Promise resolving to the output
|
|
34
|
+
*/
|
|
35
|
+
execute(input: TInput): Promise<TOutput>;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Basic HTTP request structure for any HTTP-based framework.
|
|
40
|
+
*
|
|
41
|
+
* This is the foundation type representing the data extracted from an HTTP request.
|
|
42
|
+
* Frameworks (AWS API Gateway, Cloudflare Workers, Express, etc.) map their native
|
|
43
|
+
* request types to this common interface.
|
|
44
|
+
*
|
|
45
|
+
* @example Complete request
|
|
46
|
+
* ```typescript
|
|
47
|
+
* const request: HttpRequest = {
|
|
48
|
+
* body: { name: 'John', email: 'john@example.com' },
|
|
49
|
+
* headers: { 'content-type': 'application/json', 'authorization': 'Bearer ...' },
|
|
50
|
+
* pathParams: { id: '123' },
|
|
51
|
+
* queryParams: { include: 'profile' },
|
|
52
|
+
* };
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
interface HttpRequest {
|
|
56
|
+
/**
|
|
57
|
+
* Parsed request body.
|
|
58
|
+
* For JSON requests, this is the deserialized object.
|
|
59
|
+
* For form data, this contains the parsed form fields.
|
|
60
|
+
*/
|
|
61
|
+
body?: unknown;
|
|
62
|
+
/**
|
|
63
|
+
* HTTP request headers (normalized to lowercase keys).
|
|
64
|
+
* Common headers include authorization, content-type, accept, etc.
|
|
65
|
+
*/
|
|
66
|
+
headers?: Record<string, string>;
|
|
67
|
+
/**
|
|
68
|
+
* Query string parameters from the URL.
|
|
69
|
+
* For `/users?page=1&limit=10`, this would be `{ page: '1', limit: '10' }`.
|
|
70
|
+
* When a key appears multiple times (e.g., `?tag=a&tag=b`), the value is an array.
|
|
71
|
+
*/
|
|
72
|
+
queryParams?: Record<string, string | string[]>;
|
|
73
|
+
/**
|
|
74
|
+
* Path parameters extracted from the URL pattern.
|
|
75
|
+
* For route `/users/:id` and URL `/users/123`, this would be `{ id: '123' }`.
|
|
76
|
+
*/
|
|
77
|
+
pathParams?: Record<string, string>;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Basic HTTP response structure for any HTTP-based framework.
|
|
82
|
+
*
|
|
83
|
+
* This is the foundation type representing the data to send as an HTTP response.
|
|
84
|
+
* Frameworks (AWS API Gateway, Cloudflare Workers, Express, etc.) map this common
|
|
85
|
+
* interface to their native response types.
|
|
86
|
+
*
|
|
87
|
+
* @example Success response
|
|
88
|
+
* ```typescript
|
|
89
|
+
* const response: HttpResponse = {
|
|
90
|
+
* statusCode: 200,
|
|
91
|
+
* body: { id: '123', name: 'John' },
|
|
92
|
+
* };
|
|
93
|
+
* ```
|
|
94
|
+
*
|
|
95
|
+
* @example Response with headers
|
|
96
|
+
* ```typescript
|
|
97
|
+
* const response: HttpResponse = {
|
|
98
|
+
* statusCode: 201,
|
|
99
|
+
* headers: {
|
|
100
|
+
* 'Location': '/users/123',
|
|
101
|
+
* 'X-Request-Id': 'req-abc',
|
|
102
|
+
* },
|
|
103
|
+
* body: { id: '123' },
|
|
104
|
+
* };
|
|
105
|
+
* ```
|
|
106
|
+
*/
|
|
107
|
+
interface HttpResponse {
|
|
108
|
+
/**
|
|
109
|
+
* HTTP status code (e.g., 200, 201, 400, 404, 500).
|
|
110
|
+
*/
|
|
111
|
+
statusCode: number;
|
|
112
|
+
/**
|
|
113
|
+
* Optional response headers.
|
|
114
|
+
* Common headers include Content-Type, Location, Cache-Control, etc.
|
|
115
|
+
*/
|
|
116
|
+
headers?: Record<string, unknown>;
|
|
117
|
+
/**
|
|
118
|
+
* Optional response body.
|
|
119
|
+
* Will be serialized to JSON by framework adapters if it's an object.
|
|
120
|
+
*/
|
|
121
|
+
body?: unknown;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export type { Controller as C, HttpRequest as H, HttpResponse as a };
|