From d5b3bba782a16e886b5bacc27af012e6129a6792 Mon Sep 17 00:00:00 2001 From: Alexander Cerutti Date: Fri, 17 Jan 2025 23:09:17 +0100 Subject: [PATCH] Improved examples code --- examples/self-hosted/src/PKPass.from.ts | 8 ++++---- examples/self-hosted/src/scratch.ts | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/self-hosted/src/PKPass.from.ts b/examples/self-hosted/src/PKPass.from.ts index c2f81cf..2875b0b 100644 --- a/examples/self-hosted/src/PKPass.from.ts +++ b/examples/self-hosted/src/PKPass.from.ts @@ -32,11 +32,11 @@ export function removeHidden(from: Array): Array { async function readFileOrDirectory(filePath: string) { if ((await fs.lstat(filePath)).isDirectory()) { return Promise.all(await readDirectory(filePath)); - } else { - return fs - .readFile(filePath) - .then((content) => getObjectFromModelFile(filePath, content, 1)); } + + const fileBuffer = await fs.readFile(filePath); + + return getObjectFromModelFile(filePath, fileBuffer, 1); } /** diff --git a/examples/self-hosted/src/scratch.ts b/examples/self-hosted/src/scratch.ts index 1312709..654d8a3 100644 --- a/examples/self-hosted/src/scratch.ts +++ b/examples/self-hosted/src/scratch.ts @@ -26,7 +26,7 @@ app.route("/scratch/:modelName").get(async (request, response) => { "../../models/exampleBooking.pass/icon.png", ), ), - await getCertificates(), + getCertificates(), ]); try {