@cloudcommerce/firebase
Advanced tools
Comparing version 0.0.37 to 0.0.38
import Deepmerge from '@fastify/deepmerge'; | ||
import { | ||
DEFAULT_LANG, DEFAULT_CURRENCY, DEFAULT_CURRENCY_SYMBOL, DEFAULT_COUNTRY_CODE, | ||
} from './defaults.js'; | ||
import { DEFAULT_LANG, DEFAULT_CURRENCY, DEFAULT_CURRENCY_SYMBOL, DEFAULT_COUNTRY_CODE, } from './defaults.js'; | ||
const deepmerge = Deepmerge(); | ||
const self = { | ||
__config: { | ||
hello: 'from @cloudcommerce/firebase', | ||
lang: process.env.ECOM_LANG || DEFAULT_LANG, | ||
currency: process.env.ECOM_CURRENCY || DEFAULT_CURRENCY, | ||
currencySymbol: process.env.ECOM_CURRENCY_SYMBOL || DEFAULT_CURRENCY_SYMBOL, | ||
countryCode: process.env.ECOM_COUNTRY_CODE || DEFAULT_COUNTRY_CODE, | ||
storeId: Number(process.env.ECOM_STORE_ID), | ||
httpsFunctionOptions: { | ||
region: process.env.DEPLOY_REGION || 'us-east1', | ||
__config: { | ||
hello: 'from @cloudcommerce/firebase', | ||
lang: process.env.ECOM_LANG || DEFAULT_LANG, | ||
currency: process.env.ECOM_CURRENCY || DEFAULT_CURRENCY, | ||
currencySymbol: process.env.ECOM_CURRENCY_SYMBOL || DEFAULT_CURRENCY_SYMBOL, | ||
countryCode: process.env.ECOM_COUNTRY_CODE || DEFAULT_COUNTRY_CODE, | ||
storeId: Number(process.env.ECOM_STORE_ID), | ||
httpsFunctionOptions: { | ||
region: process.env.DEPLOY_REGION || 'us-east1', | ||
}, | ||
}, | ||
}, | ||
}; | ||
export default { | ||
get() { | ||
return self.__config; | ||
}, | ||
set(config) { | ||
self.__config = deepmerge(self.__config, config); | ||
}, | ||
get() { | ||
return self.__config; | ||
}, | ||
set(config) { | ||
self.__config = deepmerge(self.__config, config); | ||
}, | ||
}; | ||
// # sourceMappingURL=config.js.map | ||
//# sourceMappingURL=config.js.map |
export const DEFAULT_LANG = 'pt_br'; | ||
export const DEFAULT_CURRENCY = 'BRL'; | ||
export const DEFAULT_CURRENCY_SYMBOL = 'R$'; | ||
export const DEFAULT_COUNTRY_CODE = 'BR'; | ||
// # sourceMappingURL=defaults.js.map | ||
//# sourceMappingURL=defaults.js.map |
export default () => { | ||
const { ECOM_AUTHENTICATION_ID, ECOM_API_KEY, GITHUB_TOKEN } = process.env; | ||
if (!ECOM_AUTHENTICATION_ID) { | ||
throw new Error('ECOM_AUTHENTICATION_ID is not set'); | ||
} | ||
if (!ECOM_API_KEY) { | ||
throw new Error('ECOM_API_KEY is not set'); | ||
} | ||
const authenticationId = ECOM_AUTHENTICATION_ID; | ||
const apiKey = ECOM_API_KEY; | ||
const githubToken = GITHUB_TOKEN; | ||
const env = { | ||
authenticationId, | ||
apiKey, | ||
githubToken, | ||
}; | ||
return env; | ||
const { ECOM_AUTHENTICATION_ID, ECOM_API_KEY, GITHUB_TOKEN, } = process.env; | ||
if (!ECOM_AUTHENTICATION_ID) { | ||
throw new Error('ECOM_AUTHENTICATION_ID is not set'); | ||
} | ||
if (!ECOM_API_KEY) { | ||
throw new Error('ECOM_API_KEY is not set'); | ||
} | ||
const authenticationId = ECOM_AUTHENTICATION_ID; | ||
const apiKey = ECOM_API_KEY; | ||
const githubToken = GITHUB_TOKEN; | ||
const env = { | ||
authenticationId, | ||
apiKey, | ||
githubToken, | ||
}; | ||
return env; | ||
}; | ||
// # sourceMappingURL=env.js.map | ||
//# sourceMappingURL=env.js.map |
@@ -6,28 +6,27 @@ // eslint-disable-next-line import/no-unresolved | ||
import getEnv from '../env.js'; | ||
export default async () => { | ||
const { authenticationId, apiKey } = getEnv(); | ||
const eventsSubs = await getFirestore().collection('eventsSubs').get(); | ||
const listenedEvents = []; | ||
eventsSubs.forEach((doc) => { | ||
const eventSub = doc.data(); | ||
if (!listenedEvents.includes(eventSub.event)) { | ||
listenedEvents.push(eventSub.event); | ||
} | ||
}); | ||
logger.info({ listenedEvents }); | ||
[ | ||
'orders', | ||
'products', | ||
'carts', | ||
].forEach(async (resource) => { | ||
const { data: { result } } = await api({ | ||
authenticationId, | ||
apiKey, | ||
endpoint: `events/${resource}`, | ||
const { authenticationId, apiKey } = getEnv(); | ||
const eventsSubs = await getFirestore().collection('eventsSubs').get(); | ||
const listenedEvents = []; | ||
eventsSubs.forEach((doc) => { | ||
const eventSub = doc.data(); | ||
if (!listenedEvents.includes(eventSub.event)) { | ||
listenedEvents.push(eventSub.event); | ||
} | ||
}); | ||
logger.info(`${resource} events: `, result); | ||
}); | ||
return true; | ||
logger.info({ listenedEvents }); | ||
[ | ||
'orders', | ||
'products', | ||
'carts', | ||
].forEach(async (resource) => { | ||
const { data: { result } } = await api({ | ||
authenticationId, | ||
apiKey, | ||
endpoint: `events/${resource}`, | ||
}); | ||
logger.info(`${resource} events: `, result); | ||
}); | ||
return true; | ||
}; | ||
// # sourceMappingURL=check-store-events.js.map | ||
//# sourceMappingURL=check-store-events.js.map |
@@ -9,8 +9,6 @@ /* eslint-disable import/prefer-default-export */ | ||
import checkStoreEvents from './handlers/check-store-events.js'; | ||
initializeApp(); | ||
export const cronStoreEvents = pubsub.schedule('* * * * *').onRun(() => { | ||
return checkStoreEvents(); | ||
return checkStoreEvents(); | ||
}); | ||
// # sourceMappingURL=index.js.map | ||
//# sourceMappingURL=index.js.map |
export {}; | ||
// # sourceMappingURL=types.js.map | ||
//# sourceMappingURL=types.js.map |
{ | ||
"name": "@cloudcommerce/firebase", | ||
"type": "module", | ||
"version": "0.0.37", | ||
"version": "0.0.38", | ||
"description": "E-Com Plus Cloud Commerce on Firebase", | ||
@@ -10,3 +10,3 @@ "main": "lib/index.js", | ||
".": "./lib/index.js", | ||
"./config": "./config.js" | ||
"./config": "./lib/config.js" | ||
}, | ||
@@ -25,3 +25,3 @@ "repository": { | ||
"dependencies": { | ||
"@cloudcommerce/api": "0.0.37", | ||
"@cloudcommerce/api": "0.0.38", | ||
"@fastify/deepmerge": "^1.1.0", | ||
@@ -34,3 +34,3 @@ "firebase-admin": "^11.0.0", | ||
"devDependencies": { | ||
"@cloudcommerce/types": "0.0.37", | ||
"@cloudcommerce/types": "0.0.38", | ||
"@firebase/app-types": "^0.7.0" | ||
@@ -37,0 +37,0 @@ }, |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
25363
1269
249
16
+ Added@cloudcommerce/api@0.0.38(transitive)
- Removed@cloudcommerce/api@0.0.37(transitive)
Updated@cloudcommerce/api@0.0.38