Setup dev printful/webflow webhooks
This commit is contained in:
+1
-1
@@ -16,7 +16,7 @@ export const env = {
|
||||
WEBFLOW_SITE_ID: requireEnv("WEBFLOW_SITE_ID"),
|
||||
WEBFLOW_COLLECTION_ID: requireEnv("WEBFLOW_COLLECTION_ID"),
|
||||
WEBFLOW_AUTH: requireEnv("WEBFLOW_AUTH"),
|
||||
WEBFLOW_WEBHOOK_SECRET: optionEnv("WEBFLOW_WEBHOOK_SECRET"),
|
||||
WEBFLOW_WEBHOOK_SECRET: requireEnv("WEBFLOW_WEBHOOK_SECRET"),
|
||||
NODE_ENV: optionEnv("NODE_ENV", "development"),
|
||||
LOG_LEVEL: optionEnv("LOG_LEVEL", "info")
|
||||
};
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
import { Printful, PrintfulClient } from "@blade-and-brawn/commerce";
|
||||
import { env } from "../env";
|
||||
|
||||
const printful = new PrintfulClient({
|
||||
token: env.PRINTFUL_AUTH,
|
||||
storeId: env.PRINTFUL_STORE_ID,
|
||||
});
|
||||
|
||||
await printful.Webhooks.register("https://dev.bladeandbrawn.com/webhook/printful", [
|
||||
Printful.Webhook.Event.ProductUpdated,
|
||||
Printful.Webhook.Event.ProductDeleted,
|
||||
Printful.Webhook.Event.PackageShipped,
|
||||
]);
|
||||
|
||||
const config = await printful.Webhooks.getConfig();
|
||||
console.log(config);
|
||||
@@ -162,6 +162,7 @@ export const app = new Elysia()
|
||||
|
||||
// WEBHOOKS
|
||||
.post("/webhook/printful", async ({ body }) => {
|
||||
// https://webflow.com/integrations/printful
|
||||
const payload = body as Printful.Webhook.EventPayload;
|
||||
|
||||
switch (payload.type) {
|
||||
|
||||
Reference in New Issue
Block a user