2023-02-07 18:11:39 +00:00
|
|
|
import { SaleorApp } from "@saleor/app-sdk/saleor-app";
|
2023-02-10 10:13:59 +00:00
|
|
|
import { APL, FileAPL, SaleorCloudAPL, UpstashAPL, VercelAPL } from "@saleor/app-sdk/APL";
|
2023-02-07 18:11:39 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* By default auth data are stored in the `.auth-data.json` (FileAPL).
|
|
|
|
* For multi-tenant applications and deployments please use UpstashAPL.
|
|
|
|
*
|
|
|
|
* To read more about storing auth data, read the
|
|
|
|
* [APL documentation](https://github.com/saleor/saleor-app-sdk/blob/main/docs/apl.md)
|
|
|
|
*/
|
|
|
|
|
|
|
|
export let apl: APL;
|
|
|
|
switch (process.env.APL) {
|
|
|
|
case "upstash":
|
|
|
|
// Require `UPSTASH_URL` and `UPSTASH_TOKEN` environment variables
|
|
|
|
apl = new UpstashAPL();
|
|
|
|
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:
|
|
|
|
apl = new FileAPL();
|
|
|
|
}
|
|
|
|
|
|
|
|
export const saleorApp = new SaleorApp({
|
|
|
|
apl,
|
|
|
|
});
|