mirror of
https://github.com/marcogll/passkit-generator.git
synced 2026-03-15 14:25:17 +00:00
Changed self-hosted to run on ESM
This commit is contained in:
@@ -5,10 +5,11 @@
|
||||
"description": "Passkit-generator self-hosted examples",
|
||||
"author": "Alexander P. Cerutti <cerutti.alexander@gmail.com>",
|
||||
"license": "ISC",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"clear:deps": "rm -rf node_modules",
|
||||
"example": "pnpm ts-node src/index.ts",
|
||||
"example:debug": "node -r ts-node/register --inspect-brk src/index.ts"
|
||||
"example": "pnpm tsx src/index.ts",
|
||||
"example:debug": "pnpm tsx --inspect-brk src/index.ts"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"passkit-generator": "workspace:*"
|
||||
@@ -22,7 +23,7 @@
|
||||
"devDependencies": {
|
||||
"@types/express": "5.0.0",
|
||||
"@types/express-serve-static-core": "^5.0.4",
|
||||
"ts-node": "^10.9.2",
|
||||
"tsx": "^4.19.2",
|
||||
"typescript": "^5.7.3"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,18 +5,30 @@
|
||||
* examples, creation through templates is already shown
|
||||
*/
|
||||
|
||||
import { app } from "./webserver";
|
||||
import { getCertificates } from "./shared";
|
||||
import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { promises as fs } from "node:fs";
|
||||
import { PKPass } from "passkit-generator";
|
||||
import { app } from "./webserver.js";
|
||||
import { getCertificates } from "./shared.js";
|
||||
|
||||
import * as Utils from "passkit-generator/lib/utils";
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
|
||||
// ******************************************** //
|
||||
// *** CODE FROM GET MODEL FOLDER INTERNALS *** //
|
||||
// ******************************************** //
|
||||
|
||||
/**
|
||||
* Removes hidden files from a list (those starting with dot)
|
||||
*
|
||||
* @params from - list of file names
|
||||
* @return
|
||||
*/
|
||||
|
||||
export function removeHidden(from: Array<string>): Array<string> {
|
||||
return from.filter((e) => e.charAt(0) !== ".");
|
||||
}
|
||||
|
||||
async function readFileOrDirectory(filePath: string) {
|
||||
if ((await fs.lstat(filePath)).isDirectory()) {
|
||||
return Promise.all(await readDirectory(filePath));
|
||||
@@ -59,7 +71,7 @@ function getObjectFromModelFile(
|
||||
*/
|
||||
|
||||
async function readDirectory(filePath: string) {
|
||||
const dirContent = await fs.readdir(filePath).then(Utils.removeHidden);
|
||||
const dirContent = await fs.readdir(filePath).then(removeHidden);
|
||||
|
||||
return dirContent.map(async (fileName) => {
|
||||
const content = await fs.readFile(path.resolve(filePath, fileName));
|
||||
|
||||
@@ -29,8 +29,8 @@
|
||||
* A feedback to Apple have been sent for this.
|
||||
*/
|
||||
|
||||
import { app } from "./webserver";
|
||||
import { getCertificates } from "./shared";
|
||||
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";
|
||||
|
||||
@@ -9,10 +9,10 @@
|
||||
* @Author: Alexander P. Cerutti
|
||||
*/
|
||||
|
||||
import { app } from "./webserver";
|
||||
import { getCertificates } from "./shared";
|
||||
import path from "node:path";
|
||||
import { PKPass } from "passkit-generator";
|
||||
import { app } from "./webserver.js";
|
||||
import { getCertificates } from "./shared.js";
|
||||
|
||||
app.route("/fields/:modelName").get(async (request, response) => {
|
||||
const passName =
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import "./fields";
|
||||
import "./localize";
|
||||
import "./PKPass.from";
|
||||
import "./PKPasses";
|
||||
import "./scratch";
|
||||
import "./setBarcodes";
|
||||
import "./setExpirationDate";
|
||||
import "./fields.js";
|
||||
import "./localize.js";
|
||||
import "./PKPass.from.js";
|
||||
import "./PKPasses.js";
|
||||
import "./scratch.js";
|
||||
import "./setBarcodes.js";
|
||||
import "./setExpirationDate.js";
|
||||
|
||||
@@ -4,10 +4,10 @@
|
||||
* .pkpass file and check for .lproj folders
|
||||
*/
|
||||
|
||||
import { app } from "./webserver";
|
||||
import { getCertificates } from "./shared";
|
||||
import path from "node:path";
|
||||
import { PKPass } from "passkit-generator";
|
||||
import { app } from "./webserver.js";
|
||||
import { getCertificates } from "./shared.js";
|
||||
|
||||
app.route("/localize/:modelName").get(async (request, response) => {
|
||||
const passName =
|
||||
|
||||
@@ -3,11 +3,11 @@
|
||||
* by adding files later and not adding pass.json
|
||||
*/
|
||||
|
||||
import { app } from "./webserver";
|
||||
import { getCertificates } from "./shared";
|
||||
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";
|
||||
|
||||
function getRandomColorPart() {
|
||||
return Math.floor(Math.random() * 255);
|
||||
|
||||
@@ -8,10 +8,10 @@
|
||||
* by a string
|
||||
*/
|
||||
|
||||
import { app } from "./webserver";
|
||||
import { getCertificates } from "./shared";
|
||||
import { PKPass } from "passkit-generator";
|
||||
import path from "node:path";
|
||||
import { app } from "./webserver.js";
|
||||
import { getCertificates } from "./shared.js";
|
||||
|
||||
app.route("/barcodes/:modelName").get(async (request, response) => {
|
||||
const passName =
|
||||
|
||||
@@ -7,10 +7,10 @@
|
||||
* have to wait two minutes.
|
||||
*/
|
||||
|
||||
import { app } from "./webserver";
|
||||
import { getCertificates } from "./shared";
|
||||
import path from "node:path";
|
||||
import { PKPass } from "passkit-generator";
|
||||
import { app } from "./webserver.js";
|
||||
import { getCertificates } from "./shared.js";
|
||||
|
||||
app.route("/expirationDate/:modelName").get(async (request, response) => {
|
||||
if (!request.query.fn) {
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
import fs from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
|
||||
interface Cache {
|
||||
certificates:
|
||||
|
||||
@@ -2,9 +2,7 @@
|
||||
"extends": "../../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"target": "ESNext",
|
||||
"module": "CommonJS",
|
||||
"outDir": "build",
|
||||
"moduleResolution": "node",
|
||||
"sourceMap": true,
|
||||
"useUnknownInCatchVariables": false
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user