Last active
November 24, 2021 04:25
-
-
Save wmakeev/1bbdf2f8aaf49a972411e1b20f257240 to your computer and use it in GitHub Desktop.
[getEcwidInstance] #ecwid #instance
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Ecwid, EcwidOptions } from '@wmakeev/ecwid' | |
import memoize from 'lodash.memoize' | |
export * from '@wmakeev/ecwid' | |
export const getInstance = memoize( | |
(_?: string, options: EcwidOptions = {}) => { | |
const { ECWID_STORE_ID, ECWID_TOKEN_SECRET } = process.env | |
if (!ECWID_STORE_ID) { | |
throw new Error('Переменная окружения ECWID_STORE_ID не определена') | |
} | |
if (!ECWID_TOKEN_SECRET) { | |
throw new Error('Переменная окружения ECWID_TOKEN_SECRET не определена') | |
} | |
return new Ecwid(ECWID_STORE_ID, ECWID_TOKEN_SECRET, options) | |
}, | |
instanceName => instanceName ?? 'default' | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment