Fixed Serverless examples: they were not returning 400 if model name was not provided

This commit is contained in:
Alexander Cerutti
2022-01-15 23:56:40 +01:00
parent 267ca6baff
commit 0a18c5200d
5 changed files with 75 additions and 20 deletions

View File

@@ -1,4 +1,7 @@
import { finish400WithoutModelName, createPassGenerator } from "../shared";
import {
throwClientErrorWithoutModelName,
createPassGenerator,
} from "../shared";
import type { ALBEvent, ALBResult } from "aws-lambda";
import type { PKPass } from "passkit-generator";
@@ -7,7 +10,11 @@ import type { PKPass } from "passkit-generator";
*/
export async function localize(event: ALBEvent) {
finish400WithoutModelName(event);
try {
throwClientErrorWithoutModelName(event);
} catch (err) {
return err;
}
const { modelName, ...passOptions } = event.queryStringParameters;