veloce-ts 0.4.1 → 0.4.3

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.
Files changed (113) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/dist/cjs/src/adapters/express.js.map +2 -2
  3. package/dist/cjs/src/adapters/hono.js.map +1 -1
  4. package/dist/cjs/src/auth/index.js +4 -4
  5. package/dist/cjs/src/auth/index.js.map +8 -7
  6. package/dist/cjs/src/cli/index.js.map +2 -2
  7. package/dist/cjs/src/docs/index.js +3 -3
  8. package/dist/cjs/src/docs/index.js.map +1 -1
  9. package/dist/cjs/src/errors/index.js +20 -19
  10. package/dist/cjs/src/errors/index.js.map +9 -8
  11. package/dist/cjs/src/graphql/index.js +14 -14
  12. package/dist/cjs/src/graphql/index.js.map +7 -6
  13. package/dist/cjs/src/index.js +30 -29
  14. package/dist/cjs/src/index.js.map +28 -27
  15. package/dist/cjs/src/middleware/index.js +10 -10
  16. package/dist/cjs/src/middleware/index.js.map +4 -4
  17. package/dist/cjs/src/plugins/index.js +21 -21
  18. package/dist/cjs/src/plugins/index.js.map +9 -8
  19. package/dist/cjs/src/testing/index.js +27 -26
  20. package/dist/cjs/src/testing/index.js.map +22 -21
  21. package/dist/cjs/src/validation/index.js +2 -2
  22. package/dist/cjs/src/validation/index.js.map +7 -6
  23. package/dist/cjs/src/websocket/index.js.map +2 -2
  24. package/dist/esm/src/adapters/express.js.map +2 -2
  25. package/dist/esm/src/adapters/hono.js.map +1 -1
  26. package/dist/esm/src/auth/index.js +4 -4
  27. package/dist/esm/src/auth/index.js.map +8 -7
  28. package/dist/esm/src/cli/index.js.map +2 -2
  29. package/dist/esm/src/docs/index.js +3 -3
  30. package/dist/esm/src/docs/index.js.map +1 -1
  31. package/dist/esm/src/errors/index.js +20 -19
  32. package/dist/esm/src/errors/index.js.map +9 -8
  33. package/dist/esm/src/graphql/index.js +15 -15
  34. package/dist/esm/src/graphql/index.js.map +7 -6
  35. package/dist/esm/src/index.js +30 -29
  36. package/dist/esm/src/index.js.map +28 -27
  37. package/dist/esm/src/middleware/index.js +8 -8
  38. package/dist/esm/src/middleware/index.js.map +4 -4
  39. package/dist/esm/src/plugins/index.js +20 -20
  40. package/dist/esm/src/plugins/index.js.map +9 -8
  41. package/dist/esm/src/testing/index.js +27 -26
  42. package/dist/esm/src/testing/index.js.map +22 -21
  43. package/dist/esm/src/validation/index.js +2 -2
  44. package/dist/esm/src/validation/index.js.map +7 -6
  45. package/dist/esm/src/websocket/index.js.map +2 -2
  46. package/dist/types/adapters/base.d.ts +3 -3
  47. package/dist/types/adapters/express.d.ts +3 -0
  48. package/dist/types/adapters/express.d.ts.map +1 -1
  49. package/dist/types/adapters/hono.d.ts +2 -2
  50. package/dist/types/auth/exceptions.d.ts +5 -10
  51. package/dist/types/auth/exceptions.d.ts.map +1 -1
  52. package/dist/types/auth/index.d.ts +4 -0
  53. package/dist/types/auth/index.d.ts.map +1 -1
  54. package/dist/types/cache/index.d.ts +2 -1
  55. package/dist/types/cache/index.d.ts.map +1 -1
  56. package/dist/types/context/request-context.d.ts +2 -2
  57. package/dist/types/core/application.d.ts +5 -0
  58. package/dist/types/core/application.d.ts.map +1 -1
  59. package/dist/types/core/compiled-metadata.d.ts +5 -0
  60. package/dist/types/core/compiled-metadata.d.ts.map +1 -1
  61. package/dist/types/core/metadata.d.ts +5 -0
  62. package/dist/types/core/metadata.d.ts.map +1 -1
  63. package/dist/types/core/plugin.d.ts +5 -0
  64. package/dist/types/core/plugin.d.ts.map +1 -1
  65. package/dist/types/core/router-compiler.d.ts +5 -0
  66. package/dist/types/core/router-compiler.d.ts.map +1 -1
  67. package/dist/types/decorators/http.d.ts.map +1 -1
  68. package/dist/types/dependencies/container.d.ts +5 -0
  69. package/dist/types/dependencies/container.d.ts.map +1 -1
  70. package/dist/types/dependencies/drizzle.d.ts +3 -0
  71. package/dist/types/dependencies/drizzle.d.ts.map +1 -1
  72. package/dist/types/docs/index.d.ts +4 -0
  73. package/dist/types/docs/index.d.ts.map +1 -1
  74. package/dist/types/errors/exceptions.d.ts +38 -52
  75. package/dist/types/errors/exceptions.d.ts.map +1 -1
  76. package/dist/types/errors/handler.d.ts +23 -43
  77. package/dist/types/errors/handler.d.ts.map +1 -1
  78. package/dist/types/errors/index.d.ts +5 -4
  79. package/dist/types/errors/index.d.ts.map +1 -1
  80. package/dist/types/errors/problem-details.d.ts +35 -0
  81. package/dist/types/errors/problem-details.d.ts.map +1 -0
  82. package/dist/types/graphql/index.d.ts +4 -0
  83. package/dist/types/graphql/index.d.ts.map +1 -1
  84. package/dist/types/index.d.ts +8 -2
  85. package/dist/types/index.d.ts.map +1 -1
  86. package/dist/types/logging/logger.d.ts +3 -4
  87. package/dist/types/logging/logger.d.ts.map +1 -1
  88. package/dist/types/middleware/index.d.ts +4 -0
  89. package/dist/types/middleware/index.d.ts.map +1 -1
  90. package/dist/types/orm/index.d.ts +4 -0
  91. package/dist/types/orm/index.d.ts.map +1 -1
  92. package/dist/types/plugins/health.d.ts.map +1 -1
  93. package/dist/types/plugins/index.d.ts +4 -0
  94. package/dist/types/plugins/index.d.ts.map +1 -1
  95. package/dist/types/responses/response.d.ts +5 -0
  96. package/dist/types/responses/response.d.ts.map +1 -1
  97. package/dist/types/testing/helpers.d.ts +4 -0
  98. package/dist/types/testing/helpers.d.ts.map +1 -1
  99. package/dist/types/testing/index.d.ts +4 -0
  100. package/dist/types/testing/index.d.ts.map +1 -1
  101. package/dist/types/testing/test-client.d.ts +4 -0
  102. package/dist/types/testing/test-client.d.ts.map +1 -1
  103. package/dist/types/types/index.d.ts +12 -0
  104. package/dist/types/types/index.d.ts.map +1 -1
  105. package/dist/types/validation/exceptions.d.ts +8 -16
  106. package/dist/types/validation/exceptions.d.ts.map +1 -1
  107. package/dist/types/validation/index.d.ts +4 -0
  108. package/dist/types/validation/index.d.ts.map +1 -1
  109. package/dist/types/validation/validator.d.ts +4 -0
  110. package/dist/types/validation/validator.d.ts.map +1 -1
  111. package/dist/types/websocket/index.d.ts +4 -0
  112. package/dist/types/websocket/index.d.ts.map +1 -1
  113. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -7,6 +7,30 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.4.3] - 2026-03-27
