
* bootstrap segment app from cms app * tracking logic * schema configuratioj * config form * form saving * Connected order_created * add more fields * Order updated webhook * Order cancelled event * order refunded webhook * order fully paid * update deps * error handling * logger * logs * Add app to workflow * add icon * remove breadcrumbs * Change 400 to 200 response if payload is invalid * link to docs * change semgent.io to segment
35 lines
797 B
TypeScript
35 lines
797 B
TypeScript
import { APL, FileAPL, SaleorCloudAPL, UpstashAPL } from "@saleor/app-sdk/APL";
|
|
import { SaleorApp } from "@saleor/app-sdk/saleor-app";
|
|
|
|
const aplType = process.env.APL ?? "file";
|
|
|
|
export let apl: APL;
|
|
|
|
switch (aplType) {
|
|
case "upstash":
|
|
apl = new UpstashAPL();
|
|
|
|
break;
|
|
case "file":
|
|
apl = new FileAPL();
|
|
|
|
break;
|
|
case "saleor-cloud": {
|
|
if (!process.env.REST_APL_ENDPOINT || !process.env.REST_APL_TOKEN) {
|
|
throw new Error("Rest APL is not configured - missing env variables. Check saleor-app.ts");
|
|
}
|
|
|
|
apl = new SaleorCloudAPL({
|
|
resourceUrl: process.env.REST_APL_ENDPOINT,
|
|
token: process.env.REST_APL_TOKEN,
|
|
});
|
|
|
|
break;
|
|
}
|
|
default: {
|
|
throw new Error("Invalid APL config, ");
|
|
}
|
|
}
|
|
export const saleorApp = new SaleorApp({
|
|
apl,
|
|
});
|