vasuzex 2.1.15 → 2.1.17

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.
@@ -2,13 +2,14 @@
2
2
  * Firebase Admin SDK Singleton
3
3
  * Centralized Firebase Admin initialization for FCM
4
4
  *
5
- * Configuration from environment variables:
6
- * - FIREBASE_PROJECT_ID
7
- * - FIREBASE_CLIENT_EMAIL
8
- * - FIREBASE_PRIVATE_KEY
5
+ * Configuration options (in priority order):
6
+ * 1. FIREBASE_SERVICE_ACCOUNT_PATH - path to service account JSON file
7
+ * 2. Environment variables: FIREBASE_PROJECT_ID, FIREBASE_CLIENT_EMAIL, FIREBASE_PRIVATE_KEY
9
8
  */
10
9
 
11
10
  import admin from 'firebase-admin';
11
+ import { readFileSync } from 'fs';
12
+ import { resolve } from 'path';
12
13
  import { Config, Log } from '../../Support/Facades/index.js';
13
14
 
14
15
  let firebaseApp = null;
@@ -24,20 +25,41 @@ export function initializeFirebaseAdmin() {
24
25
  }
25
26
 
26
27
  try {
28
+ // Option 1: Load from service account file (preferred)
29
+ const serviceAccountPath = Config.get('notification.fcm.service_account_path') || process.env.FIREBASE_SERVICE_ACCOUNT_PATH;
30
+
31
+ if (serviceAccountPath) {
32
+ // Use PROJECT_ROOT if available, otherwise use process.cwd()
33
+ const projectRoot = process.env.PROJECT_ROOT || process.cwd();
34
+
35
+ // Resolve from project root if relative, use as-is if absolute
36
+ const fullPath = serviceAccountPath.startsWith('/')
37
+ ? serviceAccountPath
38
+ : resolve(projectRoot, serviceAccountPath);
39
+ const serviceAccount = JSON.parse(readFileSync(fullPath, 'utf8'));
40
+
41
+ firebaseApp = admin.initializeApp({
42
+ credential: admin.credential.cert(serviceAccount)
43
+ });
44
+
45
+ isInitialized = true;
46
+ Log.info('Firebase Admin SDK initialized from service account file', {
47
+ projectId: serviceAccount.project_id,
48
+ path: fullPath
49
+ });
50
+ return firebaseApp;
51
+ }
52
+
53
+ // Option 2: Load from environment variables
27
54
  const projectId = Config.get('notification.fcm.project_id') || process.env.FIREBASE_PROJECT_ID;
28
55
  const clientEmail = Config.get('notification.fcm.client_email') || process.env.FIREBASE_CLIENT_EMAIL;
29
56
  const privateKey = Config.get('notification.fcm.private_key') || process.env.FIREBASE_PRIVATE_KEY;
30
57
 
31
58
  if (!projectId || !clientEmail || !privateKey) {
32
- Log.warning('Firebase Admin SDK not configured - FCM notifications disabled', {
33
- hasProjectId: !!projectId,
34
- hasClientEmail: !!clientEmail,
35
- hasPrivateKey: !!privateKey
36
- });
59
+ Log.warning('Firebase Admin SDK not configured - FCM notifications disabled');
37
60
  return null;
38
61
  }
39
62
 
40
- // Handle escaped newlines in private key
41
63
  const formattedPrivateKey = privateKey.replace(/\\n/g, '\n');
42
64
 
43
65
  firebaseApp = admin.initializeApp({
@@ -49,13 +71,11 @@ export function initializeFirebaseAdmin() {
49
71
  });
50
72
 
51
73
  isInitialized = true;
52
- Log.info('Firebase Admin SDK initialized successfully', { projectId });
53
-
74
+ Log.info('Firebase Admin SDK initialized from environment variables', { projectId });
54
75
  return firebaseApp;
55
76
  } catch (error) {
56
77
  Log.error('Failed to initialize Firebase Admin SDK', {
57
- error: error.message,
58
- stack: error.stack
78
+ error: error.message
59
79
  });
60
80
  return null;
61
81
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vasuzex",
3
- "version": "2.1.15",
3
+ "version": "2.1.17",
4
4
  "description": "Laravel-inspired framework for Node.js monorepos - V2 with optimized dependencies",
5
5
  "type": "module",
6
6
  "main": "./framework/index.js",
@@ -48,34 +48,6 @@
48
48
  "#config": "./config/index.cjs",
49
49
  "#config/*": "./config/*"
50
50
  },
51
- "scripts": {
52
- "dev": "turbo run dev",
53
- "build": "turbo run build",
54
- "start": "turbo run start",
55
- "test": "NODE_OPTIONS=--experimental-vm-modules jest",
56
- "test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch",
57
- "test:coverage": "NODE_OPTIONS=--experimental-vm-modules jest --coverage",
58
- "db:migrate": "npx vasuzex migrate",
59
- "test:all": "NODE_OPTIONS=--experimental-vm-modules npx jest",
60
- "test:unit": "NODE_OPTIONS=--experimental-vm-modules npx jest tests/unit",
61
- "test:integration": "NODE_OPTIONS=--experimental-vm-modules npx jest tests/integration",
62
- "test:e2e": "NODE_OPTIONS=--experimental-vm-modules npx jest tests/e2e",
63
- "scan:issues": "node deep-scan-issues.cjs",
64
- "dev:pilot-test-api": "turbo run dev --filter=pilot-test-api",
65
- "start:pilot-test-api": "turbo run start --filter=pilot-test-api",
66
- "dev:pilot-test-web": "turbo run dev --filter=pilot-test-web",
67
- "start:pilot-test-web": "turbo run start --filter=pilot-test-web",
68
- "dev:integration-test-api": "turbo run dev --filter=integration-test-api",
69
- "start:integration-test-api": "turbo run start --filter=integration-test-api",
70
- "dev:test-gen-api-api": "turbo run dev --filter=test-gen-api-api",
71
- "start:test-gen-api-api": "turbo run start --filter=test-gen-api-api",
72
- "dev:cleanup-test-api": "turbo run dev --filter=cleanup-test-api",
73
- "start:cleanup-test-api": "turbo run start --filter=cleanup-test-api",
74
- "dev:auth-integration-test-api": "turbo run dev --filter=auth-integration-test-api",
75
- "start:auth-integration-test-api": "turbo run start --filter=auth-integration-test-api",
76
- "dev:e2e-test-api": "turbo run dev --filter=e2e-test-api",
77
- "start:e2e-test-api": "turbo run start --filter=e2e-test-api"
78
- },
79
51
  "keywords": [
80
52
  "framework",
81
53
  "laravel",
@@ -108,7 +80,7 @@
108
80
  "express-rate-limit": "^8.2.1",
109
81
  "firebase-admin": "^13.6.0",
110
82
  "fs-extra": "^11.3.2",
111
- "guruorm": "^2.0.16",
83
+ "guruorm": "^2.0.17",
112
84
  "helmet": "^8.1.0",
113
85
  "inquirer": "^9.3.8",
114
86
  "ip2location-nodejs": "^9.7.0",
@@ -152,13 +124,6 @@
152
124
  "turbo": "^2.6.1",
153
125
  "vite": "^5.0.0"
154
126
  },
155
- "pnpm": {
156
- "overrides": {
157
- "express": "^5.2.1",
158
- "react": "^18.2.0",
159
- "vue": "^3.4.0"
160
- }
161
- },
162
127
  "repository": {
163
128
  "type": "git",
164
129
  "url": "git+https://github.com/rishicool/vasuzex.git"
@@ -167,5 +132,32 @@
167
132
  "url": "https://github.com/rishicool/vasuzex/issues"
168
133
  },
169
134
  "homepage": "https://github.com/rishicool/vasuzex#readme",
170
- "packageManager": "pnpm@10.0.0"
171
- }
135
+ "scripts": {
136
+ "dev": "turbo run dev",
137
+ "build": "turbo run build",
138
+ "start": "turbo run start",
139
+ "test": "NODE_OPTIONS=--experimental-vm-modules jest",
140
+ "test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch",
141
+ "test:coverage": "NODE_OPTIONS=--experimental-vm-modules jest --coverage",
142
+ "db:migrate": "npx vasuzex migrate",
143
+ "test:all": "NODE_OPTIONS=--experimental-vm-modules npx jest",
144
+ "test:unit": "NODE_OPTIONS=--experimental-vm-modules npx jest tests/unit",
145
+ "test:integration": "NODE_OPTIONS=--experimental-vm-modules npx jest tests/integration",
146
+ "test:e2e": "NODE_OPTIONS=--experimental-vm-modules npx jest tests/e2e",
147
+ "scan:issues": "node deep-scan-issues.cjs",
148
+ "dev:pilot-test-api": "turbo run dev --filter=pilot-test-api",
149
+ "start:pilot-test-api": "turbo run start --filter=pilot-test-api",
150
+ "dev:pilot-test-web": "turbo run dev --filter=pilot-test-web",
151
+ "start:pilot-test-web": "turbo run start --filter=pilot-test-web",
152
+ "dev:integration-test-api": "turbo run dev --filter=integration-test-api",
153
+ "start:integration-test-api": "turbo run start --filter=integration-test-api",
154
+ "dev:test-gen-api-api": "turbo run dev --filter=test-gen-api-api",
155
+ "start:test-gen-api-api": "turbo run start --filter=test-gen-api-api",
156
+ "dev:cleanup-test-api": "turbo run dev --filter=cleanup-test-api",
157
+ "start:cleanup-test-api": "turbo run start --filter=cleanup-test-api",
158
+ "dev:auth-integration-test-api": "turbo run dev --filter=auth-integration-test-api",
159
+ "start:auth-integration-test-api": "turbo run start --filter=auth-integration-test-api",
160
+ "dev:e2e-test-api": "turbo run dev --filter=e2e-test-api",
161
+ "start:e2e-test-api": "turbo run start --filter=e2e-test-api"
162
+ }
163
+ }