chore: upgrade Firebase Functions to Node.js 22 and firebase-functions v7
Node.js 20 is being decommissioned 2026-10-30. This upgrades the runtime to Node.js 22 (LTS), bumps firebase-functions from v6 to v7, removes the deprecated functions.config() fallback, and aligns the TS target to ES2022. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"functions": {
|
"functions": {
|
||||||
"source": ".",
|
"source": ".",
|
||||||
"runtime": "nodejs20",
|
"runtime": "nodejs22",
|
||||||
"ignore": [
|
"ignore": [
|
||||||
"node_modules",
|
"node_modules",
|
||||||
"src",
|
"src",
|
||||||
|
|||||||
26
backend/package-lock.json
generated
26
backend/package-lock.json
generated
@@ -21,7 +21,7 @@
|
|||||||
"express": "^4.18.2",
|
"express": "^4.18.2",
|
||||||
"express-rate-limit": "^7.1.5",
|
"express-rate-limit": "^7.1.5",
|
||||||
"firebase-admin": "^13.4.0",
|
"firebase-admin": "^13.4.0",
|
||||||
"firebase-functions": "^6.4.0",
|
"firebase-functions": "^7.0.5",
|
||||||
"helmet": "^7.1.0",
|
"helmet": "^7.1.0",
|
||||||
"joi": "^17.11.0",
|
"joi": "^17.11.0",
|
||||||
"jsonwebtoken": "^9.0.2",
|
"jsonwebtoken": "^9.0.2",
|
||||||
@@ -4649,9 +4649,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/firebase-functions": {
|
"node_modules/firebase-functions": {
|
||||||
"version": "6.4.0",
|
"version": "7.0.5",
|
||||||
"resolved": "https://registry.npmjs.org/firebase-functions/-/firebase-functions-6.4.0.tgz",
|
"resolved": "https://registry.npmjs.org/firebase-functions/-/firebase-functions-7.0.5.tgz",
|
||||||
"integrity": "sha512-Q/LGhJrmJEhT0dbV60J4hCkVSeOM6/r7xJS/ccmkXzTWMjo+UPAYX9zlQmGlEjotstZ0U9GtQSJSgbB2Z+TJDg==",
|
"integrity": "sha512-uG2dR5AObLuUrWWjj/de5XxNHCVi+Ehths0DSRcLjHJdgw1TSejwoZZ5na6gVrl3znNjRdBRy5Br5UlhaIU3Ww==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/cors": "^2.8.5",
|
"@types/cors": "^2.8.5",
|
||||||
@@ -4664,10 +4664,24 @@
|
|||||||
"firebase-functions": "lib/bin/firebase-functions.js"
|
"firebase-functions": "lib/bin/firebase-functions.js"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=14.10.0"
|
"node": ">=18.0.0"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"firebase-admin": "^11.10.0 || ^12.0.0 || ^13.0.0"
|
"@apollo/server": "^5.2.0",
|
||||||
|
"@as-integrations/express4": "^1.1.2",
|
||||||
|
"firebase-admin": "^11.10.0 || ^12.0.0 || ^13.0.0",
|
||||||
|
"graphql": "^16.12.0"
|
||||||
|
},
|
||||||
|
"peerDependenciesMeta": {
|
||||||
|
"@apollo/server": {
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"@as-integrations/express4": {
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"graphql": {
|
||||||
|
"optional": true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/flat-cache": {
|
"node_modules/flat-cache": {
|
||||||
|
|||||||
@@ -53,7 +53,7 @@
|
|||||||
"express": "^4.18.2",
|
"express": "^4.18.2",
|
||||||
"express-rate-limit": "^7.1.5",
|
"express-rate-limit": "^7.1.5",
|
||||||
"firebase-admin": "^13.4.0",
|
"firebase-admin": "^13.4.0",
|
||||||
"firebase-functions": "^6.4.0",
|
"firebase-functions": "^7.0.5",
|
||||||
"helmet": "^7.1.0",
|
"helmet": "^7.1.0",
|
||||||
"joi": "^17.11.0",
|
"joi": "^17.11.0",
|
||||||
"jsonwebtoken": "^9.0.2",
|
"jsonwebtoken": "^9.0.2",
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import dotenv from 'dotenv';
|
import dotenv from 'dotenv';
|
||||||
import Joi from 'joi';
|
import Joi from 'joi';
|
||||||
import * as functions from 'firebase-functions';
|
|
||||||
|
|
||||||
// Load environment variables from .env file (for local development)
|
// Load environment variables from .env file (for local development)
|
||||||
dotenv.config();
|
dotenv.config();
|
||||||
@@ -10,46 +9,7 @@ dotenv.config();
|
|||||||
// - firebase functions:secrets:set for sensitive data (recommended)
|
// - firebase functions:secrets:set for sensitive data (recommended)
|
||||||
// - defineString() and defineSecret() in function definitions (automatically available in process.env)
|
// - defineString() and defineSecret() in function definitions (automatically available in process.env)
|
||||||
// - .env files for local development
|
// - .env files for local development
|
||||||
// MIGRATION NOTE: functions.config() is deprecated and will be removed Dec 31, 2025
|
const env = { ...process.env };
|
||||||
// We keep it as a fallback for backward compatibility during migration
|
|
||||||
let env = { ...process.env };
|
|
||||||
|
|
||||||
// MIGRATION: Firebase Functions v1 uses functions.config(), v2 uses process.env with defineString()/defineSecret()
|
|
||||||
// When using defineString() and defineSecret() in function definitions, values are automatically
|
|
||||||
// available in process.env. This fallback is only for backward compatibility during migration.
|
|
||||||
try {
|
|
||||||
const functionsConfig = functions.config();
|
|
||||||
if (functionsConfig && Object.keys(functionsConfig).length > 0) {
|
|
||||||
console.log('[CONFIG DEBUG] functions.config() fallback available (migration in progress)');
|
|
||||||
// Merge functions.config() values into env (process.env takes precedence - this is correct)
|
|
||||||
let fallbackCount = 0;
|
|
||||||
Object.keys(functionsConfig).forEach(key => {
|
|
||||||
if (typeof functionsConfig[key] === 'object' && functionsConfig[key] !== null) {
|
|
||||||
// Handle nested config like functions.config().llm.provider
|
|
||||||
Object.keys(functionsConfig[key]).forEach(subKey => {
|
|
||||||
const envKey = `${key.toUpperCase()}_${subKey.toUpperCase()}`;
|
|
||||||
if (!env[envKey]) {
|
|
||||||
env[envKey] = String(functionsConfig[key][subKey]);
|
|
||||||
fallbackCount++;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
// Handle flat config
|
|
||||||
const envKey = key.toUpperCase();
|
|
||||||
if (!env[envKey]) {
|
|
||||||
env[envKey] = String(functionsConfig[key]);
|
|
||||||
fallbackCount++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if (fallbackCount > 0) {
|
|
||||||
console.log(`[CONFIG DEBUG] Using functions.config() fallback for ${fallbackCount} values (migration in progress)`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
// functions.config() might not be available in v2, that's okay
|
|
||||||
console.log('[CONFIG DEBUG] functions.config() not available (this is normal for v2 with defineString/defineSecret)');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Environment validation schema
|
// Environment validation schema
|
||||||
const envSchema = Joi.object({
|
const envSchema = Joi.object({
|
||||||
@@ -183,7 +143,6 @@ const envSchema = Joi.object({
|
|||||||
}).unknown();
|
}).unknown();
|
||||||
|
|
||||||
// Validate environment variables
|
// Validate environment variables
|
||||||
// Use the merged env object (process.env + functions.config() fallback)
|
|
||||||
const { error, value: envVars } = envSchema.validate(env);
|
const { error, value: envVars } = envSchema.validate(env);
|
||||||
|
|
||||||
// Enhanced error handling for serverless environments
|
// Enhanced error handling for serverless environments
|
||||||
|
|||||||
@@ -182,7 +182,6 @@ app.use('/monitoring', monitoringRoutes);
|
|||||||
app.use('/api/audit', auditRoutes);
|
app.use('/api/audit', auditRoutes);
|
||||||
|
|
||||||
|
|
||||||
import * as functions from 'firebase-functions';
|
|
||||||
import { onRequest } from 'firebase-functions/v2/https';
|
import { onRequest } from 'firebase-functions/v2/https';
|
||||||
import { defineString, defineSecret } from 'firebase-functions/params';
|
import { defineString, defineSecret } from 'firebase-functions/params';
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"target": "ES2020",
|
"target": "ES2022",
|
||||||
"module": "commonjs",
|
"module": "commonjs",
|
||||||
"lib": ["ES2020"],
|
"lib": ["ES2022"],
|
||||||
"outDir": "./dist",
|
"outDir": "./dist",
|
||||||
"rootDir": "./src",
|
"rootDir": "./src",
|
||||||
"strict": true,
|
"strict": true,
|
||||||
|
|||||||
Reference in New Issue
Block a user