Skip to content

Instantly share code, notes, and snippets.

@wmakeev
Last active November 24, 2021 04:25
Show Gist options
  • Save wmakeev/1bbdf2f8aaf49a972411e1b20f257240 to your computer and use it in GitHub Desktop.
Save wmakeev/1bbdf2f8aaf49a972411e1b20f257240 to your computer and use it in GitHub Desktop.
[getEcwidInstance] #ecwid #instance
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