data endpoint for entity 90008 (aka. a website)
1import { readFile, stat } from 'node:fs/promises';
2import { join } from 'node:path';
3import { env } from '$env/dynamic/private';
4import { initConstellation } from '$lib/constellation';
5
6export const GET = async () => {
7 const filePath = join(env.WEBSITE_DATA_DIR, 'constellation', 'background_dust.webp');
8
9 try {
10 await stat(filePath);
11 } catch (e) {
12 await initConstellation();
13 }
14
15 try {
16 const file = await readFile(filePath);
17 return new Response(file, {
18 headers: {
19 'Content-Type': 'image/webp',
20 'Cache-Control': 'public, max-age=31536000, immutable'
21 }
22 });
23 } catch (err) {
24 console.error(`error serving background dust: ${err}`);
25 return new Response('not found', { status: 404 });
26 }
27};