AWS Lambda
预设:aws_lambda
¥Preset: aws_lambda
Nitro 提供了一个内置预设,用于生成与 AWS Lambda 兼容的输出格式。.output/server/index.mjs
中的输出入口点与 AWS Lambda 格式 兼容。
¥Nitro provides a built-in preset to generate output format compatible with AWS Lambda.
The output entrypoint in .output/server/index.mjs
is compatible with AWS Lambda format.
它可以以编程方式使用,也可以作为部署的一部分使用。
¥It can be used programmatically or as part of a deployment.
import { handler } from './.output/server'
// Use programmatically
const { statusCode, headers, body } = handler({ rawPath: '/' })
内联块
¥Inlining chunks
Nitro 输出默认仅在需要时使用动态块进行延迟加载代码。但是,这有时对性能并不理想。(请参阅 nitrojs/nitro#650 中的讨论)。你可以使用 inlineDynamicImports
配置启用块内联行为。
¥Nitro output, by default uses dynamic chunks for lazy loading code only when needed. However this sometimes can not be ideal for performance. (See discussions in nitrojs/nitro#650). You can enabling chunk inlining behavior using inlineDynamicImports
config.
export default defineNitroConfig({
inlineDynamicImports: true
});
响应流
¥Response streaming
为了启用响应流,请启用 awsLambda.streaming
标志:
¥In order to enable response streaming, enable awsLambda.streaming
flag:
export default defineNitroConfig({
awsLambda: {
streaming: true
}
});