Skip to content
Snippets Groups Projects
Commit 1ec2c057 authored by Francois Romain's avatar Francois Romain
Browse files

refactor: renomme les variables d'environnement

parent 1ceab05b
No related branches found
No related tags found
No related merge requests found
......@@ -32,7 +32,7 @@ EMAIL_SMTP_SERVER=in-v3.mailjet.com
ACTIVITES_RAPPORTS_EMAIL=email@domaine.com
# API de détection d'intersection avec les communes
GEO_API_URL=""
API_GEO_URL=""
# url du serveur (docker-compose)
URL=""
......
......@@ -11,7 +11,7 @@ import fileCreate from '../file-create'
const CACHE_DIR = 'api-cache/administration/'
const MAX_CALLS_MINUTE = 200
const { ADMINISTRATION_API_URL } = process.env
const { API_ADMINISTRATION_URL } = process.env
interface IOrganisme {
features: {
......@@ -32,7 +32,7 @@ interface IOrganisme {
}
const organismeFetch = async (departementId: string, nom: string) => {
if (!ADMINISTRATION_API_URL) {
if (!API_ADMINISTRATION_URL) {
throw new Error(
"impossible de se connecter à l'API administration car la variable d'environnement est absente"
)
......@@ -41,7 +41,7 @@ const organismeFetch = async (departementId: string, nom: string) => {
console.info(`API administration: requête ${departementId}, ${nom}`)
const response = await fetch(
`${ADMINISTRATION_API_URL}/v3/departements/${departementId}/${nom}`,
`${API_ADMINISTRATION_URL}/v3/departements/${departementId}/${nom}`,
{
method: 'GET',
headers: {
......
......@@ -7,7 +7,7 @@ const communesGeojsonFetch = async (path: string, geojson: IGeoJson) => {
const properties = JSON.stringify(geojson.properties)
try {
if (!process.env.GEO_API_URL) {
if (!process.env.API_GEO_URL) {
throw new Error(
"impossible de se connecter à l'API Géo Commune car la variable d'environnement est absente"
)
......@@ -18,7 +18,7 @@ const communesGeojsonFetch = async (path: string, geojson: IGeoJson) => {
throw new Error(geojsonErrors.map(e => e.message).join('\n'))
}
const response = await fetch(process.env.GEO_API_URL + path, {
const response = await fetch(process.env.API_GEO_URL + path, {
method: 'post',
headers: {
'Content-Type': 'application/json'
......
......@@ -23,7 +23,7 @@ const MAX_RESULTS = 20
// utilise `tokenInitialize` pour l'initialiser
let apiToken = ''
const { INSEE_API_URL, INSEE_API_KEY, INSEE_API_SECRET } = process.env
const { API_INSEE_URL, API_INSEE_KEY, API_INSEE_SECRET } = process.env
const TEST_SIREN_ID = '805296415'
......@@ -69,21 +69,21 @@ const tokenInitialize = async () => {
const tokenFetch = async () => {
try {
if (!INSEE_API_URL) {
if (!API_INSEE_URL) {
throw new Error(
"impossible de se connecter car la variable d'environnement est absente"
)
}
console.info(
`API Insee: récupération du token ${INSEE_API_KEY}:${INSEE_API_SECRET}`
`API Insee: récupération du token ${API_INSEE_KEY}:${API_INSEE_SECRET}`
)
const auth = Buffer.from(`${INSEE_API_KEY}:${INSEE_API_SECRET}`).toString(
const auth = Buffer.from(`${API_INSEE_KEY}:${API_INSEE_SECRET}`).toString(
'base64'
)
const response = await fetch(`${INSEE_API_URL}/token`, {
const response = await fetch(`${API_INSEE_URL}/token`, {
method: 'POST',
body: 'grant_type=client_credentials',
headers: {
......@@ -155,7 +155,7 @@ const tokenFetchDev = async () => {
const typeFetch = async (type: 'siren' | 'siret', q: string) => {
try {
if (!INSEE_API_URL) {
if (!API_INSEE_URL) {
throw new Error(
"API Insee: impossible de se connecter car la variable d'environnement est absente"
)
......@@ -164,7 +164,7 @@ const typeFetch = async (type: 'siren' | 'siret', q: string) => {
console.info(`API Insee: requête ${type}, ids: ${q}`)
const response = await fetch(
`${INSEE_API_URL}/entreprises/sirene/V3/${type}/?q=${q}`,
`${API_INSEE_URL}/entreprises/sirene/V3/${type}/?q=${q}`,
{
method: 'GET',
headers: {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment