mirror of
https://github.com/marcogll/passkit-generator.git
synced 2026-03-15 20:25:26 +00:00
Added prettier to project
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
This is examples folder. These examples are used to test new features and as sample showcases.
|
||||
|
||||
Each example is linked to webserver.js, which *requires* express.js to run.
|
||||
Each example is linked to webserver.js, which _requires_ express.js to run.
|
||||
Express.js has been inserted as "example package" dipendency.
|
||||
|
||||
```sh
|
||||
@@ -18,6 +18,7 @@ To make them work, you'll have to edit both certificates and model path.
|
||||
|
||||
Visit [http://localhost:8080/gen/examplePass](http://localhost:8080/gen/examplePass) to get the pass. Replace "examplePass" with the pass name in models folder.
|
||||
Please note that `field.js` example will force you to download `exampleBooking.pass`, no matter what.
|
||||
___
|
||||
|
||||
---
|
||||
|
||||
Every contribution is really appreciated. ❤️ Thank you!
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
import genRoute, { app } from "./webserver";
|
||||
import { createPass, createAbstractModel, AbstractModel } from "passkit-generator";
|
||||
import {
|
||||
createPass,
|
||||
createAbstractModel,
|
||||
AbstractModel,
|
||||
} from "passkit-generator";
|
||||
|
||||
let abstractModel: AbstractModel;
|
||||
|
||||
@@ -11,148 +15,182 @@ let abstractModel: AbstractModel;
|
||||
signerCert: "../certificates/signerCert.pem",
|
||||
signerKey: {
|
||||
keyFile: "../certificates/signerKey.pem",
|
||||
passphrase: "123456"
|
||||
}
|
||||
passphrase: "123456",
|
||||
},
|
||||
},
|
||||
// overrides: request.body || request.params || request.query,
|
||||
});
|
||||
})();
|
||||
|
||||
genRoute.all(async function manageRequest(request, response) {
|
||||
const passName = request.params.modelName + "_" + (new Date()).toISOString().split('T')[0].replace(/-/ig, "");
|
||||
const passName =
|
||||
request.params.modelName +
|
||||
"_" +
|
||||
new Date().toISOString().split("T")[0].replace(/-/gi, "");
|
||||
|
||||
try {
|
||||
const pass = await createPass(abstractModel);
|
||||
|
||||
pass.transitType = "PKTransitTypeAir";
|
||||
|
||||
pass.headerFields.push({
|
||||
"key": "header1",
|
||||
"label": "Data",
|
||||
"value": "25 mag",
|
||||
"textAlignment": "PKTextAlignmentCenter"
|
||||
}, {
|
||||
"key": "header2",
|
||||
"label": "Volo",
|
||||
"value": "EZY997",
|
||||
"textAlignment": "PKTextAlignmentCenter"
|
||||
});
|
||||
pass.headerFields.push(
|
||||
{
|
||||
key: "header1",
|
||||
label: "Data",
|
||||
value: "25 mag",
|
||||
textAlignment: "PKTextAlignmentCenter",
|
||||
},
|
||||
{
|
||||
key: "header2",
|
||||
label: "Volo",
|
||||
value: "EZY997",
|
||||
textAlignment: "PKTextAlignmentCenter",
|
||||
},
|
||||
);
|
||||
|
||||
pass.primaryFields.push({
|
||||
key: "IATA-source",
|
||||
value: "NAP",
|
||||
label: "Napoli",
|
||||
textAlignment: "PKTextAlignmentLeft"
|
||||
}, {
|
||||
key: "IATA-destination",
|
||||
value: "VCE",
|
||||
label: "Venezia Marco Polo",
|
||||
textAlignment: "PKTextAlignmentRight"
|
||||
});
|
||||
pass.primaryFields.push(
|
||||
{
|
||||
key: "IATA-source",
|
||||
value: "NAP",
|
||||
label: "Napoli",
|
||||
textAlignment: "PKTextAlignmentLeft",
|
||||
},
|
||||
{
|
||||
key: "IATA-destination",
|
||||
value: "VCE",
|
||||
label: "Venezia Marco Polo",
|
||||
textAlignment: "PKTextAlignmentRight",
|
||||
},
|
||||
);
|
||||
|
||||
pass.secondaryFields.push({
|
||||
"key": "secondary1",
|
||||
"label": "Imbarco chiuso",
|
||||
"value": "18:40",
|
||||
"textAlignment": "PKTextAlignmentCenter",
|
||||
}, {
|
||||
"key": "sec2",
|
||||
"label": "Partenze",
|
||||
"value": "19:10",
|
||||
"textAlignment": "PKTextAlignmentCenter"
|
||||
}, {
|
||||
"key": "sec3",
|
||||
"label": "SB",
|
||||
"value": "Sì",
|
||||
"textAlignment": "PKTextAlignmentCenter"
|
||||
}, {
|
||||
"key": "sec4",
|
||||
"label": "Imbarco",
|
||||
"value": "Anteriore",
|
||||
"textAlignment": "PKTextAlignmentCenter"
|
||||
});
|
||||
pass.secondaryFields.push(
|
||||
{
|
||||
key: "secondary1",
|
||||
label: "Imbarco chiuso",
|
||||
value: "18:40",
|
||||
textAlignment: "PKTextAlignmentCenter",
|
||||
},
|
||||
{
|
||||
key: "sec2",
|
||||
label: "Partenze",
|
||||
value: "19:10",
|
||||
textAlignment: "PKTextAlignmentCenter",
|
||||
},
|
||||
{
|
||||
key: "sec3",
|
||||
label: "SB",
|
||||
value: "Sì",
|
||||
textAlignment: "PKTextAlignmentCenter",
|
||||
},
|
||||
{
|
||||
key: "sec4",
|
||||
label: "Imbarco",
|
||||
value: "Anteriore",
|
||||
textAlignment: "PKTextAlignmentCenter",
|
||||
},
|
||||
);
|
||||
|
||||
pass.auxiliaryFields.push({
|
||||
"key": "aux1",
|
||||
"label": "Passeggero",
|
||||
"value": "MR. WHO KNOWS",
|
||||
"textAlignment": "PKTextAlignmentLeft"
|
||||
}, {
|
||||
"key": "aux2",
|
||||
"label": "Posto",
|
||||
"value": "1A*",
|
||||
"textAlignment": "PKTextAlignmentCenter"
|
||||
});
|
||||
pass.auxiliaryFields.push(
|
||||
{
|
||||
key: "aux1",
|
||||
label: "Passeggero",
|
||||
value: "MR. WHO KNOWS",
|
||||
textAlignment: "PKTextAlignmentLeft",
|
||||
},
|
||||
{
|
||||
key: "aux2",
|
||||
label: "Posto",
|
||||
value: "1A*",
|
||||
textAlignment: "PKTextAlignmentCenter",
|
||||
},
|
||||
);
|
||||
|
||||
pass.backFields.push({
|
||||
"key": "document number",
|
||||
"label": "Numero documento:",
|
||||
"value": "- -",
|
||||
"textAlignment": "PKTextAlignmentLeft"
|
||||
}, {
|
||||
"key": "You're checked in, what next",
|
||||
"label": "Hai effettuato il check-in, Quali sono le prospettive",
|
||||
"value": "",
|
||||
"textAlignment": "PKTextAlignmentLeft"
|
||||
}, {
|
||||
"key": "Check In",
|
||||
"label": "1. check-in✓",
|
||||
"value": "",
|
||||
"textAlignment": "PKTextAlignmentLeft"
|
||||
}, {
|
||||
"key": "checkIn",
|
||||
"label": "",
|
||||
"value": "Le uscite d'imbarco chiudono 30 minuti prima della partenza, quindi sii puntuale. In questo aeroporto puoi utilizzare la corsia Fast Track ai varchi di sicurezza.",
|
||||
"textAlignment": "PKTextAlignmentLeft"
|
||||
}, {
|
||||
"key": "2. Bags",
|
||||
"label": "2. Bagaglio",
|
||||
"value": "",
|
||||
"textAlignment": "PKTextAlignmentLeft"
|
||||
}, {
|
||||
"key": "Require special assistance",
|
||||
"label": "Assistenza speciale",
|
||||
"value": "Se hai richiesto assistenza speciale, presentati a un membro del personale nell'area di Consegna bagagli almeno 90 minuti prima del volo.",
|
||||
"textAlignment": "PKTextAlignmentLeft"
|
||||
}, {
|
||||
"key": "3. Departures",
|
||||
"label": "3. Partenze",
|
||||
"value": "",
|
||||
"textAlignment": "PKTextAlignmentLeft"
|
||||
}, {
|
||||
"key": "photoId",
|
||||
"label": "Un documento d’identità corredato di fotografia",
|
||||
"value": "è obbligatorio su TUTTI i voli. Per un viaggio internazionale è necessario un passaporto valido o, dove consentita, una carta d’identità.",
|
||||
"textAlignment": "PKTextAlignmentLeft"
|
||||
}, {
|
||||
"key": "yourSeat",
|
||||
"label": "Il tuo posto:",
|
||||
"value": "verifica il tuo numero di posto nella parte superiore. Durante l’imbarco utilizza le scale anteriori e posteriori: per le file 1-10 imbarcati dalla parte anteriore; per le file 11-31 imbarcati dalla parte posteriore. Colloca le borse di dimensioni ridotte sotto il sedile davanti a te.",
|
||||
"textAlignment": "PKTextAlignmentLeft"
|
||||
}, {
|
||||
"key": "Pack safely",
|
||||
"label": "Bagaglio sicuro",
|
||||
"value": "Fai clic http://easyjet.com/it/articoli-pericolosi per maggiori informazioni sulle merci pericolose oppure visita il sito CAA http://www.caa.co.uk/default.aspx?catid=2200",
|
||||
"textAlignment": "PKTextAlignmentLeft"
|
||||
}, {
|
||||
"key": "Thank you for travelling easyJet",
|
||||
"label": "Grazie per aver viaggiato con easyJet",
|
||||
"value": "",
|
||||
"textAlignment": "PKTextAlignmentLeft"
|
||||
});
|
||||
pass.backFields.push(
|
||||
{
|
||||
key: "document number",
|
||||
label: "Numero documento:",
|
||||
value: "- -",
|
||||
textAlignment: "PKTextAlignmentLeft",
|
||||
},
|
||||
{
|
||||
key: "You're checked in, what next",
|
||||
label: "Hai effettuato il check-in, Quali sono le prospettive",
|
||||
value: "",
|
||||
textAlignment: "PKTextAlignmentLeft",
|
||||
},
|
||||
{
|
||||
key: "Check In",
|
||||
label: "1. check-in✓",
|
||||
value: "",
|
||||
textAlignment: "PKTextAlignmentLeft",
|
||||
},
|
||||
{
|
||||
key: "checkIn",
|
||||
label: "",
|
||||
value:
|
||||
"Le uscite d'imbarco chiudono 30 minuti prima della partenza, quindi sii puntuale. In questo aeroporto puoi utilizzare la corsia Fast Track ai varchi di sicurezza.",
|
||||
textAlignment: "PKTextAlignmentLeft",
|
||||
},
|
||||
{
|
||||
key: "2. Bags",
|
||||
label: "2. Bagaglio",
|
||||
value: "",
|
||||
textAlignment: "PKTextAlignmentLeft",
|
||||
},
|
||||
{
|
||||
key: "Require special assistance",
|
||||
label: "Assistenza speciale",
|
||||
value:
|
||||
"Se hai richiesto assistenza speciale, presentati a un membro del personale nell'area di Consegna bagagli almeno 90 minuti prima del volo.",
|
||||
textAlignment: "PKTextAlignmentLeft",
|
||||
},
|
||||
{
|
||||
key: "3. Departures",
|
||||
label: "3. Partenze",
|
||||
value: "",
|
||||
textAlignment: "PKTextAlignmentLeft",
|
||||
},
|
||||
{
|
||||
key: "photoId",
|
||||
label: "Un documento d’identità corredato di fotografia",
|
||||
value:
|
||||
"è obbligatorio su TUTTI i voli. Per un viaggio internazionale è necessario un passaporto valido o, dove consentita, una carta d’identità.",
|
||||
textAlignment: "PKTextAlignmentLeft",
|
||||
},
|
||||
{
|
||||
key: "yourSeat",
|
||||
label: "Il tuo posto:",
|
||||
value:
|
||||
"verifica il tuo numero di posto nella parte superiore. Durante l’imbarco utilizza le scale anteriori e posteriori: per le file 1-10 imbarcati dalla parte anteriore; per le file 11-31 imbarcati dalla parte posteriore. Colloca le borse di dimensioni ridotte sotto il sedile davanti a te.",
|
||||
textAlignment: "PKTextAlignmentLeft",
|
||||
},
|
||||
{
|
||||
key: "Pack safely",
|
||||
label: "Bagaglio sicuro",
|
||||
value:
|
||||
"Fai clic http://easyjet.com/it/articoli-pericolosi per maggiori informazioni sulle merci pericolose oppure visita il sito CAA http://www.caa.co.uk/default.aspx?catid=2200",
|
||||
textAlignment: "PKTextAlignmentLeft",
|
||||
},
|
||||
{
|
||||
key: "Thank you for travelling easyJet",
|
||||
label: "Grazie per aver viaggiato con easyJet",
|
||||
value: "",
|
||||
textAlignment: "PKTextAlignmentLeft",
|
||||
},
|
||||
);
|
||||
|
||||
const stream = pass.generate();
|
||||
response.set({
|
||||
"Content-type": "application/vnd.apple.pkpass",
|
||||
"Content-disposition": `attachment; filename=${passName}.pkpass`
|
||||
"Content-disposition": `attachment; filename=${passName}.pkpass`,
|
||||
});
|
||||
|
||||
stream.pipe(response);
|
||||
} catch(err) {
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
|
||||
response.set({
|
||||
"Content-type": "text/html"
|
||||
"Content-type": "text/html",
|
||||
});
|
||||
|
||||
response.send(err.message);
|
||||
|
||||
@@ -11,12 +11,14 @@ import fetch from "node-fetch";
|
||||
import { createPass } from "passkit-generator";
|
||||
|
||||
app.all(async function manageRequest(request, response) {
|
||||
let passName = request.params.modelName + "_" + (new Date()).toISOString().split('T')[0].replace(/-/ig, "");
|
||||
let passName =
|
||||
request.params.modelName +
|
||||
"_" +
|
||||
new Date().toISOString().split("T")[0].replace(/-/gi, "");
|
||||
|
||||
const avatar = await (
|
||||
fetch("https://s.gravatar.com/avatar/83cd11399b7ea79977bc302f3931ee52?size=32&default=retro")
|
||||
.then(res => res.buffer())
|
||||
);
|
||||
const avatar = await fetch(
|
||||
"https://s.gravatar.com/avatar/83cd11399b7ea79977bc302f3931ee52?size=32&default=retro",
|
||||
).then((res) => res.buffer());
|
||||
|
||||
const passConfig = {
|
||||
model: `./models/${request.params.modelName}`,
|
||||
@@ -25,8 +27,8 @@ app.all(async function manageRequest(request, response) {
|
||||
signerCert: "../certificates/signerCert.pem",
|
||||
signerKey: {
|
||||
keyFile: "../certificates/signerKey.pem",
|
||||
passphrase: "123456"
|
||||
}
|
||||
passphrase: "123456",
|
||||
},
|
||||
},
|
||||
overrides: request.body || request.params || request.query,
|
||||
};
|
||||
@@ -44,7 +46,7 @@ app.all(async function manageRequest(request, response) {
|
||||
|
||||
response.set({
|
||||
"Content-type": "application/vnd.apple.pkpass",
|
||||
"Content-disposition": `attachment; filename=${passName}.pkpass`
|
||||
"Content-disposition": `attachment; filename=${passName}.pkpass`,
|
||||
});
|
||||
|
||||
stream.pipe(response);
|
||||
|
||||
@@ -12,7 +12,10 @@ import app from "./webserver";
|
||||
import { createPass } from "passkit-generator";
|
||||
|
||||
app.all(async function manageRequest(request, response) {
|
||||
const passName = request.params.modelName + "_" + (new Date()).toISOString().split('T')[0].replace(/-/ig, "");
|
||||
const passName =
|
||||
request.params.modelName +
|
||||
"_" +
|
||||
new Date().toISOString().split("T")[0].replace(/-/gi, "");
|
||||
|
||||
try {
|
||||
const pass = await createPass({
|
||||
@@ -22,8 +25,8 @@ app.all(async function manageRequest(request, response) {
|
||||
signerCert: "../certificates/signerCert.pem",
|
||||
signerKey: {
|
||||
keyFile: "../certificates/signerKey.pem",
|
||||
passphrase: "123456"
|
||||
}
|
||||
passphrase: "123456",
|
||||
},
|
||||
},
|
||||
overrides: request.body || request.params || request.query,
|
||||
});
|
||||
@@ -37,17 +40,21 @@ app.all(async function manageRequest(request, response) {
|
||||
// After this, pass.props["barcodes"] will have support for just two of three
|
||||
// of the passed format (the valid ones);
|
||||
|
||||
pass.barcodes({
|
||||
message: "Thank you for using this package <3",
|
||||
format: "PKBarcodeFormatCode128"
|
||||
}, {
|
||||
message: "Thank you for using this package <3",
|
||||
format: "PKBarcodeFormatPDF417"
|
||||
}, {
|
||||
message: "Thank you for using this package <3",
|
||||
// @ts-expect-error
|
||||
format: "PKBarcodeFormatMock44617"
|
||||
});
|
||||
pass.barcodes(
|
||||
{
|
||||
message: "Thank you for using this package <3",
|
||||
format: "PKBarcodeFormatCode128",
|
||||
},
|
||||
{
|
||||
message: "Thank you for using this package <3",
|
||||
format: "PKBarcodeFormatPDF417",
|
||||
},
|
||||
{
|
||||
message: "Thank you for using this package <3",
|
||||
// @ts-expect-error
|
||||
format: "PKBarcodeFormatMock44617",
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
// You can change the format chosen for barcode prop support by calling .barcode()
|
||||
@@ -57,12 +64,15 @@ app.all(async function manageRequest(request, response) {
|
||||
pass.barcode("PKBarcodeFormatPDF417");
|
||||
|
||||
console.log("Barcode property is now:", pass.props["barcode"]);
|
||||
console.log("Barcodes support is autocompleted:", pass.props["barcodes"]);
|
||||
console.log(
|
||||
"Barcodes support is autocompleted:",
|
||||
pass.props["barcodes"],
|
||||
);
|
||||
|
||||
const stream = pass.generate();
|
||||
response.set({
|
||||
"Content-type": "application/vnd.apple.pkpass",
|
||||
"Content-disposition": `attachment; filename=${passName}.pkpass`
|
||||
"Content-disposition": `attachment; filename=${passName}.pkpass`,
|
||||
});
|
||||
|
||||
stream.pipe(response);
|
||||
|
||||
@@ -13,11 +13,16 @@ import { createPass } from "passkit-generator";
|
||||
|
||||
app.all(async function manageRequest(request, response) {
|
||||
if (!request.query.fn) {
|
||||
response.send("<a href='?fn=void'>Generate a voided pass.</a><br><a href='?fn=expiration'>Generate a pass with expiration date</a>");
|
||||
response.send(
|
||||
"<a href='?fn=void'>Generate a voided pass.</a><br><a href='?fn=expiration'>Generate a pass with expiration date</a>",
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
let passName = request.params.modelName + "_" + (new Date()).toISOString().split('T')[0].replace(/-/ig, "");
|
||||
let passName =
|
||||
request.params.modelName +
|
||||
"_" +
|
||||
new Date().toISOString().split("T")[0].replace(/-/gi, "");
|
||||
|
||||
try {
|
||||
let pass = await createPass({
|
||||
@@ -27,8 +32,8 @@ app.all(async function manageRequest(request, response) {
|
||||
signerCert: "../certificates/signerCert.pem",
|
||||
signerKey: {
|
||||
keyFile: "../certificates/signerKey.pem",
|
||||
passphrase: "123456"
|
||||
}
|
||||
passphrase: "123456",
|
||||
},
|
||||
},
|
||||
overrides: request.body || request.params || request.query,
|
||||
});
|
||||
@@ -47,7 +52,7 @@ app.all(async function manageRequest(request, response) {
|
||||
const stream = pass.generate();
|
||||
response.set({
|
||||
"Content-type": "application/vnd.apple.pkpass",
|
||||
"Content-disposition": `attachment; filename=${passName}.pkpass`
|
||||
"Content-disposition": `attachment; filename=${passName}.pkpass`,
|
||||
});
|
||||
|
||||
stream.pipe(response);
|
||||
|
||||
@@ -13,7 +13,10 @@ import app from "./webserver";
|
||||
import { createPass } from "passkit-generator";
|
||||
|
||||
app.all(async function manageRequest(request, response) {
|
||||
let passName = "exampleBooking" + "_" + (new Date()).toISOString().split('T')[0].replace(/-/ig, "");
|
||||
let passName =
|
||||
"exampleBooking" +
|
||||
"_" +
|
||||
new Date().toISOString().split("T")[0].replace(/-/gi, "");
|
||||
try {
|
||||
let pass = await createPass({
|
||||
model: `./models/exampleBooking`,
|
||||
@@ -22,133 +25,164 @@ app.all(async function manageRequest(request, response) {
|
||||
signerCert: "../certificates/signerCert.pem",
|
||||
signerKey: {
|
||||
keyFile: "../certificates/signerKey.pem",
|
||||
passphrase: "123456"
|
||||
}
|
||||
passphrase: "123456",
|
||||
},
|
||||
},
|
||||
overrides: request.body || request.params || request.query,
|
||||
});
|
||||
|
||||
pass.transitType = "PKTransitTypeAir";
|
||||
|
||||
pass.headerFields.push({
|
||||
"key": "header1",
|
||||
"label": "Data",
|
||||
"value": "25 mag",
|
||||
"textAlignment": "PKTextAlignmentCenter"
|
||||
}, {
|
||||
"key": "header2",
|
||||
"label": "Volo",
|
||||
"value": "EZY997",
|
||||
"textAlignment": "PKTextAlignmentCenter"
|
||||
});
|
||||
pass.headerFields.push(
|
||||
{
|
||||
key: "header1",
|
||||
label: "Data",
|
||||
value: "25 mag",
|
||||
textAlignment: "PKTextAlignmentCenter",
|
||||
},
|
||||
{
|
||||
key: "header2",
|
||||
label: "Volo",
|
||||
value: "EZY997",
|
||||
textAlignment: "PKTextAlignmentCenter",
|
||||
},
|
||||
);
|
||||
|
||||
pass.primaryFields.push({
|
||||
key: "IATA-source",
|
||||
value: "NAP",
|
||||
label: "Napoli",
|
||||
textAlignment: "PKTextAlignmentLeft"
|
||||
}, {
|
||||
key: "IATA-destination",
|
||||
value: "VCE",
|
||||
label: "Venezia Marco Polo",
|
||||
textAlignment: "PKTextAlignmentRight"
|
||||
});
|
||||
pass.primaryFields.push(
|
||||
{
|
||||
key: "IATA-source",
|
||||
value: "NAP",
|
||||
label: "Napoli",
|
||||
textAlignment: "PKTextAlignmentLeft",
|
||||
},
|
||||
{
|
||||
key: "IATA-destination",
|
||||
value: "VCE",
|
||||
label: "Venezia Marco Polo",
|
||||
textAlignment: "PKTextAlignmentRight",
|
||||
},
|
||||
);
|
||||
|
||||
pass.secondaryFields.push({
|
||||
"key": "secondary1",
|
||||
"label": "Imbarco chiuso",
|
||||
"value": "18:40",
|
||||
"textAlignment": "PKTextAlignmentCenter",
|
||||
}, {
|
||||
"key": "sec2",
|
||||
"label": "Partenze",
|
||||
"value": "19:10",
|
||||
"textAlignment": "PKTextAlignmentCenter"
|
||||
}, {
|
||||
"key": "sec3",
|
||||
"label": "SB",
|
||||
"value": "Sì",
|
||||
"textAlignment": "PKTextAlignmentCenter"
|
||||
}, {
|
||||
"key": "sec4",
|
||||
"label": "Imbarco",
|
||||
"value": "Anteriore",
|
||||
"textAlignment": "PKTextAlignmentCenter"
|
||||
});
|
||||
pass.secondaryFields.push(
|
||||
{
|
||||
key: "secondary1",
|
||||
label: "Imbarco chiuso",
|
||||
value: "18:40",
|
||||
textAlignment: "PKTextAlignmentCenter",
|
||||
},
|
||||
{
|
||||
key: "sec2",
|
||||
label: "Partenze",
|
||||
value: "19:10",
|
||||
textAlignment: "PKTextAlignmentCenter",
|
||||
},
|
||||
{
|
||||
key: "sec3",
|
||||
label: "SB",
|
||||
value: "Sì",
|
||||
textAlignment: "PKTextAlignmentCenter",
|
||||
},
|
||||
{
|
||||
key: "sec4",
|
||||
label: "Imbarco",
|
||||
value: "Anteriore",
|
||||
textAlignment: "PKTextAlignmentCenter",
|
||||
},
|
||||
);
|
||||
|
||||
pass.auxiliaryFields.push({
|
||||
"key": "aux1",
|
||||
"label": "Passeggero",
|
||||
"value": "MR. WHO KNOWS",
|
||||
"textAlignment": "PKTextAlignmentLeft"
|
||||
}, {
|
||||
"key": "aux2",
|
||||
"label": "Posto",
|
||||
"value": "1A*",
|
||||
"textAlignment": "PKTextAlignmentCenter"
|
||||
});
|
||||
pass.auxiliaryFields.push(
|
||||
{
|
||||
key: "aux1",
|
||||
label: "Passeggero",
|
||||
value: "MR. WHO KNOWS",
|
||||
textAlignment: "PKTextAlignmentLeft",
|
||||
},
|
||||
{
|
||||
key: "aux2",
|
||||
label: "Posto",
|
||||
value: "1A*",
|
||||
textAlignment: "PKTextAlignmentCenter",
|
||||
},
|
||||
);
|
||||
|
||||
pass.backFields.push({
|
||||
"key": "document number",
|
||||
"label": "Numero documento:",
|
||||
"value": "- -",
|
||||
"textAlignment": "PKTextAlignmentLeft"
|
||||
}, {
|
||||
"key": "You're checked in, what next",
|
||||
"label": "Hai effettuato il check-in, Quali sono le prospettive",
|
||||
"value": "",
|
||||
"textAlignment": "PKTextAlignmentLeft"
|
||||
}, {
|
||||
"key": "Check In",
|
||||
"label": "1. check-in✓",
|
||||
"value": "",
|
||||
"textAlignment": "PKTextAlignmentLeft"
|
||||
}, {
|
||||
"key": "checkIn",
|
||||
"label": "",
|
||||
"value": "Le uscite d'imbarco chiudono 30 minuti prima della partenza, quindi sii puntuale. In questo aeroporto puoi utilizzare la corsia Fast Track ai varchi di sicurezza.",
|
||||
"textAlignment": "PKTextAlignmentLeft"
|
||||
}, {
|
||||
"key": "2. Bags",
|
||||
"label": "2. Bagaglio",
|
||||
"value": "",
|
||||
"textAlignment": "PKTextAlignmentLeft"
|
||||
}, {
|
||||
"key": "Require special assistance",
|
||||
"label": "Assistenza speciale",
|
||||
"value": "Se hai richiesto assistenza speciale, presentati a un membro del personale nell'area di Consegna bagagli almeno 90 minuti prima del volo.",
|
||||
"textAlignment": "PKTextAlignmentLeft"
|
||||
}, {
|
||||
"key": "3. Departures",
|
||||
"label": "3. Partenze",
|
||||
"value": "",
|
||||
"textAlignment": "PKTextAlignmentLeft"
|
||||
}, {
|
||||
"key": "photoId",
|
||||
"label": "Un documento d’identità corredato di fotografia",
|
||||
"value": "è obbligatorio su TUTTI i voli. Per un viaggio internazionale è necessario un passaporto valido o, dove consentita, una carta d’identità.",
|
||||
"textAlignment": "PKTextAlignmentLeft"
|
||||
}, {
|
||||
"key": "yourSeat",
|
||||
"label": "Il tuo posto:",
|
||||
"value": "verifica il tuo numero di posto nella parte superiore. Durante l’imbarco utilizza le scale anteriori e posteriori: per le file 1-10 imbarcati dalla parte anteriore; per le file 11-31 imbarcati dalla parte posteriore. Colloca le borse di dimensioni ridotte sotto il sedile davanti a te.",
|
||||
"textAlignment": "PKTextAlignmentLeft"
|
||||
}, {
|
||||
"key": "Pack safely",
|
||||
"label": "Bagaglio sicuro",
|
||||
"value": "Fai clic http://easyjet.com/it/articoli-pericolosi per maggiori informazioni sulle merci pericolose oppure visita il sito CAA http://www.caa.co.uk/default.aspx?catid=2200",
|
||||
"textAlignment": "PKTextAlignmentLeft"
|
||||
}, {
|
||||
"key": "Thank you for travelling easyJet",
|
||||
"label": "Grazie per aver viaggiato con easyJet",
|
||||
"value": "",
|
||||
"textAlignment": "PKTextAlignmentLeft"
|
||||
});
|
||||
pass.backFields.push(
|
||||
{
|
||||
key: "document number",
|
||||
label: "Numero documento:",
|
||||
value: "- -",
|
||||
textAlignment: "PKTextAlignmentLeft",
|
||||
},
|
||||
{
|
||||
key: "You're checked in, what next",
|
||||
label: "Hai effettuato il check-in, Quali sono le prospettive",
|
||||
value: "",
|
||||
textAlignment: "PKTextAlignmentLeft",
|
||||
},
|
||||
{
|
||||
key: "Check In",
|
||||
label: "1. check-in✓",
|
||||
value: "",
|
||||
textAlignment: "PKTextAlignmentLeft",
|
||||
},
|
||||
{
|
||||
key: "checkIn",
|
||||
label: "",
|
||||
value:
|
||||
"Le uscite d'imbarco chiudono 30 minuti prima della partenza, quindi sii puntuale. In questo aeroporto puoi utilizzare la corsia Fast Track ai varchi di sicurezza.",
|
||||
textAlignment: "PKTextAlignmentLeft",
|
||||
},
|
||||
{
|
||||
key: "2. Bags",
|
||||
label: "2. Bagaglio",
|
||||
value: "",
|
||||
textAlignment: "PKTextAlignmentLeft",
|
||||
},
|
||||
{
|
||||
key: "Require special assistance",
|
||||
label: "Assistenza speciale",
|
||||
value:
|
||||
"Se hai richiesto assistenza speciale, presentati a un membro del personale nell'area di Consegna bagagli almeno 90 minuti prima del volo.",
|
||||
textAlignment: "PKTextAlignmentLeft",
|
||||
},
|
||||
{
|
||||
key: "3. Departures",
|
||||
label: "3. Partenze",
|
||||
value: "",
|
||||
textAlignment: "PKTextAlignmentLeft",
|
||||
},
|
||||
{
|
||||
key: "photoId",
|
||||
label: "Un documento d’identità corredato di fotografia",
|
||||
value:
|
||||
"è obbligatorio su TUTTI i voli. Per un viaggio internazionale è necessario un passaporto valido o, dove consentita, una carta d’identità.",
|
||||
textAlignment: "PKTextAlignmentLeft",
|
||||
},
|
||||
{
|
||||
key: "yourSeat",
|
||||
label: "Il tuo posto:",
|
||||
value:
|
||||
"verifica il tuo numero di posto nella parte superiore. Durante l’imbarco utilizza le scale anteriori e posteriori: per le file 1-10 imbarcati dalla parte anteriore; per le file 11-31 imbarcati dalla parte posteriore. Colloca le borse di dimensioni ridotte sotto il sedile davanti a te.",
|
||||
textAlignment: "PKTextAlignmentLeft",
|
||||
},
|
||||
{
|
||||
key: "Pack safely",
|
||||
label: "Bagaglio sicuro",
|
||||
value:
|
||||
"Fai clic http://easyjet.com/it/articoli-pericolosi per maggiori informazioni sulle merci pericolose oppure visita il sito CAA http://www.caa.co.uk/default.aspx?catid=2200",
|
||||
textAlignment: "PKTextAlignmentLeft",
|
||||
},
|
||||
{
|
||||
key: "Thank you for travelling easyJet",
|
||||
label: "Grazie per aver viaggiato con easyJet",
|
||||
value: "",
|
||||
textAlignment: "PKTextAlignmentLeft",
|
||||
},
|
||||
);
|
||||
|
||||
const stream = pass.generate();
|
||||
response.set({
|
||||
"Content-type": "application/vnd.apple.pkpass",
|
||||
"Content-disposition": `attachment; filename=${passName}.pkpass`
|
||||
"Content-disposition": `attachment; filename=${passName}.pkpass`,
|
||||
});
|
||||
|
||||
stream.pipe(response);
|
||||
@@ -156,7 +190,7 @@ app.all(async function manageRequest(request, response) {
|
||||
console.log(err);
|
||||
|
||||
response.set({
|
||||
"Content-type": "text/html"
|
||||
"Content-type": "text/html",
|
||||
});
|
||||
|
||||
response.send(err.message);
|
||||
|
||||
@@ -8,7 +8,10 @@ import app from "./webserver";
|
||||
import { createPass } from "passkit-generator";
|
||||
|
||||
app.all(async function manageRequest(request, response) {
|
||||
const passName = request.params.modelName + "_" + (new Date()).toISOString().split('T')[0].replace(/-/ig, "");
|
||||
const passName =
|
||||
request.params.modelName +
|
||||
"_" +
|
||||
new Date().toISOString().split("T")[0].replace(/-/gi, "");
|
||||
|
||||
try {
|
||||
const pass = await createPass({
|
||||
@@ -18,10 +21,10 @@ app.all(async function manageRequest(request, response) {
|
||||
signerCert: "../certificates/signerCert.pem",
|
||||
signerKey: {
|
||||
keyFile: "../certificates/signerKey.pem",
|
||||
passphrase: "123456"
|
||||
}
|
||||
passphrase: "123456",
|
||||
},
|
||||
},
|
||||
overrides: request.body || request.params || request.query
|
||||
overrides: request.body || request.params || request.query,
|
||||
});
|
||||
|
||||
// For each language you include, an .lproj folder in pass bundle
|
||||
@@ -38,30 +41,33 @@ app.all(async function manageRequest(request, response) {
|
||||
|
||||
// Italian, already has an .lproj which gets included
|
||||
pass.localize("it", {
|
||||
"EVENT": "Evento",
|
||||
"LOCATION": "Dove"
|
||||
EVENT: "Evento",
|
||||
LOCATION: "Dove",
|
||||
});
|
||||
|
||||
// German, doesn't, so is created
|
||||
pass.localize("de", {
|
||||
"EVENT": "Ereignis",
|
||||
"LOCATION": "Ort"
|
||||
EVENT: "Ereignis",
|
||||
LOCATION: "Ort",
|
||||
});
|
||||
|
||||
// This language does not exist but is still added as .lproj folder
|
||||
pass.localize("zu", {});
|
||||
|
||||
// @ts-ignore - ignoring for logging purposes. Do not replicate
|
||||
console.log("Added languages", Object.keys(pass.l10nTranslations).join(", "))
|
||||
console.log(
|
||||
"Added languages",
|
||||
Object.keys(pass.l10nTranslations).join(", "),
|
||||
);
|
||||
|
||||
const stream = pass.generate();
|
||||
response.set({
|
||||
"Content-type": "application/vnd.apple.pkpass",
|
||||
"Content-disposition": `attachment; filename=${passName}.pkpass`
|
||||
"Content-disposition": `attachment; filename=${passName}.pkpass`,
|
||||
});
|
||||
|
||||
stream.pipe(response);
|
||||
} catch(err) {
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
|
||||
response.set({
|
||||
|
||||
@@ -1,49 +1,51 @@
|
||||
{
|
||||
"formatVersion": 1,
|
||||
"passTypeIdentifier": "pass.com.example.myapp",
|
||||
"serialNumber": "nmyuxofgna",
|
||||
"teamIdentifier": "F53WB8AE67",
|
||||
"webServiceURL": "https://192.168.1.254:80/",
|
||||
"authenticationToken": "vxwxd7J8AlNNFPS8k0a0FfUFtq0ewzFdc",
|
||||
"relevantDate": "2011-12-08T13:00-08:00",
|
||||
"locations": [
|
||||
{
|
||||
"longitude": -122.3748889,
|
||||
"latitude": 37.6189722
|
||||
},
|
||||
{
|
||||
"longitude": -122.03118,
|
||||
"latitude": 37.33182
|
||||
}
|
||||
],
|
||||
"barcodes": [{
|
||||
"message": "123456789",
|
||||
"format": "PKBarcodeFormatQR",
|
||||
"messageEncoding": "iso-8859-1"
|
||||
}],
|
||||
"barcode": {
|
||||
"message": "123456789",
|
||||
"format": "PKBarcodeFormatQR",
|
||||
"messageEncoding": "iso-8859-1"
|
||||
},
|
||||
"organizationName": "Apple Inc.",
|
||||
"description": "Apple Event Ticket",
|
||||
"foregroundColor": "rgb(255, 255, 255)",
|
||||
"backgroundColor": "rgb(60, 65, 76)",
|
||||
"eventTicket": {
|
||||
"primaryFields": [
|
||||
{
|
||||
"key": "event",
|
||||
"label": "EVENT",
|
||||
"value": "The Beat Goes On"
|
||||
}
|
||||
],
|
||||
"secondaryFields": [
|
||||
{
|
||||
"key": "loc",
|
||||
"label": "LOCATION",
|
||||
"value": "Moscone West"
|
||||
}
|
||||
]
|
||||
}
|
||||
"formatVersion": 1,
|
||||
"passTypeIdentifier": "pass.com.example.myapp",
|
||||
"serialNumber": "nmyuxofgna",
|
||||
"teamIdentifier": "F53WB8AE67",
|
||||
"webServiceURL": "https://192.168.1.254:80/",
|
||||
"authenticationToken": "vxwxd7J8AlNNFPS8k0a0FfUFtq0ewzFdc",
|
||||
"relevantDate": "2011-12-08T13:00-08:00",
|
||||
"locations": [
|
||||
{
|
||||
"longitude": -122.3748889,
|
||||
"latitude": 37.6189722
|
||||
},
|
||||
{
|
||||
"longitude": -122.03118,
|
||||
"latitude": 37.33182
|
||||
}
|
||||
],
|
||||
"barcodes": [
|
||||
{
|
||||
"message": "123456789",
|
||||
"format": "PKBarcodeFormatQR",
|
||||
"messageEncoding": "iso-8859-1"
|
||||
}
|
||||
],
|
||||
"barcode": {
|
||||
"message": "123456789",
|
||||
"format": "PKBarcodeFormatQR",
|
||||
"messageEncoding": "iso-8859-1"
|
||||
},
|
||||
"organizationName": "Apple Inc.",
|
||||
"description": "Apple Event Ticket",
|
||||
"foregroundColor": "rgb(255, 255, 255)",
|
||||
"backgroundColor": "rgb(60, 65, 76)",
|
||||
"eventTicket": {
|
||||
"primaryFields": [
|
||||
{
|
||||
"key": "event",
|
||||
"label": "EVENT",
|
||||
"value": "The Beat Goes On"
|
||||
}
|
||||
],
|
||||
"secondaryFields": [
|
||||
{
|
||||
"key": "loc",
|
||||
"label": "LOCATION",
|
||||
"value": "Moscone West"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
1116
examples/package-lock.json
generated
1116
examples/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -3,7 +3,5 @@
|
||||
"compilerOptions": {
|
||||
"outDir": "build"
|
||||
},
|
||||
"exclude": [
|
||||
"node_modules"
|
||||
]
|
||||
"exclude": ["node_modules"]
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ export const app = express();
|
||||
|
||||
app.use(express.json());
|
||||
|
||||
app.listen(8080, "0.0.0.0", function(request, response) {
|
||||
app.listen(8080, "0.0.0.0", function (request, response) {
|
||||
console.log("Webserver started.");
|
||||
});
|
||||
|
||||
@@ -17,10 +17,11 @@ app.all("/", function (request, response) {
|
||||
response.redirect("/gen/");
|
||||
});
|
||||
|
||||
app.route("/gen")
|
||||
.all((req, res) => {
|
||||
res.set("Content-Type", "text/html");
|
||||
res.send("Cannot generate a pass. Specify a modelName in the url to continue. <br/>Usage: /gen/<i>modelName</i>")
|
||||
});
|
||||
app.route("/gen").all((req, res) => {
|
||||
res.set("Content-Type", "text/html");
|
||||
res.send(
|
||||
"Cannot generate a pass. Specify a modelName in the url to continue. <br/>Usage: /gen/<i>modelName</i>",
|
||||
);
|
||||
});
|
||||
|
||||
export default app.route("/gen/:modelName");
|
||||
|
||||
Reference in New Issue
Block a user