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([]);
}
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)
});
});
}