UNPKG

@koempf/shopgate-utility

Version:

Shopgate WebCheckout utility for Kömpf

37 lines (25 loc) 989 B
'use strict' const { UnknownError } = require('./errors') const validate = (property, context) => { if (!property) { console.error('A required value in the config was not set (e.g. endpoint, clientId, etc') throw new UnknownError() } } const getEndpoint = context => { const endpoint = process.env.KOS_ENDPOINT || context.config.endpoint return validate(endpoint, context) || endpoint } const getClientId = context => { const clientId = process.env.KOS_CLIENT_ID || context.config.clientId return validate(clientId, context) || clientId } const getClientSecret = context => { const clientSecret = process.env.KOS_CLIENT_SECRET || context.config.clientSecret return validate(clientSecret, context) || clientSecret } const getSentryDsn = context => { const sentryDsn = process.env.KOS_SENTRY_DSN || context.config.sentryDsn return validate(sentryDsn, context) || sentryDsn } module.exports = { getEndpoint, getClientId, getClientSecret, getSentryDsn }