11
+
12
+ ### Added
13
+ - **RFC 9457 (Problem Details):** respuestas de error por defecto con `Content-Type: application/problem+json`, campos `type`, `title`, `status`, `detail`, `instance` y extensiones (`violations`/`details` en validación; `debug` en 500 solo en desarrollo).
14
+ - **`VeloceTSConfig.errorResponseFormat`:** `'rfc9457'` (defecto) o `'legacy'` para el JSON `{ error, statusCode, details? }` anterior.
15
+ - Helpers exportados: `problemTypeUri`, `resolveProblemType`, `resolveProblemTitle`, `buildProblemInstance`, `toLegacyErrorBody`, `sendErrorResponse`, constantes `PROBLEM_JSON_MEDIA_TYPE`, `DEFAULT_PROBLEM_TYPE_BASE`.
16
+ - **`HTTPExceptionOptions`:** `problemType` y `title` opcionales en el constructor de `HTTPException`.
17
+
18
+ ### Changed
19
+ - Excepciones de auth (`AuthenticationException`, `AuthorizationException`) dejan de definir `toJSON` propio; heredan el formato unificado con URIs `authentication-error` / `authorization-error`.
20
+
21
+ ### Documentation
22
+ - Cabeceras `@module` en el núcleo (application, metadata, router-compiler, plugin, compiled-metadata), errores, validación, DI, respuestas, logging, middleware, adapters, testing, barrels y más.
23
+ - **Benchmarks:** `benchmarks/run.ts` etiquetado como v0.4.3; `BENCHMARKS.md` y `benchmarks/results/latest.json` regenerados (6 000 req, 50 concurrentes, Bun 1.3.5, 2026-03-28).
24
+
25
+ ### Notes
26
+ - El cuerpo JSON de error sigue incluyendo `error` y `statusCode` junto a los campos RFC 9457. Si tu cliente exige `Content-Type: application/json` en errores, usa `errorResponseFormat: 'legacy'` o acepta `application/problem+json`.
27
+
28
+ ## [0.4.2] - 2026-03-27
29
+
30
+ ### Fixed
31
+ - **HealthCheckPlugin:** checker display names are set with `Object.defineProperty` (with a fallback) so runtimes such as Bun do not throw when assigning `.name` on async checker functions.
32
+ - **Public API:** `@Req` is now exported from the main `veloce-ts` entry (it was implemented in `decorators/params` but missing from the package exports).
33
+
10
34
  ## [0.4.1] - 2026-03-27
