nitro 3.0.1-alpha.2 → 3.0.260415-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +6 -0
- package/README.md +2 -2
- package/dist/THIRD-PARTY-LICENSES.md +1646 -0
- package/dist/_build/common.mjs +7261 -3812
- package/dist/_build/rolldown.mjs +32 -42
- package/dist/_build/rollup.mjs +28 -48
- package/dist/_build/vite.build.mjs +10 -10
- package/dist/_chunks/nitro.mjs +102 -327
- package/dist/_chunks/nitro2.mjs +8 -9
- package/dist/_chunks/nitro3.mjs +136 -0
- package/dist/_chunks/nitro4.mjs +127 -0
- package/dist/_chunks/utils.mjs +40 -29
- package/dist/_common.mjs +13 -25
- package/dist/_dev.d.mts +0 -3
- package/dist/{_chunks/dev.mjs → _dev.mjs} +132 -330
- package/dist/_libs/_.mjs +2 -0
- package/dist/_libs/_2.mjs +2 -0
- package/dist/_libs/_3.mjs +2 -0
- package/dist/_libs/_4.mjs +2 -0
- package/dist/_libs/_5.mjs +2 -0
- package/dist/_libs/_6.mjs +2 -0
- package/dist/_libs/_7.mjs +2 -0
- package/dist/_libs/c12+rc9.mjs +814 -0
- package/dist/_libs/{c12+giget+readdirp+chokidar.d.mts → c12+readdirp+chokidar.d.mts} +49 -40
- package/dist/_libs/citty.mjs +142 -41
- package/dist/_libs/commondir+is-reference.mjs +60 -56
- package/dist/_libs/compatx.d.mts +0 -2
- package/dist/_libs/compatx.mjs +1 -4
- package/dist/_libs/esbuild.d.mts +0 -1
- package/dist/_libs/escape-string-regexp.mjs +1 -4
- package/dist/_libs/{pluginutils+plugin-commonjs.d.mts → estree+pluginutils.d.mts} +0 -5
- package/dist/_libs/estree-walker.mjs +4 -92
- package/dist/_libs/exsolve.d.mts +1 -0
- package/dist/_libs/hasown+resolve+deepmerge.mjs +160 -246
- package/dist/_libs/httpxy.d.mts +20 -13
- package/dist/_libs/httpxy.mjs +519 -95
- package/dist/_libs/js-tokens.d.mts +1 -0
- package/dist/_libs/klona.mjs +1 -4
- package/dist/_libs/magic-string.d.mts +0 -2
- package/dist/_libs/mlly.d.mts +0 -2
- package/dist/_libs/nypm+tinyexec.mjs +822 -0
- package/dist/_libs/perfect-debounce.mjs +68 -0
- package/dist/_libs/pkg-types.d.mts +0 -3
- package/dist/_libs/plugin-alias.mjs +1 -5
- package/dist/_libs/plugin-inject.mjs +1 -7
- package/dist/_libs/plugin-json.mjs +1 -5
- package/dist/_libs/pluginutils.mjs +3 -35
- package/dist/_libs/readdirp+chokidar.mjs +187 -365
- package/dist/_libs/remapping.mjs +1 -5
- package/dist/_libs/resolve-uri+gen-mapping.mjs +15 -53
- package/dist/_libs/rou3.d.mts +1 -4
- package/dist/_libs/rou3.mjs +223 -78
- package/dist/_libs/std-env.d.mts +8 -2
- package/dist/_libs/strip-literal.d.mts +1 -0
- package/dist/_libs/tsconfck.mjs +21 -334
- package/dist/_libs/ultrahtml.mjs +3 -16
- package/dist/_libs/unimport+unplugin.mjs +244 -388
- package/dist/_libs/unplugin+unimport.d.mts +5 -15
- package/dist/_libs/unwasm.d.mts +0 -3
- package/dist/_presets.mjs +576 -488
- package/dist/builder.d.mts +5 -25
- package/dist/builder.mjs +3 -8
- package/dist/cli/_chunks/build.mjs +22 -25
- package/dist/cli/_chunks/common.mjs +1 -4
- package/dist/cli/_chunks/deploy.mjs +37 -0
- package/dist/cli/_chunks/dev.mjs +6 -11
- package/dist/cli/_chunks/docs.mjs +28 -0
- package/dist/cli/_chunks/list.mjs +4 -8
- package/dist/cli/_chunks/prepare.mjs +2 -6
- package/dist/cli/_chunks/preview.mjs +48 -0
- package/dist/cli/_chunks/run.mjs +7 -11
- package/dist/cli/_chunks/task.mjs +1 -5
- package/dist/cli/index.mjs +5 -6
- package/dist/docs/0.docs/0.index/index.md +56 -0
- package/dist/docs/0.docs/1.quick-start.md +110 -0
- package/dist/docs/0.docs/10.lifecycle.md +204 -0
- package/dist/docs/0.docs/11.openapi.md +291 -0
- package/dist/docs/0.docs/12.plugins.md +164 -0
- package/dist/docs/0.docs/13.tasks.md +277 -0
- package/dist/docs/0.docs/14.websocket.md +386 -0
- package/dist/docs/0.docs/15.migration.md +213 -0
- package/dist/docs/0.docs/16.nightly.md +31 -0
- package/dist/docs/0.docs/2.renderer.md +322 -0
- package/dist/docs/0.docs/3.routing.md +711 -0
- package/dist/docs/0.docs/4.server-entry.md +239 -0
- package/dist/docs/0.docs/5.cache.md +408 -0
- package/dist/docs/0.docs/6.storage.md +261 -0
- package/dist/docs/0.docs/7.assets.md +166 -0
- package/dist/docs/0.docs/8.configuration.md +256 -0
- package/dist/docs/0.docs/9.database.md +185 -0
- package/dist/docs/1.deploy/0.index/index.md +64 -0
- package/dist/docs/1.deploy/1.runtimes/0.node.md +63 -0
- package/dist/docs/1.deploy/1.runtimes/1.bun.md +15 -0
- package/dist/docs/1.deploy/1.runtimes/2.deno.md +19 -0
- package/dist/docs/1.deploy/2.providers/0.alwaysdata.md +50 -0
- package/dist/docs/1.deploy/2.providers/1.aws.md +47 -0
- package/dist/docs/1.deploy/2.providers/10.flightcontrol.md +67 -0
- package/dist/docs/1.deploy/2.providers/11.genezio.md +67 -0
- package/dist/docs/1.deploy/2.providers/12.github-pages.md +68 -0
- package/dist/docs/1.deploy/2.providers/13.gitlab-pages.md +37 -0
- package/dist/docs/1.deploy/2.providers/14.heroku.md +84 -0
- package/dist/docs/1.deploy/2.providers/15.iis.md +38 -0
- package/dist/docs/1.deploy/2.providers/16.koyeb.md +109 -0
- package/dist/docs/1.deploy/2.providers/17.netlify.md +47 -0
- package/dist/docs/1.deploy/2.providers/18.platform-sh.md +37 -0
- package/dist/docs/1.deploy/2.providers/19.render.md +37 -0
- package/dist/docs/1.deploy/2.providers/2.aws-amplify.md +81 -0
- package/dist/docs/1.deploy/2.providers/20.stormkit.md +24 -0
- package/dist/docs/1.deploy/2.providers/21.vercel.md +270 -0
- package/dist/docs/1.deploy/2.providers/22.zeabur.md +19 -0
- package/dist/docs/1.deploy/2.providers/23.zephyr.md +99 -0
- package/dist/docs/1.deploy/2.providers/24.zerops.md +102 -0
- package/dist/docs/1.deploy/2.providers/3.azure.md +72 -0
- package/dist/docs/1.deploy/2.providers/4.cleavr.md +33 -0
- package/dist/docs/1.deploy/2.providers/5.cloudflare.md +369 -0
- package/dist/docs/1.deploy/2.providers/6.deno-deploy.md +66 -0
- package/dist/docs/1.deploy/2.providers/7.digitalocean.md +46 -0
- package/dist/docs/1.deploy/2.providers/8.edgeone.md +20 -0
- package/dist/docs/1.deploy/2.providers/9.firebase.md +32 -0
- package/dist/docs/2.config/0.index/index.md +1221 -0
- package/dist/docs/3.examples/0.index/index.md +3 -0
- package/dist/docs/3.examples/1.api-routes.md +145 -0
- package/dist/docs/3.examples/10.hono.md +74 -0
- package/dist/docs/3.examples/11.import-alias.md +97 -0
- package/dist/docs/3.examples/12.middleware.md +91 -0
- package/dist/docs/3.examples/13.mono-jsx.md +68 -0
- package/dist/docs/3.examples/14.nano-jsx.md +70 -0
- package/dist/docs/3.examples/15.plugins.md +91 -0
- package/dist/docs/3.examples/16.renderer.md +113 -0
- package/dist/docs/3.examples/17.runtime-config.md +97 -0
- package/dist/docs/3.examples/18.server-fetch.md +87 -0
- package/dist/docs/3.examples/19.shiki.md +198 -0
- package/dist/docs/3.examples/2.auto-imports.md +92 -0
- package/dist/docs/3.examples/20.virtual-routes.md +74 -0
- package/dist/docs/3.examples/21.vite-nitro-plugin.md +79 -0
- package/dist/docs/3.examples/22.vite-rsc.md +1041 -0
- package/dist/docs/3.examples/23.vite-ssr-html.md +217 -0
- package/dist/docs/3.examples/24.vite-ssr-preact.md +247 -0
- package/dist/docs/3.examples/25.vite-ssr-react.md +226 -0
- package/dist/docs/3.examples/26.vite-ssr-solid.md +256 -0
- package/dist/docs/3.examples/27.vite-ssr-tsr-react.md +442 -0
- package/dist/docs/3.examples/28.vite-ssr-tss-react.md +444 -0
- package/dist/docs/3.examples/29.vite-ssr-vue-router.md +617 -0
- package/dist/docs/3.examples/3.cached-handler.md +81 -0
- package/dist/docs/3.examples/30.vite-trpc.md +335 -0
- package/dist/docs/3.examples/31.websocket.md +282 -0
- package/dist/docs/3.examples/4.custom-error-handler.md +98 -0
- package/dist/docs/3.examples/5.database.md +157 -0
- package/dist/docs/3.examples/6.elysia.md +70 -0
- package/dist/docs/3.examples/7.express.md +78 -0
- package/dist/docs/3.examples/8.fastify.md +79 -0
- package/dist/docs/3.examples/9.hello-world.md +68 -0
- package/dist/docs/README.md +86 -0
- package/dist/docs/index.md +121 -0
- package/dist/node_modules/@poppinss/dumper/build/formatters/html/main.js +8 -0
- package/dist/node_modules/@poppinss/dumper/package.json +1 -1
- package/dist/node_modules/@speed-highlight/core/dist/index.js +4 -4
- package/dist/node_modules/@speed-highlight/core/dist/terminal.js +2 -2
- package/dist/node_modules/@speed-highlight/core/package.json +1 -1
- package/dist/node_modules/cookie-es/dist/index.mjs +299 -250
- package/dist/node_modules/cookie-es/package.json +26 -23
- package/dist/node_modules/croner/dist/croner.js +1 -1
- package/dist/node_modules/croner/package.json +11 -1
- package/dist/node_modules/defu/dist/defu.mjs +2 -2
- package/dist/node_modules/defu/package.json +33 -28
- package/dist/node_modules/rendu/dist/_chunks/libs/cookie-es.mjs +151 -0
- package/dist/node_modules/rendu/dist/index.mjs +5 -112
- package/dist/node_modules/rendu/package.json +25 -24
- package/dist/node_modules/youch/build/helpers-B9BQYaS6.js +23 -0
- package/dist/node_modules/youch/build/index.js +204 -351
- package/dist/node_modules/youch/build/public/error_info/script.js +1 -1
- package/dist/node_modules/youch/build/public_dir-C5bujZKB.js +25 -0
- package/dist/node_modules/youch/build/src/templates/error_cause/main.js +44 -0
- package/dist/node_modules/youch/build/src/templates/error_info/main.js +72 -0
- package/dist/node_modules/youch/build/src/templates/error_metadata/main.js +65 -0
- package/dist/node_modules/youch/build/src/templates/error_stack/main.js +152 -0
- package/dist/node_modules/youch/build/src/templates/error_stack_source/main.js +46 -0
- package/dist/node_modules/youch/build/src/templates/header/main.js +24 -0
- package/dist/node_modules/youch/build/src/templates/layout/main.js +27 -0
- package/dist/node_modules/youch/package.json +35 -32
- package/dist/presets/_nitro/runtime/nitro-dev.mjs +12 -57
- package/dist/presets/_nitro/runtime/nitro-prerenderer.mjs +1 -0
- package/dist/presets/_nitro/runtime/service-worker.mjs +1 -2
- package/dist/presets/aws-lambda/runtime/_utils.mjs +6 -6
- package/dist/presets/aws-lambda/runtime/aws-lambda-streaming.mjs +3 -1
- package/dist/presets/azure/runtime/_utils.mjs +5 -5
- package/dist/presets/azure/runtime/azure-swa.mjs +5 -5
- package/dist/presets/bun/runtime/bun.mjs +9 -6
- package/dist/presets/cloudflare/runtime/_module-handler.mjs +1 -1
- package/dist/presets/cloudflare/runtime/cloudflare-durable.mjs +4 -4
- package/dist/presets/cloudflare/runtime/cloudflare-module.mjs +3 -3
- package/dist/presets/cloudflare/runtime/cloudflare-pages.mjs +2 -2
- package/dist/presets/cloudflare/runtime/plugin.dev.mjs +10 -21
- package/dist/presets/deno/runtime/deno-deploy.mjs +4 -4
- package/dist/presets/deno/runtime/deno-server.mjs +9 -6
- package/dist/presets/edgeone/runtime/edgeone.mjs +10 -0
- package/dist/presets/netlify/runtime/netlify-edge.mjs +2 -3
- package/dist/presets/netlify/runtime/netlify.mjs +1 -1
- package/dist/presets/node/runtime/node-cluster.mjs +5 -4
- package/dist/presets/node/runtime/node-middleware.mjs +1 -1
- package/dist/presets/node/runtime/node-server.mjs +8 -5
- package/dist/presets/stormkit/runtime/stormkit.mjs +1 -2
- package/dist/presets/vercel/runtime/cron-handler.mjs +25 -0
- package/dist/presets/vercel/runtime/queue-handler.mjs +21 -0
- package/dist/presets/vercel/runtime/vercel.node.mjs +3 -3
- package/dist/presets/vercel/runtime/vercel.web.mjs +3 -5
- package/dist/presets/winterjs/runtime/winterjs.mjs +10 -10
- package/dist/presets/zephyr/runtime/server.mjs +3 -0
- package/dist/runtime/internal/app.mjs +12 -11
- package/dist/runtime/internal/cache.d.mts +0 -4
- package/dist/runtime/internal/cache.mjs +32 -256
- package/dist/runtime/internal/context.d.mts +3 -1
- package/dist/runtime/internal/context.mjs +1 -9
- package/dist/runtime/internal/error/dev.d.mts +5 -4
- package/dist/runtime/internal/error/dev.mjs +47 -49
- package/dist/runtime/internal/error/hooks.d.mts +1 -1
- package/dist/runtime/internal/error/prod.d.mts +2 -5
- package/dist/runtime/internal/error/prod.mjs +19 -33
- package/dist/runtime/internal/error/utils.d.mts +4 -4
- package/dist/runtime/internal/meta.d.mts +1 -1
- package/dist/runtime/internal/plugin.d.mts +2 -2
- package/dist/runtime/internal/route-rules.d.mts +11 -4
- package/dist/runtime/internal/route-rules.mjs +15 -5
- package/dist/runtime/internal/routes/dev-tasks.d.mts +3 -2
- package/dist/runtime/internal/routes/dev-tasks.mjs +15 -10
- package/dist/runtime/internal/routes/openapi.mjs +2 -2
- package/dist/runtime/internal/routes/renderer-template.d.mts +1 -1
- package/dist/runtime/internal/routes/renderer-template.dev.d.mts +2 -1
- package/dist/runtime/internal/routes/scalar.mjs +3 -3
- package/dist/runtime/internal/routes/swagger.mjs +7 -4
- package/dist/runtime/internal/runtime-config.d.mts +1 -1
- package/dist/runtime/internal/runtime-config.mjs +2 -2
- package/dist/runtime/internal/static.mjs +5 -4
- package/dist/runtime/internal/task.d.mts +3 -1
- package/dist/runtime/internal/task.mjs +7 -7
- package/dist/runtime/internal/vite/dev-entry.mjs +6 -3
- package/dist/runtime/internal/vite/dev-worker.mjs +264 -0
- package/dist/runtime/meta.d.mts +1 -0
- package/dist/runtime/meta.mjs +2 -0
- package/dist/runtime/nitro.d.mts +2 -0
- package/dist/runtime/nitro.mjs +4 -2
- package/dist/runtime/virtual/error-handler.mjs +1 -1
- package/dist/runtime/virtual/renderer-template.mjs +1 -1
- package/dist/runtime/virtual/server-assets.d.mts +2 -1
- package/dist/runtime/virtual/tracing.d.mts +5 -0
- package/dist/runtime/virtual/tracing.mjs +1 -0
- package/dist/runtime/vite.d.mts +1 -1
- package/dist/types/index.d.mts +215 -195
- package/dist/types/index.mjs +1 -11
- package/dist/vite.d.mts +3 -8
- package/dist/vite.mjs +285 -253
- package/lib/tsconfig.json +3 -5
- package/package.json +97 -80
- package/dist/_libs/confbox.mjs +0 -2509
- package/dist/_libs/nypm+giget+tinyexec.mjs +0 -3603
- package/dist/_libs/rc9+c12+dotenv.mjs +0 -972
- package/dist/node_modules/hookable/dist/index.mjs +0 -266
- package/dist/node_modules/hookable/package.json +0 -52
- package/dist/node_modules/youch/build/chunk-4L7RY2JA.js +0 -42
- package/dist/node_modules/youch/build/chunk-7QV3D5YX.js +0 -83
- package/dist/node_modules/youch/build/chunk-AUGPHE32.js +0 -39
- package/dist/node_modules/youch/build/chunk-CM7DWJNZ.js +0 -44
- package/dist/node_modules/youch/build/chunk-EJH674NB.js +0 -223
- package/dist/node_modules/youch/build/chunk-OIJ3WD7L.js +0 -81
- package/dist/node_modules/youch/build/chunk-P36L72PL.js +0 -87
- package/dist/node_modules/youch/build/chunk-PE3GG3TN.js +0 -65
- package/dist/node_modules/youch/build/chunk-X53OIOJH.js +0 -70
- package/dist/presets/_nitro/runtime/nitro-dev.d.mts +0 -2
- package/dist/presets/_nitro/runtime/nitro-prerenderer.d.mts +0 -3
- package/dist/presets/_nitro/runtime/service-worker.d.mts +0 -2
- package/dist/presets/aws-amplify/runtime/aws-amplify.d.mts +0 -2
- package/dist/presets/aws-lambda/runtime/_utils.d.mts +0 -8
- package/dist/presets/aws-lambda/runtime/aws-lambda-streaming.d.mts +0 -2
- package/dist/presets/aws-lambda/runtime/aws-lambda.d.mts +0 -3
- package/dist/presets/azure/runtime/_utils.d.mts +0 -2
- package/dist/presets/azure/runtime/azure-swa.d.mts +0 -5
- package/dist/presets/bun/runtime/bun.d.mts +0 -3
- package/dist/presets/cloudflare/runtime/_module-handler.d.mts +0 -16
- package/dist/presets/cloudflare/runtime/cloudflare-durable.d.mts +0 -11
- package/dist/presets/cloudflare/runtime/cloudflare-module.d.mts +0 -3
- package/dist/presets/cloudflare/runtime/cloudflare-pages.d.mts +0 -20
- package/dist/presets/cloudflare/runtime/plugin.dev.d.mts +0 -3
- package/dist/presets/deno/runtime/deno-deploy.d.mts +0 -5
- package/dist/presets/deno/runtime/deno-server.d.mts +0 -3
- package/dist/presets/netlify/runtime/netlify-edge.d.mts +0 -3
- package/dist/presets/netlify/runtime/netlify.d.mts +0 -4
- package/dist/presets/node/runtime/node-cluster.d.mts +0 -3
- package/dist/presets/node/runtime/node-middleware.d.mts +0 -3
- package/dist/presets/node/runtime/node-server.d.mts +0 -3
- package/dist/presets/standard/runtime/server.d.mts +0 -3
- package/dist/presets/stormkit/runtime/stormkit.d.mts +0 -21
- package/dist/presets/vercel/runtime/isr.d.mts +0 -2
- package/dist/presets/vercel/runtime/vercel.node.d.mts +0 -3
- package/dist/presets/vercel/runtime/vercel.web.d.mts +0 -8
- package/dist/presets/winterjs/runtime/winterjs.d.mts +0 -2
- package/dist/presets/zeabur/runtime/zeabur.d.mts +0 -3
- package/dist/runtime/internal/vite/node-runner.mjs +0 -359
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
> Nitro provides a built-in and lightweight SQL database layer.
|
|
2
|
+
|
|
3
|
+
The default database connection is **preconfigured** with [SQLite](https://db0.unjs.io/connectors/sqlite) and works out of the box for development mode and any Node.js compatible production deployments. By default, data will be stored in `.data/db.sqlite`.
|
|
4
|
+
|
|
5
|
+
<read-more></read-more>
|
|
6
|
+
|
|
7
|
+
> [!IMPORTANT]
|
|
8
|
+
> Database support is currently experimental.
|
|
9
|
+
> Refer to the [db0 issues](https://github.com/unjs/db0/issues) for status and bug report.
|
|
10
|
+
|
|
11
|
+
In order to enable database layer you need to enable experimental feature flag.
|
|
12
|
+
|
|
13
|
+
```ts [nitro.config.ts]
|
|
14
|
+
import { defineConfig } from "nitro";
|
|
15
|
+
|
|
16
|
+
export default defineConfig({
|
|
17
|
+
experimental: {
|
|
18
|
+
database: true
|
|
19
|
+
}
|
|
20
|
+
})
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
> [!TIP]
|
|
24
|
+
> You can change default connection or define more connections to any of the [supported databases](https://db0.unjs.io/connectors/sqlite).
|
|
25
|
+
|
|
26
|
+
> [!TIP]
|
|
27
|
+
> You can integrate database instance to any of the [supported ORMs](https://db0.unjs.io/integrations).
|
|
28
|
+
|
|
29
|
+
## Usage
|
|
30
|
+
|
|
31
|
+
```ts [server.ts]
|
|
32
|
+
import { defineHandler } from "nitro";
|
|
33
|
+
import { useDatabase } from "nitro/database";
|
|
34
|
+
|
|
35
|
+
export default defineHandler(async () => {
|
|
36
|
+
const db = useDatabase();
|
|
37
|
+
|
|
38
|
+
// Create users table
|
|
39
|
+
await db.sql`DROP TABLE IF EXISTS users`;
|
|
40
|
+
await db.sql`CREATE TABLE IF NOT EXISTS users ("id" TEXT PRIMARY KEY, "firstName" TEXT, "lastName" TEXT, "email" TEXT)`;
|
|
41
|
+
|
|
42
|
+
// Add a new user
|
|
43
|
+
const userId = String(Math.round(Math.random() * 10_000));
|
|
44
|
+
await db.sql`INSERT INTO users VALUES (${userId}, 'John', 'Doe', '')`;
|
|
45
|
+
|
|
46
|
+
// Query for users
|
|
47
|
+
const { rows } = await db.sql`SELECT * FROM users WHERE id = ${userId}`;
|
|
48
|
+
|
|
49
|
+
return {
|
|
50
|
+
rows,
|
|
51
|
+
};
|
|
52
|
+
});
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### `useDatabase`
|
|
56
|
+
|
|
57
|
+
Use `useDatabase` to get a database instance. It accepts an optional connection name (defaults to `"default"`).
|
|
58
|
+
|
|
59
|
+
```ts
|
|
60
|
+
import { useDatabase } from "nitro/database";
|
|
61
|
+
|
|
62
|
+
// Use the default connection
|
|
63
|
+
const db = useDatabase();
|
|
64
|
+
|
|
65
|
+
// Use a named connection
|
|
66
|
+
const usersDb = useDatabase("users");
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
> [!NOTE]
|
|
70
|
+
> When `experimental.database` is enabled, `useDatabase` is auto-imported and available without an explicit import statement.
|
|
71
|
+
|
|
72
|
+
Database instances are created lazily on first use and cached for subsequent calls with the same connection name. If a connection name is not configured, an error will be thrown.
|
|
73
|
+
|
|
74
|
+
### `db.sql`
|
|
75
|
+
|
|
76
|
+
Execute SQL queries using tagged template literals with automatic parameter binding:
|
|
77
|
+
|
|
78
|
+
```ts
|
|
79
|
+
const db = useDatabase();
|
|
80
|
+
|
|
81
|
+
// Insert with parameterized values (safe from SQL injection)
|
|
82
|
+
const id = "1001";
|
|
83
|
+
await db.sql`INSERT INTO users VALUES (${id}, 'John', 'Doe', 'john@example.com')`;
|
|
84
|
+
|
|
85
|
+
// Query with parameters
|
|
86
|
+
const { rows } = await db.sql`SELECT * FROM users WHERE id = ${id}`;
|
|
87
|
+
|
|
88
|
+
// The result includes rows, changes count, and last insert ID
|
|
89
|
+
const result = await db.sql`INSERT INTO posts (title) VALUES (${"Hello"})`;
|
|
90
|
+
// result.rows, result.changes, result.lastInsertRowid
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### `db.exec`
|
|
94
|
+
|
|
95
|
+
Execute a raw SQL string directly:
|
|
96
|
+
|
|
97
|
+
```ts
|
|
98
|
+
const db = useDatabase();
|
|
99
|
+
|
|
100
|
+
await db.exec("CREATE TABLE IF NOT EXISTS users (id TEXT PRIMARY KEY, name TEXT)");
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### `db.prepare`
|
|
104
|
+
|
|
105
|
+
Prepare an SQL statement for repeated execution:
|
|
106
|
+
|
|
107
|
+
```ts
|
|
108
|
+
const db = useDatabase();
|
|
109
|
+
|
|
110
|
+
const stmt = db.prepare("SELECT * FROM users WHERE id = ?");
|
|
111
|
+
const result = await stmt.bind("1001").all();
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## Configuration
|
|
115
|
+
|
|
116
|
+
You can configure database connections using `database` config:
|
|
117
|
+
|
|
118
|
+
```ts [nitro.config.ts]
|
|
119
|
+
import { defineConfig } from "nitro";
|
|
120
|
+
|
|
121
|
+
export default defineConfig({
|
|
122
|
+
database: {
|
|
123
|
+
default: {
|
|
124
|
+
connector: "sqlite",
|
|
125
|
+
options: { name: "db" }
|
|
126
|
+
},
|
|
127
|
+
users: {
|
|
128
|
+
connector: "postgresql",
|
|
129
|
+
options: {
|
|
130
|
+
url: "postgresql://username:password@hostname:port/database_name"
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
});
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### Development Database
|
|
138
|
+
|
|
139
|
+
Use the `devDatabase` config to override the database configuration **only for development mode**. This is useful for using a local SQLite database during development while targeting a different database in production.
|
|
140
|
+
|
|
141
|
+
```ts [nitro.config.ts]
|
|
142
|
+
import { defineConfig } from "nitro";
|
|
143
|
+
|
|
144
|
+
export default defineConfig({
|
|
145
|
+
database: {
|
|
146
|
+
default: {
|
|
147
|
+
connector: "postgresql",
|
|
148
|
+
options: {
|
|
149
|
+
url: "postgresql://username:password@hostname:port/database_name"
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
devDatabase: {
|
|
154
|
+
default: {
|
|
155
|
+
connector: "sqlite",
|
|
156
|
+
options: { name: "dev-db" }
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
> [!TIP]
|
|
163
|
+
> When `experimental.database` is enabled and no `database` or `devDatabase` config is provided, Nitro automatically configures a default SQLite connection. In development mode, data is stored relative to the project root directory. In Node.js production, it uses the default SQLite path.
|
|
164
|
+
|
|
165
|
+
## Connectors
|
|
166
|
+
|
|
167
|
+
Nitro supports all [db0 connectors](https://db0.unjs.io/connectors). The `connector` field in the database config accepts any of the following values:
|
|
168
|
+
|
|
169
|
+
| Connector | Description |
|
|
170
|
+
| --- | --- |
|
|
171
|
+
| `sqlite` | Node.js built-in SQLite (alias for `node-sqlite`) |
|
|
172
|
+
| `node-sqlite` | Node.js built-in SQLite |
|
|
173
|
+
| `better-sqlite3` | [better-sqlite3](https://github.com/WiseLibs/better-sqlite3) |
|
|
174
|
+
| `sqlite3` | [sqlite3](https://github.com/TryGhost/node-sqlite3) |
|
|
175
|
+
| `bun` / `bun-sqlite` | Bun built-in SQLite |
|
|
176
|
+
| `libsql` / `libsql-node` | [libSQL](https://github.com/tursodatabase/libsql) (Node.js) |
|
|
177
|
+
| `libsql-http` | libSQL over HTTP |
|
|
178
|
+
| `libsql-web` | libSQL for web environments |
|
|
179
|
+
| `postgresql` | [PostgreSQL](https://github.com/porsager/postgres) |
|
|
180
|
+
| `mysql2` | [MySQL](https://github.com/sidorares/node-mysql2) |
|
|
181
|
+
| `pglite` | [PGlite](https://github.com/electric-sql/pglite) (embedded PostgreSQL) |
|
|
182
|
+
| `planetscale` | [PlanetScale](https://github.com/planetscale/database-js) serverless |
|
|
183
|
+
| `cloudflare-d1` | [Cloudflare D1](https://developers.cloudflare.com/d1/) |
|
|
184
|
+
| `cloudflare-hyperdrive-mysql` | Cloudflare Hyperdrive with MySQL |
|
|
185
|
+
| `cloudflare-hyperdrive-postgresql` | Cloudflare Hyperdrive with PostgreSQL |
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# Deploy
|
|
2
|
+
|
|
3
|
+
> Learn more about Nitro deploy providers.
|
|
4
|
+
|
|
5
|
+
Nitro can generate different output formats suitable for different hosting providers from the same code base.
|
|
6
|
+
Using built-in presets, you can easily configure Nitro to adjust its output format with almost no additional code or configuration!
|
|
7
|
+
|
|
8
|
+
## Default output
|
|
9
|
+
|
|
10
|
+
The default production output preset is [Node.js server](/deploy/runtimes/node).
|
|
11
|
+
|
|
12
|
+
When running Nitro in development mode, Nitro will always use a special preset called `nitro-dev` using Node.js with ESM in an isolated Worker environment with behavior as close as possible to the production environment.
|
|
13
|
+
|
|
14
|
+
## Zero-Config Providers
|
|
15
|
+
|
|
16
|
+
When deploying to production using CI/CD, Nitro tries to automatically detect the provider environment and set the right one without any additional configuration required. Currently, the providers below can be auto-detected with zero config.
|
|
17
|
+
|
|
18
|
+
- [aws amplify](/deploy/providers/aws-amplify)
|
|
19
|
+
- [azure](/deploy/providers/azure)
|
|
20
|
+
- [cloudflare](/deploy/providers/cloudflare)
|
|
21
|
+
- [firebase app hosting](/deploy/providers/firebase#firebase-app-hosting)
|
|
22
|
+
- [netlify](/deploy/providers/netlify)
|
|
23
|
+
- [stormkit](/deploy/providers/stormkit)
|
|
24
|
+
- [vercel](/deploy/providers/vercel)
|
|
25
|
+
- [zeabur](/deploy/providers/zeabur)
|
|
26
|
+
|
|
27
|
+
<warning>
|
|
28
|
+
|
|
29
|
+
For Turborepo users, zero config detection will be interfered by its Strict Environment Mode. You may need to allow the variables explicitly or use its Loose Environment Mode (with `--env-mode=loose` flag).
|
|
30
|
+
</warning>
|
|
31
|
+
|
|
32
|
+
Other built-in providers are available with an explicit preset, including [zephyr](/deploy/providers/zephyr).
|
|
33
|
+
|
|
34
|
+
## Changing the deployment preset
|
|
35
|
+
|
|
36
|
+
If you need to build Nitro against a specific provider, you can target it by defining an environment variable named `NITRO_PRESET` or `SERVER_PRESET`, or by updating your Nitro [configuration](/docs/configuration) or using `--preset` argument.
|
|
37
|
+
|
|
38
|
+
Using the environment variable approach is recommended for deployments depending on CI/CD.
|
|
39
|
+
|
|
40
|
+
**Example:** Defining a `NITRO_PRESET` environment variable
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
nitro build --preset cloudflare_pages
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
**Example:** Updating the `nitro.config.ts` file
|
|
47
|
+
|
|
48
|
+
```ts
|
|
49
|
+
import { defineConfig } from "nitro";
|
|
50
|
+
|
|
51
|
+
export default defineConfig({
|
|
52
|
+
preset: 'cloudflare_pages'
|
|
53
|
+
})
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Compatibility date
|
|
57
|
+
|
|
58
|
+
Deployment providers regularly update their runtime behavior. Nitro presets are updated to support these new features.
|
|
59
|
+
|
|
60
|
+
To prevent breaking existing deployments, Nitro uses compatibility dates. These dates let you lock in behavior at the project creation time. You can also opt in to future updates when ready.
|
|
61
|
+
|
|
62
|
+
When you create a new project, the `compatibilityDate` is set to the current date. This setting is saved in your project's configuration.
|
|
63
|
+
|
|
64
|
+
You should update the compatibility date periodically. Always test your deployment thoroughly after updating. Below is a list of key dates and their effects.
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# Node.js
|
|
2
|
+
|
|
3
|
+
> Run Nitro apps with Node.js runtime.
|
|
4
|
+
|
|
5
|
+
**Preset:** `node_server`
|
|
6
|
+
|
|
7
|
+
Node.js is the default nitro output preset for production builds and Nitro has native Node.js runtime support.
|
|
8
|
+
|
|
9
|
+
Build project using nitro CLI:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
nitro build
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
When running `nitro build` with the Node server preset, the result will be an entry point that launches a ready-to-run Node server. To try output:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
$ node .output/server/index.mjs
|
|
19
|
+
Listening on http://localhost:3000
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
You can now deploy fully standalone `.output` directory to the hosting of your choice.
|
|
23
|
+
|
|
24
|
+
### Environment Variables
|
|
25
|
+
|
|
26
|
+
You can customize server behavior using following environment variables:
|
|
27
|
+
|
|
28
|
+
- `NITRO_PORT` or `PORT` (defaults to `3000`)
|
|
29
|
+
- `NITRO_HOST` or `HOST`
|
|
30
|
+
- `NITRO_UNIX_SOCKET` - if provided (a path to the desired socket file) the service will be served over the provided UNIX socket.
|
|
31
|
+
- `NITRO_SSL_CERT` and `NITRO_SSL_KEY` - if both are present, this will launch the server in HTTPS mode. In the vast majority of cases, this should not be used other than for testing, and the Nitro server should be run behind a reverse proxy like nginx or Cloudflare which terminates SSL.
|
|
32
|
+
- `NITRO_SHUTDOWN_DISABLED` - Disables the graceful shutdown feature when set to `'true'`. If it's set to `'true'`, the graceful shutdown is bypassed to speed up the development process. Defaults to `'false'`.
|
|
33
|
+
- `NITRO_SHUTDOWN_SIGNALS` - Allows you to specify which signals should be handled. Each signal should be separated with a space. Defaults to `'SIGINT SIGTERM'`.
|
|
34
|
+
- `NITRO_SHUTDOWN_TIMEOUT` - Sets the amount of time (in milliseconds) before a forced shutdown occurs. Defaults to `'30000'` milliseconds.
|
|
35
|
+
- `NITRO_SHUTDOWN_FORCE` - When set to true, it triggers `process.exit()` at the end of the shutdown process. If it's set to `'false'`, the process will simply let the event loop clear. Defaults to `'true'`.
|
|
36
|
+
|
|
37
|
+
## Cluster mode
|
|
38
|
+
**Preset:** `node_cluster`
|
|
39
|
+
|
|
40
|
+
For more performance and leveraging multi-core handling, you can use cluster preset.
|
|
41
|
+
|
|
42
|
+
### Environment Variables
|
|
43
|
+
|
|
44
|
+
In addition to environment variables from the `node_server` preset, you can customize behavior:
|
|
45
|
+
|
|
46
|
+
- `NITRO_CLUSTER_WORKERS`: Number of cluster workers (default is Number of available cpu cores)
|
|
47
|
+
|
|
48
|
+
## Handler (advanced)
|
|
49
|
+
**Preset:** `node_middleware`
|
|
50
|
+
|
|
51
|
+
Nitro also has a more low-level preset that directly exports a middleware usable for custom servers.
|
|
52
|
+
|
|
53
|
+
When running `nitro build` with the Node middleware preset, the result will be an entry point exporting a middleware handler.
|
|
54
|
+
|
|
55
|
+
**Example:**
|
|
56
|
+
|
|
57
|
+
```js
|
|
58
|
+
import { createServer } from 'node:http'
|
|
59
|
+
import { listener } from './.output/server'
|
|
60
|
+
|
|
61
|
+
const server = createServer(listener)
|
|
62
|
+
server.listen(8080)
|
|
63
|
+
```
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Bun
|
|
2
|
+
|
|
3
|
+
> Run Nitro apps with Bun runtime.
|
|
4
|
+
|
|
5
|
+
**Preset:** `bun`
|
|
6
|
+
|
|
7
|
+
Nitro output is compatible with Bun runtime. While using default [Node.js](/deploy/runtimes/node) you can also run the output in bun, using `bun` preset has advantage of better optimizations.
|
|
8
|
+
|
|
9
|
+
After building with bun preset using `bun` as preset, you can run server in production using:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
bun run ./.output/server/index.mjs
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
<read-more></read-more>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Deno
|
|
2
|
+
|
|
3
|
+
> Run Nitro apps with [Deno](https://deno.com/) runtime.
|
|
4
|
+
|
|
5
|
+
**Preset:** `deno_server`
|
|
6
|
+
|
|
7
|
+
You can build your Nitro server using Node.js to run within [Deno Runtime](https://deno.com/runtime) in a custom server.
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
# Build with the deno NITRO preset
|
|
11
|
+
NITRO_PRESET=deno_server npm run build
|
|
12
|
+
|
|
13
|
+
# Start production server
|
|
14
|
+
deno run --unstable --allow-net --allow-read --allow-env .output/server/index.ts
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Deno Deploy
|
|
18
|
+
|
|
19
|
+
<read-more></read-more>
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# Alwaysdata
|
|
2
|
+
|
|
3
|
+
> Deploy Nitro apps to alwaysdata.
|
|
4
|
+
|
|
5
|
+
**Preset:** `alwaysdata`
|
|
6
|
+
|
|
7
|
+
<read-more></read-more>
|
|
8
|
+
|
|
9
|
+
## Set up application
|
|
10
|
+
|
|
11
|
+
### Pre-requisites
|
|
12
|
+
|
|
13
|
+
1. [Register a new profile](https://www.alwaysdata.com/en/register/) on alwaysdata platform if you don't have one.
|
|
14
|
+
|
|
15
|
+
2. Get a free 100Mb plan to host your app.
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
> [!NOTE]
|
|
19
|
+
> Keep in mind your *account name* will be used to provide you a default URL in the form of `account_name.alwaysdata.net`, so choose it wisely. You can also link your existing domains to your account later or register as many accounts under your profile as you need.
|
|
20
|
+
|
|
21
|
+
### Local deployment
|
|
22
|
+
|
|
23
|
+
1. Build your project locally with `npm run build -- preset alwaysdata`
|
|
24
|
+
|
|
25
|
+
2. [Upload your app](https://help.alwaysdata.com/en/remote-access/) to your account in its own directory (e.g. `$HOME/www/my-app`). You can use any protocol you prefer (SSH/FTP/WebDAV…) to do so.
|
|
26
|
+
|
|
27
|
+
3. On your admin panel, [create a new site](https://admin.alwaysdata.com/site/add/) for your app with the following features:
|
|
28
|
+
- *Addresses*: `[account_name].alwaysdata.net`
|
|
29
|
+
|
|
30
|
+
- *Type*: Node.js
|
|
31
|
+
|
|
32
|
+
- *Command*: `node .output/server/index.mjs`
|
|
33
|
+
|
|
34
|
+
- *Working directory*: `www/my-app` (adapt it to your deployment path)
|
|
35
|
+
|
|
36
|
+
- *Environment*:
|
|
37
|
+
|
|
38
|
+
```ini
|
|
39
|
+
NITRO_PRESET=alwaysdata
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
- *Node.js version*: `Default version` is fine; pick no less than `20.0.0` (you can also [set your Node.js version globally](https://help.alwaysdata.com/en/languages/nodejs/configuration/#supported-versions))
|
|
43
|
+
|
|
44
|
+
- *Hot restart*: `SIGHUP`
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
<read-more></read-more>
|
|
48
|
+
|
|
49
|
+
- Your app is now live at `http(s)://[account_name].alwaysdata.net`.
|
|
50
|
+
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# AWS Lambda
|
|
2
|
+
|
|
3
|
+
> Deploy Nitro apps to AWS Lambda.
|
|
4
|
+
|
|
5
|
+
**Preset:** `aws_lambda`
|
|
6
|
+
|
|
7
|
+
<read-more></read-more>
|
|
8
|
+
|
|
9
|
+
Nitro provides a built-in preset to generate output format compatible with [AWS Lambda](https://aws.amazon.com/lambda/).
|
|
10
|
+
The output entrypoint in `.output/server/index.mjs` is compatible with [AWS Lambda format](https://docs.aws.amazon.com/lex/latest/dg/lambda-input-response-format.html).
|
|
11
|
+
|
|
12
|
+
It can be used programmatically or as part of a deployment.
|
|
13
|
+
|
|
14
|
+
```ts
|
|
15
|
+
import { handler } from './.output/server'
|
|
16
|
+
|
|
17
|
+
// Use programmatically
|
|
18
|
+
const { statusCode, headers, body } = handler({ rawPath: '/' })
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Inlining chunks
|
|
22
|
+
|
|
23
|
+
Nitro output, by default uses dynamic chunks for lazy loading code only when needed. However this sometimes can not be ideal for performance. (See discussions in [nitrojs/nitro#650](https://github.com/nitrojs/nitro/pull/650)). You can enabling chunk inlining behavior using [`inlineDynamicImports`](/config#inlinedynamicimports) config.
|
|
24
|
+
|
|
25
|
+
```ts [nitro.config.ts]
|
|
26
|
+
import { defineConfig } from "nitro";
|
|
27
|
+
|
|
28
|
+
export default defineConfig({
|
|
29
|
+
inlineDynamicImports: true
|
|
30
|
+
});
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Response streaming
|
|
34
|
+
|
|
35
|
+
<read-more></read-more>
|
|
36
|
+
|
|
37
|
+
In order to enable response streaming, enable `awsLambda.streaming` flag:
|
|
38
|
+
|
|
39
|
+
```ts [nitro.config.ts]
|
|
40
|
+
import { defineConfig } from "nitro";
|
|
41
|
+
|
|
42
|
+
export default defineConfig({
|
|
43
|
+
awsLambda: {
|
|
44
|
+
streaming: true
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
```
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# Flightcontrol
|
|
2
|
+
|
|
3
|
+
> Deploy Nitro apps to AWS via Flightcontrol.
|
|
4
|
+
|
|
5
|
+
**Preset:** `flightcontrol`
|
|
6
|
+
|
|
7
|
+
<read-more></read-more>
|
|
8
|
+
|
|
9
|
+
## Set Up your flightcontrol account
|
|
10
|
+
|
|
11
|
+
On a high level, the steps you will need to follow to deploy a project for the first time are:
|
|
12
|
+
|
|
13
|
+
1. Create an account at [Flightcontrol](https://app.flightcontrol.dev/signup?ref=nitro)
|
|
14
|
+
2. Create an account at [AWS](https://portal.aws.amazon.com/billing/signup) (if you don't already have one)
|
|
15
|
+
3. Link your AWS account to the Flightcontrol
|
|
16
|
+
4. Authorize the Flightcontrol GitHub App to access your chosen repositories, public or private.
|
|
17
|
+
5. Create a Flightcontrol project with configuration via the Dashboard or with configuration via `flightcontrol.json`.
|
|
18
|
+
|
|
19
|
+
### Create a project with configuration via the dashboard
|
|
20
|
+
|
|
21
|
+
1. Create a Flightcontrol project from the Dashboard. Select a repository for the source.
|
|
22
|
+
2. Select the `GUI` config type.
|
|
23
|
+
3. Select the Nuxt preset. This preset will also work for any Nitro-based applications.
|
|
24
|
+
4. Select your preferred AWS server size.
|
|
25
|
+
5. Submit the new project form.
|
|
26
|
+
|
|
27
|
+
### Create a project with configuration via `flightcontrol.json`
|
|
28
|
+
|
|
29
|
+
1. Create a Flightcontrol project from your dashboard. Select a repository for the source.
|
|
30
|
+
2. Select the `flightcontrol.json` config type.
|
|
31
|
+
3. Add a new file at the root of your repository called `flightcontrol.json`. Here is an example configuration that creates an AWS fargate service for your app:
|
|
32
|
+
|
|
33
|
+
```json [flightcontrol.json]
|
|
34
|
+
{
|
|
35
|
+
"$schema": "https://app.flightcontrol.dev/schema.json",
|
|
36
|
+
"environments": [
|
|
37
|
+
{
|
|
38
|
+
"id": "production",
|
|
39
|
+
"name": "Production",
|
|
40
|
+
"region": "us-west-2",
|
|
41
|
+
"source": {
|
|
42
|
+
"branch": "main"
|
|
43
|
+
},
|
|
44
|
+
"services": [
|
|
45
|
+
{
|
|
46
|
+
"id": "nitro",
|
|
47
|
+
"buildType": "nixpacks",
|
|
48
|
+
"name": "My Nitro site",
|
|
49
|
+
"type": "fargate",
|
|
50
|
+
"domain": "www.yourdomain.com",
|
|
51
|
+
"outputDirectory": ".output",
|
|
52
|
+
"startCommand": "node .output/server/index.mjs",
|
|
53
|
+
"cpu": 0.25,
|
|
54
|
+
"memory": 0.5
|
|
55
|
+
}
|
|
56
|
+
]
|
|
57
|
+
}
|
|
58
|
+
]
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
4. Submit the new project form.
|
|
63
|
+
|
|
64
|
+
<read-more>
|
|
65
|
+
|
|
66
|
+
Learn more about Flightcontrol's [configuration](https://www.flightcontrol.dev/docs?ref=nitro).
|
|
67
|
+
</read-more>
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# Genezio
|
|
2
|
+
|
|
3
|
+
> Deploy Nitro apps to Genezio.
|
|
4
|
+
|
|
5
|
+
**Preset:** `genezio`
|
|
6
|
+
|
|
7
|
+
<read-more></read-more>
|
|
8
|
+
|
|
9
|
+
> [!IMPORTANT]
|
|
10
|
+
> 🚧 This preset is currently experimental.
|
|
11
|
+
|
|
12
|
+
## 1. Project Setup
|
|
13
|
+
|
|
14
|
+
Create `genezio.yaml` file:
|
|
15
|
+
|
|
16
|
+
```yaml
|
|
17
|
+
# The name of the project.
|
|
18
|
+
name: nitro-app
|
|
19
|
+
# The version of the Genezio YAML configuration to parse.
|
|
20
|
+
yamlVersion: 2
|
|
21
|
+
backend:
|
|
22
|
+
# The root directory of the backend.
|
|
23
|
+
path: .output/
|
|
24
|
+
# Information about the backend's programming language.
|
|
25
|
+
language:
|
|
26
|
+
# The name of the programming language.
|
|
27
|
+
name: js
|
|
28
|
+
# The package manager used by the backend.
|
|
29
|
+
packageManager: npm
|
|
30
|
+
# Information about the backend's functions.
|
|
31
|
+
functions:
|
|
32
|
+
# The name (label) of the function.
|
|
33
|
+
- name: nitroServer
|
|
34
|
+
# The path to the function's code.
|
|
35
|
+
path: server/
|
|
36
|
+
# The name of the function handler
|
|
37
|
+
handler: handler
|
|
38
|
+
# The entry point for the function.
|
|
39
|
+
entry: index.mjs
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
<read-more>
|
|
43
|
+
|
|
44
|
+
To further customize the file to your needs, you can consult the
|
|
45
|
+
[official documentation](https://genezio.com/docs/project-structure/genezio-configuration-file/).
|
|
46
|
+
</read-more>
|
|
47
|
+
|
|
48
|
+
## 2. Deploy your project
|
|
49
|
+
|
|
50
|
+
Build with the genezio nitro preset:
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
NITRO_PRESET=genezio npm run build
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Deploy with [`genezio`](https://npmjs.com/package/genezio) cli:
|
|
57
|
+
|
|
58
|
+
<pm-x></pm-x>
|
|
59
|
+
|
|
60
|
+
<read-more>
|
|
61
|
+
|
|
62
|
+
To set environment viarables, please check out [Genezio - Environment Variables](https://genezio.com/docs/project-structure/backend-environment-variables).
|
|
63
|
+
</read-more>
|
|
64
|
+
|
|
65
|
+
## 3. Monitor your project
|
|
66
|
+
|
|
67
|
+
You can monitor and manage your application through the [Genezio App Dashboard](https://app.genez.io/dashboard). The dashboard URL, also provided after deployment, allows you to access comprehensive views of your project's status and logs.
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# GitHub Pages
|
|
2
|
+
|
|
3
|
+
> Deploy Nitro apps to GitHub Pages.
|
|
4
|
+
|
|
5
|
+
**Preset:** `github_pages`
|
|
6
|
+
|
|
7
|
+
<read-more></read-more>
|
|
8
|
+
|
|
9
|
+
## Setup
|
|
10
|
+
|
|
11
|
+
Follow the steps to [create a GitHub Pages site](https://docs.github.com/en/pages/getting-started-with-github-pages/creating-a-github-pages-site).
|
|
12
|
+
|
|
13
|
+
## Deployment
|
|
14
|
+
|
|
15
|
+
Here is an example GitHub Actions workflow to deploy your site to GitHub Pages using the `github_pages` preset:
|
|
16
|
+
|
|
17
|
+
```yaml [.github/workflows/deploy.yml]
|
|
18
|
+
# https://github.com/actions/deploy-pages#usage
|
|
19
|
+
name: Deploy to GitHub Pages
|
|
20
|
+
|
|
21
|
+
on:
|
|
22
|
+
workflow_dispatch:
|
|
23
|
+
push:
|
|
24
|
+
branches:
|
|
25
|
+
- main
|
|
26
|
+
|
|
27
|
+
jobs:
|
|
28
|
+
build:
|
|
29
|
+
runs-on: ubuntu-latest
|
|
30
|
+
steps:
|
|
31
|
+
- uses: actions/checkout@v5
|
|
32
|
+
- run: corepack enable
|
|
33
|
+
- uses: actions/setup-node@v6
|
|
34
|
+
with:
|
|
35
|
+
node-version: "18"
|
|
36
|
+
|
|
37
|
+
- run: npx nypm install
|
|
38
|
+
- run: npm run build
|
|
39
|
+
env:
|
|
40
|
+
NITRO_PRESET: github_pages
|
|
41
|
+
|
|
42
|
+
- name: Upload artifact
|
|
43
|
+
uses: actions/upload-pages-artifact@v1
|
|
44
|
+
with:
|
|
45
|
+
path: ./.output/public
|
|
46
|
+
|
|
47
|
+
# Deployment job
|
|
48
|
+
deploy:
|
|
49
|
+
# Add a dependency to the build job
|
|
50
|
+
needs: build
|
|
51
|
+
|
|
52
|
+
# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
|
|
53
|
+
permissions:
|
|
54
|
+
pages: write # to deploy to Pages
|
|
55
|
+
id-token: write # to verify the deployment originates from an appropriate source
|
|
56
|
+
|
|
57
|
+
# Deploy to the github_pages environment
|
|
58
|
+
environment:
|
|
59
|
+
name: github-pages
|
|
60
|
+
url: ${{ steps.deployment.outputs.page_url }}
|
|
61
|
+
|
|
62
|
+
# Specify runner + deployment step
|
|
63
|
+
runs-on: ubuntu-latest
|
|
64
|
+
steps:
|
|
65
|
+
- name: Deploy to GitHub Pages
|
|
66
|
+
id: deployment
|
|
67
|
+
uses: actions/deploy-pages@v1
|
|
68
|
+
```
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# GitLab Pages
|
|
2
|
+
|
|
3
|
+
> Deploy Nitro apps to GitLab Pages.
|
|
4
|
+
|
|
5
|
+
**Preset:** `gitlab_pages`
|
|
6
|
+
|
|
7
|
+
<read-more></read-more>
|
|
8
|
+
|
|
9
|
+
## Setup
|
|
10
|
+
|
|
11
|
+
Follow the steps to [create a GitLab Pages site](https://docs.gitlab.com/ee/user/project/pages/#getting-started).
|
|
12
|
+
|
|
13
|
+
## Deployment
|
|
14
|
+
|
|
15
|
+
1. Here is an example GitLab Pages workflow to deploy your site to GitLab Pages:
|
|
16
|
+
|
|
17
|
+
```yaml [.gitlab-ci.yml]
|
|
18
|
+
image: node:lts
|
|
19
|
+
before_script:
|
|
20
|
+
- npx nypm install
|
|
21
|
+
pages:
|
|
22
|
+
cache:
|
|
23
|
+
paths:
|
|
24
|
+
- node_modules/
|
|
25
|
+
variables:
|
|
26
|
+
NITRO_PRESET: gitlab_pages
|
|
27
|
+
script:
|
|
28
|
+
- npm run build
|
|
29
|
+
artifacts:
|
|
30
|
+
paths:
|
|
31
|
+
- .output/public
|
|
32
|
+
publish: .output/public
|
|
33
|
+
rules:
|
|
34
|
+
# This ensures that only pushes to the default branch
|
|
35
|
+
# will trigger a pages deploy
|
|
36
|
+
- if: $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH
|
|
37
|
+
```
|