Fixed missing __dirname in all the self-hosted examples

This commit is contained in:
Alexander Cerutti
2025-09-18 01:02:44 +02:00
parent d823ebf5b6
commit 95dfb64747
5 changed files with 24 additions and 4 deletions

View File

@@ -29,11 +29,14 @@
* A feedback to Apple have been sent for this. * 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 { app } from "./webserver.js";
import { getCertificates } from "./shared.js"; import { getCertificates } from "./shared.js";
import { promises as fs } from "node:fs";
import path from "node:path"; const __dirname = path.dirname(fileURLToPath(import.meta.url));
import { PKPass } from "passkit-generator";
// *************************** // // *************************** //
// *** EXAMPLE FROM NOW ON *** // // *** EXAMPLE FROM NOW ON *** //

View File

@@ -5,10 +5,13 @@
*/ */
import path from "node:path"; import path from "node:path";
import { fileURLToPath } from "node:url";
import { PKPass } from "passkit-generator"; import { PKPass } from "passkit-generator";
import { app } from "./webserver.js"; import { app } from "./webserver.js";
import { getCertificates } from "./shared.js"; import { getCertificates } from "./shared.js";
const __dirname = path.dirname(fileURLToPath(import.meta.url));
app.route("/localize/:modelName").get(async (request, response) => { app.route("/localize/:modelName").get(async (request, response) => {
const passName = const passName =
request.params.modelName + request.params.modelName +
@@ -31,7 +34,12 @@ app.route("/localize/:modelName").get(async (request, response) => {
signerKeyPassphrase: certificates.signerKeyPassphrase, 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... // Italian, already has an .lproj which gets included...

View File

@@ -5,10 +5,13 @@
import path from "node:path"; import path from "node:path";
import { promises as fs } from "node:fs"; import { promises as fs } from "node:fs";
import { fileURLToPath } from "node:url";
import { PKPass } from "passkit-generator"; import { PKPass } from "passkit-generator";
import { app } from "./webserver.js"; import { app } from "./webserver.js";
import { getCertificates } from "./shared.js"; import { getCertificates } from "./shared.js";
const __dirname = path.dirname(fileURLToPath(import.meta.url));
function getRandomColorPart() { function getRandomColorPart() {
return Math.floor(Math.random() * 255); return Math.floor(Math.random() * 255);
} }

View File

@@ -10,9 +10,12 @@
import { PKPass } from "passkit-generator"; import { PKPass } from "passkit-generator";
import path from "node:path"; import path from "node:path";
import { fileURLToPath } from "node:url";
import { app } from "./webserver.js"; import { app } from "./webserver.js";
import { getCertificates } from "./shared.js"; import { getCertificates } from "./shared.js";
const __dirname = path.dirname(fileURLToPath(import.meta.url));
app.route("/barcodes/:modelName").get(async (request, response) => { app.route("/barcodes/:modelName").get(async (request, response) => {
const passName = const passName =
request.params.modelName + request.params.modelName +

View File

@@ -8,10 +8,13 @@
*/ */
import path from "node:path"; import path from "node:path";
import { fileURLToPath } from "node:url";
import { PKPass } from "passkit-generator"; import { PKPass } from "passkit-generator";
import { app } from "./webserver.js"; import { app } from "./webserver.js";
import { getCertificates } from "./shared.js"; import { getCertificates } from "./shared.js";
const __dirname = path.dirname(fileURLToPath(import.meta.url));
app.route("/expirationDate/:modelName").get(async (request, response) => { app.route("/expirationDate/:modelName").get(async (request, response) => {
if (!request.query.fn) { if (!request.query.fn) {
response.send( response.send(