30 lines
1.0 KiB
TypeScript
30 lines
1.0 KiB
TypeScript
import { env } from 'cloudflare:workers';
|
|
import { D1Store } from '@/core/store';
|
|
import { rawAleEnabled } from '@/core/ale-auth';
|
|
import { recentAleEvents } from '@/core/ale-store';
|
|
import type { RuntimeConfig } from '@/core/types';
|
|
|
|
export async function GET(){
|
|
const c=env as unknown as RuntimeConfig;
|
|
try{
|
|
await new D1Store().load();
|
|
const aleEvents=await recentAleEvents(env.DB!,20);
|
|
const lastAleAt=aleEvents[0]?.at??null;
|
|
const aleActiveRecently=!!lastAleAt&&Date.now()-Date.parse(lastAleAt)<90_000;
|
|
return Response.json({
|
|
ok:true,
|
|
aleActiveRecently,
|
|
lastAleAt,
|
|
gameBackend:c.GAME_BACKEND??'azerothcore',
|
|
bridgeConfigured:c.GAME_BACKEND==='cmangos-classic'?!!c.ALE_BRIDGE_TOKEN:!!(c.BRIDGE_URL&&c.BRIDGE_TOKEN),
|
|
aleConfigured:!!c.ALE_BRIDGE_TOKEN,
|
|
aleOperatorConfigured:!!c.ALE_OPERATOR_TOKEN,
|
|
aleRawEnabled:rawAleEnabled(c),
|
|
llmConfigured:!!c.LLM_URL,
|
|
soapConfigured:!!(c.SOAP_URL&&c.SOAP_USER&&c.SOAP_PASSWORD)
|
|
});
|
|
}catch{
|
|
return Response.json({ok:false},{status:503});
|
|
}
|
|
}
|