@devries-cameron20 / t3code Mirror · read-only
Fork 0

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

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 06:00 UTC

main
ts 118 lines 3.84 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 Waku build. */
6 export const WAKU_FRAMEWORK_SPECIFIER = "@alchemy.run/frontend-frameworks/waku";
7
8 /** The AWS Lambda deploy target for the Waku build. */
9 export const WAKU_AWS_TARGET_SPECIFIER = "@alchemy.run/frontend-frameworks/waku/aws";
10
11 /** The Node deploy target for the Lambda Web Function server (the default). */
12 export const WAKU_WEB_TARGET_SPECIFIER = "@alchemy.run/frontend-frameworks/waku/node";
13
14 export type WakuProps = FrameworkSiteProps<{
15 /**
16 * Waku config overrides merged over the project's `waku.config.*`
17 * (per-key; deploy-time values win). For values that vary by stage or
18 * come from other resources — static config belongs in `waku.config.*`.
19 */
20 waku?: {
21 /**
22 * Waku `srcDir` (relative to {@link FrameworkSiteProps.rootDir}).
23 * @default "src"
24 */
25 srcDir?: string;
26 /**
27 * Waku `distDir` (relative to {@link FrameworkSiteProps.rootDir}).
28 * A custom `distDir` must be gitignored (or added to `memo.exclude`)
29 * so the build output stays excluded from the rebuild-deciding input
30 * hash.
31 * @default "dist"
32 */
33 distDir?: string;
34 /**
35 * Waku `basePath`.
36 * @default "/"
37 */
38 basePath?: string;
39 };
40 }>;
41
42 /**
43 * Deploy a [Waku](https://waku.gg) application to AWS: the RSC server on a
44 * Lambda Web Function, static assets (SSG pages included) in S3, and a
45 * CloudFront distribution whose edge router serves uploaded files from S3
46 * and forwards everything else to the server.
47 *
48 * The server runs on a Lambda Web Function: the framework's Node server
49 * (built with the `@alchemy.run/frontend-frameworks/waku/node` deploy
50 * target) serves many requests per environment and streams responses. Set
51 * `server: "function"` to use a Lambda Function behind a streaming Function
52 * URL instead, built with the `/aws` target below, for Regions without Web
53 * Functions.
54 *
55 * The build runs through `@alchemy.run/frontend-frameworks/waku` with the
56 * `@alchemy.run/frontend-frameworks/waku/aws` deploy target (this package's fork
57 * of waku's aws-lambda adapter, streaming enabled) — both must be installed
58 * in your project.
59 *
60 * ### Creating Waku Sites
61 * **Example:** Basic Waku App
62 * ```typescript
63 * const site = yield* AWS.Website.Waku("Web", {
64 * rootDir: "./app",
65 * });
66 * ```
67 *
68 * **Example:** Custom Domain
69 * ```typescript
70 * const site = yield* AWS.Website.Waku("Web", {
71 * rootDir: "./app",
72 * domain: {
73 * name: "app.example.com",
74 * hostedZoneId: zone.hostedZoneId,
75 * },
76 * });
77 * ```
78 *
79 * ### Server Configuration
80 * **Example:** Tune The Server Function
81 * ```typescript
82 * const site = yield* AWS.Website.Waku("Web", {
83 * rootDir: "./app",
84 * memorySize: 2048,
85 * env: {
86 * API_BASE: api.url,
87 * },
88 * });
89 * ```
90 *
91 * ### Waku Config Overrides
92 * Waku configuration lives in your `waku.config.*`. The `waku` prop
93 * overrides it per key at deploy time — for values that vary by stage
94 * or come from other resources.
95 *
96 * **Example:** Stage-dependent base path
97 * ```typescript
98 * const site = yield* AWS.Website.Waku("Web", {
99 * waku: {
100 * basePath: "/docs/",
101 * },
102 * });
103 * ```
104 *
105 * @resource
106 */
107 export const Waku = (id: string, props: InputProps<WakuProps, "server"> = {}) => {
108 const p = props as WakuProps;
109 return makeFrameworkSite(id, props, {
110 name: "Waku",
111 framework: WAKU_FRAMEWORK_SPECIFIER,
112 target: WAKU_AWS_TARGET_SPECIFIER,
113 webTarget: WAKU_WEB_TARGET_SPECIFIER,
114 // Deploy-time waku config overrides, merged over the project's
115 // `waku.config.*` by the integration (per-key; overrides win).
116 options: p.waku !== undefined ? { waku: p.waku } : undefined,
117 }).pipe(Namespace.push(id));
118 };