feat(cron): add automated sync endpoint and vercel cron configuration for partners
All checks were successful
Staging Build / build (push) Successful in 2m57s

This commit is contained in:
DanielS
2026-07-15 00:30:13 +02:00
parent 92eb7454dc
commit d5593900fb
4 changed files with 55 additions and 2 deletions

View File

@@ -1,7 +1,7 @@
'use server'
import { createAdminClient } from '@/lib/supabase/admin'
import { revalidatePath, unstable_noStore as noStore } from 'next/cache'
import { getLicServerConfig } from './licserver-config'
import { getLicServerConfig, getLicServerConfigSystem } from './licserver-config'
export async function getCompanies() {
noStore()
@@ -222,7 +222,7 @@ export async function adminDeleteEndCustomer(id: string) {
export async function syncCompaniesFromLicServer() {
const admin = createAdminClient()
const cfg = await getLicServerConfig()
const cfg = await getLicServerConfigSystem()
if (!cfg.base_url || !cfg.api_key) {
throw new Error('LicServer ist nicht konfiguriert.')

View File

@@ -1,6 +1,7 @@
'use server'
import { createClient } from '@/lib/supabase/server'
import { createAdminClient } from '@/lib/supabase/admin'
export interface LicServerConfig {
base_url: string | null
@@ -90,3 +91,22 @@ export async function testLicServerConnection(): Promise<{ ok: boolean; message:
return { ok: false, message: `Nicht erreichbar: ${err.message}` }
}
}
/**
* System version of getLicServerConfig that bypasses client auth check.
* Used internally by automated background jobs / cron routes.
*/
export async function getLicServerConfigSystem(): Promise<LicServerConfig> {
const admin = createAdminClient()
const { data } = await admin
.from('settings')
.select('licserver_base_url, licserver_api_key')
.eq('id', 'licserver')
.single()
return {
base_url: data?.licserver_base_url || process.env.LICSERVER_BASE_URL || null,
api_key: data?.licserver_api_key || process.env.LICSERVER_API_KEY || null,
}
}