@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,277 @@
1
+ # Tasks
2
+
3
+ > Nitro tasks allow on-off operations in runtime.
4
+
5
+ ## Opt-in to the experimental feature
6
+
7
+ > [!IMPORTANT]
8
+ > Tasks support is currently experimental.
9
+ > See [nitrojs/nitro#1974](https://github.com/nitrojs/nitro/issues/1974) for the relevant discussion.
10
+
11
+ In order to use the tasks API you need to enable experimental feature flag.
12
+
13
+ ```ts [nitro.config.ts]
14
+ import { defineNitroConfig } from "nitro/config";
15
+
16
+ export default defineNitroConfig({
17
+ experimental: {
18
+ tasks: true
19
+ }
20
+ })
21
+ ```
22
+
23
+ ## Define tasks
24
+
25
+ Tasks can be defined in `tasks/[name].ts` files.
26
+
27
+ Nested directories are supported. The task name will be joined with `:`. (Example: `tasks/db/migrate.ts` task name will be `db:migrate`)
28
+
29
+ **Example:**
30
+
31
+ ```ts [tasks/db/migrate.ts]
32
+ export default defineTask({
33
+ meta: {
34
+ name: "db:migrate",
35
+ description: "Run database migrations",
36
+ },
37
+ run({ payload, context }) {
38
+ console.log("Running DB migration task...");
39
+ return { result: "Success" };
40
+ },
41
+ });
42
+ ```
43
+
44
+ ### Task interface
45
+
46
+ The `defineTask` helper accepts an object with the following properties:
47
+
48
+ - **`meta`** (optional): An object with optional `name` and `description` string fields used for display in the dev server and CLI.
49
+ - **`run`** (required): A function that receives a [`TaskEvent`](#taskevent) and returns (or resolves to) an object with an optional `result` property.
50
+
51
+ ```ts
52
+ interface Task<RT = unknown> {
53
+ meta?: { name?: string; description?: string };
54
+ run(event: TaskEvent): { result?: RT } | Promise<{ result?: RT }>;
55
+ }
56
+ ```
57
+
58
+ ### `TaskEvent`
59
+ The `run` function receives a `TaskEvent` object with the following properties:
60
+
61
+ - **`name`**: The name of the task being executed.
62
+ - **`payload`**: An object (`Record<string, unknown>`) containing any data passed to the task.
63
+ - **`context`**: A `TaskContext` object (may include `waitUntil` depending on the runtime).
64
+
65
+ ```ts
66
+ interface TaskEvent {
67
+ name: string;
68
+ payload: TaskPayload;
69
+ context: TaskContext;
70
+ }
71
+ ```
72
+
73
+ ### Registering tasks via config
74
+ In addition to file-based scanning, tasks can be registered directly in the Nitro config. This is useful for tasks provided by modules or pointing to custom handler paths.
75
+
76
+ ```ts [nitro.config.ts]
77
+ import { defineNitroConfig } from "nitro/config";
78
+
79
+ export default defineNitroConfig({
80
+ experimental: {
81
+ tasks: true
82
+ },
83
+ tasks: {
84
+ "db:migrate": {
85
+ handler: "./tasks/custom-migrate.ts",
86
+ description: "Run database migrations"
87
+ }
88
+ }
89
+ })
90
+ ```
91
+
92
+ If a task is both scanned from the `tasks/` directory and defined in the config, the config-defined `handler` takes precedence.
93
+
94
+ ## Scheduled tasks
95
+
96
+ You can define scheduled tasks using Nitro configuration to automatically run after each period of time.
97
+
98
+ ```ts [nitro.config.ts]
99
+ import { defineNitroConfig } from "nitro/config";
100
+
101
+ export default defineNitroConfig({
102
+ scheduledTasks: {
103
+ // Run `cms:update` task every minute
104
+ '* * * * *': ['cms:update'],
105
+ // Run a single task (string shorthand)
106
+ '0 * * * *': 'db:cleanup'
107
+ }
108
+ })
109
+ ```
110
+
111
+ The `scheduledTasks` config maps cron expressions to either a single task name (string) or an array of task names. When multiple tasks are assigned to the same cron expression, they run in parallel.
112
+
113
+ > [!TIP]
114
+ > You can use [crontab.guru](https://crontab.guru/) to easily generate and understand cron tab patterns.
115
+
116
+ When a scheduled task runs, it automatically receives a `payload` with `scheduledTime` set to the current timestamp (`Date.now()`).
117
+
118
+ ### Platform support
119
+
120
+ - **`dev`**, **`node_server`**, **`node_cluster`**, **`node_middleware`**, **`bun`** and **`deno_server`** presets are supported with the [croner](https://croner.56k.guru/) engine.
121
+ - **`cloudflare_module`** and **`cloudflare_pages`** presets have native integration with [Cron Triggers](https://developers.cloudflare.com/workers/configuration/cron-triggers/). Nitro automatically generates the cron triggers in the wrangler config at build time - no manual wrangler setup required.
122
+ - **`vercel`** preset has native integration with [Vercel Cron Jobs](https://vercel.com/docs/cron-jobs). Nitro automatically generates the cron job configuration at build time - no manual `vercel.json` setup required. You can secure cron endpoints by setting the `CRON_SECRET` environment variable.
123
+ - More presets (with native primitives support) are planned to be supported!
124
+
125
+ ## `waitUntil`
126
+ When running background tasks, you might want to make sure the server or worker waits until the task is done.
127
+
128
+ An optional `context.waitUntil` function <u>might</u> be available depending on the runtime.
129
+
130
+ ```ts
131
+ export default defineTask({
132
+ run({ context }) {
133
+ const promise = fetch(...)
134
+ context.waitUntil?.(promise);
135
+ await promise;
136
+ return { result: "Success" };
137
+ },
138
+ });
139
+ ```
140
+
141
+ ## Programmatically run tasks
142
+
143
+ To manually run tasks, you can use `runTask(name, { payload?, context? })` utility from `nitro/task`.
144
+
145
+ **Example:**
146
+
147
+ ```ts [api/migrate.ts]
148
+ import { defineHandler } from "nitro";
149
+
150
+ export default defineHandler(async (event) => {
151
+ // IMPORTANT: Authenticate user and validate payload!
152
+ const payload = Object.fromEntries(event.url.searchParams);
153
+ const { result } = await runTask("db:migrate", { payload });
154
+
155
+ return { result };
156
+ });
157
+ ```
158
+
159
+ ### Error handling
160
+
161
+ `runTask` throws an HTTP error if:
162
+
163
+ - The task does not exist (status `404`).
164
+ - The task has no handler implementation (status `501`).
165
+ Any errors thrown inside the task's `run` function will propagate to the caller.
166
+
167
+ ## Run tasks with dev server
168
+
169
+ Nitro's built-in dev server exposes tasks to be easily executed without programmatic usage.
170
+
171
+ ### Using API routes
172
+
173
+ #### `/_nitro/tasks`
174
+
175
+ This endpoint returns a list of available task names and their meta.
176
+
177
+ ```json
178
+ // [GET] /_nitro/tasks
179
+ {
180
+ "tasks": {
181
+ "db:migrate": {
182
+ "description": "Run database migrations"
183
+ },
184
+ "cms:update": {
185
+ "description": "Update CMS content"
186
+ }
187
+ },
188
+ "scheduledTasks": [
189
+ {
190
+ "cron": "* * * * *",
191
+ "tasks": [
192
+ "cms:update"
193
+ ]
194
+ }
195
+ ]
196
+ }
197
+ ```
198
+
199
+ #### `/_nitro/tasks/:name`
200
+
201
+ This endpoint executes a task. You can provide a payload using both query parameters and body JSON payload. The payload sent in the JSON body payload must be under the `"payload"` property.
202
+
203
+ <code-group>
204
+
205
+ ```ts [tasks/echo/payload.ts]
206
+ export default defineTask({
207
+ meta: {
208
+ name: "echo:payload",
209
+ description: "Returns the provided payload",
210
+ },
211
+ run({ payload, context }) {
212
+ console.log("Running echo task...");
213
+ return { result: payload };
214
+ },
215
+ });
216
+ ```
217
+
218
+ ```json [GET]
219
+ // [GET] /_nitro/tasks/echo:payload?field=value&array=1&array=2
220
+ {
221
+ "field": "value",
222
+ "array": ["1", "2"]
223
+ }
224
+ ```
225
+
226
+ ```json [POST]
227
+ /**
228
+ * [POST] /_nitro/tasks/echo:payload?field=value
229
+ * body: {
230
+ * "payload": {
231
+ * "answer": 42,
232
+ * "nested": {
233
+ * "value": true
234
+ * }
235
+ * }
236
+ * }
237
+ */
238
+ {
239
+ "field": "value",
240
+ "answer": 42,
241
+ "nested": {
242
+ "value": true
243
+ }
244
+ }
245
+ ```
246
+ </code-group>
247
+
248
+ > [!NOTE]
249
+ > The JSON payload included in the body will overwrite the keys present in the query params.
250
+
251
+ ### Using CLI
252
+
253
+ > [!IMPORTANT]
254
+ > It is only possible to run these commands while the **dev server is running**. You should run them in a second terminal.
255
+
256
+ #### List tasks
257
+
258
+ ```sh
259
+ nitro task list
260
+ ```
261
+
262
+ #### Run a task
263
+
264
+ ```sh
265
+ nitro task run db:migrate --payload "{}"
266
+ ```
267
+
268
+ The `--payload` flag accepts a JSON string that will be parsed and passed to the task. If the value is not a valid JSON object, the task runs without a payload.
269
+
270
+ ## Notes
271
+
272
+ ### Concurrency
273
+
274
+ Each task can have **one running instance**. Calling a task of same name multiple times in parallel, results in calling it once and all callers will get the same return value.
275
+
276
+ > [!NOTE]
277
+ > Nitro tasks can be running multiple times and in parallel.
@@ -0,0 +1,145 @@
1
+ # API Routes
2
+
3
+ > File-based API routing with HTTP method support and dynamic parameters.
4
+
5
+ <code-tree>
6
+
7
+ ```html [index.html]
8
+ <!doctype html>
9
+ <html lang="en">
10
+ <head>
11
+ <meta charset="utf-8" />
12
+ <meta name="viewport" content="width=device-width,initial-scale=1" />
13
+ <title>API Routes</title>
14
+ </head>
15
+ <body>
16
+ <h2>API Routes:</h2>
17
+ <ul>
18
+ <li><a href="/api/hello">/api/hello</a></li>
19
+ <li><a href="/api/hello/world">/api/hello/world</a></li>
20
+ <li><a href="/api/test">/api/test</a></li>
21
+ </ul>
22
+ </body>
23
+ </html>
24
+ ```
25
+
26
+ ```ts [nitro.config.ts]
27
+ import { defineConfig } from "nitro";
28
+
29
+ export default defineConfig({
30
+ serverDir: "./",
31
+ });
32
+ ```
33
+
34
+ ```json [package.json]
35
+ {
36
+ "type": "module",
37
+ "scripts": {
38
+ "dev": "nitro dev",
39
+ "build": "nitro build"
40
+ },
41
+ "devDependencies": {
42
+ "nitro": "latest"
43
+ }
44
+ }
45
+ ```
46
+
47
+ ```json [tsconfig.json]
48
+ {
49
+ "extends": "nitro/tsconfig"
50
+ }
51
+ ```
52
+
53
+ ```ts [vite.config.ts]
54
+ import { defineConfig } from "vite";
55
+ import { nitro } from "nitro/vite";
56
+
57
+ export default defineConfig({ plugins: [nitro()] });
58
+ ```
59
+
60
+ ```ts [api/hello.ts]
61
+ import { defineHandler } from "nitro";
62
+
63
+ export default defineHandler(() => "Nitro is amazing!");
64
+ ```
65
+
66
+ ```ts [api/test.get.ts]
67
+ import { defineHandler } from "nitro";
68
+
69
+ export default defineHandler(() => "Test get handler");
70
+ ```
71
+
72
+ ```ts [api/test.post.ts]
73
+ import { defineHandler } from "nitro";
74
+
75
+ export default defineHandler(async (event) => {
76
+ const body = await event.req.json();
77
+ return {
78
+ message: "Test post handler",
79
+ body,
80
+ };
81
+ });
82
+ ```
83
+
84
+ ```ts [api/hello/[name].ts]
85
+ import { defineHandler } from "nitro";
86
+
87
+ export default defineHandler((event) => `Hello (param: ${event.context.params!.name})!`);
88
+ ```
89
+ </code-tree>
90
+
91
+ Nitro supports file-based routing in the `api/` or `routes/` directory. Each file becomes an API endpoint based on its path.
92
+
93
+ ## Basic Route
94
+
95
+ Create a file in the `api/` directory to define a route. The file path becomes the URL path:
96
+
97
+ ```ts [api/hello.ts]
98
+ import { defineHandler } from "nitro";
99
+
100
+ export default defineHandler(() => "Nitro is amazing!");
101
+ ```
102
+
103
+ This creates a `GET /api/hello` endpoint.
104
+
105
+ ## Dynamic Routes
106
+
107
+ Use square brackets `[param]` for dynamic URL segments. Access params via `event.context.params`:
108
+
109
+ ```ts [api/hello/[name].ts]
110
+ import { defineHandler } from "nitro";
111
+
112
+ export default defineHandler((event) => `Hello (param: ${event.context.params!.name})!`);
113
+ ```
114
+
115
+ This creates a `GET /api/hello/:name` endpoint (e.g., `/api/hello/world`).
116
+
117
+ ## HTTP Methods
118
+
119
+ Suffix your file with the HTTP method (`.get.ts`, `.post.ts`, `.put.ts`, `.delete.ts`, etc.):
120
+
121
+ ### GET Handler
122
+
123
+ ```ts [api/test.get.ts]
124
+ import { defineHandler } from "nitro";
125
+
126
+ export default defineHandler(() => "Test get handler");
127
+ ```
128
+
129
+ ### POST Handler
130
+
131
+ ```ts [api/test.post.ts]
132
+ import { defineHandler } from "nitro";
133
+
134
+ export default defineHandler(async (event) => {
135
+ const body = await event.req.json();
136
+ return {
137
+ message: "Test post handler",
138
+ body,
139
+ };
140
+ });
141
+ ```
142
+
143
+ ## Learn More
144
+
145
+ - [Routing](/docs/routing)
@@ -0,0 +1,93 @@
1
+ # Auto Imports
2
+
3
+ > Automatic imports for utilities and composables.
4
+
5
+ <code-tree>
6
+
7
+ ```ts [nitro.config.ts]
8
+ import { defineConfig } from "nitro";
9
+
10
+ export default defineConfig({
11
+ serverDir: true,
12
+ imports: {},
13
+ });
14
+ ```
15
+
16
+ ```json [package.json]
17
+ {
18
+ "type": "module",
19
+ "scripts": {
20
+ "dev": "nitro dev",
21
+ "build": "nitro build"
22
+ },
23
+ "devDependencies": {
24
+ "nitro": "latest"
25
+ }
26
+ }
27
+ ```
28
+
29
+ ```ts [server.ts]
30
+ import { defineHandler } from "nitro";
31
+ import { makeGreeting } from "./server/utils/hello.ts";
32
+
33
+ export default defineHandler(() => `<h1>${makeGreeting("Nitro")}</h1>`);
34
+ ```
35
+
36
+ ```json [tsconfig.json]
37
+ {
38
+ "include": [".nitro/types/nitro-imports.d.ts", "src"]
39
+ }
40
+ ```
41
+
42
+ ```ts [vite.config.ts]
43
+ import { defineConfig } from "vite";
44
+ import { nitro } from "nitro/vite";
45
+
46
+ export default defineConfig({ plugins: [nitro()] });
47
+ ```
48
+
49
+ ```ts [server/utils/hello.ts]
50
+ export function makeGreeting(name: string) {
51
+ return `Hello, ${name}!`;
52
+ }
53
+ ```
54
+ </code-tree>
55
+
56
+ Functions exported from `server/utils/` are automatically available without explicit imports when auto-imports are enabled. Define a utility once and use it anywhere in your server code.
57
+
58
+ ## Configuration
59
+
60
+ Enable auto-imports by setting `imports` in your config:
61
+
62
+ ```ts [nitro.config.ts]
63
+ import { defineConfig } from "nitro";
64
+
65
+ export default defineConfig({
66
+ serverDir: true,
67
+ imports: {},
68
+ });
69
+ ```
70
+
71
+ ## Using Auto Imports
72
+
73
+ 1. Create a utility file in `server/utils/`:
74
+
75
+ ```ts [server/utils/hello.ts]
76
+ export function makeGreeting(name: string) {
77
+ return `Hello, ${name}!`;
78
+ }
79
+ ```
80
+
81
+ 2. The function is available without importing it:
82
+
83
+ ```ts [server.ts]
84
+ import { defineHandler } from "nitro";
85
+ import { makeGreeting } from "./server/utils/hello.ts";
86
+
87
+ export default defineHandler(() => `<h1>${makeGreeting("Nitro")}</h1>`);
88
+ ```
89
+ With this setup, any function exported from `server/utils/` becomes globally available. Nitro scans the directory and generates the necessary imports automatically.
90
+
91
+ ## Learn More
92
+
93
+ - [Configuration](/docs/configuration)
@@ -0,0 +1,81 @@
1
+ # Cached Handler
2
+
3
+ > Cache route responses with configurable bypass logic.
4
+
5
+ <code-tree>
6
+
7
+ ```ts [nitro.config.ts]
8
+ import { defineConfig } from "nitro";
9
+
10
+ export default defineConfig({});
11
+ ```
12
+
13
+ ```json [package.json]
14
+ {
15
+ "type": "module",
16
+ "scripts": {
17
+ "dev": "nitro dev",
18
+ "build": "nitro build"
19
+ },
20
+ "devDependencies": {
21
+ "nitro": "latest"
22
+ }
23
+ }
24
+ ```
25
+
26
+ ```ts [server.ts]
27
+ import { html } from "nitro";
28
+ import { defineCachedHandler } from "nitro/cache";
29
+
30
+ export default defineCachedHandler(
31
+ async () => {
32
+ await new Promise((resolve) => setTimeout(resolve, 500));
33
+ return html`
34
+ Response generated at ${new Date().toISOString()} (took 500ms)
35
+ <br />(<a href="?skipCache=true">skip cache</a>)
36
+ `;
37
+ },
38
+ { shouldBypassCache: ({ req }) => req.url.includes("skipCache=true") }
39
+ );
40
+ ```
41
+
42
+ ```json [tsconfig.json]
43
+ {
44
+ "extends": "nitro/tsconfig"
45
+ }
46
+ ```
47
+
48
+ ```ts [vite.config.ts]
49
+ import { defineConfig } from "vite";
50
+ import { nitro } from "nitro/vite";
51
+
52
+ export default defineConfig({ plugins: [nitro()] });
53
+ ```
54
+ </code-tree>
55
+
56
+ This example shows how to cache an expensive operation (a 500 ms delay) and conditionally bypass the cache using a query parameter. On first request, the handler executes and caches the result. Subsequent requests return the cached response instantly until the cache expires or is bypassed.
57
+
58
+ ## How It Works
59
+
60
+ ```ts [server.ts]
61
+ import { html } from "nitro";
62
+ import { defineCachedHandler } from "nitro/cache";
63
+
64
+ export default defineCachedHandler(
65
+ async () => {
66
+ await new Promise((resolve) => setTimeout(resolve, 500));
67
+ return html`
68
+ Response generated at ${new Date().toISOString()} (took 500ms)
69
+ <br />(<a href="?skipCache=true">skip cache</a>)
70
+ `;
71
+ },
72
+ { shouldBypassCache: ({ req }) => req.url.includes("skipCache=true") }
73
+ );
74
+ ```
75
+
76
+ The handler simulates a slow operation with a 500ms delay. As `defineCachedHandler` wraps it, the response is cached after the first execution. The `shouldBypassCache` option checks for `?skipCache=true` in the URL and when present the cache is skipped and the handler runs fresh.
77
+
78
+ ## Learn More
79
+
80
+ - [Cache](/docs/cache)
81
+ - [Storage](/docs/storage)
@@ -0,0 +1,98 @@
1
+ # Custom Error Handler
2
+
3
+ > Customize error responses with a global error handler.
4
+
5
+ <code-tree>
6
+
7
+ ```ts [error.ts]
8
+ import { defineErrorHandler } from "nitro";
9
+
10
+ export default defineErrorHandler((error, _event) => {
11
+ return new Response(`Custom Error Handler: ${error.message}`, {
12
+ status: 500,
13
+ headers: { "Content-Type": "text/plain" },
14
+ });
15
+ });
16
+ ```
17
+
18
+ ```ts [nitro.config.ts]
19
+ import { defineConfig } from "nitro";
20
+ // import errorHandler from "./error";
21
+
22
+ export default defineConfig({
23
+ errorHandler: "./error.ts",
24
+ // devErrorHandler: errorHandler,
25
+ });
26
+ ```
27
+
28
+ ```json [package.json]
29
+ {
30
+ "type": "module",
31
+ "scripts": {
32
+ "dev": "nitro dev",
33
+ "build": "nitro build"
34
+ },
35
+ "devDependencies": {
36
+ "nitro": "latest"
37
+ }
38
+ }
39
+ ```
40
+
41
+ ```ts [server.ts]
42
+ import { defineHandler, HTTPError } from "nitro";
43
+
44
+ export default defineHandler(() => {
45
+ throw new HTTPError("Example Error!", { status: 500 });
46
+ });
47
+ ```
48
+
49
+ ```json [tsconfig.json]
50
+ {
51
+ "extends": "nitro/tsconfig"
52
+ }
53
+ ```
54
+
55
+ ```ts [vite.config.ts]
56
+ import { defineConfig } from "vite";
57
+ import { nitro } from "nitro/vite";
58
+
59
+ export default defineConfig({ plugins: [nitro()] });
60
+ ```
61
+ </code-tree>
62
+
63
+ This example shows how to intercept all errors and return a custom response format. When any route throws an error, Nitro calls your error handler instead of returning the default error page.
64
+
65
+ ## Error Handler
66
+
67
+ Create an `error.ts` file in your project root to define the global error handler:
68
+
69
+ ```ts [error.ts]
70
+ import { defineErrorHandler } from "nitro";
71
+
72
+ export default defineErrorHandler((error, _event) => {
73
+ return new Response(`Custom Error Handler: ${error.message}`, {
74
+ status: 500,
75
+ headers: { "Content-Type": "text/plain" },
76
+ });
77
+ });
78
+ ```
79
+
80
+ The handler receives the thrown error and the H3 event object. You can use the event to access request details like headers, cookies, or the URL path to customize responses per route.
81
+
82
+ ## Triggering an Error
83
+
84
+ The main handler throws an error to demonstrate the custom error handler:
85
+
86
+ ```ts [server.ts]
87
+ import { defineHandler, HTTPError } from "nitro";
88
+
89
+ export default defineHandler(() => {
90
+ throw new HTTPError("Example Error!", { status: 500 });
91
+ });
92
+ ```
93
+
94
+ When you visit the page, instead of seeing a generic error page, you'll see "Custom Error Handler: Example Error!" because the error handler intercepts the thrown error.
95
+
96
+ ## Learn More
97
+
98
+ - [Server Entry](/docs/server-entry)