<commit_before>require('dotenv').config();
const express = require('express');
const router = express.Router();
const fetch = require('node-fetch');
const hbs = require('hbs');
const co = require('co');

const Airtable = require('airtable');
Airtable.configure({
  endpointUrl: 'https://api.airtable.com',
  apiKey: process.env.AIRTABLE_API_KEY
});
const base = Airtable.base(process.env.AIRTABLE_APP_ID);

hbs.registerHelper('concat', (...args) => args.slice(0, -1).join(''));
hbs.registerHelper("inc", value => parseInt(value) + 1);

function *getWotDDefinition(wotd) {
  const b = yield fetch('https://od-api.oxforddictionaries.com/api/v1/entries/e/' + wotd, {
      headers: {
        app_id: process.env.OED_APP_ID,
        app_key: process.env.OED_APP_KEY
      }
    });

  const j = yield b.json();

  return j.results[0];
}

router.get('/wotd', function (req, res, next) {  
  co(function*() {
    try {
      let defn = yield getWotDDefinition('ace');
      res.send(defn);
    } catch (err) {
      console.error (err);
    }
  });
});




router.get('/', function (req, res, next) {
  const meetingDetails = {};

  const p1 = base('Meetings').select({ view: 'Grid view' }).all().then(meetingRecords => {
    const meeting = meetingRecords[0];
    const word = meeting.get('Word of the Day');
    const location = meeting.get('Location');
    const date = new Date(meeting.get('Date and Time')).toLocaleDateString();
    const topic = meeting.get('Topic');

    meetingDetails.wotd = word;
    meetingDetails.location = location;
    meetingDetails.date = date;
    meetingDetails.topic = topic;

    const wotdP = fetch('https://od-api.oxforddictionaries.com/api/v1/entries/en/' + word, {<commit_msg>Playing around with await/async as alternative to generators.<commit_after>require('dotenv').config();
const express = require('express');
const router = express.Router();
const fetch = require('node-fetch');
const hbs = require('hbs');
const co = require('co');

const Airtable = require('airtable');
Airtable.configure({
  endpointUrl: 'https://api.airtable.com',
  apiKey: process.env.AIRTABLE_API_KEY
});
const base = Airtable.base(process.env.AIRTABLE_APP_ID);

hbs.registerHelper('concat', (...args) => args.slice(0, -1).join(''));
hbs.registerHelper("inc", value => parseInt(value) + 1);

function *getWotDDefinition(wotd) {
  const b = yield fetch('https://od-api.oxforddictionaries.com/api/v1/entries/en/' + wotd, {
      headers: {
        app_id: process.env.OED_APP_ID,
        app_key: process.env.OED_APP_KEY
      }
    });

  const j = yield b.json();

  return j.results[0];
}

router.get('/wotd', function (req, res, next) {  
  co(function*() {
    try {
      let defn = yield getWotDDefinition('ace');
      res.send(defn);
    } catch (err) {
      console.error (err);
    }
  });
});

async function getWotDDefinition2(wotd) {
  const b = await fetch('https://od-api.oxforddictionaries.com/api/v1/entries/en/' + wotd, {
      headers: {
        app_id: process.env.OED_APP_ID,
        app_key: process.env.OED_APP_KEY
      }
    });

  const j = await b.json();

  return j.results[0];
}

router.get('/wotd2', function (req, res, next) {  
  (async function() {
    const r = await getWotDDefinition2('ace')
    res.send(r);
  })();
    
});


router.get('/', function (req, res, next) {
  const meetingDetails = {};

  const p1 = base('Meetings').select({ view: 'Grid view' }).all().then(meetingRecords => {
    const meeting = meetingRecords[0];
    const word = meeting.get('Word of the Day');
    const location = meeting.get('Location');
    const date = new Date(meeting.get('Date and Time')).toLocaleDateString();
    const topic = meeting.get('Topic');

    meetingDetails.wotd = word;
    meetingDetails.location = location;
    meetingDetails.date = date;
    meetingDetails.topic = topic;

    const wotdP = fetch('https://od-api.oxforddictionaries.com/api/v1/entries/en/' + word, {
{'fraction_non_alphanumeric': 0.17150127226463105, 'fraction_numerical': 0.0053435114503816794, 'mean_word_length': 3.586931155192532, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 7, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4178968', 'n_tokens_mistral': 1344, 'n_tokens_neox': 1322, 'n_words': 270}