@mohasinac/appkit 2.6.2 → 2.6.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -47,6 +47,27 @@ export function getAdminAppLite() {
47
47
  databaseURL: dbUrl,
48
48
  });
49
49
  }
50
+ else if (
51
+ // Application Default Credentials path — used by Firebase Functions /
52
+ // Cloud Run / GCE / GKE. The runtime sets `FUNCTION_TARGET` (gen 2
53
+ // Functions) or `K_SERVICE` (Cloud Run); FIREBASE_CONFIG carries the
54
+ // project info Firebase auto-injects. When any of those is present, defer
55
+ // to ADC by calling `initializeApp()` with no credential — the SDK pulls
56
+ // creds from the GCE metadata server.
57
+ process.env.FUNCTION_TARGET ||
58
+ process.env.K_SERVICE ||
59
+ process.env.FIREBASE_CONFIG ||
60
+ process.env.GOOGLE_APPLICATION_CREDENTIALS) {
61
+ const firebaseConfig = process.env.FIREBASE_CONFIG
62
+ ? JSON.parse(process.env.FIREBASE_CONFIG)
63
+ : {};
64
+ const projectId = firebaseConfig.projectId ?? process.env.GCLOUD_PROJECT ?? "";
65
+ const dbUrl = firebaseConfig.databaseURL ??
66
+ process.env.FIREBASE_ADMIN_DATABASE_URL ??
67
+ process.env.NEXT_PUBLIC_FIREBASE_DATABASE_URL ??
68
+ (projectId ? `https://${projectId}-default-rtdb.firebaseio.com` : undefined);
69
+ app = initializeApp(dbUrl ? { databaseURL: dbUrl } : undefined);
70
+ }
50
71
  else {
51
72
  throw new Error("@mohasinac/db-firebase: Firebase Admin credentials not found.");
52
73
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mohasinac/appkit",
3
- "version": "2.6.2",
3
+ "version": "2.6.3",
4
4
  "license": "MIT",
5
5
  "publishConfig": {
6
6
  "access": "public"