import * as Namespace from "../../Namespace.ts"; import { makeFrameworkSite, type FrameworkSiteProps } from "./FrameworkSite.ts"; /** The framework-integration package that drives the Octane build. */ export const OCTANE_FRAMEWORK_SPECIFIER = "@alchemy.run/frontend-frameworks/octane"; /** The AWS Lambda deploy target for the Octane build. */ export const OCTANE_AWS_TARGET_SPECIFIER = "@alchemy.run/frontend-frameworks/octane/aws"; export interface OctaneProps extends FrameworkSiteProps { /** * Project root directory (the directory containing `vite.config.ts` and * `octane.config.ts`). * @default "." */ rootDir?: string; } /** * Deploy an [OctaneJS](https://octanejs.dev) application to AWS: Octane's * SSR server on a streaming Lambda Function URL, static assets in S3, and a * CloudFront distribution whose edge router serves uploaded files from S3 * and forwards everything else to the server. * * The build runs through `@alchemy.run/frontend-frameworks/octane` with the * `@alchemy.run/frontend-frameworks/octane/aws` deploy target — the project's * own `vite build` (with `@octanejs/vite-plugin`) produces the * self-contained node server bundle, and the target's finishing pass wraps * its fetch handler as a streaming Lambda handler. The project's * `octane.config.ts` must select the AWS marker adapter: * * ```ts * import { aws } from "@alchemy.run/frontend-frameworks/octane/aws-adapter"; * import { defineConfig } from "@octanejs/vite-plugin"; * * export default defineConfig({ * adapter: aws(), * // ... * }); * ``` * * ### Creating Octane Sites * **Example:** Basic Octane App * ```typescript * const site = yield* AWS.Website.Octane("Web", { * rootDir: "./app", * }); * ``` * * **Example:** Custom Domain * ```typescript * const site = yield* AWS.Website.Octane("Web", { * rootDir: "./app", * domain: { * name: "app.example.com", * hostedZoneId: zone.hostedZoneId, * }, * }); * ``` * * ### Server Configuration * **Example:** Tune The Server Function * ```typescript * const site = yield* AWS.Website.Octane("Web", { * rootDir: "./app", * server: { * memorySize: 2048, * environment: { * API_BASE: api.url, * }, * }, * }); * ``` * * @resource */ export const Octane = (id: string, props: OctaneProps = {}) => makeFrameworkSite(id, props, { name: "Octane", framework: OCTANE_FRAMEWORK_SPECIFIER, target: OCTANE_AWS_TARGET_SPECIFIER, }).pipe(Namespace.push(id));