31 lines
946 B
TypeScript
31 lines
946 B
TypeScript
import { clientAddressIsPrivate, clientConfig, serverConfig } from '$lib/server/config';
|
|
import type { PageServerLoad } from './$types';
|
|
import { getServiceHandler } from '$lib/services/services';
|
|
|
|
export const load: PageServerLoad = ({ fetch, getClientAddress }) => {
|
|
const serviceData: Array<Array<unknown>> = [];
|
|
const config = clientConfig();
|
|
|
|
const privateConfig = serverConfig();
|
|
|
|
for (const [i, group] of privateConfig.services.entries()) {
|
|
const groupData: Array<unknown> = [];
|
|
serviceData.push(groupData);
|
|
for (const [j, service] of group.items.entries()) {
|
|
const handler = getServiceHandler(service.type || '');
|
|
if (handler == undefined) {
|
|
config.services[i].items[j].type = undefined;
|
|
groupData.push(undefined);
|
|
} else {
|
|
groupData.push(handler({ fetch, config: service }));
|
|
}
|
|
}
|
|
}
|
|
|
|
return {
|
|
config,
|
|
serviceData,
|
|
privateAccess: clientAddressIsPrivate(getClientAddress(), privateConfig)
|
|
};
|
|
};
|