The best way to control Claude Code, Codex and more from any computer or phone

main
ts 92 lines 2.82 KB
Raw
1 import * as Namespace from "alchemy/Namespace";
2 import * as Effect from "effect/Effect";
3 import { REDIS_URL_ENV, type Redis } from "../Redis.ts";
4 import { ref } from "../ref.ts";
5 import { makeFrameworkSite, type FrameworkSiteProps } from "./FrameworkSite.ts";
6
7 /**
8 * The vinext Node framework module (it is its own deploy target — not
9 * the Cloudflare Worker source).
10 */
11 export const VINEXT_FRAMEWORK_SPECIFIER = "@alchemy.run/frontend-frameworks/vinext/node";
12
13 /** The Node container deploy target for the vinext build. */
14 export const VINEXT_NODE_TARGET_SPECIFIER = "@alchemy.run/frontend-frameworks/vinext/node";
15
16 export interface VinextProps extends FrameworkSiteProps {
17 /**
18 * Optional Redis for ISR / `"use cache"`. Alchemy writes `REDIS_URL`
19 * onto the Service and injects the Redis data-cache adapter automatically.
20 * Missing `REDIS_URL` (`alchemy dev`) falls back to memory.
21 */
22 redis?: Redis;
23 }
24
25 /**
26 * Deploy a [vinext](https://vinext.dev) application to Railway as a
27 * long-running Node process: vinext's Vite build, then vinext's production
28 * server (`startProdServer`) on `PORT` (default 3000). **Not** the
29 * Cloudflare Worker path — those wrappers are workerd.
30 *
31 * The image `npm install`s `vinext`, `react`, `react-dom`, and
32 * `react-server-dom-webpack`, and bakes `dist/` into `/app`.
33 *
34 * During `alchemy dev` the site is vinext's own dev server (`vinext
35 * dev`) and no cloud resources are declared; `Alchemy.remote()` opts
36 * back into the full live deployment.
37 *
38 * ### Creating vinext Sites
39 * **Example:** Basic vinext App
40 * ```typescript
41 * const site = yield* Railway.Website.Vinext("Web", {
42 * rootDir: "./app",
43 * });
44 * ```
45 *
46 * ### Server Configuration
47 * **Example:** Process Environment
48 * ```typescript
49 * const site = yield* Railway.Website.Vinext("Web", {
50 * rootDir: "./app",
51 * env: {
52 * GREETING: "Hello from vinext on Railway!",
53 * },
54 * });
55 * ```
56 *
57 * **Example:** Redis data cache
58 * ```typescript
59 * const project = yield* Railway.Project("Project");
60 * const redis = yield* Railway.Redis("Cache", { project });
61 * const site = yield* Railway.Website.Vinext("Web", {
62 * project,
63 * redis,
64 * });
65 * ```
66 *
67 * @resource
68 * @product Website
69 */
70 export const Vinext = (id: string, propsIn: VinextProps = {}) =>
71 Effect.gen(function* () {
72 const { redis, ...props } = propsIn;
73 return yield* makeFrameworkSite(
74 id,
75 {
76 ...props,
77 env:
78 redis === undefined
79 ? props.env
80 : {
81 [REDIS_URL_ENV]: ref(redis, REDIS_URL_ENV),
82 ...props.env,
83 },
84 },
85 {
86 name: "Vinext",
87 framework: VINEXT_FRAMEWORK_SPECIFIER,
88 target: VINEXT_NODE_TARGET_SPECIFIER,
89 install: ["vinext", "react", "react-dom", "react-server-dom-webpack"],
90 },
91 );
92 }).pipe(Namespace.push(id));