11
35
 
12
36
  ### Fixed
@@ -2,9 +2,9 @@
2
2
  "version": 3,
3
3
  "sources": ["..\\..\\src\\adapters\\express.ts"],
4
4
  "sourcesContent": [
5
- "/**\r\n * Express adapter for Veloce-TS\r\n *\r\n * Bridges Veloce-TS / Hono routes into an existing Express application.\r\n * The adapter works by forwarding every request received by Express to\r\n * Hono's `fetch()` handler and then writing the Web-standard `Response`\r\n * back through Express's `res` object.\r\n *\r\n * Express is a **peer dependency** — install it separately:\r\n * npm install express\r\n * npm install --save-dev @types/express\r\n *\r\n * @example\r\n * ```ts\r\n * import express from 'express';\r\n * import { VeloceTS } from 'veloce-ts';\r\n * import { ExpressAdapter } from 'veloce-ts/adapters/express';\r\n *\r\n * const veloce = new VeloceTS({ docs: true });\r\n * veloce.get('/hello', { handler: () => ({ message: 'Hello from Veloce!' }) });\r\n * await veloce.compile();\r\n *\r\n * const adapter = new ExpressAdapter(veloce);\r\n *\r\n * // Mount Veloce-TS under a sub-path (or mount at root with '/')\r\n * const expressApp = express();\r\n * expressApp.use('/api', adapter.getHandler());\r\n * expressApp.listen(3000);\r\n * ```\r\n */\r\nimport type { Adapter } from './base';\r\nimport type { VeloceTS } from '../core/application';\r\n\r\n/**\r\n * ExpressAdapter — bridges Veloce-TS to Express.js.\r\n *\r\n * The adapter is completely **standalone** (no `require` at module load time).\r\n * Express is loaded lazily the first time the adapter is constructed, so\r\n * apps that do not use it pay no startup cost.\r\n */\r\nexport class ExpressAdapter implements Adapter {\r\n name = 'express';\r\n private expressApp: any;\r\n\r\n /**\r\n * @param veloceApp - A compiled (or not-yet-compiled) VeloceTS instance.\r\n * @param expressInstance - Optional pre-created Express application.\r\n * Pass your own `express()` if you need to add middleware before the\r\n * Veloce-TS bridge is attached.\r\n */\r\n constructor(private veloceApp: VeloceTS, expressInstance?: any) {\r\n this.expressApp = expressInstance ?? ExpressAdapter.createExpressApp();\r\n this.setupBridge();\r\n }\r\n\r\n // -------------------------------------------------------------------------\r\n // Public API\r\n // -------------------------------------------------------------------------\r\n\r\n /**\r\n * Start listening on `port`.\r\n * @returns The underlying `http.Server` instance.\r\n */\r\n listen(port: number, callback?: () => void): any {\r\n return this.expressApp.listen(port, callback);\r\n }\r\n\r\n /**\r\n * Return the Express application so you can attach additional middleware\r\n * or mount it with `app.use('/prefix', adapter.getHandler())`.\r\n */\r\n getHandler(): any {\r\n return this.expressApp;\r\n }\r\n\r\n /** Alias for `getHandler()`. */\r\n getExpressApp(): any {\r\n return this.expressApp;\r\n }\r\n\r\n // -------------------------------------------------------------------------\r\n // Internal helpers\r\n // -------------------------------------------------------------------------\r\n\r\n /**\r\n * Lazily load Express (works in ESM and CJS, Bun and Node).\r\n * Express is a peer dependency so we load it at runtime.\r\n */\r\n private static createExpressApp(): any {\r\n // Use Function constructor to escape TypeScript's module-aware narrowing of\r\n // `require`. This also ensures the bundler does not try to inline express.\r\n // eslint-disable-next-line no-new-func\r\n const _require = (typeof require !== 'undefined'\r\n ? require\r\n : Function('return require')()) as (id: string) => any;\r\n\r\n let expressFactory: (...args: any[]) => any;\r\n try {\r\n expressFactory = _require('express') as (...args: any[]) => any;\r\n } catch {\r\n throw new Error(\r\n '[ExpressAdapter] Could not load the \"express\" package.\\n' +\r\n 'Install it as a peer dependency: npm install express'\r\n );\r\n }\r\n\r\n return expressFactory();\r\n }\r\n\r\n /**\r\n * Register a catch-all Express middleware that forwards every request to\r\n * Hono and writes the result back.\r\n */\r\n private setupBridge(): void {\r\n const honoApp = this.veloceApp.getHono();\r\n\r\n this.expressApp.use(async (req: any, res: any, next: any) => {\r\n try {\r\n const webRequest = this.toWebRequest(req);\r\n const webResponse = await honoApp.fetch(webRequest);\r\n await this.writeExpressResponse(res, webResponse);\r\n } catch (err) {\r\n // Let Express handle unexpected errors through its error middleware\r\n next(err);\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Convert an Express `req` to a Web-standard `Request`.\r\n *\r\n * Body handling:\r\n * - If Express's `body-parser` (or similar) already parsed the body, it is\r\n * re-serialised as JSON.\r\n * - If the body was streamed directly (raw middleware), the raw buffer is\r\n * forwarded as-is.\r\n */\r\n private toWebRequest(req: any): Request {\r\n const protocol = req.protocol ?? 'http';\r\n const host = req.get?.('host') ?? req.headers?.host ?? 'localhost';\r\n const url = `${protocol}://${host}${req.originalUrl ?? req.url}`;\r\n\r\n const headers = new Headers();\r\n for (const [key, value] of Object.entries<any>(req.headers ?? {})) {\r\n if (typeof value === 'string') {\r\n headers.set(key, value);\r\n } else if (Array.isArray(value)) {\r\n value.forEach((v: string) => headers.append(key, v));\r\n }\r\n }\r\n\r\n const init: RequestInit = { method: req.method, headers };\r\n\r\n if (req.method !== 'GET' && req.method !== 'HEAD') {\r\n if (Buffer.isBuffer(req.body)) {\r\n // Raw body from express.raw() or multer\r\n init.body = req.body;\r\n } else if (req.body !== undefined && req.body !== null) {\r\n // Parsed body from express.json() / express.urlencoded()\r\n init.body = JSON.stringify(req.body);\r\n if (!headers.has('content-type')) {\r\n headers.set('content-type', 'application/json');\r\n }\r\n }\r\n }\r\n\r\n return new Request(url, init);\r\n }\r\n\r\n /**\r\n * Write a Web-standard `Response` back through Express `res`.\r\n */\r\n private async writeExpressResponse(res: any, response: Response): Promise<void> {\r\n res.status(response.status);\r\n\r\n // Forward all headers from Hono to Express\r\n response.headers.forEach((value: string, key: string) => {\r\n // Skip hop-by-hop headers that Express manages itself\r\n if (key.toLowerCase() !== 'transfer-encoding') {\r\n res.setHeader(key, value);\r\n }\r\n });\r\n\r\n if (!response.body) {\r\n res.end();\r\n return;\r\n }\r\n\r\n const contentType = response.headers.get('content-type') ?? '';\r\n\r\n if (contentType.includes('application/json')) {\r\n const json = await response.json();\r\n res.json(json);\r\n } else if (contentType.startsWith('text/')) {\r\n const text = await response.text();\r\n res.send(text);\r\n } else {\r\n // Binary / streaming content — send as Buffer\r\n const buffer = await response.arrayBuffer();\r\n res.send(Buffer.from(buffer));\r\n }\r\n }\r\n}\r\n"
5
+ "/**\r\n * @module veloce-ts/adapters/express\r\n * @description {@link ExpressAdapter}: monta la app Hono interna detrás de Express reenviando cada request a `fetch` y copiando la `Response`.\r\n *\r\n * Express adapter for Veloce-TS\r\n *\r\n * Bridges Veloce-TS / Hono routes into an existing Express application.\r\n * The adapter works by forwarding every request received by Express to\r\n * Hono's `fetch()` handler and then writing the Web-standard `Response`\r\n * back through Express's `res` object.\r\n *\r\n * Express is a **peer dependency** — install it separately:\r\n * npm install express\r\n * npm install --save-dev @types/express\r\n *\r\n * @example\r\n * ```ts\r\n * import express from 'express';\r\n * import { VeloceTS } from 'veloce-ts';\r\n * import { ExpressAdapter } from 'veloce-ts/adapters/express';\r\n *\r\n * const veloce = new VeloceTS({ docs: true });\r\n * veloce.get('/hello', { handler: () => ({ message: 'Hello from Veloce!' }) });\r\n * await veloce.compile();\r\n *\r\n * const adapter = new ExpressAdapter(veloce);\r\n *\r\n * // Mount Veloce-TS under a sub-path (or mount at root with '/')\r\n * const expressApp = express();\r\n * expressApp.use('/api', adapter.getHandler());\r\n * expressApp.listen(3000);\r\n * ```\r\n */\r\nimport type { Adapter } from './base';\r\nimport type { VeloceTS } from '../core/application';\r\n\r\n/**\r\n * ExpressAdapter — bridges Veloce-TS to Express.js.\r\n *\r\n * The adapter is completely **standalone** (no `require` at module load time).\r\n * Express is loaded lazily the first time the adapter is constructed, so\r\n * apps that do not use it pay no startup cost.\r\n */\r\nexport class ExpressAdapter implements Adapter {\r\n name = 'express';\r\n private expressApp: any;\r\n\r\n /**\r\n * @param veloceApp - A compiled (or not-yet-compiled) VeloceTS instance.\r\n * @param expressInstance - Optional pre-created Express application.\r\n * Pass your own `express()` if you need to add middleware before the\r\n * Veloce-TS bridge is attached.\r\n */\r\n constructor(private veloceApp: VeloceTS, expressInstance?: any) {\r\n this.expressApp = expressInstance ?? ExpressAdapter.createExpressApp();\r\n this.setupBridge();\r\n }\r\n\r\n // -------------------------------------------------------------------------\r\n // Public API\r\n // -------------------------------------------------------------------------\r\n\r\n /**\r\n * Start listening on `port`.\r\n * @returns The underlying `http.Server` instance.\r\n */\r\n listen(port: number, callback?: () => void): any {\r\n return this.expressApp.listen(port, callback);\r\n }\r\n\r\n /**\r\n * Return the Express application so you can attach additional middleware\r\n * or mount it with `app.use('/prefix', adapter.getHandler())`.\r\n */\r\n getHandler(): any {\r\n return this.expressApp;\r\n }\r\n\r\n /** Alias for `getHandler()`. */\r\n getExpressApp(): any {\r\n return this.expressApp;\r\n }\r\n\r\n // -------------------------------------------------------------------------\r\n // Internal helpers\r\n // -------------------------------------------------------------------------\r\n\r\n /**\r\n * Lazily load Express (works in ESM and CJS, Bun and Node).\r\n * Express is a peer dependency so we load it at runtime.\r\n */\r\n private static createExpressApp(): any {\r\n // Use Function constructor to escape TypeScript's module-aware narrowing of\r\n // `require`. This also ensures the bundler does not try to inline express.\r\n // eslint-disable-next-line no-new-func\r\n const _require = (typeof require !== 'undefined'\r\n ? require\r\n : Function('return require')()) as (id: string) => any;\r\n\r\n let expressFactory: (...args: any[]) => any;\r\n try {\r\n expressFactory = _require('express') as (...args: any[]) => any;\r\n } catch {\r\n throw new Error(\r\n '[ExpressAdapter] Could not load the \"express\" package.\\n' +\r\n 'Install it as a peer dependency: npm install express'\r\n );\r\n }\r\n\r\n return expressFactory();\r\n }\r\n\r\n /**\r\n * Register a catch-all Express middleware that forwards every request to\r\n * Hono and writes the result back.\r\n */\r\n private setupBridge(): void {\r\n const honoApp = this.veloceApp.getHono();\r\n\r\n this.expressApp.use(async (req: any, res: any, next: any) => {\r\n try {\r\n const webRequest = this.toWebRequest(req);\r\n const webResponse = await honoApp.fetch(webRequest);\r\n await this.writeExpressResponse(res, webResponse);\r\n } catch (err) {\r\n // Let Express handle unexpected errors through its error middleware\r\n next(err);\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Convert an Express `req` to a Web-standard `Request`.\r\n *\r\n * Body handling:\r\n * - If Express's `body-parser` (or similar) already parsed the body, it is\r\n * re-serialised as JSON.\r\n * - If the body was streamed directly (raw middleware), the raw buffer is\r\n * forwarded as-is.\r\n */\r\n private toWebRequest(req: any): Request {\r\n const protocol = req.protocol ?? 'http';\r\n const host = req.get?.('host') ?? req.headers?.host ?? 'localhost';\r\n const url = `${protocol}://${host}${req.originalUrl ?? req.url}`;\r\n\r\n const headers = new Headers();\r\n for (const [key, value] of Object.entries<any>(req.headers ?? {})) {\r\n if (typeof value === 'string') {\r\n headers.set(key, value);\r\n } else if (Array.isArray(value)) {\r\n value.forEach((v: string) => headers.append(key, v));\r\n }\r\n }\r\n\r\n const init: RequestInit = { method: req.method, headers };\r\n\r\n if (req.method !== 'GET' && req.method !== 'HEAD') {\r\n if (Buffer.isBuffer(req.body)) {\r\n // Raw body from express.raw() or multer\r\n init.body = req.body;\r\n } else if (req.body !== undefined && req.body !== null) {\r\n // Parsed body from express.json() / express.urlencoded()\r\n init.body = JSON.stringify(req.body);\r\n if (!headers.has('content-type')) {\r\n headers.set('content-type', 'application/json');\r\n }\r\n }\r\n }\r\n\r\n return new Request(url, init);\r\n }\r\n\r\n /**\r\n * Write a Web-standard `Response` back through Express `res`.\r\n */\r\n private async writeExpressResponse(res: any, response: Response): Promise<void> {\r\n res.status(response.status);\r\n\r\n // Forward all headers from Hono to Express\r\n response.headers.forEach((value: string, key: string) => {\r\n // Skip hop-by-hop headers that Express manages itself\r\n if (key.toLowerCase() !== 'transfer-encoding') {\r\n res.setHeader(key, value);\r\n }\r\n });\r\n\r\n if (!response.body) {\r\n res.end();\r\n return;\r\n }\r\n\r\n const contentType = response.headers.get('content-type') ?? '';\r\n\r\n if (contentType.includes('application/json')) {\r\n const json = await response.json();\r\n res.json(json);\r\n } else if (contentType.startsWith('text/')) {\r\n const text = await response.text();\r\n res.send(text);\r\n } else {\r\n // Binary / stre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AQ,QAAQ,CAAC,EAAe,IAAgB,CAEvD,GAAI,EAAI,YAAY,IAAM,oBACxB,EAAI,UAAU,EAAK,CAAK,EAE3B,EAEG,CAAC,EAAS,KAAM,CAClB,EAAI,IAAI,EACR,OAGF,IAAM,EAAc,EAAS,QAAQ,IAAI,cAAc,GAAK,GAE5D,GAAI,EAAY,SAAS,kBAAkB,EAAG,CAC5C,IAAM,EAAO,MAAM,EAAS,KAAK,EACjC,EAAI,KAAK,CAAI,EACR,QAAI,EAAY,WAAW,OAAO,EAAG,CAC1C,IAAM,EAAO,MAAM,EAAS,KAAK,EACjC,EAAI,KAAK,CAAI,EACR,KAEL,IAAM,EAAS,MAAM,EAAS,YAAY,EAC1C,EAAI,KAAK,OAAO,KAAK,CAAM,CAAC,GAGlC",
8
8
  "debugId": "8B5C1D588B2B820364756E2164756E21",
9
9
  "names": []
10
10
  }
