glasswork 0.1.1 → 0.2.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/dist/authorization/ability-middleware.d.ts +61 -0
- package/dist/authorization/ability-middleware.d.ts.map +1 -0
- package/dist/authorization/ability-middleware.js +74 -0
- package/dist/authorization/ability-middleware.js.map +1 -0
- package/dist/authorization/index.d.ts +46 -0
- package/dist/authorization/index.d.ts.map +1 -0
- package/dist/authorization/index.js +46 -0
- package/dist/authorization/index.js.map +1 -0
- package/dist/authorization/route-helpers.d.ts +106 -0
- package/dist/authorization/route-helpers.d.ts.map +1 -0
- package/dist/authorization/route-helpers.js +136 -0
- package/dist/authorization/route-helpers.js.map +1 -0
- package/dist/authorization/service-proxy.d.ts +59 -0
- package/dist/authorization/service-proxy.d.ts.map +1 -0
- package/dist/authorization/service-proxy.js +110 -0
- package/dist/authorization/service-proxy.js.map +1 -0
- package/dist/authorization/types.d.ts +58 -0
- package/dist/authorization/types.d.ts.map +1 -0
- package/dist/authorization/types.js +7 -0
- package/dist/authorization/types.js.map +1 -0
- package/dist/config/config-service.d.ts +101 -0
- package/dist/config/config-service.d.ts.map +1 -0
- package/dist/config/config-service.js +164 -0
- package/dist/config/config-service.js.map +1 -0
- package/dist/config/helpers.d.ts +101 -0
- package/dist/config/helpers.d.ts.map +1 -0
- package/dist/config/helpers.js +122 -0
- package/dist/config/helpers.js.map +1 -0
- package/dist/config/index.d.ts +39 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +41 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/providers.d.ts +163 -0
- package/dist/config/providers.d.ts.map +1 -0
- package/dist/config/providers.js +188 -0
- package/dist/config/providers.js.map +1 -0
- package/dist/config/types.d.ts +98 -0
- package/dist/config/types.d.ts.map +1 -0
- package/dist/config/types.js +7 -0
- package/dist/config/types.js.map +1 -0
- package/dist/core/bootstrap.js +9 -3
- package/dist/core/bootstrap.js.map +1 -1
- package/dist/core/types.d.ts +2 -1
- package/dist/core/types.d.ts.map +1 -1
- package/dist/hooks/authorization-hook.d.ts +100 -0
- package/dist/hooks/authorization-hook.d.ts.map +1 -0
- package/dist/hooks/authorization-hook.js +93 -0
- package/dist/hooks/authorization-hook.js.map +1 -0
- package/dist/hooks/index.d.ts +54 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +55 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/service-hooks.d.ts +82 -0
- package/dist/hooks/service-hooks.d.ts.map +1 -0
- package/dist/hooks/service-hooks.js +158 -0
- package/dist/hooks/service-hooks.js.map +1 -0
- package/dist/hooks/types.d.ts +151 -0
- package/dist/hooks/types.d.ts.map +1 -0
- package/dist/hooks/types.js.map +1 -0
- package/dist/http/errors.d.ts +39 -0
- package/dist/http/errors.d.ts.map +1 -1
- package/dist/http/errors.js +78 -0
- package/dist/http/errors.js.map +1 -1
- package/dist/http/route-helpers.d.ts +39 -13
- package/dist/http/route-helpers.d.ts.map +1 -1
- package/dist/http/route-helpers.js +45 -2
- package/dist/http/route-helpers.js.map +1 -1
- package/dist/index.d.ts +5 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -5
- package/dist/index.js.map +1 -1
- package/dist/middleware/rate-limit.d.ts.map +1 -1
- package/dist/middleware/rate-limit.js +2 -16
- package/dist/middleware/rate-limit.js.map +1 -1
- package/dist/openapi/openapi.d.ts +1 -1
- package/dist/openapi/openapi.d.ts.map +1 -1
- package/dist/openapi/openapi.js +21 -3
- package/dist/openapi/openapi.js.map +1 -1
- package/package.json +22 -1
- package/dist/bootstrap.d.ts +0 -55
- package/dist/bootstrap.d.ts.map +0 -1
- package/dist/bootstrap.js +0 -359
- package/dist/bootstrap.js.map +0 -1
- package/dist/environment.d.ts +0 -21
- package/dist/environment.d.ts.map +0 -1
- package/dist/environment.js +0 -29
- package/dist/environment.js.map +0 -1
- package/dist/error-handler.d.ts +0 -33
- package/dist/error-handler.d.ts.map +0 -1
- package/dist/error-handler.js +0 -53
- package/dist/error-handler.js.map +0 -1
- package/dist/errors.d.ts +0 -36
- package/dist/errors.d.ts.map +0 -1
- package/dist/errors.js +0 -65
- package/dist/errors.js.map +0 -1
- package/dist/get-client-ip.d.ts +0 -24
- package/dist/get-client-ip.d.ts.map +0 -1
- package/dist/get-client-ip.js +0 -49
- package/dist/get-client-ip.js.map +0 -1
- package/dist/logger.d.ts +0 -37
- package/dist/logger.d.ts.map +0 -1
- package/dist/logger.js +0 -52
- package/dist/logger.js.map +0 -1
- package/dist/module.d.ts +0 -21
- package/dist/module.d.ts.map +0 -1
- package/dist/module.js +0 -85
- package/dist/module.js.map +0 -1
- package/dist/omit.d.ts +0 -20
- package/dist/omit.d.ts.map +0 -1
- package/dist/omit.js +0 -28
- package/dist/omit.js.map +0 -1
- package/dist/openapi-defaults.d.ts +0 -11
- package/dist/openapi-defaults.d.ts.map +0 -1
- package/dist/openapi-defaults.js +0 -127
- package/dist/openapi-defaults.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 -80
- package/dist/openapi-hooks.js.map +0 -1
- package/dist/openapi.d.ts +0 -24
- package/dist/openapi.d.ts.map +0 -1
- package/dist/openapi.js +0 -106
- package/dist/openapi.js.map +0 -1
- package/dist/pagination.d.ts +0 -48
- package/dist/pagination.d.ts.map +0 -1
- package/dist/pagination.js +0 -43
- package/dist/pagination.js.map +0 -1
- package/dist/pick.d.ts +0 -20
- package/dist/pick.d.ts.map +0 -1
- package/dist/pick.js +0 -28
- package/dist/pick.js.map +0 -1
- package/dist/rate-limit.d.ts +0 -7
- package/dist/rate-limit.d.ts.map +0 -1
- package/dist/rate-limit.js +0 -180
- package/dist/rate-limit.js.map +0 -1
- package/dist/route-helpers.d.ts +0 -172
- package/dist/route-helpers.d.ts.map +0 -1
- package/dist/route-helpers.js +0 -249
- package/dist/route-helpers.js.map +0 -1
- package/dist/serialize-dates.d.ts +0 -27
- package/dist/serialize-dates.d.ts.map +0 -1
- package/dist/serialize-dates.js +0 -39
- package/dist/serialize-dates.js.map +0 -1
- package/dist/testing.d.ts +0 -87
- package/dist/testing.d.ts.map +0 -1
- package/dist/testing.js +0 -94
- package/dist/testing.js.map +0 -1
- package/dist/types.d.ts +0 -273
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js.map +0 -1
- package/dist/utils.d.ts +0 -9
- package/dist/utils.d.ts.map +0 -1
- package/dist/utils.js +0 -31
- package/dist/utils.js.map +0 -1
- /package/dist/{types.js → hooks/types.js} +0 -0
package/dist/openapi-defaults.js
DELETED
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Default OpenAPI components provided by Glasswork.
|
|
3
|
-
* These include headers for features implemented by the framework:
|
|
4
|
-
* - Rate limiting headers
|
|
5
|
-
* - Pagination headers
|
|
6
|
-
* - CORS headers
|
|
7
|
-
* - Error response schemas
|
|
8
|
-
*/
|
|
9
|
-
export const defaultOpenAPIComponents = {
|
|
10
|
-
schemas: {
|
|
11
|
-
// Error response schemas
|
|
12
|
-
ErrorResponse: {
|
|
13
|
-
type: 'object',
|
|
14
|
-
required: ['error'],
|
|
15
|
-
properties: {
|
|
16
|
-
error: {
|
|
17
|
-
type: 'string',
|
|
18
|
-
maxLength: 1000,
|
|
19
|
-
pattern: '^[\\s\\S]*$', // Any characters including whitespace
|
|
20
|
-
description: 'Error message',
|
|
21
|
-
},
|
|
22
|
-
issues: {
|
|
23
|
-
type: 'array',
|
|
24
|
-
maxItems: 100,
|
|
25
|
-
items: {
|
|
26
|
-
type: 'object',
|
|
27
|
-
required: ['message'],
|
|
28
|
-
properties: {
|
|
29
|
-
message: {
|
|
30
|
-
type: 'string',
|
|
31
|
-
maxLength: 500,
|
|
32
|
-
},
|
|
33
|
-
path: {
|
|
34
|
-
type: 'array',
|
|
35
|
-
maxItems: 20,
|
|
36
|
-
items: {
|
|
37
|
-
oneOf: [
|
|
38
|
-
{ type: 'string', maxLength: 200 },
|
|
39
|
-
{ type: 'number', format: 'int32' },
|
|
40
|
-
],
|
|
41
|
-
},
|
|
42
|
-
},
|
|
43
|
-
},
|
|
44
|
-
},
|
|
45
|
-
description: 'Validation error details',
|
|
46
|
-
},
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
},
|
|
50
|
-
headers: {
|
|
51
|
-
// CORS headers
|
|
52
|
-
'Access-Control-Allow-Origin': {
|
|
53
|
-
description: 'Allowed origin for CORS requests',
|
|
54
|
-
schema: {
|
|
55
|
-
type: 'string',
|
|
56
|
-
maxLength: 2048,
|
|
57
|
-
pattern: '^https?://[a-zA-Z0-9.-]+(:[0-9]+)?$',
|
|
58
|
-
},
|
|
59
|
-
},
|
|
60
|
-
// Rate limiting headers (from rate-limit.ts)
|
|
61
|
-
'RateLimit-Limit': {
|
|
62
|
-
description: 'Total requests allowed in the current time window',
|
|
63
|
-
schema: {
|
|
64
|
-
type: 'integer',
|
|
65
|
-
format: 'int32',
|
|
66
|
-
minimum: 0,
|
|
67
|
-
maximum: 10000,
|
|
68
|
-
},
|
|
69
|
-
},
|
|
70
|
-
'RateLimit-Remaining': {
|
|
71
|
-
description: 'Remaining requests in the current window',
|
|
72
|
-
schema: {
|
|
73
|
-
type: 'integer',
|
|
74
|
-
format: 'int32',
|
|
75
|
-
minimum: 0,
|
|
76
|
-
maximum: 10000,
|
|
77
|
-
},
|
|
78
|
-
},
|
|
79
|
-
'RateLimit-Reset': {
|
|
80
|
-
description: 'Seconds until the rate limit window resets',
|
|
81
|
-
schema: {
|
|
82
|
-
type: 'integer',
|
|
83
|
-
format: 'int32',
|
|
84
|
-
minimum: 0,
|
|
85
|
-
maximum: 3600,
|
|
86
|
-
},
|
|
87
|
-
},
|
|
88
|
-
'Retry-After': {
|
|
89
|
-
description: 'Seconds to wait before retrying the request (429 response)',
|
|
90
|
-
schema: {
|
|
91
|
-
type: 'integer',
|
|
92
|
-
format: 'int32',
|
|
93
|
-
minimum: 1,
|
|
94
|
-
maximum: 3600,
|
|
95
|
-
},
|
|
96
|
-
},
|
|
97
|
-
// Pagination headers (from pagination.ts)
|
|
98
|
-
'X-Total-Count': {
|
|
99
|
-
description: 'Total number of items available',
|
|
100
|
-
schema: {
|
|
101
|
-
type: 'integer',
|
|
102
|
-
format: 'int32',
|
|
103
|
-
minimum: 0,
|
|
104
|
-
maximum: 2147483647, // Max int32
|
|
105
|
-
},
|
|
106
|
-
},
|
|
107
|
-
'X-Page': {
|
|
108
|
-
description: 'Current page number',
|
|
109
|
-
schema: {
|
|
110
|
-
type: 'integer',
|
|
111
|
-
format: 'int32',
|
|
112
|
-
minimum: 1,
|
|
113
|
-
maximum: 2147483647, // Max int32
|
|
114
|
-
},
|
|
115
|
-
},
|
|
116
|
-
'X-Limit': {
|
|
117
|
-
description: 'Number of items per page',
|
|
118
|
-
schema: {
|
|
119
|
-
type: 'integer',
|
|
120
|
-
format: 'int32',
|
|
121
|
-
minimum: 1,
|
|
122
|
-
maximum: 100,
|
|
123
|
-
},
|
|
124
|
-
},
|
|
125
|
-
},
|
|
126
|
-
};
|
|
127
|
-
//# sourceMappingURL=openapi-defaults.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"openapi-defaults.js","sourceRoot":"","sources":["../src/openapi-defaults.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAA+B;IAClE,OAAO,EAAE;QACP,yBAAyB;QACzB,aAAa,EAAE;YACb,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,CAAC,OAAO,CAAC;YACnB,UAAU,EAAE;gBACV,KAAK,EAAE;oBACL,IAAI,EAAE,QAAQ;oBACd,SAAS,EAAE,IAAI;oBACf,OAAO,EAAE,aAAa,EAAE,sCAAsC;oBAC9D,WAAW,EAAE,eAAe;iBAC7B;gBACD,MAAM,EAAE;oBACN,IAAI,EAAE,OAAO;oBACb,QAAQ,EAAE,GAA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;YACzE,MAAM,EAAE;gBACN,IAAI,EAAE,SAAS;gBACf,MAAM,EAAE,OAAO;gBACf,OAAO,EAAE,CAAC;gBACV,OAAO,EAAE,IAAI;aACd;SACF;QAED,0CAA0C;QAC1C,eAAe,EAAE;YACf,WAAW,EAAE,iCAAiC;YAC9C,MAAM,EAAE;gBACN,IAAI,EAAE,SAAS;gBACf,MAAM,EAAE,OAAO;gBACf,OAAO,EAAE,CAAC;gBACV,OAAO,EAAE,UAAU,EAAE,YAAY;aAClC;SACF;QACD,QAAQ,EAAE;YACR,WAAW,EAAE,qBAAqB;YAClC,MAAM,EAAE;gBACN,IAAI,EAAE,SAAS;gBACf,MAAM,EAAE,OAAO;gBACf,OAAO,EAAE,CAAC;gBACV,OAAO,EAAE,UAAU,EAAE,YAAY;aAClC;SACF;QACD,SAAS,EAAE;YACT,WAAW,EAAE,0BAA0B;YACvC,MAAM,EAAE;gBACN,IAAI,EAAE,SAAS;gBACf,MAAM,EAAE,OAAO;gBACf,OAAO,EAAE,CAAC;gBACV,OAAO,EAAE,GAAG;aACb;SACF;KACF;CACF,CAAC"}
|
package/dist/openapi-hooks.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { OpenAPIResponseHook } from './types.js';
|
|
2
|
-
/**
|
|
3
|
-
* Create a hook that adds CORS headers to responses
|
|
4
|
-
*/
|
|
5
|
-
export declare function createCorsHeadersHook(enabled: boolean): OpenAPIResponseHook;
|
|
6
|
-
/**
|
|
7
|
-
* Create a hook that adds rate limiting headers to responses
|
|
8
|
-
*/
|
|
9
|
-
export declare function createRateLimitHeadersHook(enabled: boolean): OpenAPIResponseHook;
|
|
10
|
-
/**
|
|
11
|
-
* Create a hook that adds pagination headers to 200 responses
|
|
12
|
-
*/
|
|
13
|
-
export declare function createPaginationHeadersHook(): OpenAPIResponseHook;
|
|
14
|
-
//# sourceMappingURL=openapi-hooks.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"openapi-hooks.d.ts","sourceRoot":"","sources":["../src/openapi-hooks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEtD;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,OAAO,GAAG,mBAAmB,CAc3E;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,OAAO,GAAG,mBAAmB,CAgChF;AAED;;GAEG;AACH,wBAAgB,2BAA2B,IAAI,mBAAmB,CAyBjE"}
|
package/dist/openapi-hooks.js
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Create a hook that adds CORS headers to responses
|
|
3
|
-
*/
|
|
4
|
-
export function createCorsHeadersHook(enabled) {
|
|
5
|
-
return (response, _context) => {
|
|
6
|
-
if (!enabled)
|
|
7
|
-
return response;
|
|
8
|
-
return {
|
|
9
|
-
...response,
|
|
10
|
-
headers: {
|
|
11
|
-
...response.headers,
|
|
12
|
-
'Access-Control-Allow-Origin': {
|
|
13
|
-
$ref: '#/components/headers/Access-Control-Allow-Origin',
|
|
14
|
-
},
|
|
15
|
-
},
|
|
16
|
-
};
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Create a hook that adds rate limiting headers to responses
|
|
21
|
-
*/
|
|
22
|
-
export function createRateLimitHeadersHook(enabled) {
|
|
23
|
-
return (response, context) => {
|
|
24
|
-
if (!enabled)
|
|
25
|
-
return response;
|
|
26
|
-
const { statusCode } = context;
|
|
27
|
-
const headers = {
|
|
28
|
-
'RateLimit-Limit': {
|
|
29
|
-
$ref: '#/components/headers/RateLimit-Limit',
|
|
30
|
-
},
|
|
31
|
-
'RateLimit-Remaining': {
|
|
32
|
-
$ref: '#/components/headers/RateLimit-Remaining',
|
|
33
|
-
},
|
|
34
|
-
'RateLimit-Reset': {
|
|
35
|
-
$ref: '#/components/headers/RateLimit-Reset',
|
|
36
|
-
},
|
|
37
|
-
};
|
|
38
|
-
// Add Retry-After header for 429 responses
|
|
39
|
-
if (statusCode === '429') {
|
|
40
|
-
headers['Retry-After'] = {
|
|
41
|
-
$ref: '#/components/headers/Retry-After',
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
return {
|
|
45
|
-
...response,
|
|
46
|
-
headers: {
|
|
47
|
-
...response.headers,
|
|
48
|
-
...headers,
|
|
49
|
-
},
|
|
50
|
-
};
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Create a hook that adds pagination headers to 200 responses
|
|
55
|
-
*/
|
|
56
|
-
export function createPaginationHeadersHook() {
|
|
57
|
-
return (response, context) => {
|
|
58
|
-
const { statusCode, routeConfig } = context;
|
|
59
|
-
// Only add pagination headers to 200 responses with paginate flag
|
|
60
|
-
if (statusCode !== '200' || !routeConfig.paginate) {
|
|
61
|
-
return response;
|
|
62
|
-
}
|
|
63
|
-
return {
|
|
64
|
-
...response,
|
|
65
|
-
headers: {
|
|
66
|
-
...response.headers,
|
|
67
|
-
'X-Total-Count': {
|
|
68
|
-
$ref: '#/components/headers/X-Total-Count',
|
|
69
|
-
},
|
|
70
|
-
'X-Page': {
|
|
71
|
-
$ref: '#/components/headers/X-Page',
|
|
72
|
-
},
|
|
73
|
-
'X-Limit': {
|
|
74
|
-
$ref: '#/components/headers/X-Limit',
|
|
75
|
-
},
|
|
76
|
-
},
|
|
77
|
-
};
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
//# sourceMappingURL=openapi-hooks.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"openapi-hooks.js","sourceRoot":"","sources":["../src/openapi-hooks.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,UAAU,qBAAqB,CAAC,OAAgB;IACpD,OAAO,CAAC,QAAQ,EAAE,QAAQ,EAAE,EAAE;QAC5B,IAAI,CAAC,OAAO;YAAE,OAAO,QAAQ,CAAC;QAE9B,O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oBACf,IAAI,EAAE,oCAAoC;iBAC3C;gBACD,QAAQ,EAAE;oBACR,IAAI,EAAE,6BAA6B;iBACpC;gBACD,SAAS,EAAE;oBACT,IAAI,EAAE,8BAA8B;iBACrC;aACF;SACF,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC"}
|
package/dist/openapi.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type { Hono } from 'hono';
|
|
2
|
-
import type { Environment, MiddlewareOptions, OpenAPIOptions, RateLimitOptions } from './types.js';
|
|
3
|
-
export interface ConfigureOpenAPIOptions {
|
|
4
|
-
app: Hono;
|
|
5
|
-
environment: Environment;
|
|
6
|
-
openapi: OpenAPIOptions;
|
|
7
|
-
rateLimit?: RateLimitOptions;
|
|
8
|
-
middleware?: MiddlewareOptions;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Configure OpenAPI documentation for the application.
|
|
12
|
-
*
|
|
13
|
-
* Behavior by environment:
|
|
14
|
-
* - development: Serve specs and UI at /api and /api/openapi.json
|
|
15
|
-
* - production: Write spec to disk (openapi.json), no serving
|
|
16
|
-
* - test: Disabled by default
|
|
17
|
-
*
|
|
18
|
-
* This function automatically sets up response hooks based on enabled features
|
|
19
|
-
* and merges them with any application-provided hooks.
|
|
20
|
-
*
|
|
21
|
-
* @param options - Configuration options
|
|
22
|
-
*/
|
|
23
|
-
export declare function configureOpenAPI(options: ConfigureOpenAPIOptions): void;
|
|
24
|
-
//# sourceMappingURL=openapi.d.ts.map
|
package/dist/openapi.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"openapi.d.ts","sourceRoot":"","sources":["../src/openapi.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAUjC,OAAO,KAAK,EAAE,WAAW,EAAE,iBAAiB,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAGnG,MAAM,WAAW,uBAAuB;IACtC,GAAG,EAAE,IAAI,CAAC;IACV,WAAW,EAAE,WAAW,CAAC;IACzB,OAAO,EAAE,cAAc,CAAC;IACxB,SAAS,CAAC,EAAE,gBAAgB,CAAC;IAC7B,UAAU,CAAC,EAAE,iBAAiB,CAAC;CAChC;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,uBAAuB,GAAG,IAAI,CAgEvE"}
|
package/dist/openapi.js
DELETED
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
import { writeFile } from 'node:fs/promises';
|
|
2
|
-
import { swaggerUI } from '@hono/swagger-ui';
|
|
3
|
-
import { openAPISpecs } from 'hono-openapi';
|
|
4
|
-
import { defaultOpenAPIComponents } from './openapi-defaults.js';
|
|
5
|
-
import { createCorsHeadersHook, createPaginationHeadersHook, createRateLimitHeadersHook, } from './openapi-hooks.js';
|
|
6
|
-
import { setGlobalResponseHooks } from './route-helpers.js';
|
|
7
|
-
import { deepMerge } from './utils.js';
|
|
8
|
-
/**
|
|
9
|
-
* Configure OpenAPI documentation for the application.
|
|
10
|
-
*
|
|
11
|
-
* Behavior by environment:
|
|
12
|
-
* - development: Serve specs and UI at /api and /api/openapi.json
|
|
13
|
-
* - production: Write spec to disk (openapi.json), no serving
|
|
14
|
-
* - test: Disabled by default
|
|
15
|
-
*
|
|
16
|
-
* This function automatically sets up response hooks based on enabled features
|
|
17
|
-
* and merges them with any application-provided hooks.
|
|
18
|
-
*
|
|
19
|
-
* @param options - Configuration options
|
|
20
|
-
*/
|
|
21
|
-
export function configureOpenAPI(options) {
|
|
22
|
-
const { app, environment, openapi, rateLimit, middleware } = options;
|
|
23
|
-
if (!openapi.enabled) {
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
const shouldServeSpecs = openapi.serveSpecs ?? environment === 'development';
|
|
27
|
-
const shouldServeUI = openapi.serveUI ?? environment === 'development';
|
|
28
|
-
// Build response hooks based on enabled features
|
|
29
|
-
const frameworkHooks = [
|
|
30
|
-
createCorsHeadersHook(!!middleware?.cors),
|
|
31
|
-
createRateLimitHeadersHook(rateLimit?.enabled ?? false),
|
|
32
|
-
createPaginationHeadersHook(),
|
|
33
|
-
];
|
|
34
|
-
// Merge with application-provided hooks
|
|
35
|
-
const allHooks = [...frameworkHooks, ...(openapi.responseHooks || [])];
|
|
36
|
-
// Make hooks available to route definitions globally
|
|
37
|
-
// This must be done synchronously before routes are mounted
|
|
38
|
-
setGlobalResponseHooks(allHooks);
|
|
39
|
-
// Filter components based on enabled features (only include headers that are actually used)
|
|
40
|
-
const filteredComponents = filterComponentsByFeatures(defaultOpenAPIComponents, {
|
|
41
|
-
rateLimitEnabled: rateLimit?.enabled ?? false,
|
|
42
|
-
corsEnabled: !!middleware?.cors,
|
|
43
|
-
});
|
|
44
|
-
// Merge application documentation with filtered Glasswork defaults
|
|
45
|
-
const mergedDocumentation = deepMerge({ components: filteredComponents }, openapi.documentation || {});
|
|
46
|
-
// Serve OpenAPI spec endpoint (development only by default)
|
|
47
|
-
if (shouldServeSpecs) {
|
|
48
|
-
app.get('/api/openapi.json', openAPISpecs(app, { documentation: mergedDocumentation }));
|
|
49
|
-
}
|
|
50
|
-
// Serve Swagger UI (development only by default)
|
|
51
|
-
if (shouldServeUI) {
|
|
52
|
-
app.get('/api', swaggerUI({ url: '/api/openapi.json' }));
|
|
53
|
-
}
|
|
54
|
-
// Write OpenAPI spec to file (production/Lambda)
|
|
55
|
-
if (openapi.writeToFile) {
|
|
56
|
-
const filePath = openapi.writeToFile;
|
|
57
|
-
// Generate spec and write to file
|
|
58
|
-
// This happens after routes are registered
|
|
59
|
-
setTimeout(async () => {
|
|
60
|
-
try {
|
|
61
|
-
// Use Hono's built-in request method to simulate the request
|
|
62
|
-
const response = await app.request('/api/openapi.json');
|
|
63
|
-
const specContent = await response.text();
|
|
64
|
-
await writeFile(filePath, specContent, 'utf-8');
|
|
65
|
-
console.log(`[Glasswork] OpenAPI spec written to ${filePath}`);
|
|
66
|
-
}
|
|
67
|
-
catch (error) {
|
|
68
|
-
console.error('[Glasswork] Failed to write OpenAPI spec:', error);
|
|
69
|
-
}
|
|
70
|
-
}, 1000); // Wait for routes to be registered
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Filter component headers based on enabled features.
|
|
75
|
-
* This removes header definitions from the components schema that won't be used.
|
|
76
|
-
*/
|
|
77
|
-
function filterComponentsByFeatures(components, features) {
|
|
78
|
-
if (!components.headers) {
|
|
79
|
-
return components;
|
|
80
|
-
}
|
|
81
|
-
const filteredHeaders = Object.fromEntries(Object.entries(components.headers).filter(([name]) => shouldIncludeHeader(name, features)));
|
|
82
|
-
return {
|
|
83
|
-
...components,
|
|
84
|
-
headers: filteredHeaders,
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Determine if a header should be included based on feature configuration
|
|
89
|
-
*/
|
|
90
|
-
function shouldIncludeHeader(headerName, { rateLimitEnabled, corsEnabled }) {
|
|
91
|
-
// Always include pagination headers (they're route-specific, not feature-gated)
|
|
92
|
-
if (headerName.startsWith('X-')) {
|
|
93
|
-
return true;
|
|
94
|
-
}
|
|
95
|
-
// Include CORS headers only if CORS is enabled
|
|
96
|
-
if (headerName === 'AccessControlAllowOrigin') {
|
|
97
|
-
return corsEnabled;
|
|
98
|
-
}
|
|
99
|
-
// Include rate limit headers only if rate limiting is enabled
|
|
100
|
-
if (headerName.startsWith('RateLimit') || headerName === 'RetryAfter') {
|
|
101
|
-
return rateLimitEnabled;
|
|
102
|
-
}
|
|
103
|
-
// Include other headers by default
|
|
104
|
-
return true;
|
|
105
|
-
}
|
|
106
|
-
//# sourceMappingURL=openapi.js.map
|
package/dist/openapi.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"openapi.js","sourceRoot":"","sources":["../src/openapi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC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,0BAA0B,CACjC,UAAsC,EACtC,QAA6D;IAE7D,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;QACxB,OAAO,UAAU,CAAC;IACpB,CAAC;IAED,MAAM,eAAe,GAAG,MAAM,CAAC,WAAW,CACxC,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,mBAAmB,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAC3F,CAAC;IAEF,OAAO;QACL,GAAG,UAAU;QACb,OAAO,EAAE,eAAe;KACzB,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,SAAS,mBAAmB,CAC1B,UAAkB,EAClB,EAAE,gBAAgB,EAAE,WAAW,EAAuD;IAEtF,gFAAgF;IAChF,IAAI,UAAU,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QAChC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,+CAA+C;IAC/C,IAAI,UAAU,KAAK,0BAA0B,EAAE,CAAC;QAC9C,OAAO,WAAW,CAAC;IACrB,CAAC;IAED,8DAA8D;IAC9D,IAAI,UAAU,CAAC,UAAU,CAAC,WAAW,CAAC,IAAI,UAAU,KAAK,YAAY,EAAE,CAAC;QACtE,OAAO,gBAAgB,CAAC;IAC1B,CAAC;IAED,mCAAmC;IACnC,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/dist/pagination.d.ts
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import type { Context } from 'hono';
|
|
2
|
-
/**
|
|
3
|
-
* Pagination input parameters
|
|
4
|
-
*/
|
|
5
|
-
export interface PaginationInput {
|
|
6
|
-
page: number;
|
|
7
|
-
limit: number;
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Paginated output structure
|
|
11
|
-
*/
|
|
12
|
-
export interface PaginatedOutput<T> {
|
|
13
|
-
data: T[];
|
|
14
|
-
total: number;
|
|
15
|
-
page: number;
|
|
16
|
-
limit: number;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Execute a paginated query and set response headers.
|
|
20
|
-
*
|
|
21
|
-
* This helper extracts pagination parameters from the query string,
|
|
22
|
-
* executes the provided function, and sets the appropriate response headers.
|
|
23
|
-
*
|
|
24
|
-
* @template T - The type of items in the result
|
|
25
|
-
* @param c - Hono context
|
|
26
|
-
* @param fn - Function that executes the paginated query
|
|
27
|
-
* @returns Array of items (headers are set as side effect)
|
|
28
|
-
*
|
|
29
|
-
* @example
|
|
30
|
-
* ```typescript
|
|
31
|
-
* router.get('/users', route({
|
|
32
|
-
* paginate: true,
|
|
33
|
-
* handler: async ({ context }) => {
|
|
34
|
-
* return await paginate(context, (p) => userService.getUsers(p));
|
|
35
|
-
* }
|
|
36
|
-
* }));
|
|
37
|
-
* ```
|
|
38
|
-
*/
|
|
39
|
-
export declare function paginate<T>(c: Context, fn: (p: PaginationInput) => Promise<PaginatedOutput<T>>): Promise<T[]>;
|
|
40
|
-
/**
|
|
41
|
-
* Extract pagination parameters from Hono context.
|
|
42
|
-
*
|
|
43
|
-
* @param c - Hono context
|
|
44
|
-
* @param defaultLimit - Default limit if not provided (default: 100)
|
|
45
|
-
* @returns Pagination input with page and limit
|
|
46
|
-
*/
|
|
47
|
-
export declare function paginationInput(c: Context, defaultLimit?: number): PaginationInput;
|
|
48
|
-
//# sourceMappingURL=pagination.d.ts.map
|
package/dist/pagination.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pagination.d.ts","sourceRoot":"","sources":["../src/pagination.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAEpC;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,eAAe,CAAC,CAAC;IAChC,IAAI,EAAE,CAAC,EAAE,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,QAAQ,CAAC,CAAC,EAC9B,CAAC,EAAE,OAAO,EACV,EAAE,EAAE,CAAC,CAAC,EAAE,eAAe,KAAK,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,GACtD,OAAO,CAAC,CAAC,EAAE,CAAC,CAUd;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,OAAO,EAAE,YAAY,SAAM,GAAG,eAAe,CAI/E"}
|
package/dist/pagination.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Execute a paginated query and set response headers.
|
|
3
|
-
*
|
|
4
|
-
* This helper extracts pagination parameters from the query string,
|
|
5
|
-
* executes the provided function, and sets the appropriate response headers.
|
|
6
|
-
*
|
|
7
|
-
* @template T - The type of items in the result
|
|
8
|
-
* @param c - Hono context
|
|
9
|
-
* @param fn - Function that executes the paginated query
|
|
10
|
-
* @returns Array of items (headers are set as side effect)
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* ```typescript
|
|
14
|
-
* router.get('/users', route({
|
|
15
|
-
* paginate: true,
|
|
16
|
-
* handler: async ({ context }) => {
|
|
17
|
-
* return await paginate(context, (p) => userService.getUsers(p));
|
|
18
|
-
* }
|
|
19
|
-
* }));
|
|
20
|
-
* ```
|
|
21
|
-
*/
|
|
22
|
-
export async function paginate(c, fn) {
|
|
23
|
-
const pagination = paginationInput(c);
|
|
24
|
-
const result = await fn(pagination);
|
|
25
|
-
// Set pagination headers
|
|
26
|
-
c.header('X-Total-Count', result.total.toString());
|
|
27
|
-
c.header('X-Page', result.page.toString());
|
|
28
|
-
c.header('X-Limit', result.limit.toString());
|
|
29
|
-
return result.data;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Extract pagination parameters from Hono context.
|
|
33
|
-
*
|
|
34
|
-
* @param c - Hono context
|
|
35
|
-
* @param defaultLimit - Default limit if not provided (default: 100)
|
|
36
|
-
* @returns Pagination input with page and limit
|
|
37
|
-
*/
|
|
38
|
-
export function paginationInput(c, defaultLimit = 100) {
|
|
39
|
-
const page = Number.parseInt(c.req.query('page') ?? '1', 10);
|
|
40
|
-
const limit = Number.parseInt(c.req.query('limit') ?? defaultLimit.toString(), 10);
|
|
41
|
-
return { page, limit };
|
|
42
|
-
}
|
|
43
|
-
//# sourceMappingURL=pagination.js.map
|
package/dist/pagination.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pagination.js","sourceRoot":"","sources":["../src/pagination.ts"],"names":[],"mappings":"AAoBA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAC5B,CAAU,EACV,EAAuD;IAEvD,MAAM,UAAU,GAAG,eAAe,CAAC,CAAC,CAAC,CAAC;IACtC,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC,UAAU,CAAC,CAAC;IAEpC,yBAAyB;IACzB,CAAC,CAAC,MAAM,CAAC,eAAe,EAAE,MAAM,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC;IACnD,CAAC,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC3C,CAAC,CAAC,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC;IAE7C,OAAO,MAAM,CAAC,IAAI,CAAC;AACrB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAAC,CAAU,EAAE,YAAY,GAAG,GAAG;IAC5D,MAAM,IAAI,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,GAAG,EAAE,EAAE,CAAC,CAAC;IAC7D,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,YAAY,CAAC,QAAQ,EAAE,EAAE,EAAE,CAAC,CAAC;IACnF,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;AACzB,CAAC"}
|
package/dist/pick.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Creates a new object by picking specified keys from the source object.
|
|
3
|
-
*
|
|
4
|
-
* This implementation preserves the object's prototype, making it suitable
|
|
5
|
-
* for use with class instances and objects with custom prototypes.
|
|
6
|
-
*
|
|
7
|
-
* @template T - The type of the source object
|
|
8
|
-
* @template K - The type of keys to pick (must be keys of T)
|
|
9
|
-
* @param obj - The source object to pick keys from
|
|
10
|
-
* @param paths - Array of keys to pick from the object
|
|
11
|
-
* @returns A new object containing only the specified keys
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* ```typescript
|
|
15
|
-
* const user = { id: 1, name: 'John', email: 'john@example.com', password: 'secret' };
|
|
16
|
-
* const publicUser = pick(user, ['id', 'name']); // { id: 1, name: 'John' }
|
|
17
|
-
* ```
|
|
18
|
-
*/
|
|
19
|
-
export declare function pick<T extends object, K extends keyof T>(obj: T, paths: K[]): Pick<T, K>;
|
|
20
|
-
//# sourceMappingURL=pick.d.ts.map
|
package/dist/pick.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pick.d.ts","sourceRoot":"","sources":["../src/pick.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,IAAI,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAUxF"}
|
package/dist/pick.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Creates a new object by picking specified keys from the source object.
|
|
3
|
-
*
|
|
4
|
-
* This implementation preserves the object's prototype, making it suitable
|
|
5
|
-
* for use with class instances and objects with custom prototypes.
|
|
6
|
-
*
|
|
7
|
-
* @template T - The type of the source object
|
|
8
|
-
* @template K - The type of keys to pick (must be keys of T)
|
|
9
|
-
* @param obj - The source object to pick keys from
|
|
10
|
-
* @param paths - Array of keys to pick from the object
|
|
11
|
-
* @returns A new object containing only the specified keys
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* ```typescript
|
|
15
|
-
* const user = { id: 1, name: 'John', email: 'john@example.com', password: 'secret' };
|
|
16
|
-
* const publicUser = pick(user, ['id', 'name']); // { id: 1, name: 'John' }
|
|
17
|
-
* ```
|
|
18
|
-
*/
|
|
19
|
-
export function pick(obj, paths) {
|
|
20
|
-
const result = Object.create(Object.getPrototypeOf(obj));
|
|
21
|
-
for (const key of paths) {
|
|
22
|
-
if (Object.hasOwn(obj, key)) {
|
|
23
|
-
result[key] = obj[key];
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
return result;
|
|
27
|
-
}
|
|
28
|
-
//# sourceMappingURL=pick.js.map
|
package/dist/pick.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pick.js","sourceRoot":"","sources":["../src/pick.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,IAAI,CAAsC,GAAM,EAAE,KAAU;IAC1E,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,GAAG,CAAC,CAAe,CAAC;IAEvE,KAAK,MAAM,GAAG,IAAI,KAAK,EAAE,CAAC;QACxB,IAAI,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,CAAC;YAC5B,MAAM,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;QACzB,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/dist/rate-limit.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { MiddlewareHandler } from 'hono';
|
|
2
|
-
import type { RateLimitOptions } from './types.js';
|
|
3
|
-
/**
|
|
4
|
-
* Create rate limiting middleware
|
|
5
|
-
*/
|
|
6
|
-
export declare function createRateLimitMiddleware(options: RateLimitOptions): MiddlewareHandler;
|
|
7
|
-
//# sourceMappingURL=rate-limit.d.ts.map
|
package/dist/rate-limit.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"rate-limit.d.ts","sourceRoot":"","sources":["../src/rate-limit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AAC9C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAkKnD;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,gBAAgB,GAAG,iBAAiB,CAuDtF"}
|