From 45c746ef05293eacce52d24e686072da696d6765 Mon Sep 17 00:00:00 2001 From: Martin Raifer Date: Sat, 25 Feb 2023 18:18:28 +0100 Subject: [PATCH] also make other CDNs and services configurable via env vars --- API.md | 9 +++++++-- config/envs.mjs | 9 ++++++++- config/id.js | 20 ++++++++++++-------- 3 files changed, 27 insertions(+), 11 deletions(-) diff --git a/API.md b/API.md index 68387ac40..30d3ea7c2 100644 --- a/API.md +++ b/API.md @@ -106,9 +106,14 @@ In addition, the following parameters are available as **URL query parameters**: Environment variables or a dotenv file can be used to configure certain aspects of iD at build time. +* __`ID_API_CONNECTION_URL`__, __`ID_API_CONNECTION_CLIENT_ID`__, __`ID_API_CONNECTION_CLIENT_SECRET`__ - Custom [Oauth2](https://wiki.openstreetmap.org/wiki/OAuth#OAuth_2.0_2) connection details to an OSM API server. +* __`ID_API_CONNECTION`__ - Either `live` or `dev`, if only either one should be made offered for editing. * __`ID_PRESETS_CDN_URL`__ - The URL where iD should fetch it's tagging presets from. Needs to point to a CORS enabled web server which is serving the `package.json` and `dist` folder of a repository built on [`@ideditor/schema-builder`](https://github.com/ideditor/schema-builder). -* __`ID_API_CONNECTION_URL`__, __`ID_API_CONNECTION_CLIENT_ID`__, __`ID_API_CONNECTION_CLIENT_SECRET`__ - custom [Oauth2](https://wiki.openstreetmap.org/wiki/OAuth#OAuth_2.0_2) connection details to an OSM API server -* __`ID_API_CONNECTION`__ - either `live` or `dev`, if only either one should be made offered for editing +* __`ENV__ID_OCI_CDN_URL`__ - URL to a hosted version of the [osm-community-index](https://github.com/osmlab/osm-community-index) +* __`ENV__ID_NSI_CDN_URL`__ - URL to a hosted version of the [name-suggestion-index](https://github.com/osmlab/name-suggestion-index) +* __`ENV__ID_WMF_SITEMATRIX_CDN_URL`__ - URL to a hosted version of the [wmf-sitematrix](https://github.com/osmlab/wmf-sitematrix) +* __`ID_TAGINFO_API_URL`__ - URL to a [taginfo](https://wiki.openstreetmap.org/wiki/Taginfo) service. +* __`ID_NOMINATIM_API_URL`__ - URL to a [nominatim](https://wiki.openstreetmap.org/wiki/Nominatim) geocoding service. ## CSS selectors diff --git a/config/envs.mjs b/config/envs.mjs index 4485813a3..aa682f282 100644 --- a/config/envs.mjs +++ b/config/envs.mjs @@ -3,10 +3,17 @@ import dotenv from 'dotenv'; dotenv.config(); const envs = { ENV__ID_PRESETS_CDN_URL: JSON.stringify(process.env.ID_PRESETS_CDN_URL || null), + ENV__ID_OCI_CDN_URL: JSON.stringify(process.env.ID_OCI_CDN_URL || null), + ENV__ID_NSI_CDN_URL: JSON.stringify(process.env.ID_NSI_CDN_URL || null), + ENV__ID_WMF_SITEMATRIX_CDN_URL: JSON.stringify(process.env.ID_WMF_SITEMATRIX_CDN_URL || null), + ENV__ID_API_CONNECTION_URL: JSON.stringify(process.env.ID_API_CONNECTION_URL || null), ENV__ID_API_CONNECTION_CLIENT_ID: JSON.stringify(process.env.ID_API_CONNECTION_CLIENT_ID || null), ENV__ID_API_CONNECTION_CLIENT_SECRET: JSON.stringify(process.env.ID_API_CONNECTION_CLIENT_SECRET || null), - ENV__ID_API_CONNECTION: JSON.stringify(process.env.ID_API_CONNECTION || null) + ENV__ID_API_CONNECTION: JSON.stringify(process.env.ID_API_CONNECTION || null), + + ENV__ID_TAGINFO_API_URL: JSON.stringify(process.env.ENV__ID_TAGINFO_API_URL || null), + ENV__ID_NOMINATIM_API_URL: JSON.stringify(process.env.ENV__ID_NOMINATIM_API_URL || null), } export default envs; diff --git a/config/id.js b/config/id.js index d8dcfa12b..1ac157746 100644 --- a/config/id.js +++ b/config/id.js @@ -1,10 +1,12 @@ -//import * as env from 'env'; - // cdns for external data packages -const presetsCdnUrl = ENV__ID_PRESETS_CDN_URL || 'https://cdn.jsdelivr.net/npm/@openstreetmap/id-tagging-schema@{presets_version}/'; -const ociCdnUrl = 'https://cdn.jsdelivr.net/npm/osm-community-index@{version}/'; -const wmfSitematrixCdnUrl = 'https://cdn.jsdelivr.net/npm/wmf-sitematrix@{version}/'; -const nsiCdnUrl = 'https://cdn.jsdelivr.net/npm/name-suggestion-index@{version}/'; +const presetsCdnUrl = ENV__ID_PRESETS_CDN_URL + || 'https://cdn.jsdelivr.net/npm/@openstreetmap/id-tagging-schema@{presets_version}/'; +const ociCdnUrl = ENV__ID_OCI_CDN_URL + || 'https://cdn.jsdelivr.net/npm/osm-community-index@{version}/'; +const wmfSitematrixCdnUrl = ENV__ID_WMF_SITEMATRIX_CDN_URL + || 'https://cdn.jsdelivr.net/npm/wmf-sitematrix@{version}/'; +const nsiCdnUrl = ENV__ID_NSI_CDN_URL + || 'https://cdn.jsdelivr.net/npm/name-suggestion-index@{version}/'; // api urls and settings const defaultOsmApiConnections = { @@ -42,8 +44,10 @@ if (ENV__ID_API_CONNECTION_URL !== null && } // auxiliary OSM services -const taginfoApiUrl = 'https://taginfo.openstreetmap.org/api/4/'; -const nominatimApiUrl = 'https://nominatim.openstreetmap.org/'; +const taginfoApiUrl = ENV__ID_TAGINFO_API_URL + || 'https://taginfo.openstreetmap.org/api/4/'; +const nominatimApiUrl = ENV__ID_NOMINATIM_API_URL + || 'https://nominatim.openstreetmap.org/'; export { presetsCdnUrl,