saleor-apps-redis_apl/apps/cms/saleor-app.ts
Dawid a07f337992
Add CMS hub app (#262)
* Add CMS hub app

* Cleanup

* Refactor CMS product variants webhooks

* Test utils 1

* Remove legacy code

* Add .env example

* Update types

* Remove unused code

* Fix cms client opertions settings test

* Fix pnpm-lock file

* Bump typescript to 4.9, support satisfies expressions
2023-03-16 11:17:00 +01:00

37 lines
1.1 KiB
TypeScript

import { APL, FileAPL, SaleorCloudAPL, UpstashAPL } from "@saleor/app-sdk/APL";
import { SaleorApp } from "@saleor/app-sdk/saleor-app";
/**
* 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)
*/
let apl: APL;
const aplType = process.env.APL ?? "file";
switch (aplType) {
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 as string,
token: process.env.REST_APL_TOKEN,
});
break;
}
default:
apl = new FileAPL();
}
export const saleorApp = new SaleorApp({
apl,
});