glasswork 0.13.3 → 1.0.1
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/CHANGELOG.md +80 -0
- package/README.md +6 -2
- package/dist/auth/abilities.d.ts +9 -6
- package/dist/auth/abilities.d.ts.map +1 -1
- package/dist/auth/abilities.js +15 -19
- package/dist/auth/abilities.js.map +1 -1
- package/dist/auth/assert.d.ts +3 -3
- package/dist/auth/assert.d.ts.map +1 -1
- package/dist/auth/casl-bridge.d.ts +19 -0
- package/dist/auth/casl-bridge.d.ts.map +1 -0
- package/dist/auth/casl-bridge.js +29 -0
- package/dist/auth/casl-bridge.js.map +1 -0
- package/dist/auth/index.d.ts +1 -0
- package/dist/auth/index.d.ts.map +1 -1
- package/dist/auth/index.js +1 -0
- package/dist/auth/index.js.map +1 -1
- package/dist/auth/middleware.d.ts +3 -3
- package/dist/auth/middleware.d.ts.map +1 -1
- package/dist/auth/middleware.js +2 -2
- package/dist/auth/middleware.js.map +1 -1
- package/dist/auth/types.d.ts +2 -2
- package/dist/auth/types.d.ts.map +1 -1
- package/dist/config/index.d.ts +1 -1
- package/dist/config/index.js +1 -1
- package/dist/core/bootstrap.d.ts +0 -17
- package/dist/core/bootstrap.d.ts.map +1 -1
- package/dist/core/bootstrap.js +4 -240
- package/dist/core/bootstrap.js.map +1 -1
- package/dist/core/index.d.ts +19 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +15 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/lifecycle.d.ts +7 -0
- package/dist/core/lifecycle.d.ts.map +1 -0
- package/dist/core/lifecycle.js +28 -0
- package/dist/core/lifecycle.js.map +1 -0
- package/dist/core/module-graph.d.ts +21 -0
- package/dist/core/module-graph.d.ts.map +1 -0
- package/dist/core/module-graph.js +169 -0
- package/dist/core/module-graph.js.map +1 -0
- package/dist/core/route-factory.d.ts +20 -0
- package/dist/core/route-factory.d.ts.map +1 -0
- package/dist/core/route-factory.js +2 -0
- package/dist/core/route-factory.js.map +1 -0
- package/dist/core/types.d.ts +4 -14
- package/dist/core/types.d.ts.map +1 -1
- package/dist/email/compiler/compile-templates.d.ts +3 -8
- package/dist/email/compiler/compile-templates.d.ts.map +1 -1
- package/dist/email/compiler/compile-templates.js +3 -3
- package/dist/email/compiler/compile-templates.js.map +1 -1
- package/dist/email/compiler/compiler.d.ts +5 -2
- package/dist/email/compiler/compiler.d.ts.map +1 -1
- package/dist/email/compiler/compiler.js +2 -21
- package/dist/email/compiler/compiler.js.map +1 -1
- package/dist/email/transports/ses-transport.d.ts.map +1 -1
- package/dist/email/transports/ses-transport.js +11 -18
- package/dist/email/transports/ses-transport.js.map +1 -1
- package/dist/email/webhooks/handler-factory.d.ts +1 -1
- package/dist/email/webhooks/handler-factory.js +1 -1
- package/dist/email/webhooks/notification-parser.d.ts +1 -1
- package/dist/email/webhooks/notification-parser.js +1 -1
- package/dist/email/webhooks/signature-verification.d.ts +1 -1
- package/dist/email/webhooks/signature-verification.js +1 -1
- package/dist/email/webhooks/subscription-handler.d.ts +1 -1
- package/dist/email/webhooks/subscription-handler.js +1 -1
- package/dist/hono-context.d.ts +13 -0
- package/dist/hono-context.d.ts.map +1 -0
- package/dist/hono-context.js +2 -0
- package/dist/hono-context.js.map +1 -0
- package/dist/http/index.d.ts +18 -0
- package/dist/http/index.d.ts.map +1 -0
- package/dist/http/index.js +15 -0
- package/dist/http/index.js.map +1 -0
- package/dist/http/route-authorization.d.ts +9 -0
- package/dist/http/route-authorization.d.ts.map +1 -0
- package/dist/http/route-authorization.js +19 -0
- package/dist/http/route-authorization.js.map +1 -0
- package/dist/http/route-context.d.ts +8 -0
- package/dist/http/route-context.d.ts.map +1 -0
- package/dist/http/route-context.js +26 -0
- package/dist/http/route-context.js.map +1 -0
- package/dist/http/route-helpers.d.ts +6 -419
- package/dist/http/route-helpers.d.ts.map +1 -1
- package/dist/http/route-helpers.js +7 -462
- package/dist/http/route-helpers.js.map +1 -1
- package/dist/http/route-openapi-context.d.ts +27 -0
- package/dist/http/route-openapi-context.d.ts.map +1 -0
- package/dist/http/route-openapi-context.js +16 -0
- package/dist/http/route-openapi-context.js.map +1 -0
- package/dist/http/route-openapi.d.ts +5 -0
- package/dist/http/route-openapi.d.ts.map +1 -0
- package/dist/http/route-openapi.js +112 -0
- package/dist/http/route-openapi.js.map +1 -0
- package/dist/http/route-response.d.ts +5 -0
- package/dist/http/route-response.d.ts.map +1 -0
- package/dist/http/route-response.js +78 -0
- package/dist/http/route-response.js.map +1 -0
- package/dist/http/route-types.d.ts +93 -0
- package/dist/http/route-types.d.ts.map +1 -0
- package/dist/http/route-types.js +22 -0
- package/dist/http/route-types.js.map +1 -0
- package/dist/http/route-validation.d.ts +11 -0
- package/dist/http/route-validation.d.ts.map +1 -0
- package/dist/http/route-validation.js +24 -0
- package/dist/http/route-validation.js.map +1 -0
- package/dist/index.d.ts +7 -45
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -65
- package/dist/index.js.map +1 -1
- package/dist/jobs/drivers/eventbridge-scheduler-driver.d.ts.map +1 -1
- package/dist/jobs/drivers/eventbridge-scheduler-driver.js +1 -3
- package/dist/jobs/drivers/eventbridge-scheduler-driver.js.map +1 -1
- package/dist/jobs/drivers/sqs-driver.d.ts +1 -1
- package/dist/jobs/drivers/sqs-driver.d.ts.map +1 -1
- package/dist/jobs/drivers/sqs-driver.js +1 -3
- package/dist/jobs/drivers/sqs-driver.js.map +1 -1
- package/dist/jobs/worker.d.ts.map +1 -1
- package/dist/jobs/worker.js +3 -14
- package/dist/jobs/worker.js.map +1 -1
- package/dist/list-query/builder.d.ts +26 -5
- package/dist/list-query/builder.d.ts.map +1 -1
- package/dist/list-query/builder.js +18 -10
- package/dist/list-query/builder.js.map +1 -1
- package/dist/list-query/casl.d.ts +20 -4
- package/dist/list-query/casl.d.ts.map +1 -1
- package/dist/list-query/casl.js +3 -12
- package/dist/list-query/casl.js.map +1 -1
- package/dist/list-query/filter-value-schemas.d.ts +16 -0
- package/dist/list-query/filter-value-schemas.d.ts.map +1 -0
- package/dist/list-query/filter-value-schemas.js +46 -0
- package/dist/list-query/filter-value-schemas.js.map +1 -0
- package/dist/list-query/index.d.ts +7 -1
- package/dist/list-query/index.d.ts.map +1 -1
- package/dist/list-query/index.js +6 -2
- package/dist/list-query/index.js.map +1 -1
- package/dist/list-query/list-params.d.ts +17 -0
- package/dist/list-query/list-params.d.ts.map +1 -0
- package/dist/list-query/list-params.js +2 -0
- package/dist/list-query/list-params.js.map +1 -0
- package/dist/list-query/parse-filter-values.d.ts +21 -0
- package/dist/list-query/parse-filter-values.d.ts.map +1 -0
- package/dist/list-query/parse-filter-values.js +177 -0
- package/dist/list-query/parse-filter-values.js.map +1 -0
- package/dist/list-query/prisma-builder.d.ts.map +1 -1
- package/dist/list-query/prisma-builder.js +3 -50
- package/dist/list-query/prisma-builder.js.map +1 -1
- package/dist/list-query/prisma-executor.d.ts +63 -0
- package/dist/list-query/prisma-executor.d.ts.map +1 -0
- package/dist/list-query/prisma-executor.js +88 -0
- package/dist/list-query/prisma-executor.js.map +1 -0
- package/dist/list-query/schema-helpers.d.ts +37 -17
- package/dist/list-query/schema-helpers.d.ts.map +1 -1
- package/dist/list-query/schema-helpers.js +87 -24
- package/dist/list-query/schema-helpers.js.map +1 -1
- package/dist/list-query/sort-field-types.d.ts +21 -0
- package/dist/list-query/sort-field-types.d.ts.map +1 -0
- package/dist/list-query/sort-field-types.js +2 -0
- package/dist/list-query/sort-field-types.js.map +1 -0
- package/dist/list-query/unrestricted-schemas.d.ts +13 -0
- package/dist/list-query/unrestricted-schemas.d.ts.map +1 -0
- package/dist/list-query/unrestricted-schemas.js +9 -0
- package/dist/list-query/unrestricted-schemas.js.map +1 -0
- package/dist/list-query/validator.d.ts +2 -2
- package/dist/list-query/validator.d.ts.map +1 -1
- package/dist/observability/exception-tracking.d.ts +5 -4
- package/dist/observability/exception-tracking.d.ts.map +1 -1
- package/dist/observability/exception-tracking.js +4 -3
- package/dist/observability/exception-tracking.js.map +1 -1
- package/dist/observability/index.d.ts +8 -0
- package/dist/observability/index.d.ts.map +1 -0
- package/dist/observability/index.js +8 -0
- package/dist/observability/index.js.map +1 -0
- package/dist/observability/pino-logger.d.ts +3 -3
- package/dist/observability/pino-logger.js +3 -3
- package/dist/observability/request-context.d.ts +4 -4
- package/dist/observability/request-context.js +4 -4
- package/package.json +93 -53
- package/dist/authorization/ability-middleware.d.ts +0 -61
- package/dist/authorization/ability-middleware.d.ts.map +0 -1
- package/dist/authorization/ability-middleware.js +0 -74
- package/dist/authorization/ability-middleware.js.map +0 -1
- package/dist/authorization/index.d.ts +0 -46
- package/dist/authorization/index.d.ts.map +0 -1
- package/dist/authorization/index.js +0 -46
- package/dist/authorization/index.js.map +0 -1
- package/dist/authorization/route-helpers.d.ts +0 -106
- package/dist/authorization/route-helpers.d.ts.map +0 -1
- package/dist/authorization/route-helpers.js +0 -136
- package/dist/authorization/route-helpers.js.map +0 -1
- package/dist/authorization/service-proxy.d.ts +0 -59
- package/dist/authorization/service-proxy.d.ts.map +0 -1
- package/dist/authorization/service-proxy.js +0 -110
- package/dist/authorization/service-proxy.js.map +0 -1
- package/dist/authorization/types.d.ts +0 -58
- package/dist/authorization/types.d.ts.map +0 -1
- package/dist/authorization/types.js +0 -7
- package/dist/authorization/types.js.map +0 -1
- package/dist/hooks/authorization-hook.d.ts +0 -100
- package/dist/hooks/authorization-hook.d.ts.map +0 -1
- package/dist/hooks/authorization-hook.js +0 -93
- package/dist/hooks/authorization-hook.js.map +0 -1
- package/dist/hooks/index.d.ts +0 -54
- package/dist/hooks/index.d.ts.map +0 -1
- package/dist/hooks/index.js +0 -55
- package/dist/hooks/index.js.map +0 -1
- package/dist/hooks/service-hooks.d.ts +0 -82
- package/dist/hooks/service-hooks.d.ts.map +0 -1
- package/dist/hooks/service-hooks.js +0 -158
- package/dist/hooks/service-hooks.js.map +0 -1
- package/dist/hooks/types.d.ts +0 -151
- package/dist/hooks/types.d.ts.map +0 -1
- package/dist/hooks/types.js +0 -2
- package/dist/hooks/types.js.map +0 -1
- package/dist/openapi/hooks.d.ts +0 -14
- package/dist/openapi/hooks.d.ts.map +0 -1
- package/dist/openapi/hooks.js +0 -83
- package/dist/openapi/hooks.js.map +0 -1
- package/dist/openapi/openapi-transformer.d.ts +0 -13
- package/dist/openapi/openapi-transformer.d.ts.map +0 -1
- package/dist/openapi/openapi-transformer.js +0 -87
- package/dist/openapi/openapi-transformer.js.map +0 -1
- package/dist/utils/pagination.d.ts +0 -48
- package/dist/utils/pagination.d.ts.map +0 -1
- package/dist/utils/pagination.js +0 -42
- package/dist/utils/pagination.js.map +0 -1
- package/dist/utils/serialize-dates.d.ts +0 -27
- package/dist/utils/serialize-dates.d.ts.map +0 -1
- package/dist/utils/serialize-dates.js +0 -39
- package/dist/utils/serialize-dates.js.map +0 -1
|
@@ -1,200 +1,32 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
import { ForbiddenException, UnauthorizedException } from './errors.js';
|
|
9
|
-
/**
|
|
10
|
-
* Logger instance for route helpers
|
|
11
|
-
*/
|
|
12
|
-
const logger = createLogger('Routes');
|
|
13
|
-
/**
|
|
14
|
-
* Storage for OpenAPI context per Hono app instance.
|
|
15
|
-
* Uses WeakMap to avoid memory leaks and support multiple app instances.
|
|
16
|
-
*/
|
|
17
|
-
const openAPIContextMap = new WeakMap();
|
|
18
|
-
/**
|
|
19
|
-
* Set the OpenAPI context for a Hono app instance.
|
|
20
|
-
* This is called during bootstrap and makes processors/schemes available to route definitions.
|
|
21
|
-
*
|
|
22
|
-
* @internal
|
|
23
|
-
*/
|
|
24
|
-
export function setOpenAPIContext(app, context) {
|
|
25
|
-
openAPIContextMap.set(app, context);
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Get the OpenAPI context for a Hono app instance.
|
|
29
|
-
*
|
|
30
|
-
* @internal
|
|
31
|
-
*/
|
|
32
|
-
export function getOpenAPIContext(app) {
|
|
33
|
-
return openAPIContextMap.get(app) ?? { processors: [], securitySchemes: [], pino: undefined };
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* HTTP status codes with descriptions
|
|
37
|
-
*/
|
|
38
|
-
const STATUS_DESCRIPTIONS = {
|
|
39
|
-
200: 'Success',
|
|
40
|
-
201: 'Created',
|
|
41
|
-
202: 'Accepted',
|
|
42
|
-
204: 'No Content',
|
|
43
|
-
301: 'Moved Permanently',
|
|
44
|
-
302: 'Found',
|
|
45
|
-
307: 'Temporary Redirect',
|
|
46
|
-
308: 'Permanent Redirect',
|
|
47
|
-
400: 'Bad Request',
|
|
48
|
-
401: 'Unauthorized',
|
|
49
|
-
403: 'Forbidden',
|
|
50
|
-
404: 'Not Found',
|
|
51
|
-
409: 'Conflict',
|
|
52
|
-
422: 'Unprocessable Entity',
|
|
53
|
-
429: 'Too Many Requests',
|
|
54
|
-
500: 'Internal Server Error',
|
|
55
|
-
};
|
|
1
|
+
import { enforceRouteAuthorization } from './route-authorization.js';
|
|
2
|
+
import { buildRouteContext } from './route-context.js';
|
|
3
|
+
import { buildOpenAPIMiddleware } from './route-openapi.js';
|
|
4
|
+
import { getOpenAPIContext } from './route-openapi-context.js';
|
|
5
|
+
import { handleResponse } from './route-response.js';
|
|
6
|
+
import { createValidationMiddleware, hasPaginationFields } from './route-validation.js';
|
|
7
|
+
export { getOpenAPIContext, setOpenAPIContext } from './route-openapi-context.js';
|
|
56
8
|
/**
|
|
57
9
|
* Create routes with typed service injection and pre-bound route function.
|
|
58
|
-
*
|
|
59
|
-
* The `route` function passed to your factory is pre-bound to the router's
|
|
60
|
-
* OpenAPI context, so you don't need to pass the router to every route call.
|
|
61
|
-
*
|
|
62
|
-
* @template TServices - The shape of services required by these routes
|
|
63
|
-
*
|
|
64
|
-
* @example
|
|
65
|
-
* ```typescript
|
|
66
|
-
* interface AuthRoutesServices {
|
|
67
|
-
* authService: AuthService;
|
|
68
|
-
* userService: UserService;
|
|
69
|
-
* }
|
|
70
|
-
*
|
|
71
|
-
* export const authRoutes = createRoutes<AuthRoutesServices>((router, services, route) => {
|
|
72
|
-
* // services.authService is typed as AuthService!
|
|
73
|
-
* // route is pre-bound to this router's OpenAPI context
|
|
74
|
-
* router.post('/login', ...route({
|
|
75
|
-
* body: LoginDto,
|
|
76
|
-
* responses: { 200: SessionDto },
|
|
77
|
-
* handler: async ({ body }) => {
|
|
78
|
-
* return services.authService.login(body);
|
|
79
|
-
* }
|
|
80
|
-
* }));
|
|
81
|
-
* });
|
|
82
|
-
* ```
|
|
83
10
|
*/
|
|
84
11
|
export function createRoutes(factory) {
|
|
85
12
|
return (router, services) => {
|
|
86
|
-
// Create a bound route function for this router
|
|
87
13
|
const boundRoute = (config) => route(router, config);
|
|
88
14
|
factory(router, services, boundRoute);
|
|
89
15
|
};
|
|
90
16
|
}
|
|
91
|
-
/**
|
|
92
|
-
* Detect if a query schema includes pagination fields (page, pageSize).
|
|
93
|
-
* Used to auto-detect pagination for OpenAPI documentation.
|
|
94
|
-
*/
|
|
95
|
-
function hasPaginationFields(schema) {
|
|
96
|
-
if (!schema)
|
|
97
|
-
return false;
|
|
98
|
-
// Check if schema has page or pageSize entries
|
|
99
|
-
// This works for Valibot object schemas
|
|
100
|
-
const schemaAny = schema;
|
|
101
|
-
if (schemaAny.entries) {
|
|
102
|
-
return 'page' in schemaAny.entries || 'pageSize' in schemaAny.entries;
|
|
103
|
-
}
|
|
104
|
-
return false;
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Create a validation middleware for request validation.
|
|
108
|
-
* Returns 422 Unprocessable Entity on validation failure (instead of Hono's default 400).
|
|
109
|
-
*
|
|
110
|
-
* @param type - The validation target ('json' or 'form' for body, 'query', or 'param')
|
|
111
|
-
* @param schema - The Valibot schema to validate against
|
|
112
|
-
*/
|
|
113
|
-
function createValidationMiddleware(type, schema) {
|
|
114
|
-
return validator(type, schema, (result, c) => {
|
|
115
|
-
if (!result.success) {
|
|
116
|
-
return c.json({ error: 'Validation failed', issues: result.error }, 422);
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
17
|
/**
|
|
121
18
|
* Create a route handler with validation and OpenAPI metadata.
|
|
122
|
-
*
|
|
123
|
-
* Type inference works automatically:
|
|
124
|
-
* - Body type is inferred from the `body` schema
|
|
125
|
-
* - Return type is inferred as a union of all 2xx response schemas (200, 201, etc.)
|
|
126
|
-
* - Response data is automatically validated and extra keys are stripped
|
|
127
|
-
* - HTTP status code is automatically set based on which schema matches
|
|
128
|
-
*
|
|
129
|
-
* Response Validation & Status Code:
|
|
130
|
-
* - Responses are parsed through their corresponding 2xx schema
|
|
131
|
-
* - Extra keys not defined in the schema are automatically stripped
|
|
132
|
-
* - The HTTP status code is automatically set based on which schema validates
|
|
133
|
-
* - If multiple 2xx schemas are defined, each is tried in order (200, 201)
|
|
134
|
-
* - The first schema that successfully validates determines the status code
|
|
135
|
-
*
|
|
136
|
-
* @param router - The Hono router instance (needed for OpenAPI context)
|
|
137
|
-
* @param config - Route configuration
|
|
138
|
-
*
|
|
139
|
-
* @example
|
|
140
|
-
* ```typescript
|
|
141
|
-
* // Single response type
|
|
142
|
-
* router.post('/session', ...route(router, {
|
|
143
|
-
* body: StartSessionDto,
|
|
144
|
-
* responses: { 200: StartSessionResponseDto },
|
|
145
|
-
* handler: async ({ body }) => {
|
|
146
|
-
* // body is typed as InferOutput<typeof StartSessionDto>
|
|
147
|
-
* return { email: body.email }; // Must match StartSessionResponseDto
|
|
148
|
-
* }
|
|
149
|
-
* }))
|
|
150
|
-
*
|
|
151
|
-
* // Union response type (multiple 2xx responses with automatic status)
|
|
152
|
-
* router.post('/login', ...route(router, {
|
|
153
|
-
* body: LoginDto,
|
|
154
|
-
* responses: {
|
|
155
|
-
* 200: MfaRequiredDto, // Returns 200 if data matches this
|
|
156
|
-
* 201: SessionDto // Returns 201 if data matches this
|
|
157
|
-
* },
|
|
158
|
-
* handler: async ({ body }) => {
|
|
159
|
-
* // Return type is: MfaRequiredDto | SessionDto
|
|
160
|
-
* // Status code is set automatically based on which schema matches!
|
|
161
|
-
* if (needsMfa) return { mfaRequired: true, methods: ['totp'] }; // 200
|
|
162
|
-
* return { sessionId: '123', token: 'abc' }; // 201
|
|
163
|
-
* }
|
|
164
|
-
* }))
|
|
165
|
-
*
|
|
166
|
-
* // With pagination (auto-detected from ListQuerySchema)
|
|
167
|
-
* router.get('/users', ...route(router, {
|
|
168
|
-
* query: ListQuerySchema, // Contains page, pageSize - pagination headers auto-added
|
|
169
|
-
* responses: { 200: UsersResponseDto },
|
|
170
|
-
* handler: async ({ query }) => { ... }
|
|
171
|
-
* }))
|
|
172
|
-
*
|
|
173
|
-
* // With custom response headers
|
|
174
|
-
* router.get('/data', ...route(router, {
|
|
175
|
-
* openapi: {
|
|
176
|
-
* responseHeaders: ['Api-Version', 'Server-Timing']
|
|
177
|
-
* },
|
|
178
|
-
* responses: { 200: DataDto },
|
|
179
|
-
* handler: async () => { ... }
|
|
180
|
-
* }))
|
|
181
|
-
* ```
|
|
182
19
|
*/
|
|
183
20
|
export function route(router, config) {
|
|
184
21
|
const middlewares = [];
|
|
185
|
-
// Get OpenAPI context from the router
|
|
186
22
|
const openAPIContext = getOpenAPIContext(router);
|
|
187
|
-
// Detect pagination from query schema
|
|
188
23
|
const hasPagination = hasPaginationFields(config.query);
|
|
189
|
-
// Add OpenAPI metadata
|
|
190
24
|
if (!config.openapi?.exclude) {
|
|
191
25
|
middlewares.push(buildOpenAPIMiddleware(config, openAPIContext, hasPagination));
|
|
192
26
|
}
|
|
193
|
-
// Add custom middleware (e.g., auth) before validation
|
|
194
27
|
if (config.middleware) {
|
|
195
28
|
middlewares.push(...config.middleware);
|
|
196
29
|
}
|
|
197
|
-
// Add validation middleware (returns 422 instead of Hono's default 400)
|
|
198
30
|
if (config.body) {
|
|
199
31
|
middlewares.push(createValidationMiddleware(config.bodyType || 'json', config.body));
|
|
200
32
|
}
|
|
@@ -204,7 +36,6 @@ export function route(router, config) {
|
|
|
204
36
|
if (config.params) {
|
|
205
37
|
middlewares.push(createValidationMiddleware('param', config.params));
|
|
206
38
|
}
|
|
207
|
-
// Add handler wrapper
|
|
208
39
|
middlewares.push(async (c) => {
|
|
209
40
|
const routeContext = buildRouteContext(c, config, openAPIContext);
|
|
210
41
|
if (config.authorize) {
|
|
@@ -213,292 +44,6 @@ export function route(router, config) {
|
|
|
213
44
|
const result = await config.handler(routeContext);
|
|
214
45
|
return handleResponse(result, config.responses, config.serialization, config.strictTypes, config.summary, c);
|
|
215
46
|
});
|
|
216
|
-
// Cast to RouteHandlers tuple type - we always have at least one handler (the final handler wrapper)
|
|
217
47
|
return middlewares;
|
|
218
48
|
}
|
|
219
|
-
function enforceRouteAuthorization(authorize, routeContext) {
|
|
220
|
-
const ability = routeContext
|
|
221
|
-
.ability;
|
|
222
|
-
const user = routeContext.user;
|
|
223
|
-
const isAuthenticated = routeContext.isAuthenticated ?? Boolean(user);
|
|
224
|
-
const allowGuest = authorize.allowGuest ?? false;
|
|
225
|
-
if (!isAuthenticated && !allowGuest) {
|
|
226
|
-
throw new UnauthorizedException('Authentication required');
|
|
227
|
-
}
|
|
228
|
-
const canAccess = ability?.can?.(authorize.action, authorize.subject);
|
|
229
|
-
if (!canAccess) {
|
|
230
|
-
if (!isAuthenticated) {
|
|
231
|
-
throw new UnauthorizedException('Authentication required');
|
|
232
|
-
}
|
|
233
|
-
throw new ForbiddenException(`You don't have permission to ${authorize.action} ${authorize.subject}`);
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
/**
|
|
237
|
-
* Serialize response data with custom transformers and default Prisma type handling.
|
|
238
|
-
*
|
|
239
|
-
* @param data - The raw response data from the handler
|
|
240
|
-
* @param serializationConfig - Optional custom serialization configuration
|
|
241
|
-
* @returns Serialized data with Prisma types converted to JSON-safe types
|
|
242
|
-
* @throws Error if circular reference or max depth is exceeded
|
|
243
|
-
*/
|
|
244
|
-
function serializeResponseData(data, serializationConfig) {
|
|
245
|
-
const config = serializationConfig
|
|
246
|
-
? {
|
|
247
|
-
transformers: [
|
|
248
|
-
...(serializationConfig.transformers || []),
|
|
249
|
-
...defaultSerializationConfig.transformers,
|
|
250
|
-
],
|
|
251
|
-
}
|
|
252
|
-
: defaultSerializationConfig;
|
|
253
|
-
return serializePrismaTypes(data, config);
|
|
254
|
-
}
|
|
255
|
-
/**
|
|
256
|
-
* Handle response serialization and validation, including error handling.
|
|
257
|
-
*
|
|
258
|
-
* @param result - The raw result from the handler
|
|
259
|
-
* @param responses - The response schemas configuration
|
|
260
|
-
* @param serializationConfig - Optional custom serialization configuration
|
|
261
|
-
* @param routeSummary - Route summary for logging
|
|
262
|
-
* @param context - Hono context
|
|
263
|
-
* @returns Response object or undefined if handled
|
|
264
|
-
*/
|
|
265
|
-
async function handleResponse(result, responses, serializationConfig, strictTypes, routeSummary, context) {
|
|
266
|
-
// If handler returned a Response, return it directly (for custom responses like text)
|
|
267
|
-
if (result instanceof Response) {
|
|
268
|
-
return result;
|
|
269
|
-
}
|
|
270
|
-
// Handle empty responses
|
|
271
|
-
if (result === null || result === undefined) {
|
|
272
|
-
context.status(204);
|
|
273
|
-
return context.body(null);
|
|
274
|
-
}
|
|
275
|
-
// Serialize Prisma types and custom transformers
|
|
276
|
-
let serializedResult;
|
|
277
|
-
try {
|
|
278
|
-
// Only serialize if strictTypes is disabled (default)
|
|
279
|
-
// If strictTypes is true, we expect the handler to return exact types
|
|
280
|
-
if (!strictTypes) {
|
|
281
|
-
serializedResult = serializeResponseData(result, serializationConfig);
|
|
282
|
-
}
|
|
283
|
-
else {
|
|
284
|
-
serializedResult = result;
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
catch (error) {
|
|
288
|
-
// Handle serialization errors (circular references, max depth exceeded)
|
|
289
|
-
logger.error('Failed to serialize response data', {
|
|
290
|
-
error: error instanceof Error ? error.message : String(error),
|
|
291
|
-
route: routeSummary || 'unknown',
|
|
292
|
-
});
|
|
293
|
-
// In production, don't leak error details
|
|
294
|
-
const errorMessage = process.env.NODE_ENV === 'production'
|
|
295
|
-
? 'Failed to serialize response data'
|
|
296
|
-
: error instanceof Error
|
|
297
|
-
? error.message
|
|
298
|
-
: String(error);
|
|
299
|
-
return context.json({ error: 'Internal Server Error', message: errorMessage }, 500);
|
|
300
|
-
}
|
|
301
|
-
// Parse and validate response through schema
|
|
302
|
-
const { data: parsedResult, statusCode } = await parseResponse(serializedResult, responses);
|
|
303
|
-
// Set status code if determined by schema matching
|
|
304
|
-
if (statusCode) {
|
|
305
|
-
context.status(statusCode);
|
|
306
|
-
}
|
|
307
|
-
return context.json(parsedResult);
|
|
308
|
-
}
|
|
309
|
-
/**
|
|
310
|
-
* Parse and validate response data through the appropriate success/redirect schema.
|
|
311
|
-
* Tries each 2xx and 3xx schema in order until one successfully validates.
|
|
312
|
-
* This automatically strips extra keys not defined in the schema and determines
|
|
313
|
-
* the appropriate HTTP status code.
|
|
314
|
-
*
|
|
315
|
-
* @param data - The raw response data from the handler
|
|
316
|
-
* @param responses - The response schemas configuration
|
|
317
|
-
* @returns Object with parsed data and the matching status code
|
|
318
|
-
*/
|
|
319
|
-
async function parseResponse(data, responses) {
|
|
320
|
-
// If no response schemas defined, return data as-is
|
|
321
|
-
if (!responses) {
|
|
322
|
-
return { data };
|
|
323
|
-
}
|
|
324
|
-
// Try each success/redirect schema in order (2xx and 3xx codes)
|
|
325
|
-
const successCodes = [
|
|
326
|
-
200, 201, 202, 204, 301, 302, 307, 308,
|
|
327
|
-
];
|
|
328
|
-
for (const statusCode of successCodes) {
|
|
329
|
-
const schema = responses[statusCode];
|
|
330
|
-
if (!schema)
|
|
331
|
-
continue;
|
|
332
|
-
// Try to parse with this schema
|
|
333
|
-
// Use async parse to support both sync and async schemas
|
|
334
|
-
const result = await safeParseAsync(schema, data);
|
|
335
|
-
if (result.success) {
|
|
336
|
-
// Successfully parsed - return the validated data and matching status code
|
|
337
|
-
return { data: result.output, statusCode };
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
// No schema matched - this is a potential security issue in production
|
|
341
|
-
if (process.env.NODE_ENV === 'production') {
|
|
342
|
-
// In production, throw an error to prevent leaking unvalidated data
|
|
343
|
-
// This could expose sensitive fields that should have been stripped
|
|
344
|
-
logger.error('Response data does not match any defined success/redirect schema. ' +
|
|
345
|
-
'Refusing to return unvalidated data in production.');
|
|
346
|
-
throw new Error('Response validation failed: Data does not match any defined response schema. ' +
|
|
347
|
-
'This prevents potentially sensitive data from being leaked.');
|
|
348
|
-
}
|
|
349
|
-
// In development, log a warning and return data as-is for debugging
|
|
350
|
-
logger.warn('Response data does not match any defined success/redirect schema. ' +
|
|
351
|
-
'Data will be returned as-is without validation or key stripping. ' +
|
|
352
|
-
'This would throw an error in production.');
|
|
353
|
-
return { data };
|
|
354
|
-
}
|
|
355
|
-
function buildOpenAPIMiddleware(config, openAPIContext, hasPagination) {
|
|
356
|
-
const responses = buildOpenAPIResponses(config, openAPIContext, hasPagination);
|
|
357
|
-
// Build security requirement based on security schemes from context
|
|
358
|
-
// Public routes have no security, authenticated routes use all available schemes
|
|
359
|
-
const security = config.public
|
|
360
|
-
? []
|
|
361
|
-
: openAPIContext.securitySchemes.map((scheme) => ({ [scheme]: [] }));
|
|
362
|
-
// Extract responseHeaders and exclude from openapi config to avoid passing it to hono-openapi
|
|
363
|
-
const { responseHeaders: _responseHeaders, exclude: _exclude, docs, ...restOpenapi } = config.openapi ?? {};
|
|
364
|
-
const openApiConfig = {
|
|
365
|
-
operationId: config.operationId || config.summary,
|
|
366
|
-
tags: config.tags,
|
|
367
|
-
summary: config.summary,
|
|
368
|
-
description: config.description,
|
|
369
|
-
externalDocs: docs,
|
|
370
|
-
responses: responses,
|
|
371
|
-
security,
|
|
372
|
-
...restOpenapi,
|
|
373
|
-
};
|
|
374
|
-
return honoDescribeRoute(openApiConfig);
|
|
375
|
-
}
|
|
376
|
-
/**
|
|
377
|
-
* Build default error responses based on route configuration.
|
|
378
|
-
*/
|
|
379
|
-
function buildDefaultErrorResponses(config) {
|
|
380
|
-
const hasValidation = !!(config.body || config.query || config.params);
|
|
381
|
-
if (config.public) {
|
|
382
|
-
return {
|
|
383
|
-
400: undefined,
|
|
384
|
-
...(hasValidation && { 422: undefined }),
|
|
385
|
-
429: undefined,
|
|
386
|
-
500: undefined,
|
|
387
|
-
};
|
|
388
|
-
}
|
|
389
|
-
return {
|
|
390
|
-
400: undefined,
|
|
391
|
-
401: undefined,
|
|
392
|
-
...(hasValidation && { 422: undefined }),
|
|
393
|
-
429: undefined,
|
|
394
|
-
500: undefined,
|
|
395
|
-
};
|
|
396
|
-
}
|
|
397
|
-
/**
|
|
398
|
-
* Build response content for a single status code.
|
|
399
|
-
*/
|
|
400
|
-
function buildResponseContent(schema, isErrorResponse) {
|
|
401
|
-
if (schema) {
|
|
402
|
-
return {
|
|
403
|
-
content: {
|
|
404
|
-
'application/json': {
|
|
405
|
-
schema: resolver(schema, {
|
|
406
|
-
errorMode: 'ignore',
|
|
407
|
-
}),
|
|
408
|
-
},
|
|
409
|
-
},
|
|
410
|
-
};
|
|
411
|
-
}
|
|
412
|
-
if (isErrorResponse) {
|
|
413
|
-
return {
|
|
414
|
-
content: {
|
|
415
|
-
'application/json': {
|
|
416
|
-
schema: { $ref: '#/components/schemas/ErrorResponse' },
|
|
417
|
-
},
|
|
418
|
-
},
|
|
419
|
-
};
|
|
420
|
-
}
|
|
421
|
-
return {};
|
|
422
|
-
}
|
|
423
|
-
/**
|
|
424
|
-
* Build binary response object for file download endpoints.
|
|
425
|
-
*/
|
|
426
|
-
function buildBinaryResponse(binaryConfig) {
|
|
427
|
-
const description = binaryConfig.description ??
|
|
428
|
-
STATUS_DESCRIPTIONS[(binaryConfig.statusCode ?? 200)] ??
|
|
429
|
-
'File download';
|
|
430
|
-
return {
|
|
431
|
-
description,
|
|
432
|
-
content: {
|
|
433
|
-
[binaryConfig.contentType]: {
|
|
434
|
-
schema: { type: 'string', format: 'binary' },
|
|
435
|
-
},
|
|
436
|
-
},
|
|
437
|
-
};
|
|
438
|
-
}
|
|
439
|
-
function buildOpenAPIResponses(config, openAPIContext, hasPagination) {
|
|
440
|
-
const responses = {};
|
|
441
|
-
const defaultResponses = buildDefaultErrorResponses(config);
|
|
442
|
-
const allResponses = { ...defaultResponses, ...(config.responses || {}) };
|
|
443
|
-
const binaryResponse = config.openapi?.binaryResponse;
|
|
444
|
-
const binaryStatusCode = String(binaryResponse?.statusCode ?? 200);
|
|
445
|
-
if (binaryResponse) {
|
|
446
|
-
responses[binaryStatusCode] = buildBinaryResponse(binaryResponse);
|
|
447
|
-
}
|
|
448
|
-
for (const [statusCode, schema] of Object.entries(allResponses)) {
|
|
449
|
-
if (binaryResponse && statusCode === binaryStatusCode) {
|
|
450
|
-
continue;
|
|
451
|
-
}
|
|
452
|
-
const code = Number(statusCode);
|
|
453
|
-
const description = STATUS_DESCRIPTIONS[code] || 'Response';
|
|
454
|
-
const isErrorResponse = code >= 400;
|
|
455
|
-
let response = {
|
|
456
|
-
description,
|
|
457
|
-
...buildResponseContent(schema, isErrorResponse && !schema),
|
|
458
|
-
};
|
|
459
|
-
const processorContext = {
|
|
460
|
-
statusCode,
|
|
461
|
-
hasPagination,
|
|
462
|
-
routeConfig: {
|
|
463
|
-
...config,
|
|
464
|
-
public: config.public,
|
|
465
|
-
tags: config.tags,
|
|
466
|
-
summary: config.summary,
|
|
467
|
-
openapi: config.openapi,
|
|
468
|
-
},
|
|
469
|
-
};
|
|
470
|
-
response = applyProcessors(response, processorContext, openAPIContext.processors);
|
|
471
|
-
responses[statusCode] = response;
|
|
472
|
-
}
|
|
473
|
-
return responses;
|
|
474
|
-
}
|
|
475
|
-
/**
|
|
476
|
-
* Build the route context for a handler.
|
|
477
|
-
* Creates a context-aware logger using the route's first tag or operationId as the service name.
|
|
478
|
-
*/
|
|
479
|
-
function buildRouteContext(c, config, openAPIContext) {
|
|
480
|
-
const req = c.req;
|
|
481
|
-
// Create a context-aware logger for this route
|
|
482
|
-
// Use first tag, operationId, or 'Route' as the service name
|
|
483
|
-
const serviceName = config.tags?.[0] || config.operationId || 'Route';
|
|
484
|
-
const routeLogger = openAPIContext.pino
|
|
485
|
-
? createContextAwarePinoLogger({ pino: openAPIContext.pino, service: serviceName })
|
|
486
|
-
: createLogger(serviceName); // Uses default level (silent in test mode when no pino configured)
|
|
487
|
-
// Spread all context variables (from ContextVariableMap)
|
|
488
|
-
// This includes session, ability, role, and any other middleware-added variables
|
|
489
|
-
// Return with TSessionRequired=false to allow undefined session
|
|
490
|
-
// The type will be narrowed at the call site based on the route's public setting
|
|
491
|
-
return {
|
|
492
|
-
...c.var,
|
|
493
|
-
body: req.valid(config.bodyType || 'json'),
|
|
494
|
-
query: req.valid('query'),
|
|
495
|
-
params: req.valid('param'),
|
|
496
|
-
services: c.get('services') || {},
|
|
497
|
-
session: c.get('session'),
|
|
498
|
-
ip: getClientIp(c),
|
|
499
|
-
userAgent: c.req.header('user-agent'),
|
|
500
|
-
logger: routeLogger,
|
|
501
|
-
context: c,
|
|
502
|
-
};
|
|
503
|
-
}
|
|
504
49
|
//# sourceMappingURL=route-helpers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route-helpers.js","sourceRoot":"","sources":["../../src/http/route-helpers.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,aAAa,IAAI,iBAAiB,EAClC,QAAQ,EACR,SAAS,GACV,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AASzC,OAAO,EAAE,4BAA4B,EAAmB,MAAM,iCAAiC,CAAC;AAChG,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,YAAY,EAAe,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAEL,aAAa,IAAI,0BA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ogger } from '../observability/pino-logger.js';
|
|
4
|
+
/**
|
|
5
|
+
* OpenAPI context stored in Hono app context.
|
|
6
|
+
* Set during bootstrap and used when defining routes.
|
|
7
|
+
*/
|
|
8
|
+
export interface OpenAPIContext {
|
|
9
|
+
processors: OpenAPIResponseProcessor[];
|
|
10
|
+
securitySchemes: string[];
|
|
11
|
+
/**
|
|
12
|
+
* Pino logger instance for creating context-aware loggers in route handlers.
|
|
13
|
+
* When set, enables `logger` property in RouteContext.
|
|
14
|
+
*/
|
|
15
|
+
pino?: PinoLogger;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Set the OpenAPI context for a Hono app instance.
|
|
19
|
+
* @internal
|
|
20
|
+
*/
|
|
21
|
+
export declare function setOpenAPIContext(app: Hono, context: OpenAPIContext): void;
|
|
22
|
+
/**
|
|
23
|
+
* Get the OpenAPI context for a Hono app instance.
|
|
24
|
+
* @internal
|
|
25
|
+
*/
|
|
26
|
+
export declare function getOpenAPIContext(app: Hono): OpenAPIContext;
|
|
27
|
+
//# sourceMappingURL=route-openapi-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"route-openapi-context.d.ts","sourceRoot":"","sources":["../../src/http/route-openapi-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AACjC,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAElE;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,UAAU,EAAE,wBAAwB,EAAE,CAAC;IACvC,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B;;;OAGG;IACH,IAAI,CAAC,EAAE,UAAU,CAAC;CACnB;AAID;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,cAAc,GAAG,IAAI,CAE1E;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,IAAI,GAAG,cAAc,CAE3D"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const openAPIContextMap = new WeakMap();
|
|
2
|
+
/**
|
|
3
|
+
* Set the OpenAPI context for a Hono app instance.
|
|
4
|
+
* @internal
|
|
5
|
+
*/
|
|
6
|
+
export function setOpenAPIContext(app, context) {
|
|
7
|
+
openAPIContextMap.set(app, context);
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Get the OpenAPI context for a Hono app instance.
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
export function getOpenAPIContext(app) {
|
|
14
|
+
return openAPIContextMap.get(app) ?? { processors: [], securitySchemes: [], pino: undefined };
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=route-openapi-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"route-openapi-context.js","sourceRoot":"","sources":["../../src/http/route-openapi-context.ts"],"names":[],"mappings":"AAkBA,MAAM,iBAAiB,GAAG,IAAI,OAAO,EAAwB,CAAC;AAE9D;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAAC,GAAS,EAAE,OAAuB;IAClE,iBAAiB,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;AACtC,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAAC,GAAS;IACzC,OAAO,iBAAiB,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE,EAAE,eAAe,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;AAChG,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { MiddlewareHandler } from 'hono';
|
|
2
|
+
import type { OpenAPIContext } from './route-openapi-context.js';
|
|
3
|
+
import { type RouteConfig, STATUS_DESCRIPTIONS, type ValibotSchema } from './route-types.js';
|
|
4
|
+
export declare function buildOpenAPIMiddleware<TBody extends ValibotSchema | undefined, TQuery extends ValibotSchema | undefined, TParams extends ValibotSchema | undefined, TResponses extends Partial<Record<keyof typeof STATUS_DESCRIPTIONS, ValibotSchema | undefined>>, TPublic extends boolean, TStrictTypes extends boolean>(config: RouteConfig<TBody, TQuery, TParams, TResponses, TPublic, TStrictTypes>, openAPIContext: OpenAPIContext, hasPagination: boolean): MiddlewareHandler;
|
|
5
|
+
//# sourceMappingURL=route-openapi.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"route-openapi.d.ts","sourceRoot":"","sources":["../../src/http/route-openapi.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AAS9C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EACL,KAAK,WAAW,EAEhB,mBAAmB,EACnB,KAAK,aAAa,EACnB,MAAM,kBAAkB,CAAC;AAsH1B,wBAAgB,sBAAsB,CACpC,KAAK,SAAS,aAAa,GAAG,SAAS,EACvC,MAAM,SAAS,aAAa,GAAG,SAAS,EACxC,OAAO,SAAS,aAAa,GAAG,SAAS,EACzC,UAAU,SAAS,OAAO,CAAC,MAAM,CAAC,MAAM,OAAO,mBAAmB,EAAE,aAAa,GAAG,SAAS,CAAC,CAAC,EAC/F,OAAO,SAAS,OAAO,EACvB,YAAY,SAAS,OAAO,EAE5B,MAAM,EAAE,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,YAAY,CAAC,EAC9E,cAAc,EAAE,cAAc,EAC9B,aAAa,EAAE,OAAO,GACrB,iBAAiB,CA0BnB"}
|