-
Notifications
You must be signed in to change notification settings - Fork 216
/
+page.server.ts
28 lines (24 loc) · 1.07 KB
/
+page.server.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import type { EntryGenerator, PageServerLoad } from './$types';
import { getService } from '$lib/utils/specs';
import { Platform, Service, versions } from '$lib/utils/references';
import { error } from '@sveltejs/kit';
const services = Object.values(Service);
const platforms = Object.values(Platform);
export const entries: EntryGenerator = () => {
return ['cloud', ...(versions as string[])].flatMap((version) => {
return platforms.flatMap((platform) => {
return services.map((service) => {
return { service, version, platform };
});
});
});
};
export const load: PageServerLoad = async ({ params }) => {
const { platform, service } = params;
const version = params.version === 'cloud' ? '1.6.x' : params.version;
if (!versions.includes(version)) error(404, 'Invalid version');
if (!services.includes(service as Service)) error(404, 'Invalid service');
if (!platforms.includes(platform as Platform)) error(404, 'Invalid platform');
const data = getService(version, platform, service);
return data;
};