Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import db, { isoDate } from './db';
import Airtable from 'airtable';
import { airtable as airTableConf } from 'getconfig';
import fs from 'fs';
const request = require('request').defaults({ encoding: null });
const base = new Airtable({ apiKey: airTableConf.apiKey }).base(
airTableConf.base
);
// used on LIVE to sync data with the AirTable
// base, so that users can submit ads easily
async function sync({ reset } = {}) {
console.log('syncing');
try {
const ids = await getRecords({ reset });
const updateIds = await updateExistingRecords();
if (!reset) {
await updateRecords([...ids, ...updateIds]);
}
} catch (err) {
console.error(err);
throw err;
componentDidMount() {
const { currentPage } = this.props;
const that = this;
// nested arrays for pagination purposes
const allRows = [[]];
let currentRow = 1;
const base = new Airtable({
apiKey: process.env.AIRTABLE_API_KEY
}).base(process.env.BASE_ID);
tableHasPublishedColumn(base, includePublished =>
base(process.env.TABLE_ID)
.select({
view: process.env.VIEW,
...(includePublished ? { filterByFormula: "{Published}" } : {})
})
.eachPage(
function page(records, fetchNextPage) {
records.forEach(row => {
if (currentRow > 10) {
currentRow = 1;
allRows.push([]);
}
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 = {};
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
export default function airtableInit(baseID: string) {
const { serverRuntimeConfig } = getConfig()
if (!airTableSingleton) {
airTableSingleton = new AirtableAPI({ apiKey: serverRuntimeConfig.AIRTABLE_API_KEY })
}
return airTableSingleton.base(baseID)
}
function getExpensesTable(context: AutomatronContext) {
return new Airtable({ apiKey: context.secrets.AIRTABLE_API_KEY })
.base(context.secrets.AIRTABLE_EXPENSE_BASE)
.table('Expense records')
}
async function getExpensesSummaryData(context: AutomatronContext) {
export function getCronTable(context: AutomatronContext) {
return new Airtable({ apiKey: context.secrets.AIRTABLE_API_KEY })
.base(context.secrets.AIRTABLE_CRON_BASE)
.table('Cron jobs')
}
componentDidMount() {
const {
match: {
params: { slugOrId }
}
} = this.props;
const base = new Airtable({
apiKey: process.env.AIRTABLE_API_KEY
}).base(process.env.BASE_ID);
const that = this;
base(process.env.TABLE_ID).find(slugOrId, (err, record) => {
that.setState({
row: formatAirtableRowData(record)
});
});
}
function _configureAirtable() {
Airtable.configure({ apiKey: '__AIRTABLE_API_KEY__' });
return Airtable.base('__AIRTABLE_BASE_ID__')('Attendees');
}