@depup/nitro 3.0.260311-beta-depup.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (370) hide show
  1. package/LICENSE +27 -0
  2. package/README.md +32 -0
  3. package/changes.json +14 -0
  4. package/dist/THIRD-PARTY-LICENSES.md +1646 -0
  5. package/dist/_build/common.mjs +29361 -0
  6. package/dist/_build/rolldown.mjs +173 -0
  7. package/dist/_build/rollup.mjs +194 -0
  8. package/dist/_build/vite.build.mjs +18 -0
  9. package/dist/_chunks/nitro.mjs +1159 -0
  10. package/dist/_chunks/nitro2.mjs +102 -0
  11. package/dist/_chunks/nitro3.mjs +129 -0
  12. package/dist/_chunks/utils.mjs +272 -0
  13. package/dist/_common.mjs +35 -0
  14. package/dist/_dev.d.mts +12 -0
  15. package/dist/_dev.mjs +519 -0
  16. package/dist/_libs/_.mjs +3 -0
  17. package/dist/_libs/_2.mjs +2 -0
  18. package/dist/_libs/_3.mjs +3 -0
  19. package/dist/_libs/_4.mjs +2 -0
  20. package/dist/_libs/_5.mjs +3 -0
  21. package/dist/_libs/_6.mjs +4 -0
  22. package/dist/_libs/_7.mjs +5 -0
  23. package/dist/_libs/c12+rc9.mjs +812 -0
  24. package/dist/_libs/c12+readdirp+chokidar.d.mts +230 -0
  25. package/dist/_libs/citty.mjs +361 -0
  26. package/dist/_libs/commondir+is-reference.mjs +1311 -0
  27. package/dist/_libs/compatx.d.mts +47 -0
  28. package/dist/_libs/compatx.mjs +45 -0
  29. package/dist/_libs/esbuild.d.mts +20 -0
  30. package/dist/_libs/escape-string-regexp.mjs +7 -0
  31. package/dist/_libs/estree+pluginutils.d.mts +241 -0
  32. package/dist/_libs/estree-walker.mjs +184 -0
  33. package/dist/_libs/exsolve.d.mts +1 -0
  34. package/dist/_libs/hasown+resolve+deepmerge.mjs +1949 -0
  35. package/dist/_libs/httpxy.d.mts +82 -0
  36. package/dist/_libs/httpxy.mjs +671 -0
  37. package/dist/_libs/js-tokens.d.mts +1 -0
  38. package/dist/_libs/klona.mjs +37 -0
  39. package/dist/_libs/magic-string.d.mts +220 -0
  40. package/dist/_libs/mlly.d.mts +57 -0
  41. package/dist/_libs/nypm+tinyexec.mjs +845 -0
  42. package/dist/_libs/perfect-debounce.mjs +88 -0
  43. package/dist/_libs/pkg-types.d.mts +23 -0
  44. package/dist/_libs/plugin-alias.mjs +64 -0
  45. package/dist/_libs/plugin-inject.mjs +131 -0
  46. package/dist/_libs/plugin-json.mjs +34 -0
  47. package/dist/_libs/pluginutils.mjs +646 -0
  48. package/dist/_libs/readdirp+chokidar.mjs +1606 -0
  49. package/dist/_libs/remapping.mjs +115 -0
  50. package/dist/_libs/resolve-uri+gen-mapping.mjs +442 -0
  51. package/dist/_libs/rou3.d.mts +44 -0
  52. package/dist/_libs/rou3.mjs +496 -0
  53. package/dist/_libs/std-env.d.mts +12 -0
  54. package/dist/_libs/strip-literal.d.mts +1 -0
  55. package/dist/_libs/tsconfck.mjs +813 -0
  56. package/dist/_libs/ultrahtml.mjs +127 -0
  57. package/dist/_libs/unimport+unplugin.mjs +1684 -0
  58. package/dist/_libs/unplugin+unimport.d.mts +423 -0
  59. package/dist/_libs/unwasm.d.mts +29 -0
  60. package/dist/_presets.mjs +1759 -0
  61. package/dist/builder.d.mts +64 -0
  62. package/dist/builder.mjs +15 -0
  63. package/dist/cli/_chunks/build.mjs +47 -0
  64. package/dist/cli/_chunks/common.mjs +14 -0
  65. package/dist/cli/_chunks/deploy.mjs +40 -0
  66. package/dist/cli/_chunks/dev.mjs +62 -0
  67. package/dist/cli/_chunks/docs.mjs +30 -0
  68. package/dist/cli/_chunks/list.mjs +25 -0
  69. package/dist/cli/_chunks/prepare.mjs +17 -0
  70. package/dist/cli/_chunks/preview.mjs +51 -0
  71. package/dist/cli/_chunks/run.mjs +53 -0
  72. package/dist/cli/_chunks/task.mjs +14 -0
  73. package/dist/cli/index.d.mts +1 -0
  74. package/dist/cli/index.mjs +22 -0
  75. package/dist/node_modules/@poppinss/colors/build/index.js +139 -0
  76. package/dist/node_modules/@poppinss/colors/package.json +118 -0
  77. package/dist/node_modules/@poppinss/dumper/build/chunk-26HALFTP.js +602 -0
  78. package/dist/node_modules/@poppinss/dumper/build/formatters/console/main.js +441 -0
  79. package/dist/node_modules/@poppinss/dumper/build/formatters/html/main.js +725 -0
  80. package/dist/node_modules/@poppinss/dumper/package.json +122 -0
  81. package/dist/node_modules/@poppinss/exception/build/index.js +44 -0
  82. package/dist/node_modules/@poppinss/exception/package.json +109 -0
  83. package/dist/node_modules/@sindresorhus/is/distribution/index.js +1354 -0
  84. package/dist/node_modules/@sindresorhus/is/distribution/utilities.js +3 -0
  85. package/dist/node_modules/@sindresorhus/is/package.json +81 -0
  86. package/dist/node_modules/@speed-highlight/core/dist/index.js +4 -0
  87. package/dist/node_modules/@speed-highlight/core/dist/terminal.js +2 -0
  88. package/dist/node_modules/@speed-highlight/core/package.json +94 -0
  89. package/dist/node_modules/cookie-es/dist/index.mjs +262 -0
  90. package/dist/node_modules/cookie-es/package.json +37 -0
  91. package/dist/node_modules/croner/dist/croner.js +1 -0
  92. package/dist/node_modules/croner/package.json +73 -0
  93. package/dist/node_modules/defu/dist/defu.mjs +69 -0
  94. package/dist/node_modules/defu/package.json +43 -0
  95. package/dist/node_modules/destr/dist/index.mjs +72 -0
  96. package/dist/node_modules/destr/package.json +47 -0
  97. package/dist/node_modules/error-stack-parser-es/dist/index.mjs +38 -0
  98. package/dist/node_modules/error-stack-parser-es/dist/lite.mjs +167 -0
  99. package/dist/node_modules/error-stack-parser-es/package.json +83 -0
  100. package/dist/node_modules/get-port-please/dist/index.mjs +430 -0
  101. package/dist/node_modules/get-port-please/package.json +39 -0
  102. package/dist/node_modules/kleur/index.mjs +110 -0
  103. package/dist/node_modules/kleur/package.json +51 -0
  104. package/dist/node_modules/rendu/dist/index.mjs +380 -0
  105. package/dist/node_modules/rendu/package.json +47 -0
  106. package/dist/node_modules/scule/dist/index.mjs +80 -0
  107. package/dist/node_modules/scule/package.json +43 -0
  108. package/dist/node_modules/source-map/lib/array-set.js +100 -0
  109. package/dist/node_modules/source-map/lib/base64-vlq.js +94 -0
  110. package/dist/node_modules/source-map/lib/base64.js +19 -0
  111. package/dist/node_modules/source-map/lib/binary-search.js +113 -0
  112. package/dist/node_modules/source-map/lib/mapping-list.js +83 -0
  113. package/dist/node_modules/source-map/lib/mappings.wasm +0 -0
  114. package/dist/node_modules/source-map/lib/read-wasm.js +27 -0
  115. package/dist/node_modules/source-map/lib/source-map-consumer.js +1081 -0
  116. package/dist/node_modules/source-map/lib/source-map-generator.js +439 -0
  117. package/dist/node_modules/source-map/lib/source-node.js +430 -0
  118. package/dist/node_modules/source-map/lib/url.js +13 -0
  119. package/dist/node_modules/source-map/lib/util.js +444 -0
  120. package/dist/node_modules/source-map/lib/wasm.js +138 -0
  121. package/dist/node_modules/source-map/package.json +79 -0
  122. package/dist/node_modules/source-map/source-map.js +10 -0
  123. package/dist/node_modules/supports-color/index.js +202 -0
  124. package/dist/node_modules/supports-color/package.json +64 -0
  125. package/dist/node_modules/ufo/dist/index.mjs +645 -0
  126. package/dist/node_modules/ufo/package.json +48 -0
  127. package/dist/node_modules/unctx/dist/index.mjs +131 -0
  128. package/dist/node_modules/unctx/package.json +67 -0
  129. package/dist/node_modules/youch/build/helpers-B9BQYaS6.js +23 -0
  130. package/dist/node_modules/youch/build/index.js +212 -0
  131. package/dist/node_modules/youch/build/public/error_cause/style.css +5 -0
  132. package/dist/node_modules/youch/build/public/error_info/script.js +13 -0
  133. package/dist/node_modules/youch/build/public/error_info/style.css +145 -0
  134. package/dist/node_modules/youch/build/public/error_metadata/style.css +3 -0
  135. package/dist/node_modules/youch/build/public/error_stack/script.js +72 -0
  136. package/dist/node_modules/youch/build/public/error_stack/style.css +219 -0
  137. package/dist/node_modules/youch/build/public/error_stack_source/style.css +123 -0
  138. package/dist/node_modules/youch/build/public/header/script.js +14 -0
  139. package/dist/node_modules/youch/build/public/header/style.css +56 -0
  140. package/dist/node_modules/youch/build/public/layout/script.js +12 -0
  141. package/dist/node_modules/youch/build/public/layout/style.css +435 -0
  142. package/dist/node_modules/youch/build/public_dir-C5bujZKB.js +25 -0
  143. package/dist/node_modules/youch/build/src/templates/error_cause/main.js +44 -0
  144. package/dist/node_modules/youch/build/src/templates/error_info/main.js +72 -0
  145. package/dist/node_modules/youch/build/src/templates/error_metadata/main.js +65 -0
  146. package/dist/node_modules/youch/build/src/templates/error_stack/main.js +152 -0
  147. package/dist/node_modules/youch/build/src/templates/error_stack_source/main.js +46 -0
  148. package/dist/node_modules/youch/build/src/templates/header/main.js +24 -0
  149. package/dist/node_modules/youch/build/src/templates/layout/main.js +27 -0
  150. package/dist/node_modules/youch/package.json +135 -0
  151. package/dist/node_modules/youch-core/build/index.js +316 -0
  152. package/dist/node_modules/youch-core/package.json +124 -0
  153. package/dist/presets/_nitro/runtime/nitro-dev.mjs +20 -0
  154. package/dist/presets/_nitro/runtime/nitro-prerenderer.mjs +15 -0
  155. package/dist/presets/_nitro/runtime/service-worker.mjs +23 -0
  156. package/dist/presets/aws-amplify/runtime/aws-amplify.mjs +14 -0
  157. package/dist/presets/aws-lambda/runtime/_utils.mjs +116 -0
  158. package/dist/presets/aws-lambda/runtime/aws-lambda-streaming.mjs +31 -0
  159. package/dist/presets/aws-lambda/runtime/aws-lambda.mjs +13 -0
  160. package/dist/presets/azure/runtime/_utils.mjs +50 -0
  161. package/dist/presets/azure/runtime/azure-swa.mjs +30 -0
  162. package/dist/presets/bun/runtime/bun.mjs +40 -0
  163. package/dist/presets/cloudflare/runtime/_module-handler.mjs +87 -0
  164. package/dist/presets/cloudflare/runtime/cloudflare-durable.mjs +72 -0
  165. package/dist/presets/cloudflare/runtime/cloudflare-module.mjs +17 -0
  166. package/dist/presets/cloudflare/runtime/cloudflare-pages.mjs +39 -0
  167. package/dist/presets/cloudflare/runtime/plugin.dev.mjs +96 -0
  168. package/dist/presets/cloudflare/runtime/shims/workers.dev.mjs +27 -0
  169. package/dist/presets/deno/runtime/deno-deploy.mjs +19 -0
  170. package/dist/presets/deno/runtime/deno-server.mjs +39 -0
  171. package/dist/presets/netlify/runtime/netlify-edge.mjs +20 -0
  172. package/dist/presets/netlify/runtime/netlify.mjs +20 -0
  173. package/dist/presets/node/runtime/node-cluster.mjs +54 -0
  174. package/dist/presets/node/runtime/node-middleware.mjs +14 -0
  175. package/dist/presets/node/runtime/node-server.mjs +47 -0
  176. package/dist/presets/standard/runtime/server.mjs +4 -0
  177. package/dist/presets/stormkit/runtime/stormkit.mjs +27 -0
  178. package/dist/presets/vercel/runtime/cron-handler.mjs +25 -0
  179. package/dist/presets/vercel/runtime/isr.mjs +19 -0
  180. package/dist/presets/vercel/runtime/vercel.node.mjs +24 -0
  181. package/dist/presets/vercel/runtime/vercel.web.mjs +23 -0
  182. package/dist/presets/winterjs/runtime/winterjs.mjs +91 -0
  183. package/dist/presets/zeabur/runtime/zeabur.mjs +4 -0
  184. package/dist/presets/zephyr/runtime/server.mjs +3 -0
  185. package/dist/runtime/app.d.mts +1 -0
  186. package/dist/runtime/app.mjs +1 -0
  187. package/dist/runtime/cache.d.mts +1 -0
  188. package/dist/runtime/cache.mjs +1 -0
  189. package/dist/runtime/config.d.mts +3 -0
  190. package/dist/runtime/config.mjs +4 -0
  191. package/dist/runtime/context.d.mts +1 -0
  192. package/dist/runtime/context.mjs +1 -0
  193. package/dist/runtime/database.d.mts +1 -0
  194. package/dist/runtime/database.mjs +1 -0
  195. package/dist/runtime/internal/app.d.mts +16 -0
  196. package/dist/runtime/internal/app.mjs +208 -0
  197. package/dist/runtime/internal/cache.d.mts +7 -0
  198. package/dist/runtime/internal/cache.mjs +41 -0
  199. package/dist/runtime/internal/context.d.mts +14 -0
  200. package/dist/runtime/internal/context.mjs +24 -0
  201. package/dist/runtime/internal/database.d.mts +2 -0
  202. package/dist/runtime/internal/database.mjs +12 -0
  203. package/dist/runtime/internal/empty.mjs +0 -0
  204. package/dist/runtime/internal/error/dev.d.mts +10 -0
  205. package/dist/runtime/internal/error/dev.mjs +121 -0
  206. package/dist/runtime/internal/error/hooks.d.mts +1 -0
  207. package/dist/runtime/internal/error/hooks.mjs +9 -0
  208. package/dist/runtime/internal/error/prod.d.mts +6 -0
  209. package/dist/runtime/internal/error/prod.mjs +40 -0
  210. package/dist/runtime/internal/error/utils.d.mts +8 -0
  211. package/dist/runtime/internal/error/utils.mjs +3 -0
  212. package/dist/runtime/internal/meta.d.mts +2 -0
  213. package/dist/runtime/internal/meta.mjs +3 -0
  214. package/dist/runtime/internal/plugin.d.mts +3 -0
  215. package/dist/runtime/internal/plugin.mjs +4 -0
  216. package/dist/runtime/internal/route-rules.d.mts +9 -0
  217. package/dist/runtime/internal/route-rules.mjs +72 -0
  218. package/dist/runtime/internal/routes/dev-tasks.d.mts +3 -0
  219. package/dist/runtime/internal/routes/dev-tasks.mjs +25 -0
  220. package/dist/runtime/internal/routes/openapi.d.mts +3 -0
  221. package/dist/runtime/internal/routes/openapi.mjs +94 -0
  222. package/dist/runtime/internal/routes/renderer-template.d.mts +2 -0
  223. package/dist/runtime/internal/routes/renderer-template.dev.d.mts +3 -0
  224. package/dist/runtime/internal/routes/renderer-template.dev.mjs +19 -0
  225. package/dist/runtime/internal/routes/renderer-template.mjs +4 -0
  226. package/dist/runtime/internal/routes/scalar.d.mts +3 -0
  227. package/dist/runtime/internal/routes/scalar.mjs +193 -0
  228. package/dist/runtime/internal/routes/swagger.d.mts +3 -0
  229. package/dist/runtime/internal/routes/swagger.mjs +42 -0
  230. package/dist/runtime/internal/runtime-config.d.mts +9 -0
  231. package/dist/runtime/internal/runtime-config.mjs +54 -0
  232. package/dist/runtime/internal/static.d.mts +3 -0
  233. package/dist/runtime/internal/static.mjs +67 -0
  234. package/dist/runtime/internal/storage.d.mts +2 -0
  235. package/dist/runtime/internal/storage.mjs +6 -0
  236. package/dist/runtime/internal/task.d.mts +19 -0
  237. package/dist/runtime/internal/task.mjs +69 -0
  238. package/dist/runtime/internal/vite/dev-entry.mjs +18 -0
  239. package/dist/runtime/internal/vite/dev-worker.mjs +264 -0
  240. package/dist/runtime/internal/vite/ssr-renderer.mjs +6 -0
  241. package/dist/runtime/meta.d.mts +5 -0
  242. package/dist/runtime/meta.mjs +27 -0
  243. package/dist/runtime/nitro.d.mts +11 -0
  244. package/dist/runtime/nitro.mjs +34 -0
  245. package/dist/runtime/runtime-config.d.mts +1 -0
  246. package/dist/runtime/runtime-config.mjs +1 -0
  247. package/dist/runtime/storage.d.mts +1 -0
  248. package/dist/runtime/storage.mjs +1 -0
  249. package/dist/runtime/task.d.mts +1 -0
  250. package/dist/runtime/task.mjs +1 -0
  251. package/dist/runtime/virtual/_runtime_warn.d.mts +1 -0
  252. package/dist/runtime/virtual/_runtime_warn.mjs +5 -0
  253. package/dist/runtime/virtual/database.d.mts +8 -0
  254. package/dist/runtime/virtual/database.mjs +2 -0
  255. package/dist/runtime/virtual/error-handler.d.mts +6 -0
  256. package/dist/runtime/virtual/error-handler.mjs +9 -0
  257. package/dist/runtime/virtual/feature-flags.d.mts +7 -0
  258. package/dist/runtime/virtual/feature-flags.mjs +7 -0
  259. package/dist/runtime/virtual/plugins.d.mts +3 -0
  260. package/dist/runtime/virtual/plugins.mjs +2 -0
  261. package/dist/runtime/virtual/polyfills.d.mts +3 -0
  262. package/dist/runtime/virtual/polyfills.mjs +2 -0
  263. package/dist/runtime/virtual/public-assets.d.mts +9 -0
  264. package/dist/runtime/virtual/public-assets.mjs +8 -0
  265. package/dist/runtime/virtual/renderer-template.d.mts +4 -0
  266. package/dist/runtime/virtual/renderer-template.mjs +7 -0
  267. package/dist/runtime/virtual/routing-meta.d.mts +7 -0
  268. package/dist/runtime/virtual/routing-meta.mjs +2 -0
  269. package/dist/runtime/virtual/routing.d.mts +8 -0
  270. package/dist/runtime/virtual/routing.mjs +11 -0
  271. package/dist/runtime/virtual/runtime-config.d.mts +3 -0
  272. package/dist/runtime/virtual/runtime-config.mjs +5 -0
  273. package/dist/runtime/virtual/server-assets.d.mts +7 -0
  274. package/dist/runtime/virtual/server-assets.mjs +12 -0
  275. package/dist/runtime/virtual/storage.d.mts +3 -0
  276. package/dist/runtime/virtual/storage.mjs +5 -0
  277. package/dist/runtime/virtual/tasks.d.mts +10 -0
  278. package/dist/runtime/virtual/tasks.mjs +3 -0
  279. package/dist/runtime/vite.d.mts +8 -0
  280. package/dist/runtime/vite.mjs +9 -0
  281. package/dist/types/index.d.mts +3010 -0
  282. package/dist/types/index.mjs +1 -0
  283. package/dist/vite.d.mts +52 -0
  284. package/dist/vite.mjs +740 -0
  285. package/lib/h3.d.mts +1 -0
  286. package/lib/h3.mjs +1 -0
  287. package/lib/tsconfig.json +27 -0
  288. package/lib/vite.types.d.mts +26 -0
  289. package/lib/vite.types.mjs +2 -0
  290. package/package.json +256 -0
  291. package/skills/nitro/SKILL.md +10 -0
  292. package/skills/nitro/docs/TOC.md +83 -0
  293. package/skills/nitro/docs/_navigation.json +679 -0
  294. package/skills/nitro/docs/config/index.md +1147 -0
  295. package/skills/nitro/docs/deploy/index.md +64 -0
  296. package/skills/nitro/docs/deploy/providers/alwaysdata.md +50 -0
  297. package/skills/nitro/docs/deploy/providers/aws-amplify.md +81 -0
  298. package/skills/nitro/docs/deploy/providers/aws.md +47 -0
  299. package/skills/nitro/docs/deploy/providers/azure.md +72 -0
  300. package/skills/nitro/docs/deploy/providers/cleavr.md +33 -0
  301. package/skills/nitro/docs/deploy/providers/cloudflare.md +375 -0
  302. package/skills/nitro/docs/deploy/providers/deno-deploy.md +66 -0
  303. package/skills/nitro/docs/deploy/providers/digitalocean.md +46 -0
  304. package/skills/nitro/docs/deploy/providers/firebase.md +32 -0
  305. package/skills/nitro/docs/deploy/providers/flightcontrol.md +67 -0
  306. package/skills/nitro/docs/deploy/providers/genezio.md +67 -0
  307. package/skills/nitro/docs/deploy/providers/github-pages.md +68 -0
  308. package/skills/nitro/docs/deploy/providers/gitlab-pages.md +37 -0
  309. package/skills/nitro/docs/deploy/providers/heroku.md +84 -0
  310. package/skills/nitro/docs/deploy/providers/iis.md +38 -0
  311. package/skills/nitro/docs/deploy/providers/koyeb.md +109 -0
  312. package/skills/nitro/docs/deploy/providers/netlify.md +47 -0
  313. package/skills/nitro/docs/deploy/providers/platform-sh.md +37 -0
  314. package/skills/nitro/docs/deploy/providers/render.md +37 -0
  315. package/skills/nitro/docs/deploy/providers/stormkit.md +24 -0
  316. package/skills/nitro/docs/deploy/providers/vercel.md +179 -0
  317. package/skills/nitro/docs/deploy/providers/zeabur.md +19 -0
  318. package/skills/nitro/docs/deploy/providers/zephyr.md +99 -0
  319. package/skills/nitro/docs/deploy/providers/zerops.md +102 -0
  320. package/skills/nitro/docs/deploy/runtimes/bun.md +15 -0
  321. package/skills/nitro/docs/deploy/runtimes/deno.md +19 -0
  322. package/skills/nitro/docs/deploy/runtimes/node.md +63 -0
  323. package/skills/nitro/docs/docs/assets.md +166 -0
  324. package/skills/nitro/docs/docs/cache.md +408 -0
  325. package/skills/nitro/docs/docs/configuration.md +256 -0
  326. package/skills/nitro/docs/docs/database.md +185 -0
  327. package/skills/nitro/docs/docs/index.md +56 -0
  328. package/skills/nitro/docs/docs/lifecycle.md +204 -0
  329. package/skills/nitro/docs/docs/migration.md +215 -0
  330. package/skills/nitro/docs/docs/nightly.md +31 -0
  331. package/skills/nitro/docs/docs/plugins.md +164 -0
  332. package/skills/nitro/docs/docs/quick-start.md +110 -0
  333. package/skills/nitro/docs/docs/renderer.md +322 -0
  334. package/skills/nitro/docs/docs/routing.md +711 -0
  335. package/skills/nitro/docs/docs/server-entry.md +239 -0
  336. package/skills/nitro/docs/docs/storage.md +261 -0
  337. package/skills/nitro/docs/docs/tasks.md +277 -0
  338. package/skills/nitro/docs/examples/api-routes.md +145 -0
  339. package/skills/nitro/docs/examples/auto-imports.md +93 -0
  340. package/skills/nitro/docs/examples/cached-handler.md +81 -0
  341. package/skills/nitro/docs/examples/custom-error-handler.md +98 -0
  342. package/skills/nitro/docs/examples/database.md +157 -0
  343. package/skills/nitro/docs/examples/elysia.md +70 -0
  344. package/skills/nitro/docs/examples/express.md +78 -0
  345. package/skills/nitro/docs/examples/fastify.md +79 -0
  346. package/skills/nitro/docs/examples/hello-world.md +68 -0
  347. package/skills/nitro/docs/examples/hono.md +74 -0
  348. package/skills/nitro/docs/examples/import-alias.md +100 -0
  349. package/skills/nitro/docs/examples/index.md +3 -0
  350. package/skills/nitro/docs/examples/middleware.md +91 -0
  351. package/skills/nitro/docs/examples/mono-jsx.md +68 -0
  352. package/skills/nitro/docs/examples/nano-jsx.md +70 -0
  353. package/skills/nitro/docs/examples/plugins.md +91 -0
  354. package/skills/nitro/docs/examples/renderer.md +113 -0
  355. package/skills/nitro/docs/examples/runtime-config.md +97 -0
  356. package/skills/nitro/docs/examples/server-fetch.md +87 -0
  357. package/skills/nitro/docs/examples/shiki.md +198 -0
  358. package/skills/nitro/docs/examples/virtual-routes.md +74 -0
  359. package/skills/nitro/docs/examples/vite-nitro-plugin.md +79 -0
  360. package/skills/nitro/docs/examples/vite-rsc.md +1041 -0
  361. package/skills/nitro/docs/examples/vite-ssr-html.md +217 -0
  362. package/skills/nitro/docs/examples/vite-ssr-preact.md +247 -0
  363. package/skills/nitro/docs/examples/vite-ssr-react.md +226 -0
  364. package/skills/nitro/docs/examples/vite-ssr-solid.md +256 -0
  365. package/skills/nitro/docs/examples/vite-ssr-tsr-react.md +442 -0
  366. package/skills/nitro/docs/examples/vite-ssr-tss-react.md +444 -0
  367. package/skills/nitro/docs/examples/vite-ssr-vue-router.md +616 -0
  368. package/skills/nitro/docs/examples/vite-trpc.md +335 -0
  369. package/skills/nitro/docs/examples/websocket.md +282 -0
  370. package/skills/nitro/docs/index.md +121 -0
