@architect/functions
Version:
Runtime utility library for Functional Web Apps (FWAs) built with Architect (https://arc.codes)
17 lines (16 loc) • 488 B
JavaScript
/**
* No magic url helper for legacy REST APIs
* Given path `/`, it returns:
*
* - `/` if ARC_ENV === testing
* - `/staging` if ARC_ENV === staging
* - `/production` if ARC_ENV === production
*/
module.exports = function url (url) {
let { ARC_ENV, ARC_LOCAL } = process.env
let staging = ARC_ENV === 'staging'
let production = ARC_ENV === 'production'
if (!ARC_LOCAL && (staging || production))
return `/${ARC_ENV}${url}`
return url // fallthru for ARC_ENV=testing
}