@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, 04:45 UTC

main
ts 102 lines 3.63 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 SvelteKit build. */
6 export const SVELTEKIT_FRAMEWORK_SPECIFIER = "@alchemy.run/frontend-frameworks/sveltekit";
7
8 /** The AWS Lambda deploy target for the SvelteKit build. */
9 export const SVELTEKIT_AWS_TARGET_SPECIFIER = "@alchemy.run/frontend-frameworks/sveltekit/aws";
10
11 /** The Node deploy target for the Lambda Web Function server (the default). */
12 export const SVELTEKIT_WEB_TARGET_SPECIFIER = "@alchemy.run/frontend-frameworks/sveltekit/node";
13
14 export type SvelteKitProps = FrameworkSiteProps<{
15 /**
16 * SvelteKit config overrides for the `sveltekit(...)` plugin call, merged
17 * over the options of the user's own call (these win). JSON-serializable
18 * only — no `preprocess`/`vitePlugin`/functions; construction-time options
19 * (`preprocess`, `extensions`, `compilerOptions`, `vitePlugin`) can only
20 * apply when no user `vite.config.*` exists. The `adapter` field is
21 * always owned by alchemy.
22 */
23 kit?: Record<string, unknown>;
24 }>;
25
26 /**
27 * Deploy a SvelteKit application to AWS: kit's SSR server on a Lambda Web
28 * Function, static assets (prerendered pages included) in S3, and a
29 * CloudFront distribution whose edge router serves uploaded files from S3
30 * and forwards everything else to the server.
31 *
32 * The server runs on a Lambda Web Function: the framework's Node server
33 * (built with the `@alchemy.run/frontend-frameworks/sveltekit/node` deploy
34 * target) serves many requests per environment and streams responses. Set
35 * `server: "function"` to use a Lambda Function behind a streaming Function
36 * URL instead, built with the `/aws` target below, for Regions without Web
37 * Functions.
38 *
39 * The build runs through `@alchemy.run/frontend-frameworks/sveltekit` with the
40 * `@alchemy.run/frontend-frameworks/sveltekit/aws` deploy target (an in-memory
41 * kit adapter emitting a streaming Lambda handler) — both must be
42 * installed in your project.
43 *
44 * ### Creating SvelteKit Sites
45 * **Example:** Basic SvelteKit App
46 * ```typescript
47 * const site = yield* AWS.Website.SvelteKit("Web", {
48 * rootDir: "./app",
49 * });
50 * ```
51 *
52 * **Example:** Custom Domain
53 * ```typescript
54 * const site = yield* AWS.Website.SvelteKit("Web", {
55 * rootDir: "./app",
56 * domain: {
57 * name: "app.example.com",
58 * hostedZoneId: zone.hostedZoneId,
59 * },
60 * });
61 * ```
62 *
63 * ### Server Configuration
64 * **Example:** Tune The Server Function
65 * ```typescript
66 * const site = yield* AWS.Website.SvelteKit("Web", {
67 * rootDir: "./app",
68 * memorySize: 2048,
69 * env: {
70 * API_BASE: api.url,
71 * },
72 * });
73 * ```
74 *
75 * ### Kit Overrides
76 * Kit options live in the `sveltekit(...)` call in your `vite.config.ts`,
77 * which loads natively. The `kit` prop is a deploy-time override bag
78 * merged over your own options (the prop wins) — useful for per-stage
79 * values the config file can't compute. JSON-serializable values only.
80 *
81 * **Example:** Deploy-time kit overrides
82 * ```typescript
83 * const site = yield* AWS.Website.SvelteKit("Web", {
84 * rootDir: "./app",
85 * kit: {
86 * paths: { base: "/docs" },
87 * },
88 * });
89 * ```
90 *
91 * @resource
92 */
93 export const SvelteKit = (id: string, props: InputProps<SvelteKitProps, "server"> = {}) => {
94 const p = props as SvelteKitProps;
95 return makeFrameworkSite(id, props, {
96 name: "SvelteKit",
97 framework: SVELTEKIT_FRAMEWORK_SPECIFIER,
98 target: SVELTEKIT_AWS_TARGET_SPECIFIER,
99 webTarget: SVELTEKIT_WEB_TARGET_SPECIFIER,
100 options: { kit: p.kit },
101 }).pipe(Namespace.push(id));
102 };