@@ -0,0 +1,4 @@
1
+ import "#nitro/virtual/polyfills";
2
+ import { useNitroApp } from "nitro/app";
3
+ const nitroApp = useNitroApp();
4
+ export default { fetch: nitroApp.fetch };
@@ -0,0 +1,27 @@
1
+ import "#nitro/virtual/polyfills";
2
+ import { useNitroApp } from "nitro/app";
3
+ import { awsResponseBody } from "../../aws-lambda/runtime/_utils.mjs";
4
+ const nitroApp = useNitroApp();
5
+ export const handler = async function(event, context) {
6
+ const req = new Request(event.url, {
7
+ method: event.method || "GET",
8
+ headers: event.headers,
9
+ body: event.body
10
+ });
11
+ // srvx compatibility
12
+ req.runtime ??= { name: "stormkit" };
13
+ req.runtime.stormkit ??= {
14
+ event,
15
+ context
16
+ };
17
+ const response = await nitroApp.fetch(req);
18
+ const { body, isBase64Encoded } = await awsResponseBody(response);
19
+ return {
20
+ statusCode: response.status,
21
+ headers: normalizeOutgoingHeaders(response.headers),
22
+ [isBase64Encoded ? "buffer" : "body"]: body
23
+ };
24
+ };
25
+ function normalizeOutgoingHeaders(headers) {
26
+ return Object.fromEntries(Object.entries(headers).map(([k, v]) => [k, Array.isArray(v) ? v.join(",") : String(v)]));
27
+ }
@@ -0,0 +1,25 @@
1
+ import { timingSafeEqual } from "node:crypto";
2
+ import { defineHandler, HTTPError } from "nitro/h3";
3
+ import { runCronTasks } from "#nitro/runtime/task";
4
+ export default defineHandler(async (event) => {
5
+ // Validate CRON_SECRET if set - https://vercel.com/docs/cron-jobs/manage-cron-jobs#securing-cron-jobs
6
+ const cronSecret = process.env.CRON_SECRET;
7
+ if (cronSecret) {
8
+ const authHeader = event.req.headers.get("authorization") || "";
9
+ const expected = `Bearer ${cronSecret}`;
10
+ const a = Buffer.from(authHeader);
11
+ const b = Buffer.from(expected);
12
+ if (a.length !== b.length || !timingSafeEqual(a, b)) {
13
+ throw new HTTPError("Unauthorized", { status: 401 });
14
+ }
15
+ }
16
+ const cron = event.req.headers.get("x-vercel-cron-schedule");
17
+ if (!cron) {
18
+ throw new HTTPError("Missing x-vercel-cron-schedule header", { status: 400 });
19
+ }
20
+ await runCronTasks(cron, {
21
+ context: { waitUntil: event.req.waitUntil },
22
+ payload: { scheduledTime: Date.now() }
23
+ });
24
+ return { success: true };
25
+ });
@@ -0,0 +1,19 @@
1
+ export const ISR_URL_PARAM = "__isr_route";
2
+ export function isrRouteRewrite(reqUrl, xNowRouteMatches) {
3
+ if (xNowRouteMatches) {
4
+ const isrURL = new URLSearchParams(xNowRouteMatches).get(ISR_URL_PARAM);
5
+ if (isrURL) {
6
+ return [decodeURIComponent(isrURL), ""];
7
+ }
8
+ } else {
9
+ const queryIndex = reqUrl.indexOf("?");
10
+ if (queryIndex !== -1) {
11
+ const params = new URLSearchParams(reqUrl.slice(queryIndex + 1));
12
+ const isrURL = params.get(ISR_URL_PARAM);
13
+ if (isrURL) {
14
+ params.delete(ISR_URL_PARAM);
15
+ return [decodeURIComponent(isrURL), params.toString()];
16
+ }
17
+ }
18
+ }
19
+ }
@@ -0,0 +1,24 @@
1
+ import "#nitro/virtual/polyfills";
2
+ import { toNodeHandler } from "srvx/node";
3
+ import { useNitroApp, getRouteRules } from "nitro/app";
4
+ import { isrRouteRewrite } from "./isr.mjs";
5
+ const nitroApp = useNitroApp();
6
+ const handler = toNodeHandler(nitroApp.fetch);
7
+ export default function nodeHandler(req, res) {
8
+ // https://vercel.com/docs/headers/request-headers#x-forwarded-for
9
+ // srvx node adapter uses req.socket.remoteAddress for req.ip
10
+ let ip;
11
+ Object.defineProperty(req.socket, "remoteAddress", { get() {
12
+ const h = req.headers["x-forwarded-for"];
13
+ return ip ??= h?.split?.(",").shift()?.trim();
14
+ } });
15
+ // ISR route rewrite
16
+ const isrURL = isrRouteRewrite(req.url, req.headers["x-now-route-matches"]);
17
+ if (isrURL) {
18
+ const { routeRules } = getRouteRules("", isrURL[0]);
19
+ if (routeRules?.isr) {
20
+ req.url = isrURL[0] + (isrURL[1] ? `?${isrURL[1]}` : "");
21
+ }
22
+ }
23
+ return handler(req, res);
24
+ }
@@ -0,0 +1,23 @@
1
+ import "#nitro/virtual/polyfills";
2
+ import { useNitroApp, getRouteRules } from "nitro/app";
3
+ import { isrRouteRewrite } from "./isr.mjs";
4
+ const nitroApp = useNitroApp();
5
+ export default { fetch(req, context) {
6
+ // ISR route rewrite
7
+ const isrURL = isrRouteRewrite(req.url, req.headers.get("x-now-route-matches"));
8
+ if (isrURL) {
9
+ const { routeRules } = getRouteRules("", isrURL[0]);
10
+ if (routeRules?.isr) {
11
+ req = new Request(new URL(isrURL[0] + (isrURL[1] ? `?${isrURL[1]}` : ""), req.url).href, req);
12
+ }
13
+ }
14
+ req.runtime ??= { name: "vercel" };
15
+ req.runtime.vercel = { context };
16
+ let ip;
17
+ Object.defineProperty(req, "ip", { get() {
18
+ const h = req.headers.get("x-forwarded-for");
19
+ return ip ??= h?.split(",").shift()?.trim();
20
+ } });
21
+ req.waitUntil = context?.waitUntil;
22
+ return nitroApp.fetch(req);
23
+ } };
@@ -0,0 +1,91 @@
1
+ // @ts-nocheck TODO: Remove after removing polyfills
2
+ import "#nitro/virtual/polyfills";
3
+ import { useNitroApp } from "nitro/app";
4
+ import { hasProtocol, joinURL } from "ufo";
5
+ const nitroApp = useNitroApp();
6
+ // Use plain handler as winterjs Web API is incomplete
7
+ // TODO: Migrate to toWebHandler
8
+ const _handler = toPlainHandler(nitroApp.h3App);
9
+ async function _handleEvent(event) {
10
+ try {
11
+ const res = await _handler({
12
+ path: event.request.url.pathname + (event.request.url.search ? `?${event.request.url.search}` : ""),
13
+ method: event.request.getMethod() || "GET",
14
+ body: event.request.body,
15
+ headers: event.request.headers,
16
+ context: {
17
+ waitUntil: (promise) => event.waitUntil(promise),
18
+ _platform: { winterjs: { event } }
19
+ }
20
+ });
21
+ const body = typeof res.body === "string" ? res.body : await toBuffer(res.body);
22
+ return new Response(body, {
23
+ status: res.status,
24
+ statusText: res.statusText,
25
+ headers: res.headers
26
+ });
27
+ } catch (error) {
28
+ const errString = error?.message + "\n" + error?.stack;
29
+ console.error(errString);
30
+ return new Response(errString, { status: 500 });
31
+ }
32
+ }
33
+ addEventListener("fetch", async (event) => {
34
+ event.respondWith(await _handleEvent(event));
35
+ });
36
+ // ------------------------------
37
+ // Polyfills for missing APIs
38
+ // ------------------------------
39
+ function toBuffer(data) {
40
+ return new Promise((resolve, reject) => {
41
+ const chunks = [];
42
+ data.pipeTo(new WritableStream({
43
+ write(chunk) {
44
+ chunks.push(chunk);
45
+ },
46
+ close() {
47
+ resolve(Buffer.concat(chunks));
48
+ },
49
+ abort(reason) {
50
+ reject(reason);
51
+ }
52
+ })).catch(reject);
53
+ });
54
+ }
55
+ // Headers.entries
56
+ if (!Headers.prototype.entries) {
57
+ // @ts-ignore
58
+ Headers.prototype.entries = function() {
59
+ return [...this];
60
+ };
61
+ }
62
+ // URL.pathname
63
+ if (!URL.prototype.pathname) {
64
+ Object.defineProperty(URL.prototype, "pathname", { get() {
65
+ return this.path || "/";
66
+ } });
67
+ }
68
+ // URL constructor (relative support)
69
+ const _URL = globalThis.URL;
70
+ globalThis.URL = class URL extends _URL {
71
+ constructor(url, base) {
72
+ if (!base || hasProtocol(url)) {
73
+ super(url);
74
+ return;
75
+ }
76
+ super(joinURL(base, url));
77
+ }
78
+ };
79
+ // Response (avoid Promise body)
80
+ const _Response = globalThis.Response;
81
+ globalThis.Response = class Response extends _Response {
82
+ _body;
83
+ constructor(body, init) {
84
+ super(body, init);
85
+ this._body = body;
86
+ }
87
+ get body() {
88
+ // TODO: Return ReadableStream (should be iterable)
89
+ return this._body;
90
+ }
91
+ };
@@ -0,0 +1,4 @@
1
+ import "#nitro/virtual/polyfills";
2
+ import { toNodeHandler } from "srvx/node";
3
+ import { useNitroApp } from "nitro/app";
4
+ export default toNodeHandler(useNitroApp().fetch);
@@ -0,0 +1,3 @@
1
+ import "#nitro/virtual/polyfills";
2
+ import { createHandler } from "../../cloudflare/runtime/_module-handler.mjs";
3
+ export default createHandler({ fetch() {} });
@@ -0,0 +1 @@
1
+ export { useNitroApp, useNitroHooks, serverFetch, getRouteRules, fetch } from "./internal/app.mjs";
@@ -0,0 +1 @@
1
+ export { useNitroApp, useNitroHooks, serverFetch, getRouteRules, fetch } from "./internal/app.mjs";
@@ -0,0 +1 @@
1
+ export { defineCachedFunction, defineCachedHandler } from "./internal/cache.mjs";
@@ -0,0 +1 @@
1
+ export { defineCachedFunction, defineCachedHandler } from "./internal/cache.mjs";
@@ -0,0 +1,3 @@
1
+ import type { NitroConfig } from "nitro/types";
2
+ export declare function defineConfig(config: Omit<NitroConfig, "rootDir">): Omit<NitroConfig, "rootDir">;
3
+ export { defineConfig as defineNitroConfig };
@@ -0,0 +1,4 @@
1
+ export function defineConfig(config) {
2
+ return config;
3
+ }
4
+ export { defineConfig as defineNitroConfig };
@@ -0,0 +1 @@
1
+ export { useRequest } from "./internal/context.mjs";
@@ -0,0 +1 @@
1
+ export { useRequest } from "./internal/context.mjs";
@@ -0,0 +1 @@
1
+ export { useDatabase } from "./internal/database.mjs";
@@ -0,0 +1 @@
1
+ export { useDatabase } from "./internal/database.mjs";
@@ -0,0 +1,16 @@
1
+ import type { MatchedRouteRules, NitroApp, NitroRuntimeHooks } from "nitro/types";
2
+ import type { ServerRequest, ServerRequestContext } from "srvx";
3
+ import type { H3EventContext, Middleware, WebSocketHooks } from "h3";
4
+ import { HookableCore } from "hookable";
5
+ declare global {
6
+ var __nitro__: Partial<Record<"default" | "prerender" | (string & {}), NitroApp | undefined>> | undefined;
7
+ }
8
+ export declare function useNitroApp(): NitroApp;
9
+ export declare function useNitroHooks(): HookableCore<NitroRuntimeHooks>;
10
+ export declare function serverFetch(resource: string | URL | Request, init?: RequestInit, context?: ServerRequestContext | H3EventContext): Promise<Response>;
11
+ export declare function resolveWebsocketHooks(req: ServerRequest): Promise<Partial<WebSocketHooks>>;
12
+ export declare function fetch(resource: string | URL | Request, init?: RequestInit, context?: ServerRequestContext | H3EventContext): Promise<Response>;
13
+ export declare function getRouteRules(method: string, pathname: string): {
14
+ routeRules?: MatchedRouteRules;
15
+ routeRuleMiddleware: Middleware[];
16
+ };
@@ -0,0 +1,208 @@
1
+ import { H3Core, toRequest } from "h3";
2
+ import { HookableCore } from "hookable";
3
+ import { nitroAsyncContext } from "./context.mjs";
4
+ // IMPORTANT: virtual imports and user code should be imported last to avoid initialization order issues
5
+ import errorHandler from "#nitro/virtual/error-handler";
6
+ import { plugins } from "#nitro/virtual/plugins";
7
+ import { findRoute, findRouteRules, globalMiddleware, findRoutedMiddleware } from "#nitro/virtual/routing";
8
+ import { hasRouteRules, hasRoutedMiddleware, hasGlobalMiddleware, hasRoutes, hasHooks, hasPlugins } from "#nitro/virtual/feature-flags";
9
+ const APP_ID = import.meta.prerender ? "prerender" : "default";
10
+ export function useNitroApp() {
11
+ let instance = useNitroApp._instance;
12
+ if (instance) {
13
+ return instance;
14
+ }
15
+ instance = useNitroApp._instance = createNitroApp();
16
+ globalThis.__nitro__ = globalThis.__nitro__ || {};
17
+ globalThis.__nitro__[APP_ID] = instance;
18
+ if (hasPlugins) {
19
+ initNitroPlugins(instance);
20
+ }
21
+ return instance;
22
+ }
23
+ export function useNitroHooks() {
24
+ const nitroApp = useNitroApp();
25
+ const hooks = nitroApp.hooks;
26
+ if (hooks) {
27
+ return hooks;
28
+ }
29
+ return nitroApp.hooks = new HookableCore();
30
+ }
31
+ export function serverFetch(resource, init, context) {
32
+ const req = toRequest(resource, init);
33
+ req.context = {
34
+ ...req.context,
35
+ ...context
36
+ };
37
+ const appHandler = useNitroApp().fetch;
38
+ try {
39
+ return Promise.resolve(appHandler(req));
40
+ } catch (error) {
41
+ return Promise.reject(error);
42
+ }
43
+ }
44
+ export async function resolveWebsocketHooks(req) {
45
+ // https://github.com/h3js/h3/blob/c11ca743d476e583b3b47de1717e6aae92114357/src/utils/ws.ts#L37
46
+ const hooks = (await serverFetch(req)).crossws;
47
+ return hooks || {};
48
+ }
49
+ export function fetch(resource, init, context) {
50
+ if (typeof resource === "string" && resource.charCodeAt(0) === 47) {
51
+ return serverFetch(resource, init, context);
52
+ }
53
+ resource = resource._request || resource;
54
+ return fetch(resource, init);
55
+ }
56
+ function createNitroApp() {
57
+ const hooks = hasHooks ? new HookableCore() : undefined;
58
+ const captureError = (error, errorCtx) => {
59
+ const promise = hasHooks && hooks.callHook("error", error, errorCtx)?.catch?.((hookError) => {
60
+ console.error("Error while capturing another error", hookError);
61
+ });
62
+ if (errorCtx?.event) {
63
+ const errors = errorCtx.event.req.context?.nitro?.errors;
64
+ if (errors) {
65
+ errors.push({
66
+ error,
67
+ context: errorCtx
68
+ });
69
+ }
70
+ if (hasHooks && promise && typeof errorCtx.event.req.waitUntil === "function") {
71
+ errorCtx.event.req.waitUntil(promise);
72
+ }
73
+ }
74
+ };
75
+ const h3App = createH3App({ onError(error, event) {
76
+ hasHooks && captureError(error, { event });
77
+ return errorHandler(error, event);
78
+ } });
79
+ if (hasHooks) {
80
+ h3App.config.onRequest = (event) => {
81
+ return hooks.callHook("request", event)?.catch?.((error) => {
82
+ captureError(error, {
83
+ event,
84
+ tags: ["request"]
85
+ });
86
+ });
87
+ };
88
+ h3App.config.onResponse = (res, event) => {
89
+ return hooks.callHook("response", res, event)?.catch?.((error) => {
90
+ captureError(error, {
91
+ event,
92
+ tags: ["response"]
93
+ });
94
+ });
95
+ };
96
+ }
97
+ let appHandler = (req) => {
98
+ req.context ||= {};
99
+ req.context.nitro = req.context.nitro || { errors: [] };
100
+ return h3App.fetch(req);
101
+ };
102
+ // Experimental async context support
103
+ if (import.meta._asyncContext) {
104
+ const originalHandler = appHandler;
105
+ appHandler = (req) => {
106
+ const asyncCtx = { request: req };
107
+ return nitroAsyncContext.callAsync(asyncCtx, () => originalHandler(req));
108
+ };
109
+ }
110
+ const app = {
111
+ fetch: appHandler,
112
+ h3: h3App,
113
+ hooks,
114
+ captureError
115
+ };
116
+ return app;
117
+ }
118
+ function initNitroPlugins(app) {
119
+ for (const plugin of plugins) {
120
+ try {
121
+ plugin(app);
122
+ } catch (error) {
123
+ app.captureError?.(error, { tags: ["plugin"] });
124
+ throw error;
125
+ }
126
+ }
127
+ return app;
128
+ }
129
+ function createH3App(config) {
130
+ // Create H3 app
131
+ const h3App = new H3Core(config);
132
+ // Compiled route matching
133
+ hasRoutes && (h3App["~findRoute"] = (event) => findRoute(event.req.method, event.url.pathname));
134
+ hasGlobalMiddleware && h3App["~middleware"].push(...globalMiddleware);
135
+ if (hasRouteRules || hasRoutedMiddleware) {
136
+ h3App["~getMiddleware"] = (event, route) => {
137
+ const needsRouting = hasRouteRules || hasRoutedMiddleware;
138
+ const pathname = needsRouting ? event.url.pathname : undefined;
139
+ const method = needsRouting ? event.req.method : undefined;
140
+ const middleware = [];
141
+ if (hasRouteRules) {
142
+ const routeRules = getRouteRules(method, pathname);
143
+ event.context.routeRules = routeRules?.routeRules;
144
+ if (routeRules?.routeRuleMiddleware.length) {
145
+ middleware.push(...routeRules.routeRuleMiddleware);
146
+ }
147
+ }
148
+ hasGlobalMiddleware && middleware.push(...h3App["~middleware"]);
149
+ hasRoutedMiddleware && middleware.push(...findRoutedMiddleware(method, pathname).map((r) => r.data));
150
+ if (hasRoutes && route?.data?.middleware?.length) {
151
+ middleware.push(...route.data.middleware);
152
+ }
153
+ return middleware;
154
+ };
155
+ }
156
+ return h3App;
157
+ }
158
+ export function getRouteRules(method, pathname) {
159
+ const m = findRouteRules(method, pathname);
160
+ if (!m?.length) {
161
+ return { routeRuleMiddleware: [] };
162
+ }
163
+ const routeRules = {};
164
+ for (const layer of m) {
165
+ for (const rule of layer.data) {
166
+ const currentRule = routeRules[rule.name];
167
+ if (currentRule) {
168
+ if (rule.options === false) {
169
+ // Remove/Reset existing rule with `false` value
170
+ delete routeRules[rule.name];
171
+ continue;
172
+ }
173
+ if (typeof currentRule.options === "object" && typeof rule.options === "object") {
174
+ // Merge nested rule objects
175
+ currentRule.options = {
176
+ ...currentRule.options,
177
+ ...rule.options
178
+ };
179
+ } else {
180
+ // Override rule if non object
181
+ currentRule.options = rule.options;
182
+ }
183
+ // Routing (route and params)
184
+ currentRule.route = rule.route;
185
+ currentRule.params = {
186
+ ...currentRule.params,
187
+ ...layer.params
188
+ };
189
+ } else if (rule.options !== false) {
190
+ routeRules[rule.name] = {
191
+ ...rule,
192
+ params: layer.params
193
+ };
194
+ }
195
+ }
196
+ }
197
+ const middleware = [];
198
+ for (const rule of Object.values(routeRules)) {
199
+ if (rule.options === false || !rule.handler) {
200
+ continue;
201
+ }
202
+ middleware.push(rule.handler(rule));
203
+ }
204
+ return {
205
+ routeRules,
206
+ routeRuleMiddleware: middleware
207
+ };
208
+ }
@@ -0,0 +1,7 @@
1
+ import type { EventHandler } from "h3";
2
+ import type { CacheOptions, CachedEventHandlerOptions } from "nitro/types";
3
+ export declare function defineCachedFunction<
4
+ T,
5
+ ArgsT extends unknown[] = any[]
6
+ >(fn: (...args: ArgsT) => T | Promise<T>, opts?: CacheOptions<T, ArgsT>): (...args: ArgsT) => Promise<T>;
7
+ export declare function defineCachedHandler(handler: EventHandler, opts?: CachedEventHandlerOptions): EventHandler;
@@ -0,0 +1,41 @@
1
+ import { defineHandler, handleCacheHeaders, toResponse } from "h3";
2
+ import { FastResponse } from "srvx";
3
+ import { defineCachedFunction as _defineCachedFunction, defineCachedHandler as _defineCachedHandler, setStorage } from "ocache";
4
+ import { useNitroApp } from "./app.mjs";
5
+ import { useStorage } from "./storage.mjs";
6
+ let _storageReady = false;
7
+ function ensureStorage() {
8
+ if (_storageReady) {
9
+ return;
10
+ }
11
+ _storageReady = true;
12
+ const storage = useStorage();
13
+ setStorage({
14
+ get: (key) => storage.getItem(key),
15
+ set: (key, value, opts) => storage.setItem(key, value, opts?.ttl ? { ttl: opts.ttl } : undefined)
16
+ });
17
+ }
18
+ function defaultOnError(error) {
19
+ console.error("[cache]", error);
20
+ useNitroApp().captureError?.(error, { tags: ["cache"] });
21
+ }
22
+ export function defineCachedFunction(fn, opts = {}) {
23
+ ensureStorage();
24
+ return _defineCachedFunction(fn, {
25
+ group: "nitro/functions",
26
+ onError: defaultOnError,
27
+ ...opts
28
+ });
29
+ }
30
+ export function defineCachedHandler(handler, opts = {}) {
31
+ ensureStorage();
32
+ const ocacheHandler = _defineCachedHandler(handler, {
33
+ group: "nitro/handlers",
34
+ onError: defaultOnError,
35
+ toResponse: (value, event) => toResponse(value, event),
36
+ createResponse: (body, init) => new FastResponse(body, init),
37
+ handleCacheHeaders: (event, conditions) => handleCacheHeaders(event, conditions),
38
+ ...opts
39
+ });
40
+ return defineHandler((event) => ocacheHandler(event));
41
+ }
@@ -0,0 +1,14 @@
1
+ import type { NitroAsyncContext } from "nitro/types";
2
+ import type { ServerRequest } from "srvx";
3
+ import { type UseContext } from "unctx";
4
+ export declare const nitroAsyncContext: UseContext<NitroAsyncContext>;
5
+ /**
6
+ *
7
+ * Access to the current Nitro request.
8
+ *
9
+ * @experimental
10
+ * - Requires `experimental.asyncContext: true` config to work.
11
+ * - Works in Node.js and limited runtimes only
12
+ *
13
+ */
14
+ export declare function useRequest(): ServerRequest;
@@ -0,0 +1,24 @@
1
+ import { AsyncLocalStorage } from "node:async_hooks";
2
+ import { HTTPError } from "h3";
3
+ import { getContext } from "unctx";
4
+ export const nitroAsyncContext = /* @__PURE__ */ (() => getContext("nitro-app", {
5
+ asyncContext: import.meta._asyncContext,
6
+ AsyncLocalStorage: import.meta._asyncContext ? AsyncLocalStorage : undefined
7
+ }))();
8
+ /**
9
+ *
10
+ * Access to the current Nitro request.
11
+ *
12
+ * @experimental
13
+ * - Requires `experimental.asyncContext: true` config to work.
14
+ * - Works in Node.js and limited runtimes only
15
+ *
16
+ */
17
+ export function useRequest() {
18
+ try {
19
+ return nitroAsyncContext.use().request;
20
+ } catch {
21
+ const hint = import.meta._asyncContext ? "Note: This is an experimental feature and might be broken on non-Node.js environments." : "Enable the experimental flag using `experimental.asyncContext: true`.";
22
+ throw new HTTPError({ message: `Nitro request context is not available. ${hint}` });
23
+ }
24
+ }
@@ -0,0 +1,2 @@
1
+ import type { Database } from "db0";
2
+ export declare function useDatabase(name?: string): Database;
@@ -0,0 +1,12 @@
1
+ import { createDatabase } from "db0";
2
+ import { connectionConfigs } from "#nitro/virtual/database";
3
+ const instances = Object.create(null);
4
+ export function useDatabase(name = "default") {
5
+ if (instances[name]) {
6
+ return instances[name];
7
+ }
8
+ if (!connectionConfigs[name]) {
9
+ throw new Error(`Database connection "${name}" not configured.`);
10
+ }
11
+ return instances[name] = createDatabase(connectionConfigs[name].connector(connectionConfigs[name].options || {}));
12
+ }
File without changes
@@ -0,0 +1,10 @@
1
+ import { HTTPError, type HTTPEvent } from "h3";
2
+ import type { InternalHandlerResponse } from "./utils.mjs";
3
+ import type { NitroErrorHandler } from "nitro/types";
4
+ declare const errorHandler: NitroErrorHandler;
5
+ export default errorHandler;
6
+ export declare function defaultHandler(error: HTTPError, event: HTTPEvent, opts?: {
7
+ silent?: boolean;
8
+ json?: boolean;
9
+ }): Promise<InternalHandlerResponse>;
10
+ export declare function loadStackTrace(error: any): Promise<void>;