mirror of
https://github.com/marcogll/passkit-generator.git
synced 2026-03-15 21:25:26 +00:00
Added check on boardingPass in examples to not make crash the request if we are creating a boarding pass
This commit is contained in:
@@ -128,6 +128,11 @@ app.route("/pkpassfrom/:modelName").get(async (request, response) => {
|
||||
request.body || request.params || request.query,
|
||||
);
|
||||
|
||||
if (pass.type === "boardingPass" && !pass.transitType) {
|
||||
// Just to not make crash the creation if we use a boardingPass
|
||||
pass.transitType = "PKTransitTypeAir";
|
||||
}
|
||||
|
||||
const stream = pass.getAsStream();
|
||||
|
||||
response.set({
|
||||
|
||||
@@ -51,6 +51,11 @@ app.route("/localize/:modelName").get(async (request, response) => {
|
||||
|
||||
console.log("Added languages", Object.keys(pass.languages).join(", "));
|
||||
|
||||
if (pass.type === "boardingPass" && !pass.transitType) {
|
||||
// Just to not make crash the creation if we use a boardingPass
|
||||
pass.transitType = "PKTransitTypeAir";
|
||||
}
|
||||
|
||||
const stream = pass.getAsStream();
|
||||
|
||||
response.set({
|
||||
|
||||
@@ -62,6 +62,11 @@ app.route("/barcodes/:modelName").get(async (request, response) => {
|
||||
);
|
||||
}
|
||||
|
||||
if (pass.type === "boardingPass" && !pass.transitType) {
|
||||
// Just to not make crash the creation if we use a boardingPass
|
||||
pass.transitType = "PKTransitTypeAir";
|
||||
}
|
||||
|
||||
const stream = pass.getAsStream();
|
||||
|
||||
response.set({
|
||||
|
||||
@@ -62,6 +62,11 @@ app.route("/expirationDate/:modelName").get(async (request, response) => {
|
||||
);
|
||||
}
|
||||
|
||||
if (pass.type === "boardingPass" && !pass.transitType) {
|
||||
// Just to not make crash the creation if we use a boardingPass
|
||||
pass.transitType = "PKTransitTypeAir";
|
||||
}
|
||||
|
||||
const stream = pass.getAsStream();
|
||||
|
||||
response.set({
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user