text: // this is aliased in webpack config based on server/client build
  import api from 'create-api'
  
  // warm the front page cache every 15 min
  // make sure to do this only once across all requests
  if (api.onServer && !api.warmCacheStarted) {
    api.warmCacheStarted = true
    warmCache()
  }
  
  function warmCache () {
    fetchItems((api.cachedIds.items || []).slice(0, 30))
    setTimeout(warmCache, 1000 * 60 * 15)
  }
  
  function fetch (child) {
    const cache = api.cachedItems
    if (cache && cache.has(child)) {
      return Promise.resolve(cache.get(child))
    } else {
      return new Promise((resolve, reject) => {
        api.child(child).once('value', snapshot => {
          const val = snapshot.val()
          // mark the timestamp when this item is cached
          if (val) val.__lastUpdated = Date.now()
          cache && cache.set(child, val)
          resolve(val)
        }, reject)
      })
    }
  }
  
  export function fetchItems () {
    return api.cachedIds && api.cachedIds[`items`]
      ? Promise.resolve(api.cachedIds[`items`])
      : fetch(`items`)
  }