52 lines
1.8 KiB
TypeScript
52 lines
1.8 KiB
TypeScript
import "@shopify/shopify-app-react-router/adapters/node";
|
|
import {
|
|
ApiVersion,
|
|
AppDistribution,
|
|
BillingInterval,
|
|
shopifyApp,
|
|
} from "@shopify/shopify-app-react-router/server";
|
|
import { PrismaSessionStorage } from "@shopify/shopify-app-session-storage-prisma";
|
|
import prisma from "./db.server";
|
|
import { ensureShop } from "./services/config.server";
|
|
|
|
/** Plan names are referenced by billing checks and feature gates (services/plans.ts). */
|
|
export const PLAN_GROWTH = "Growth";
|
|
export const PLAN_PRO = "Pro";
|
|
|
|
const shopify = shopifyApp({
|
|
apiKey: process.env.SHOPIFY_API_KEY,
|
|
apiSecretKey: process.env.SHOPIFY_API_SECRET || "",
|
|
apiVersion: ApiVersion.January26,
|
|
scopes: process.env.SCOPES?.split(","),
|
|
appUrl: process.env.SHOPIFY_APP_URL || "",
|
|
authPathPrefix: "/auth",
|
|
sessionStorage: new PrismaSessionStorage(prisma),
|
|
distribution: AppDistribution.AppStore,
|
|
future: { expiringOfflineAccessTokens: true },
|
|
billing: {
|
|
[PLAN_GROWTH]: {
|
|
trialDays: 14,
|
|
lineItems: [{ amount: 19, currencyCode: "USD", interval: BillingInterval.Every30Days }],
|
|
},
|
|
[PLAN_PRO]: {
|
|
trialDays: 14,
|
|
lineItems: [{ amount: 49, currencyCode: "USD", interval: BillingInterval.Every30Days }],
|
|
},
|
|
},
|
|
hooks: {
|
|
afterAuth: async ({ session, admin }) => {
|
|
await ensureShop(session.shop, admin);
|
|
},
|
|
},
|
|
...(process.env.SHOP_CUSTOM_DOMAIN ? { customShopDomains: [process.env.SHOP_CUSTOM_DOMAIN] } : {}),
|
|
});
|
|
|
|
export default shopify;
|
|
export const apiVersion = ApiVersion.January26;
|
|
export const addDocumentResponseHeaders = shopify.addDocumentResponseHeaders;
|
|
export const authenticate = shopify.authenticate;
|
|
export const unauthenticated = shopify.unauthenticated;
|
|
export const login = shopify.login;
|
|
export const registerWebhooks = shopify.registerWebhooks;
|
|
export const sessionStorage = shopify.sessionStorage;
|