diff --git a/examples/self-hosted/src/PKPasses.ts b/examples/self-hosted/src/PKPasses.ts index 368aa89..cb6e759 100644 --- a/examples/self-hosted/src/PKPasses.ts +++ b/examples/self-hosted/src/PKPasses.ts @@ -29,11 +29,14 @@ * A feedback to Apple have been sent for this. */ +import { fileURLToPath } from "node:url"; +import path from "node:path"; +import { promises as fs } from "node:fs"; +import { PKPass } from "passkit-generator"; import { app } from "./webserver.js"; import { getCertificates } from "./shared.js"; -import { promises as fs } from "node:fs"; -import path from "node:path"; -import { PKPass } from "passkit-generator"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); // *************************** // // *** EXAMPLE FROM NOW ON *** // diff --git a/examples/self-hosted/src/localize.ts b/examples/self-hosted/src/localize.ts index 4eb87cf..6fff96e 100644 --- a/examples/self-hosted/src/localize.ts +++ b/examples/self-hosted/src/localize.ts @@ -5,10 +5,13 @@ */ import path from "node:path"; +import { fileURLToPath } from "node:url"; import { PKPass } from "passkit-generator"; import { app } from "./webserver.js"; import { getCertificates } from "./shared.js"; +const __dirname = path.dirname(fileURLToPath(import.meta.url)); + app.route("/localize/:modelName").get(async (request, response) => { const passName = request.params.modelName + @@ -31,7 +34,12 @@ app.route("/localize/:modelName").get(async (request, response) => { signerKeyPassphrase: certificates.signerKeyPassphrase, }, }, - request.body || request.params || request.query, + Object.assign( + { + serialNumber: Math.random().toString(36).substring(2, 15), + }, + request.body || request.query || {}, + ), ); // Italian, already has an .lproj which gets included... diff --git a/examples/self-hosted/src/scratch.ts b/examples/self-hosted/src/scratch.ts index 654d8a3..a15e2e3 100644 --- a/examples/self-hosted/src/scratch.ts +++ b/examples/self-hosted/src/scratch.ts @@ -5,10 +5,13 @@ import path from "node:path"; import { promises as fs } from "node:fs"; +import { fileURLToPath } from "node:url"; import { PKPass } from "passkit-generator"; import { app } from "./webserver.js"; import { getCertificates } from "./shared.js"; +const __dirname = path.dirname(fileURLToPath(import.meta.url)); + function getRandomColorPart() { return Math.floor(Math.random() * 255); } diff --git a/examples/self-hosted/src/setBarcodes.ts b/examples/self-hosted/src/setBarcodes.ts index b620d98..54fed2b 100644 --- a/examples/self-hosted/src/setBarcodes.ts +++ b/examples/self-hosted/src/setBarcodes.ts @@ -10,9 +10,12 @@ import { PKPass } from "passkit-generator"; import path from "node:path"; +import { fileURLToPath } from "node:url"; import { app } from "./webserver.js"; import { getCertificates } from "./shared.js"; +const __dirname = path.dirname(fileURLToPath(import.meta.url)); + app.route("/barcodes/:modelName").get(async (request, response) => { const passName = request.params.modelName + diff --git a/examples/self-hosted/src/setExpirationDate.ts b/examples/self-hosted/src/setExpirationDate.ts index 4c341c9..6670af2 100644 --- a/examples/self-hosted/src/setExpirationDate.ts +++ b/examples/self-hosted/src/setExpirationDate.ts @@ -8,10 +8,13 @@ */ import path from "node:path"; +import { fileURLToPath } from "node:url"; import { PKPass } from "passkit-generator"; import { app } from "./webserver.js"; import { getCertificates } from "./shared.js"; +const __dirname = path.dirname(fileURLToPath(import.meta.url)); + app.route("/expirationDate/:modelName").get(async (request, response) => { if (!request.query.fn) { response.send(