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:
admin
2026-02-24 11:41:00 -05:00
parent 6429e98f58
commit 9a5ff52d12
6 changed files with 25 additions and 53 deletions

View File

@@ -1,7 +1,7 @@
{
"functions": {
"source": ".",
"runtime": "nodejs20",
"runtime": "nodejs22",
"ignore": [
"node_modules",
"src",

View File

@@ -21,7 +21,7 @@
"express": "^4.18.2",
"express-rate-limit": "^7.1.5",
"firebase-admin": "^13.4.0",
"firebase-functions": "^6.4.0",
"firebase-functions": "^7.0.5",
"helmet": "^7.1.0",
"joi": "^17.11.0",
"jsonwebtoken": "^9.0.2",
@@ -4649,9 +4649,9 @@
}
},
"node_modules/firebase-functions": {
"version": "6.4.0",
"resolved": "https://registry.npmjs.org/firebase-functions/-/firebase-functions-6.4.0.tgz",
"integrity": "sha512-Q/LGhJrmJEhT0dbV60J4hCkVSeOM6/r7xJS/ccmkXzTWMjo+UPAYX9zlQmGlEjotstZ0U9GtQSJSgbB2Z+TJDg==",
"version": "7.0.5",
"resolved": "https://registry.npmjs.org/firebase-functions/-/firebase-functions-7.0.5.tgz",
"integrity": "sha512-uG2dR5AObLuUrWWjj/de5XxNHCVi+Ehths0DSRcLjHJdgw1TSejwoZZ5na6gVrl3znNjRdBRy5Br5UlhaIU3Ww==",
"license": "MIT",
"dependencies": {
"@types/cors": "^2.8.5",
@@ -4664,10 +4664,24 @@
"firebase-functions": "lib/bin/firebase-functions.js"
},
"engines": {
"node": ">=14.10.0"
"node": ">=18.0.0"
},
"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": {

View File

@@ -53,7 +53,7 @@
"express": "^4.18.2",
"express-rate-limit": "^7.1.5",
"firebase-admin": "^13.4.0",
"firebase-functions": "^6.4.0",
"firebase-functions": "^7.0.5",
"helmet": "^7.1.0",
"joi": "^17.11.0",
"jsonwebtoken": "^9.0.2",

View File

@@ -1,6 +1,5 @@
import dotenv from 'dotenv';
import Joi from 'joi';
import * as functions from 'firebase-functions';
// Load environment variables from .env file (for local development)
dotenv.config();
@@ -10,46 +9,7 @@ dotenv.config();
// - firebase functions:secrets:set for sensitive data (recommended)
// - defineString() and defineSecret() in function definitions (automatically available in process.env)
// - .env files for local development
// MIGRATION NOTE: functions.config() is deprecated and will be removed Dec 31, 2025
// 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)');
}
const env = { ...process.env };
// Environment validation schema
const envSchema = Joi.object({
@@ -183,7 +143,6 @@ const envSchema = Joi.object({
}).unknown();
// Validate environment variables
// Use the merged env object (process.env + functions.config() fallback)
const { error, value: envVars } = envSchema.validate(env);
// Enhanced error handling for serverless environments

View File

@@ -182,7 +182,6 @@ app.use('/monitoring', monitoringRoutes);
app.use('/api/audit', auditRoutes);
import * as functions from 'firebase-functions';
import { onRequest } from 'firebase-functions/v2/https';
import { defineString, defineSecret } from 'firebase-functions/params';

View File

@@ -1,8 +1,8 @@
{
"compilerOptions": {
"target": "ES2020",
"target": "ES2022",
"module": "commonjs",
"lib": ["ES2020"],
"lib": ["ES2022"],
"outDir": "./dist",
"rootDir": "./src",
"strict": true,