1
0
mirror of synced 2025-12-19 18:10:59 -05:00
Files
docs/lib/fetch-early-access-paths.js
Vanessa Yuen 3df90fc9b8 Hello git history spelunker!
Are you looking for something? Here is all of the GitHub Docs history in one single commit. Enjoy! 🎉
2020-09-27 14:10:11 +02:00

34 lines
962 B
JavaScript

// This module loads an array of Early Access page paths from EARLY_ACCESS_HOSTNAME
//
// See also middleware/early-acces-proxy.js which fetches Early Access docs from the obscured remote host
require('dotenv').config()
const got = require('got')
const isURL = require('is-url')
module.exports = async function fetchEarlyAccessPaths () {
let url
if (process.env.NODE_ENV === 'test') return []
if (!isURL(process.env.EARLY_ACCESS_HOSTNAME)) {
console.log('EARLY_ACCESS_HOSTNAME is not defined; skipping fetching early access paths')
return []
}
try {
url = `${process.env.EARLY_ACCESS_HOSTNAME}/early-access-paths.json`
const { body } = await got(url, {
json: true,
timeout: 3000,
headers: {
'early-access-shared-secret': process.env.EARLY_ACCESS_SHARED_SECRET
}
})
return body
} catch (err) {
console.error('Unable to fetch early-access-paths.json from', url, err)
return []
}
}