Conversation
WHAT? Add additional tests to `aws-lambda` runtime. WHY? Improve the thoroughness and accuracy of the tests. HOW? `pnpm build && pnpm test`
WHAT? Add support for ALB lambda function targets. WHY? `ALBEvent` is similar to `APIGatewayProxyEvent`. However, it has key differences such as: - Query string parameters are not URL-decoded automatically. - The events either have `headers`/`queryStringParameters` or `multiValueHeaders`/`multiValueQueryStringParameters`, but not both. - Headers without values are removed from the event's input. Without this change, using `nitro` with Lambda + ALB yields unexpected behaviors like double URL encoding. HOW? `pnpm build && pnpm test`
WHAT? Update `aws-lambda` preset's documentation to clearly indicate which event types are supported. WHY? Avoid confusion from users when trying to use an unsupported event type.
There was a problem hiding this comment.
Note: Tests are based on the behaviors observed here.
There was a problem hiding this comment.
When work finished, would be nice if we can also setup for nitro-deploys to make sure preset works also in actual environment.
There was a problem hiding this comment.
When work finished, would be nice if we can also setup for nitro-deploys to make sure preset works also in actual environment.
I'm not sure how to action this since there doesn't seem to be any workflow in place that deploys to AWS (AWS account, credentials and infra would would be a pre-req). Also, it seems all deployments except alwaysdata.yml are currently disabled.
|
Thanks for PR. Considering several differences, i think it would be nicer if we develop a standalone subpreset + entry such as |
aws-lambda-alb support
|
Thanks for the reply @pi0!
Just to confirm, do you mean something like the following? Update: nitro/src/presets/aws-lambda/types.ts Lines 1 to 3 in f982f99 to: export type AwsLambdaOptions =
| {
// backwards compatibility, the presence of `type` overrides this
streaming?: boolean;
}
| {
/**
* The Lambda function type:
*
* - `alb`: An ALB Lambda target group.
* - `api-gateway`: An API Gateway REST API Lambda proxy integration, HTTP API Lambda integration, or Lambda function URL.
* - `function-url`: A synonym of `api-gateway`.
* - `function-url-stream`: A Lambda function URL with response streaming.
*
* @default "api-gateway"
*/
type?: "api-gateway" | "alb" | "function-url" | "function-url-stream";
};And update: nitro/src/presets/aws-lambda/preset.ts Lines 10 to 16 in f982f99 to: hooks: {
"rollup:before": (nitro, rollupConfig) => {
if ("type" in nitro.options.awsLambda) {
if (nitro.options.awsLambda.type === "alb") {
(rollupConfig.input as string) += "-alb";
} else if (nitro.options.awsLambda.type === "function-url-stream") {
(rollupConfig.input as string) += "-streaming";
}
} else if (nitro.options.awsLambda.streaming) {
(rollupConfig.input as string) += "-streaming";
}
},
}, |
|
I mean making new variant / export in presets (similar to cloudflare/) |
🔗 Linked issue
#2072
❓ Type of change
📚 Description
WHAT?
Add support for ALB lambda function targets.
WHY?
ALBEventis similar toAPIGatewayProxyEvent. However, it has key differences such as:headers/queryStringParametersormultiValueHeaders/multiValueQueryStringParameters, butnot both.
Without this change, using
nitrowith Lambda + ALB yields unexpected behaviors like double URL encoding.RESOLVES?
#2072
📝 Checklist