@@ -2,7 +2,7 @@
2
2
  "version": 3,
3
3
  "sources": ["..\\..\\src\\adapters\\hono.ts"],
4
4
  "sourcesContent": [
5
- "/**\r\n * Hono adapter for runtime-agnostic server deployment\r\n * Supports Bun, Node.js, Deno, and Cloudflare Workers\r\n */\r\nimport type { Hono } from 'hono';\r\nimport type { Adapter, ServerInstance } from './base';\r\n\r\n// Type declarations for runtime globals\r\ndeclare const Deno: any;\r\ndeclare const Bun: any;\r\n\r\n/**\r\n * Runtime detection utilities\r\n */\r\nconst detectRuntime = (): 'bun' | 'deno' | 'node' | 'workerd' | 'unknown' => {\r\n // Check for Bun\r\n if (typeof Bun !== 'undefined') {\r\n return 'bun';\r\n }\r\n\r\n // Check for Deno\r\n if (typeof Deno !== 'undefined') {\r\n return 'deno';\r\n }\r\n\r\n // Check for Cloudflare Workers\r\n if (typeof navigator !== 'undefined' && navigator.userAgent === 'Cloudflare-Workers') {\r\n return 'workerd';\r\n }\r\n\r\n // Check for Node.js\r\n if (typeof process !== 'undefined' && process.versions && process.versions.node) {\r\n return 'node';\r\n }\r\n\r\n return 'unknown';\r\n};\r\n\r\n/**\r\n * HonoAdapter - Adapts Hono.js to work across multiple runtimes\r\n * Automatically detects the runtime and uses the appropriate server implementation\r\n */\r\nexport class HonoAdapter implements Adapter {\r\n name = 'hono';\r\n private runtime: ReturnType<typeof detectRuntime>;\r\n\r\n constructor(private hono: Hono) {\r\n this.runtime = detectRuntime();\r\n }\r\n\r\n /**\r\n * Start the server on the specified port\r\n * Automatically uses the appropriate server for the detected runtime\r\n */\r\n listen(port: number, callback?: () => void): ServerInstance {\r\n switch (this.runtime) {\r\n case 'bun':\r\n return this.listenBun(port, callback);\r\n \r\n case 'deno':\r\n return this.listenDeno(port, callback);\r\n \r\n case 'node':\r\n return this.listenNode(port, callback);\r\n \r\n case 'workerd':\r\n throw new Error(\r\n 'Cloudflare Workers do not support listen(). Deploy using wrangler or export the handler with getHandler().'\r\n );\r\n \r\n default:\r\n throw new Error(\r\n `Unsupported runtime: ${this.runtime}. FastAPI-TS supports Bun, Node.js, Deno, and Cloudflare Workers.`\r\n );\r\n }\r\n }\r\n\r\n /**\r\n * Get the Hono fetch handler\r\n * This can be used directly in serverless environments or for custom server setups\r\n */\r\n getHandler() {\r\n return this.hono.fetch;\r\n }\r\n\r\n /**\r\n * Get the detected runtime\r\n */\r\n getRuntime(): string {\r\n return this.runtime;\r\n }\r\n\r\n /**\r\n * Start server using Bun's native server\r\n */\r\n private listenBun(port: number, callback?: () => void): ServerInstance {\r\n const server = Bun.serve({\r\n port,\r\n fetch: this.hono.fetch,\r\n });\r\n\r\n if (callback) {\r\n callback();\r\n }\r\n\r\n return {\r\n port,\r\n close: async () => {\r\n server.stop();\r\n },\r\n ...server\r\n };\r\n }\r\n\r\n /**\r\n * Start server using Deno's native server\r\n */\r\n private listenDeno(port: number, callback?: () => void): ServerInstance {\r\n // Deno.serve returns a promise, so we handle it appropriately\r\n const ac = new AbortController();\r\n \r\n Deno.serve(\r\n {\r\n port,\r\n signal: ac.signal,\r\n onListen: callback\r\n },\r\n this.hono.fetch\r\n );\r\n\r\n // Return an object with a close method for consistency\r\n return {\r\n port,\r\n close: async () => {\r\n ac.abort();\r\n },\r\n };\r\n }\r\n\r\n /**\r\n * Start server using Node.js adapter\r\n * Requires @hono/node-server package\r\n */\r\n private listenNode(port: number, callback?: () => void): ServerInstance {\r\n try {\r\n // Dynamically import @hono/node-server\r\n // This is a peer dependency that users need to install for Node.js support\r\n const { serve } = require('@hono/node-server');\r\n \r\n const server = serve(\r\n {\r\n fetch: this.hono.fetch,\r\n port,\r\n },\r\n callback\r\n );\r\n\r\n return {\r\n port,\r\n close: async () => {\r\n return new Promise<void>((resolve) => {\r\n server.close(() => resolve());\r\n });\r\n },\r\n ...server\r\n };\r\n } catch (error) {\r\n throw new Error(\r\n 'Node.js adapter requires @hono/node-server package. Install it with: npm install @hono/node-server'\r\n );\r\n }\r\n }\r\n}\r\n"
5
+ "/**\r\n * @module veloce-ts/adapters/hono\r\n * @description {@link HonoAdapter}: detecta runtime (Bun/Node/Deno/Workers) y expone `listen` sobre la instancia Hono.\r\n */\r\nimport type { Hono } from 'hono';\r\nimport type { Adapter, ServerInstance } from './base';\r\n\r\n// Type declarations for runtime globals\r\ndeclare const Deno: any;\r\ndeclare const Bun: any;\r\n\r\n/**\r\n * Runtime detection utilities\r\n */\r\nconst detectRuntime = (): 'bun' | 'deno' | 'node' | 'workerd' | 'unknown' => {\r\n // Check for Bun\r\n if (typeof Bun !== 'undefined') {\r\n return 'bun';\r\n }\r\n\r\n // Check for Deno\r\n if (typeof Deno !== 'undefined') {\r\n return 'deno';\r\n }\r\n\r\n // Check for Cloudflare Workers\r\n if (typeof navigator !== 'undefined' && navigator.userAgent === 'Cloudflare-Workers') {\r\n return 'workerd';\r\n }\r\n\r\n // Check for Node.js\r\n if (typeof process !== 'undefined' && process.versions && process.versions.node) {\r\n return 'node';\r\n }\r\n\r\n return 'unknown';\r\n};\r\n\r\n/**\r\n * HonoAdapter - Adapts Hono.js to work across multiple runtimes\r\n * Automatically detects the runtime and uses the appropriate server implementation\r\n */\r\nexport class HonoAdapter implements Adapter {\r\n name = 'hono';\r\n private runtime: ReturnType<typeof detectRuntime>;\r\n\r\n constructor(private hono: Hono) {\r\n this.runtime = detectRuntime();\r\n }\r\n\r\n /**\r\n * Start the server on the specified port\r\n * Automatically uses the appropriate server for the detected runtime\r\n */\r\n listen(port: number, callback?: () => void): ServerInstance {\r\n switch (this.runtime) {\r\n case 'bun':\r\n return this.listenBun(port, callback);\r\n \r\n case 'deno':\r\n return this.listenDeno(port, callback);\r\n \r\n case 'node':\r\n return this.listenNode(port, callback);\r\n \r\n case 'workerd':\r\n throw new Error(\r\n 'Cloudflare Workers do not support listen(). Deploy using wrangler or export the handler with getHandler().'\r\n );\r\n \r\n default:\r\n throw new Error(\r\n `Unsupported runtime: ${this.runtime}. FastAPI-TS supports Bun, Node.js, Deno, and Cloudflare Workers.`\r\n );\r\n }\r\n }\r\n\r\n /**\r\n * Get the Hono fetch handler\r\n * This can be used directly in serverless environments or for custom server setups\r\n */\r\n getHandler() {\r\n return this.hono.fetch;\r\n }\r\n\r\n /**\r\n * Get the detected runtime\r\n */\r\n getRuntime(): string {\r\n return this.runtime;\r\n }\r\n\r\n /**\r\n * Start server using Bun's native server\r\n */\r\n private listenBun(port: number, callback?: () => void): ServerInstance {\r\n const server = Bun.serve({\r\n port,\r\n fetch: this.hono.fetch,\r\n });\r\n\r\n if (callback) {\r\n callback();\r\n }\r\n\r\n return {\r\n port,\r\n close: async () => {\r\n server.stop();\r\n },\r\n ...server\r\n };\r\n }\r\n\r\n /**\r\n * Start server using Deno's native server\r\n */\r\n private listenDeno(port: number, callback?: () => void): ServerInstance {\r\n // Deno.serve returns a promise, so we handle it appropriately\r\n const ac = new AbortController();\r\n \r\n Deno.serve(\r\n {\r\n port,\r\n signal: ac.signal,\r\n onListen: callback\r\n },\r\n this.hono.fetch\r\n );\r\n\r\n // Return an object with a close method for consistency\r\n return {\r\n port,\r\n close: async () => {\r\n ac.abort();\r\n },\r\n };\r\n }\r\n\r\n /**\r\n * Start server using Node.js adapter\r\n * Requires @hono/node-server package\r\n */\r\n private listenNode(port: number, callback?: () => void): ServerInstance {\r\n try {\r\n // Dynamically import @hono/node-server\r\n // This is a peer dependency that users need to install for Node.js support\r\n const { serve } = require('@hono/node-server');\r\n \r\n const server = serve(\r\n {\r\n fetch: this.hono.fetch,\r\n port,\r\n },\r\n callback\r\n );\r\n\r\n return {\r\n port,\r\n close: async () => {\r\n return new Promise<void>((resolve) => {\r\n server.close(() => resolve());\r\n });\r\n },\r\n ...server\r\n };\r\n } catch (error) {\r\n throw new Error(\r\n 'Node.js adapter requires @hono/node-server package. Install it with: npm install @hono/node-server'\r\n );\r\n }\r\n }\r\n}\r\n"
6
6
  ],
