mirror of
https://github.com/marcogll/passkit-generator.git
synced 2026-03-15 14:25:17 +00:00
Fixed a few things in example
This commit is contained in:
@@ -1,28 +1,29 @@
|
|||||||
const functions = require("firebase-functions");
|
const functions = require("firebase-functions");
|
||||||
const admin = require("firebase-admin");
|
const admin = require("firebase-admin");
|
||||||
const { PKPass } = require("passkit-generator");
|
const { PKPass } = require("passkit-generator");
|
||||||
var fs = require("node:fs");
|
const fs = require("node:fs");
|
||||||
var path = require("node:path");
|
const path = require("node:path");
|
||||||
var axios = require("axios");
|
const axios = require("axios");
|
||||||
var os = require("node:os");
|
const os = require("node:os");
|
||||||
|
|
||||||
// Firebase init
|
// Firebase init
|
||||||
admin.initializeApp({
|
admin.initializeApp({
|
||||||
credential: admin.credential.cert(require("CERTIFICATE_PATH")),
|
credential: admin.credential.cert(require("CERTIFICATE_PATH")),
|
||||||
storageBucket: "STORAGE_BUCKET_URL",
|
storageBucket: "STORAGE_BUCKET_URL",
|
||||||
});
|
});
|
||||||
var storageRef = admin.storage().bucket();
|
|
||||||
|
|
||||||
exports.pass = functions.https.onRequest((request, response) => {
|
const storageRef = admin.storage().bucket();
|
||||||
PKPass.from(
|
|
||||||
|
exports.pass = functions.https.onRequest(async (request, response) => {
|
||||||
|
const newPass = await PKPass.from(
|
||||||
{
|
{
|
||||||
// Get relevant pass model from model folder (see passkit-generator/examples/models/)
|
// Get relevant pass model from model folder (see passkit-generator/examples/models/)
|
||||||
model: `./model/${request.body.passType}.pass`,
|
model: `./model/${request.body.passType}.pass`,
|
||||||
certificates: {
|
certificates: {
|
||||||
// Assigning certificates from certs folder (you will need to provide these yourself)
|
// Assigning certificates from certs folder (you will need to provide these yourself)
|
||||||
wwdr: fs.fs.readFileSync("./certs/wwdr.pem"),
|
wwdr: fs.readFileSync("./certs/wwdr.pem"),
|
||||||
signerCert: fs.fs.readFileSync("./certs/signerCert.pem"),
|
signerCert: fs.readFileSync("./certs/signerCert.pem"),
|
||||||
signerKey: fs.fs.readFileSync("./certs/signerKey.pem"),
|
signerKey: fs.readFileSync("./certs/signerKey.pem"),
|
||||||
signerKeyPassphrase: "PASSPHRASE",
|
signerKeyPassphrase: "PASSPHRASE",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -34,7 +35,8 @@ exports.pass = functions.https.onRequest((request, response) => {
|
|||||||
backgroundColor: request.body.backgroundColor,
|
backgroundColor: request.body.backgroundColor,
|
||||||
labelColor: request.body.labelColor,
|
labelColor: request.body.labelColor,
|
||||||
},
|
},
|
||||||
).then(async (newPass) => {
|
);
|
||||||
|
|
||||||
let currentPassType = request.body.passType;
|
let currentPassType = request.body.passType;
|
||||||
|
|
||||||
if (currentPassType == "boardingPass") {
|
if (currentPassType == "boardingPass") {
|
||||||
@@ -201,4 +203,3 @@ exports.pass = functions.https.onRequest((request, response) => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|||||||
Reference in New Issue
Block a user