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

main
ts 86 lines 3.07 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 Octane build. */
6 export const OCTANE_FRAMEWORK_SPECIFIER = "@alchemy.run/frontend-frameworks/octane";
7
8 /** The AWS Lambda deploy target for the Octane build. */
9 export const OCTANE_AWS_TARGET_SPECIFIER = "@alchemy.run/frontend-frameworks/octane/aws";
10
11 /** The Node deploy target for the Lambda Web Function server (the default). */
12 export const OCTANE_WEB_TARGET_SPECIFIER = "@alchemy.run/frontend-frameworks/octane/node";
13
14 export type OctaneProps = FrameworkSiteProps<{
15 /**
16 * Project root directory (the directory containing `vite.config.ts` and
17 * `octane.config.ts`).
18 * @default "."
19 */
20 rootDir?: string;
21 }>;
22
23 /**
24 * Deploy an [OctaneJS](https://octanejs.dev) application to AWS: Octane's
25 * SSR server on a Lambda Web Function, static assets in S3, and a CloudFront
26 * distribution whose edge router serves uploaded files from S3 and forwards
27 * everything else to the server.
28 *
29 * The server runs on a Lambda Web Function: the framework's Node server
30 * (built with the `@alchemy.run/frontend-frameworks/octane/node` deploy
31 * target) serves many requests per environment and streams responses. Set
32 * `server: "function"` to use a Lambda Function behind a streaming Function
33 * URL instead, built with the `/aws` target below, for Regions without Web
34 * Functions.
35 *
36 * The build runs through `@alchemy.run/frontend-frameworks/octane` with the
37 * `@alchemy.run/frontend-frameworks/octane/aws` deploy target — the project's
38 * own `vite build` (with `@octanejs/vite-plugin`) produces the
39 * default native Node server bundle, and the target's finishing pass
40 * automatically wraps its fetch handler as a streaming Lambda handler.
41 * `AWS.Website.Octane` selects hosting; keep native compiler and route
42 * settings in `octane.config.ts` without an adapter. The legacy AWS marker
43 * adapter remains optional for existing projects.
44 *
45 * ### Creating Octane Sites
46 * **Example:** Basic Octane App
47 * ```typescript
48 * const site = yield* AWS.Website.Octane("Web", {
49 * rootDir: "./app",
50 * });
51 * ```
52 *
53 * **Example:** Custom Domain
54 * ```typescript
55 * const site = yield* AWS.Website.Octane("Web", {
56 * rootDir: "./app",
57 * domain: {
58 * name: "app.example.com",
59 * hostedZoneId: zone.hostedZoneId,
60 * },
61 * });
62 * ```
63 *
64 * ### Server Configuration
65 * **Example:** Tune The Server Function
66 * ```typescript
67 * const site = yield* AWS.Website.Octane("Web", {
68 * rootDir: "./app",
69 * memorySize: 2048,
70 * env: {
71 * API_BASE: api.url,
72 * },
73 * });
74 * ```
75 *
76 * @resource
77 */
78 export const Octane = (id: string, props: InputProps<OctaneProps, "server"> = {}) =>
79 makeFrameworkSite(id, props, {
80 name: "Octane",
81 framework: OCTANE_FRAMEWORK_SPECIFIER,
82 target: OCTANE_AWS_TARGET_SPECIFIER,
83 webTarget: OCTANE_WEB_TARGET_SPECIFIER,
84 // The SSR entry reads `index.html` beside itself at runtime.
85 webPrebuilt: true,
86 }).pipe(Namespace.push(id));