7
7
  "mappings": "szBA0CO,MAAM,CAA+B,CAItB,KAHpB,KAAO,OACC,QAER,WAAW,CAAS,EAAY,CAAZ,YAClB,KAAK,QAAU,EAAc,EAO/B,MAAM,CAAC,EAAc,EAAuC,CAC1D,OAAQ,KAAK,aACN,MACH,OAAO,KAAK,UAAU,EAAM,CAAQ,MAEjC,OACH,OAAO,KAAK,WAAW,EAAM,CAAQ,MAElC,OACH,OAAO,KAAK,WAAW,EAAM,CAAQ,MAElC,UACH,MAAU,MACR,4GACF,UAGA,MAAU,MACR,wBAAwB,KAAK,0EAC/B,GAQN,UAAU,EAAG,CACX,OAAO,KAAK,KAAK,MAMnB,UAAU,EAAW,CACnB,OAAO,KAAK,QAMN,SAAS,CAAC,EAAc,EAAuC,CACrE,IAAM,EAAS,IAAI,MAAM,CACvB,OACA,MAAO,KAAK,KAAK,KACnB,CAAC,EAED,GAAI,EACF,EAAS,EAGX,MAAO,CACL,OACA,MAAO,SAAY,CACjB,EAAO,KAAK,MAEX,CACL,EAMM,UAAU,CAAC,EAAc,EAAuC,CAEtE,IAAM,EAAK,IAAI,gBAYf,OAVA,KAAK,MACH,CACE,OACA,OAAQ,EAAG,OACX,SAAU,CACZ,EACA,KAAK,KAAK,KACZ,EAGO,CACL,OACA,MA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