mirror of
https://github.com/complexcaresolutions/cms.c2sgmbh.git
synced 2026-03-17 19:44:12 +00:00
- Hardened cron endpoints with coordination and auth improvements - Added API guards and input validation layer - Security observability and secrets health checks - Monitoring types and service improvements - PDF URL validation and newsletter unsubscribe security - Unit tests for security-critical paths Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
45 lines
1.5 KiB
TypeScript
45 lines
1.5 KiB
TypeScript
/**
|
|
* Next.js Instrumentation Hook
|
|
*
|
|
* Wird beim Server-Start ausgeführt. Initialisiert Scheduled Jobs.
|
|
* https://nextjs.org/docs/app/building-your-application/optimizing/instrumentation
|
|
*/
|
|
export async function register() {
|
|
// Nur auf dem Server ausführen, nicht im Edge Runtime
|
|
if (process.env.NEXT_RUNTIME === 'nodejs') {
|
|
const { getPayload } = await import('payload')
|
|
const config = await import('./payload.config')
|
|
|
|
// Payload initialisieren
|
|
const payload = await getPayload({
|
|
config: config.default,
|
|
})
|
|
|
|
const schedulerMode = (
|
|
process.env.SCHEDULER_MODE ||
|
|
(process.env.NODE_ENV === 'production' ? 'external' : 'in-process')
|
|
).toLowerCase()
|
|
const explicitInProcess = process.env.ENABLE_IN_PROCESS_SCHEDULER === 'true'
|
|
const shouldRunInProcessScheduler =
|
|
schedulerMode === 'in-process' ||
|
|
(explicitInProcess && schedulerMode !== 'external')
|
|
|
|
if (process.env.NODE_ENV === 'production' && shouldRunInProcessScheduler) {
|
|
console.warn(
|
|
'[Instrumentation] In-process scheduler is enabled in production. ' +
|
|
'Use SCHEDULER_MODE=external for multi-instance safe scheduling.',
|
|
)
|
|
}
|
|
|
|
if (shouldRunInProcessScheduler) {
|
|
const { initScheduledJobs } = await import('./jobs/scheduler')
|
|
initScheduledJobs(payload)
|
|
} else {
|
|
console.log(
|
|
'[Instrumentation] In-process scheduler disabled (SCHEDULER_MODE=external).',
|
|
)
|
|
}
|
|
|
|
console.log('[Instrumentation] Payload und Scheduled Jobs initialisiert.')
|
|
}
|
|
}
|