UNPKG

@shopify/shopify-app-react-router

Version:

Shopify React Router - to simplify the building of Shopify Apps with React Router

1 lines 1.3 kB
{"version":3,"file":"factory.mjs","sources":["../../../../../../src/server/unauthenticated/admin/factory.ts"],"sourcesContent":["import {createOrLoadOfflineSession} from '../../authenticate/helpers/create-or-load-offline-session';\nimport {SessionNotFoundError} from '../../errors';\nimport {BasicParams} from '../../types';\nimport {adminClientFactory} from '../../clients/admin';\n\nimport {UnauthenticatedAdminContext} from './types';\n\nexport function unauthenticatedAdminContextFactory(params: BasicParams) {\n return async (shop: string): Promise<UnauthenticatedAdminContext> => {\n const session = await createOrLoadOfflineSession(shop, params);\n\n if (!session) {\n throw new SessionNotFoundError(\n `Could not find a session for shop ${shop} when creating unauthenticated admin context`,\n );\n }\n\n return {\n session,\n admin: adminClientFactory({params, session}),\n };\n };\n}\n"],"names":[],"mappings":";;;;AAOM,SAAU,kCAAkC,CAAC,MAAmB,EAAA;AACpE,IAAA,OAAO,OAAO,IAAY,KAA0C;QAClE,MAAM,OAAO,GAAG,MAAM,0BAA0B,CAAC,IAAI,EAAE,MAAM,CAAC;QAE9D,IAAI,CAAC,OAAO,EAAE;AACZ,YAAA,MAAM,IAAI,oBAAoB,CAC5B,qCAAqC,IAAI,CAAA,4CAAA,CAA8C,CACxF;QACH;QAEA,OAAO;YACL,OAAO;YACP,KAAK,EAAE,kBAAkB,CAAC,EAAC,MAAM,EAAE,OAAO,EAAC,CAAC;SAC7C;AACH,IAAA,CAAC;AACH;;;;"}