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

main
ts 110 lines 3.86 KB
Raw
1 import type { InputProps } from "alchemy/Input";
2 import * as Namespace from "alchemy/Namespace";
3 import { makeFrameworkSite, type FrameworkSiteProps } from "./FrameworkSite.ts";
4
5 /** The framework-integration package that drives the Nuxt build. */
6 export const NUXT_FRAMEWORK_SPECIFIER = "@alchemy.run/frontend-frameworks/nuxt";
7
8 /** The AWS Lambda deploy target for the Nuxt build. */
9 export const NUXT_AWS_TARGET_SPECIFIER = "@alchemy.run/frontend-frameworks/nuxt/aws";
10
11 /** The Node deploy target for the Lambda Web Function server (the default). */
12 export const NUXT_WEB_TARGET_SPECIFIER = "@alchemy.run/frontend-frameworks/nuxt/node";
13
14 export type NuxtProps = FrameworkSiteProps<{
15 /**
16 * Nuxt config overrides merged over the project's own `nuxt.config.ts`
17 * (the highest-priority c12 layer — a value here wins over the file).
18 * Use it for deploy-time values the config file can't express, e.g.
19 * per-stage `runtimeConfig`; `nuxt.config.ts` remains the primary home
20 * for everything else.
21 *
22 * Must be JSON-serializable — no functions, plugins, or modules (the
23 * value persists in state and participates in the rebuild hash).
24 * `nitro.preset` is always owned by the deploy target and cannot be
25 * overridden here.
26 */
27 nuxt?: Record<string, unknown>;
28 }>;
29
30 /**
31 * Deploy a Nuxt application to AWS: the nitro server on a Lambda Web
32 * Function, static assets (prerendered pages included) in S3, and a
33 * CloudFront distribution whose edge router serves uploaded files from S3
34 * and forwards everything else to the server.
35 *
36 * The server runs on a Lambda Web Function: the framework's Node server
37 * (built with the `@alchemy.run/frontend-frameworks/nuxt/node` deploy
38 * target) serves many requests per environment and streams responses. Set
39 * `server: "function"` to use a Lambda Function behind a streaming Function
40 * URL instead, built with the `/aws` target below, for Regions without Web
41 * Functions.
42 *
43 * The build runs through `@alchemy.run/frontend-frameworks/nuxt` with the
44 * `@alchemy.run/frontend-frameworks/nuxt/aws` deploy target (nitro's `aws-lambda` preset,
45 * streaming enabled) — both must be installed in your project.
46 *
47 * ### Creating Nuxt Sites
48 * **Example:** Basic Nuxt App
49 * ```typescript
50 * const site = yield* AWS.Website.Nuxt("Web", {
51 * rootDir: "./app",
52 * });
53 * ```
54 *
55 * **Example:** Custom Domain
56 * ```typescript
57 * const site = yield* AWS.Website.Nuxt("Web", {
58 * rootDir: "./app",
59 * domain: {
60 * name: "app.example.com",
61 * hostedZoneId: zone.hostedZoneId,
62 * },
63 * });
64 * ```
65 *
66 * ### Server Configuration
67 * **Example:** Tune The Server Function
68 * ```typescript
69 * const site = yield* AWS.Website.Nuxt("Web", {
70 * rootDir: "./app",
71 * memorySize: 2048,
72 * env: {
73 * NUXT_PUBLIC_API_BASE: api.url,
74 * },
75 * });
76 * ```
77 *
78 * ### Config Overrides
79 * `nuxt.config.ts` is the primary home for Nuxt configuration — it loads
80 * natively. The `nuxt` prop layers deploy-time overrides on top (the
81 * highest-priority c12 layer) for values the file can't express, like
82 * per-stage settings. The bag must be JSON-serializable — no functions,
83 * plugins, or modules — and `nitro.preset` stays owned by the deploy
84 * target.
85 *
86 * **Example:** Deploy-time config overrides
87 * ```typescript
88 * const site = yield* AWS.Website.Nuxt("Web", {
89 * rootDir: "./app",
90 * nuxt: {
91 * app: { baseURL: "/docs/" },
92 * runtimeConfig: {
93 * public: { apiBase: "https://api.example.com" },
94 * },
95 * },
96 * });
97 * ```
98 *
99 * @resource
100 */
101 export const Nuxt = (id: string, props: InputProps<NuxtProps, "server"> = {}) => {
102 const p = props as NuxtProps;
103 return makeFrameworkSite(id, props, {
104 name: "Nuxt",
105 framework: NUXT_FRAMEWORK_SPECIFIER,
106 target: NUXT_AWS_TARGET_SPECIFIER,
107 webTarget: NUXT_WEB_TARGET_SPECIFIER,
108 options: p.nuxt !== undefined ? { nuxt: p.nuxt } : undefined,
109 }).pipe(Namespace.push(id));
110 };