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

main
ts 100 lines 3.47 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 TanStack Start build. */
6 export const TANSTACK_START_FRAMEWORK_SPECIFIER = "@alchemy.run/frontend-frameworks/tanstack-start";
7
8 /** The AWS Lambda deploy target for the TanStack Start build. */
9 export const TANSTACK_START_AWS_TARGET_SPECIFIER =
10 "@alchemy.run/frontend-frameworks/tanstack-start/aws";
11
12 /** The Node deploy target for the Lambda Web Function server (the default). */
13 export const TANSTACK_START_WEB_TARGET_SPECIFIER =
14 "@alchemy.run/frontend-frameworks/tanstack-start/node";
15
16 export type TanStackStartProps = FrameworkSiteProps;
17
18 /**
19 * Deploy a [TanStack Start](https://tanstack.com/start) application to AWS:
20 * the SSR server on a Lambda Web Function, client assets in S3, and a
21 * CloudFront distribution whose edge router serves uploaded files from S3
22 * and forwards everything else to the server.
23 *
24 * The server runs on a Lambda Web Function: the framework's Node server
25 * (built with the `@alchemy.run/frontend-frameworks/tanstack-start/node` deploy
26 * target) serves many requests per environment and streams responses. Set
27 * `server: "function"` to use a Lambda Function behind a streaming Function
28 * URL instead, built with the `/aws` target below, for Regions without Web
29 * Functions.
30 *
31 * The build runs through
32 * `@alchemy.run/frontend-frameworks/tanstack-start` with the
33 * `@alchemy.run/frontend-frameworks/tanstack-start/aws` deploy target — both
34 * must be installed in your project, alongside `@tanstack/react-start` (or
35 * `@tanstack/solid-start`) and `vite`.
36 *
37 * Your `vite.config.ts` needs no adapter wiring: TanStack Start is pure
38 * Vite, so the integration drives the project's own `vite build`, forces the
39 * SSR bundle to be self-contained, and wraps its fetch handler as a
40 * streaming Lambda handler.
41 *
42 * ### Creating TanStack Start Sites
43 * **Example:** Basic TanStack Start App
44 * ```typescript
45 * const site = yield* AWS.Website.TanStackStart("Web", {
46 * rootDir: "./app",
47 * });
48 * ```
49 *
50 * **Example:** Custom Domain
51 * ```typescript
52 * const site = yield* AWS.Website.TanStackStart("Web", {
53 * rootDir: "./app",
54 * domain: {
55 * name: "app.example.com",
56 * hostedZoneId: zone.hostedZoneId,
57 * },
58 * });
59 * ```
60 *
61 * ### Server Configuration
62 * **Example:** Tune The Server Function
63 * ```typescript
64 * const site = yield* AWS.Website.TanStackStart("Web", {
65 * rootDir: "./app",
66 * memorySize: 2048,
67 * env: {
68 * API_BASE: api.url,
69 * },
70 * });
71 * ```
72 *
73 * **Example:** Read An Environment Variable From A Server Function
74 * ```typescript
75 * // src/routes/index.tsx
76 * const getApiBase = createServerFn({ method: "GET" }).handler(() => ({
77 * apiBase: process.env.API_BASE,
78 * }));
79 * ```
80 *
81 * ### Shared Router
82 * **Example:** Serve Through An Existing Router
83 * ```typescript
84 * const router = yield* AWS.Website.Router("FrontDoor", {});
85 *
86 * const site = yield* AWS.Website.TanStackStart("Web", {
87 * rootDir: "./app",
88 * domain: { router },
89 * });
90 * ```
91 *
92 * @resource
93 */
94 export const TanStackStart = (id: string, props: InputProps<TanStackStartProps, "server"> = {}) =>
95 makeFrameworkSite(id, props, {
96 name: "TanStackStart",
97 framework: TANSTACK_START_FRAMEWORK_SPECIFIER,
98 target: TANSTACK_START_AWS_TARGET_SPECIFIER,
99 webTarget: TANSTACK_START_WEB_TARGET_SPECIFIER,
100 }).pipe(Namespace.push(id));