diff --git a/src/presets/vercel.ts b/src/presets/vercel.ts index 7c0a761c02..9ff0644541 100644 --- a/src/presets/vercel.ts +++ b/src/presets/vercel.ts @@ -5,7 +5,10 @@ import { withoutLeadingSlash } from "ufo"; import { writeFile } from "../utils"; import { defineNitroPreset } from "../preset"; import type { Nitro } from "../types"; -import type { VercelBuildConfigV3 } from "../types/presets"; +import type { + VercelBuildConfigV3, + VercelServerlessFunctionConfig, +} from "../types/presets"; // https://vercel.com/docs/build-output-api/v3 @@ -36,11 +39,12 @@ export const vercel = defineNitroPreset({ nitro.options.output.serverDir, ".vc-config.json" ); - const functionConfig = { + const functionConfig: VercelServerlessFunctionConfig = { runtime: runtimeVersion, handler: "index.mjs", launcherType: "Nodejs", shouldAddHelpers: false, + supportsResponseStreaming: true, ...nitro.options.vercel?.functions, }; await writeFile( diff --git a/src/types/presets.ts b/src/types/presets.ts index 0c90cd90b7..42e0cc671c 100644 --- a/src/types/presets.ts +++ b/src/types/presets.ts @@ -52,18 +52,43 @@ export interface VercelBuildConfigV3 { }[]; } +/** + * https://vercel.com/docs/build-output-api/v3/primitives#serverless-function-configuration + */ +export interface VercelServerlessFunctionConfig { + /** + * Amount of memory (RAM in MB) that will be allocated to the Serverless Function. + */ + memory?: number; + + /** + * Maximum execution duration (in seconds) that will be allowed for the Serverless Function. + */ + maxDuration?: number; + + /** + * True if a custom runtime has support for Lambda runtime wrappers. + */ + supportsWrapper?: boolean; + + /** + * When true, the Serverless Function will stream the response to the client. + */ + supportsResponseStreaming?: boolean; + + [key: string]: unknown; +} + export interface PresetOptions { vercel: { config: VercelBuildConfigV3; + /** * If you are using `vercel-edge`, you can specify the region(s) for your edge function. * @see https://vercel.com/docs/concepts/functions/edge-functions#edge-function-regions */ regions?: string[]; - functions?: { - memory: number; - maxDuration: number; - [key: string]: unknown; - }; + + functions?: VercelServerlessFunctionConfig; }; }