more cleanup

This commit is contained in:
Dominic Ferrando
2026-06-14 14:19:46 -04:00
parent 05dc26adb5
commit 5bb762961a
5 changed files with 42 additions and 48 deletions
+4
View File
@@ -3,6 +3,10 @@
"module": "index.ts",
"type": "module",
"private": true,
"scripts": {
"dev": "bun run --hot src/index.ts",
"start": "bun run src/index.ts"
},
"dependencies": {
"@elysiajs/cors": "^1.4.2",
"elysia": "^1.4.28",
+9 -7
View File
@@ -1,17 +1,16 @@
<script lang="ts">
import type { Printful } from "@blade-and-brawn/commerce";
import { PUBLIC_API_URL } from "$env/static/public";
import { onMount } from "svelte";
const { data } = $props();
const apiUrl = "http://localhost:3000";
const synchronizer = $state({
isSyncing: false,
syncingIds: [] as number[],
poll: async function () {
const res = (await (
await fetch(`${apiUrl}/products/sync`)
await fetch(`${PUBLIC_API_URL}/products/sync`)
).json()) as any;
if (res.data) {
synchronizer.isSyncing = res.data.isSyncing;
@@ -26,13 +25,16 @@
},
syncAll: async () => {
synchronizer.startPolling();
await fetch(`${apiUrl}/products/sync`, { method: "POST" });
await fetch(`${PUBLIC_API_URL}/products/sync`, { method: "POST" });
},
sync: async (printfulProductId: number) => {
synchronizer.startPolling();
await fetch(`${apiUrl}/products/sync/${printfulProductId}`, {
await fetch(
`${PUBLIC_API_URL}/products/sync/${printfulProductId}`,
{
method: "POST",
});
},
);
},
});
@@ -84,7 +86,7 @@
onclick={async () => {
const productData = (await (
await fetch(
`${apiUrl}/products/${printfulProduct.id}`,
`${PUBLIC_API_URL}/products/${printfulProduct.id}`,
)
).json()) as any;
console.log(productData);
+5
View File
@@ -5,6 +5,11 @@
"apps/*",
"packages/*"
],
"scripts": {
"dev:api": "bun run --filter @blade-and-brawn/api dev",
"dev:portal": "bun run --filter @blade-and-brawn/portal dev",
"build:portal": "bun run --filter @blade-and-brawn/portal build"
},
"peerDependencies": {
"typescript": "^5.9.3"
},
-4
View File
@@ -35,7 +35,6 @@ export class PrintfulService {
const allSyncProducts: Printful.Products.SyncProduct[] = [];
while (true) {
try {
const res = await fetch(
`${env().API_URL}/store/products?offset=${offset}`,
{
@@ -58,9 +57,6 @@ export class PrintfulService {
offset = allSyncProducts.length;
if (allSyncProducts.length >= payload.paging.total) break;
} catch (error) {
throw error;
}
}
return allSyncProducts;
+1 -14
View File
@@ -78,10 +78,9 @@ export class SyncService {
mainPrintfulProduct.colors.add(productColor);
}
} catch (error) {
throw error;
} finally {
this.state.isSyncing = false;
this.state.syncingIds = [];
throw error;
}
// TODO: Validate main printful products
@@ -308,18 +307,6 @@ export class SyncService {
}
}
} catch (err) {
// SYNC IMAGES
// for (const sku of existingWebflowProduct.skus) {
// const skuColor = sku.fieldData["sku-values"]?.["color"]?.toLowerCase() ?? "None";
// const skuSlug = `${existingWebflowProduct.product.fieldData.slug}-${skuColor}`;
// const skuImageUrls = await this.getProductImageUrls(skuSlug);
//
// sku.fieldData["main-image"] = skuImageUrls[0] ?? sku.fieldData["main-image"];
// sku.fieldData["more-images"] = skuImageUrls.slice(1).map(url => ({ url }));
//
// await WebflowService.Products.Skus.update(existingWebflowProduct.product.id, sku.id, sku);
// }
//
if (err instanceof FetchError) {
console.error(err.message, err.payload);
}