UNPKG

@shopify/shopify-app-express

Version:

Shopify Express Middleware - to simplify the building of Shopify Apps with Express

32 lines (30 loc) 1.22 kB
class AppInstallations { sessionStorage; constructor(config) { if (!config.sessionStorage.findSessionsByShop) { throw new Error('To use this Express package, you must provide a session storage manager that implements findSessionsByShop'); } if (!config.sessionStorage.deleteSessions) { throw new Error('To use this Express package, you must provide a session storage manager that implements deleteSessions'); } this.sessionStorage = config.sessionStorage; } async includes(shopDomain) { const shopSessions = await this.sessionStorage.findSessionsByShop(shopDomain); if (shopSessions.length > 0) { for (const session of shopSessions) { if (session.accessToken) return true; } } return false; } async delete(shopDomain) { const shopSessions = await this.sessionStorage.findSessionsByShop(shopDomain); if (shopSessions.length > 0) { await this.sessionStorage.deleteSessions(shopSessions.map((session) => session.id)); } } } export { AppInstallations }; //# sourceMappingURL=app-installations.mjs.map