Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
exports.sourceNodes = async (
{ boundActionCreators },
{ types, credential, appConfig }
) => {
try {
if (firebase.apps || !firebase.apps.length) {
const cfg = appConfig ? appConfig : {credential: firebase.credential.cert(credential)}
firebase.initializeApp(cfg);
}
} catch (e) {
report.warn(
'Could not initialize Firebase. Please check `credential` property in gatsby-config.js'
);
report.warn(e);
return;
}
const db = firebase.firestore();
db.settings({
timestampsInSnapshots: true,
});
const { createNode } = boundActionCreators;
const promises = types.map(
async ({ collection, type, map = node => node }) => {
const snapshot = await db.collection(collection).get();
for (let doc of snapshot.docs) {
exports.sourceNodes = async (
{ boundActionCreators },
{ types, credential, appConfig }
) => {
try {
if (firebase.apps || !firebase.apps.length) {
const cfg = appConfig ? appConfig : {credential: firebase.credential.cert(credential)}
firebase.initializeApp(cfg);
}
} catch (e) {
report.warn(
'Could not initialize Firebase. Please check `credential` property in gatsby-config.js'
);
report.warn(e);
return;
}
const db = firebase.firestore();
db.settings({
timestampsInSnapshots: true,
});
const { createNode } = boundActionCreators;
const promises = types.map(
async ({ collection, type, map = node => node }) => {
const snapshot = await db.collection(collection).get();
for (let doc of snapshot.docs) {
const contentDigest = getDigest(doc.id);
createNode(
Object.assign({}, map(doc.data()), {