forked from Remitwise-Org/Remitwise-Frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstrumentation.ts
More file actions
31 lines (28 loc) · 1.02 KB
/
instrumentation.ts
File metadata and controls
31 lines (28 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/**
* Next.js instrumentation hook
* Runs once when the server starts (both dev and production)
* Used for server initialization tasks like configuration validation
*
* @see https://nextjs.org/docs/app/building-your-application/optimizing/instrumentation
*/
import { validateSessionConfig } from '@/lib/session';
/**
* Register function runs once on server startup
* Validates session configuration and logs startup information
*/
export async function register() {
// Only run on server-side
if (process.env.NEXT_RUNTIME === 'nodejs') {
try {
// Validate session configuration on startup
// This will throw if SESSION_PASSWORD is invalid
// and log warnings/info for other configuration values
validateSessionConfig();
console.info('Session configuration validated successfully');
} catch (error) {
// Log error and exit - invalid configuration should prevent server start
console.error('Failed to validate session configuration:', error);
throw error;
}
}
}