Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var airtable = require('airtable');
var async = require('async');
var md5 = require('md5');
var moment = require('moment');
var fs = require('fs');
var configs = require('./configs');
var emailSender = require('./emailSender');
var secrets = require('./secrets');
// Set up connection to Airtable
airtable.configure({
endpointUrl: 'https://api.airtable.com',
apiKey: secrets.apiKey
});
var base = airtable.base(secrets.airtableBase);
// Create local storage for hashes of records
var hashDir = './localStorage/';
if (!fs.existsSync(hashDir)) {
fs.mkdirSync(hashDir);
}
exports.hackLastUpdated = function hackLastUpdated() {
// Each record that was updated will be included in email notifications
var recordsUpdated = [];
// Retrieve records from all tables listed
async.forEach(configs.airtableTables, function(table, callback) {
var hashPath = hashDir + table + '.json';
var hashes = {};
function _configureAirtable() {
Airtable.configure({ apiKey: '__AIRTABLE_API_KEY__' });
return Airtable.base('__AIRTABLE_BASE_ID__')('Attendees');
}
_mergeConfig(config) {
if(!config) return this.config;
let override = {};
if(typeof config === "string") override.tableName = config;
if(typeof config === "object") {
if(typeof config.transform !== "function") config.transform = undefined;
override = config;
}
let cfg = { ...this.config, ...override };
if(cfg.apiKey !== Airtable.apiKey) {
Airtable.apiKey = cfg.apiKey;
cfg.base = Airtable.base(cfg.baseID);
}
if(!cfg.base || (cfg.baseID !== cfg.base.getId())) cfg.base = Airtable.base(cfg.baseID);
return cfg;
}
let override = {};
if(typeof config === "string") override.tableName = config;
if(typeof config === "object") {
if(typeof config.transform !== "function") config.transform = undefined;
override = config;
}
let cfg = { ...this.config, ...override };
if(cfg.apiKey !== Airtable.apiKey) {
Airtable.apiKey = cfg.apiKey;
cfg.base = Airtable.base(cfg.baseID);
}
if(!cfg.base || (cfg.baseID !== cfg.base.getId())) cfg.base = Airtable.base(cfg.baseID);
return cfg;
}