Added check on boardingPass in examples to not make crash the request if we are creating a boarding pass

This commit is contained in:
Alexander Cerutti
2021-12-30 13:31:22 +01:00
parent 92ab060c7d
commit 8c39928f0c
6 changed files with 27 additions and 2 deletions

View File

@@ -13,7 +13,7 @@ export async function barcodes(event: ALBEvent) {
const passGenerator = createPassGenerator(modelName, passOptions);
const pass = (await passGenerator.next()).value as PKPass;
const pass = (await passGenerator.next()).value as unknown as PKPass;
if (alt === "true") {
// After this, pass.props["barcodes"] will have support for all the formats
@@ -39,5 +39,5 @@ export async function barcodes(event: ALBEvent) {
);
}
return (await passGenerator.next(pass as PKPass)).value as ALBResult;
return (await passGenerator.next()).value as ALBResult;
}

View File

@@ -143,6 +143,11 @@ export async function* createPassGenerator(
);
}
if (pass.type === "boardingPass" && !pass.transitType) {
// Just to not make crash the creation if we use a boardingPass
pass.transitType = "PKTransitTypeAir";
}
pass = yield pass;
const buffer = pass.getAsBuffer();