1import type { InputProps } from "../../Input.ts";
2import * as Namespace from "../../Namespace.ts";
3import { makeFrameworkSite, type FrameworkSiteProps } from "./FrameworkSite.ts";
4
5/** The framework-integration package that drives the Octane build. */
6export const OCTANE_FRAMEWORK_SPECIFIER =
7 "@alchemy.run/frontend-frameworks/octane";
8
9/** The AWS Lambda deploy target for the Octane build. */
10export const OCTANE_AWS_TARGET_SPECIFIER =
11 "@alchemy.run/frontend-frameworks/octane/aws";
12
13export interface OctaneProps extends FrameworkSiteProps {
14 /**
15 * Project root directory (the directory containing `vite.config.ts` and
16 * `octane.config.ts`).
17 * @default "."
18 */
19 rootDir?: string;
20}
21
22/**
23 * Deploy an [OctaneJS](https://octanejs.dev) application to AWS: Octane's
24 * SSR server on a streaming Lambda Function URL, static assets in S3, and a
25 * CloudFront distribution whose edge router serves uploaded files from S3
26 * and forwards everything else to the server.
27 *
28 * The build runs through `@alchemy.run/frontend-frameworks/octane` with the
29 * `@alchemy.run/frontend-frameworks/octane/aws` deploy target — the project's
30 * own `vite build` (with `@octanejs/vite-plugin`) produces the
31 * default native Node server bundle, and the target's finishing pass
32 * automatically wraps its fetch handler as a streaming Lambda handler.
33 * `AWS.Website.Octane` selects hosting; keep native compiler and route
34 * settings in `octane.config.ts` without an adapter. The legacy AWS marker
35 * adapter remains optional for existing projects.
36 *
37 * ### Creating Octane Sites
38 * **Example:** Basic Octane App
39 * ```typescript
40 * const site = yield* AWS.Website.Octane("Web", {
41 * rootDir: "./app",
42 * });
43 * ```
44 *
45 * **Example:** Custom Domain
46 * ```typescript
47 * const site = yield* AWS.Website.Octane("Web", {
48 * rootDir: "./app",
49 * domain: {
50 * name: "app.example.com",
51 * hostedZoneId: zone.hostedZoneId,
52 * },
53 * });
54 * ```
55 *
56 * ### Server Configuration
57 * **Example:** Tune The Server Function
58 * ```typescript
59 * const site = yield* AWS.Website.Octane("Web", {
60 * rootDir: "./app",
61 * memorySize: 2048,
62 * env: {
63 * API_BASE: api.url,
64 * },
65 * });
66 * ```
67 *
68 * @resource
69 */
70export const Octane = (id: string, props: InputProps<OctaneProps> = {}) =>
71 makeFrameworkSite(id, props, {
72 name: "Octane",
73 framework: OCTANE_FRAMEWORK_SPECIFIER,
74 target: OCTANE_AWS_TARGET_SPECIFIER,
75 }).pipe(Namespace.push(id));