35 lines
782 B
TypeScript
35 lines
782 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";
|
|
|
|
let apl: APL;
|
|
|
|
switch (aplType) {
|
|
case "upstash":
|
|
apl = new UpstashAPL();
|
|
|
|
break;
|
|
case "file":
|
|
apl = new FileAPL();
|
|
|
|
break;
|
|
case "rest": {
|
|
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,
|
|
});
|