import { PrintfulClient, WebflowClient } from "@blade-and-brawn/commerce";
import { env } from "$env/dynamic/private";
import type { PageServerLoad } from "./$types";

const printful = new PrintfulClient({ token: env.PRINTFUL_AUTH, storeId: env.PRINTFUL_STORE_ID });
const webflow = new WebflowClient({
    siteId: env.WEBFLOW_SITE_ID,
    collectionsId: env.WEBFLOW_COLLECTION_ID,
    token: env.WEBFLOW_AUTH,
    webhookSecret: env.WEBFLOW_WEBHOOK_SECRET,
});

export const load = async ({ }: Parameters<PageServerLoad>[0]) => {
    return {
        products: {
            printful: printful.Products.list({ forceAll: true }),
            webflow: webflow.Products.list({ forceAll: true }),
        },
    };
};
