feat: add durable asset synchronization worker
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
import { json } from '@sveltejs/kit';
|
||||
import type { RequestHandler } from './$types';
|
||||
import { live, session } from '$lib/server/application';
|
||||
import { configuration } from '$lib/server/config';
|
||||
import { capabilityDisabledReason, capabilityEnabled } from '$lib/server/release-gate';
|
||||
|
||||
export const GET: RequestHandler = async (event) => {
|
||||
const config = configuration();
|
||||
if (!capabilityEnabled('asset_sync', config.capabilityAllowlist)) return json({ error: capabilityDisabledReason('asset_sync') }, { status: 503 });
|
||||
const current = await session(event);
|
||||
if (!current) return json({ error: 'Connect an EVE character first.' }, { status: 401 });
|
||||
const jobId = event.url.searchParams.get('job');
|
||||
if (!jobId || jobId.length > 128) return json({ error: 'A sync job is required.' }, { status: 400 });
|
||||
try {
|
||||
const job = await live().store.syncJob(current.userId, jobId);
|
||||
return job ? json(job) : json({ error: 'Sync job not found.' }, { status: 404 });
|
||||
} catch {
|
||||
return json({ error: 'Synchronization status unavailable.' }, { status: 503 });
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user