CognxSafeTrack commited on
Commit ·
ce3c4bc
1
Parent(s): ed26c4c
fix(startup): WHATSAPP_APP_SECRET demoted to warning — API no longer crashes if absent
Browse files- apps/api/src/index.ts +8 -1
apps/api/src/index.ts
CHANGED
|
@@ -10,13 +10,20 @@ import { paymentRoutes, stripeWebhookRoute } from './routes/payments';
|
|
| 10 |
import { internalRoutes } from './routes/internal';
|
| 11 |
|
| 12 |
// ── Fail-fast: vérifier les secrets critiques au démarrage ─────────────────────
|
| 13 |
-
const REQUIRED_ENV = ['ADMIN_API_KEY', '
|
|
|
|
|
|
|
| 14 |
for (const key of REQUIRED_ENV) {
|
| 15 |
if (!process.env[key]) {
|
| 16 |
console.error(`[STARTUP] ❌ Missing required environment variable: ${key}`);
|
| 17 |
process.exit(1);
|
| 18 |
}
|
| 19 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
const server = Fastify({
|
| 22 |
logger: true,
|
|
|
|
| 10 |
import { internalRoutes } from './routes/internal';
|
| 11 |
|
| 12 |
// ── Fail-fast: vérifier les secrets critiques au démarrage ─────────────────────
|
| 13 |
+
const REQUIRED_ENV = ['ADMIN_API_KEY', 'WHATSAPP_VERIFY_TOKEN'];
|
| 14 |
+
const WARN_ENV = ['WHATSAPP_APP_SECRET']; // Warning seulement — HMAC skipped if absent
|
| 15 |
+
|
| 16 |
for (const key of REQUIRED_ENV) {
|
| 17 |
if (!process.env[key]) {
|
| 18 |
console.error(`[STARTUP] ❌ Missing required environment variable: ${key}`);
|
| 19 |
process.exit(1);
|
| 20 |
}
|
| 21 |
}
|
| 22 |
+
for (const key of WARN_ENV) {
|
| 23 |
+
if (!process.env[key]) {
|
| 24 |
+
console.warn(`[STARTUP] ⚠️ ${key} not set — HMAC signature verification will be skipped`);
|
| 25 |
+
}
|
| 26 |
+
}
|
| 27 |
|
| 28 |
const server = Fastify({
|
| 29 |
logger: true,
|