| 1 | import * as Namespace from "../../Namespace.ts"; |
| 2 | import { makeFrameworkSite, type FrameworkSiteProps } from "./FrameworkSite.ts"; |
| 3 | |
| 4 | /** |
| 5 | * The framework-integration module that drives vinext's Vite build plus |
| 6 | * vinext's Node `startProdServer` serve entry. |
| 7 | */ |
| 8 | export const VINEXT_NODE_FRAMEWORK_SPECIFIER = |
| 9 | "@alchemy.run/frontend-frameworks/vinext/node"; |
| 10 | |
| 11 | export interface VinextProps extends FrameworkSiteProps {} |
| 12 | |
| 13 | /** |
| 14 | * Deploy a [vinext](https://vinext.dev) application to a Hetzner Cloud |
| 15 | * Server: vinext's Vite build then a long-running `startProdServer` systemd |
| 16 | * unit on port 3000. Does **not** use the Cloudflare Worker entry |
| 17 | * (`vinext/server/fetch-handler`). |
| 18 | * |
| 19 | * The `dist/` output is packed into the unit archive. `vinext`, |
| 20 | * `react`, `react-dom`, and `react-server-dom-webpack` are installed on |
| 21 | * the unit with `npm install` rather than bundled. |
| 22 | * |
| 23 | * During `alchemy dev` the site is `vinext dev` and no cloud resources |
| 24 | * are declared; `Alchemy.remote()` opts back into the live Service. |
| 25 | * |
| 26 | * ### Creating vinext Sites |
| 27 | * **Example:** Basic vinext App |
| 28 | * ```typescript |
| 29 | * const site = yield* Hetzner.Website.Vinext("Web", { |
| 30 | * rootDir: "./app", |
| 31 | * }); |
| 32 | * ``` |
| 33 | * |
| 34 | * **Example:** Custom Domain |
| 35 | * ```typescript |
| 36 | * const site = yield* Hetzner.Website.Vinext("Web", { |
| 37 | * rootDir: "./app", |
| 38 | * domain: "app.example.com", |
| 39 | * zone, |
| 40 | * }); |
| 41 | * ``` |
| 42 | * |
| 43 | * **Example:** Redis data cache |
| 44 | * ISR / `"use cache"` default to in-process memory. Set `env.REDIS_URL` on |
| 45 | * this resource for a durable Redis store; the adapter is injected automatically. |
| 46 | * ```typescript |
| 47 | * const site = yield* Hetzner.Website.Vinext("Web", { |
| 48 | * env: { |
| 49 | * REDIS_URL: "redis://cache.internal:6379", |
| 50 | * }, |
| 51 | * }); |
| 52 | * ``` |
| 53 | * |
| 54 | * @resource |
| 55 | * @product Website |
| 56 | */ |
| 57 | export const Vinext = (id: string, props: VinextProps = {}) => |
| 58 | makeFrameworkSite(id, props, { |
| 59 | name: "Vinext", |
| 60 | framework: VINEXT_NODE_FRAMEWORK_SPECIFIER, |
| 61 | target: VINEXT_NODE_FRAMEWORK_SPECIFIER, |
| 62 | install: ["vinext", "react", "react-dom", "react-server-dom-webpack"], |
| 63 | }).pipe(Namespace.push(id)); |