Updated firebase function example

This commit is contained in:
Alexander Cerutti
2025-01-11 15:56:51 +01:00
parent 8c8763f8cd
commit aae3ad5982
3 changed files with 1098 additions and 967 deletions

View File

@@ -10,23 +10,24 @@
"build": "rm -rf lib && pnpm tsc"
},
"engines": {
"node": "16"
"node": "20"
},
"type": "module",
"main": "lib/index.js",
"dependencies": {
"firebase-admin": "^11.11.1",
"firebase-functions": "^4.9.0",
"tslib": "^2.7.0",
"firebase-admin": "^13.0.2",
"firebase-functions": "^6.2.0",
"tslib": "^2.8.1",
"passkit-generator": "workspace:*"
},
"peerDependencies": {
"passkit-generator": "workspace:*"
},
"devDependencies": {
"firebase-functions-test": "^0.2.3",
"firebase-tools": "^12.9.1",
"typescript": "^5.7.3"
"firebase-functions-test": "^3.4.0",
"firebase-tools": "^13.29.1",
"typescript": "^5.7.3",
"@types/node": "^20"
},
"private": true
}

View File

@@ -1,7 +1,7 @@
import * as functions from "firebase-functions";
import * as functions from "firebase-functions/https";
import { initializeApp } from "firebase-admin/app";
import { getStorage } from "firebase-admin/storage";
import passkit from "passkit-generator";
import { PKPass } from "passkit-generator";
import type { Barcode, TransitType } from "passkit-generator";
import fs from "node:fs";
import path from "node:path";
@@ -12,8 +12,6 @@ import os from "node:os";
// Should probably not be used in production
import startData from "./startData.json" assert { type: "json" };
const PKPass = passkit.PKPass;
interface RequestWithBody extends functions.Request {
body: {
passModel: string;
@@ -68,7 +66,7 @@ initializeApp({
const storageRef = getStorage().bucket();
export const pass = functions.https.onRequest(
export const pass = functions.onRequest(
async (request: RequestWithBody, response) => {
let modelBasePath: string;