Mise à jour des environnements
This commit is contained in:
@@ -3,13 +3,11 @@ NODE_ENV="development"
|
||||
DEBUG=false
|
||||
MONGODB_URI="mongodb://localhost:27017/headupdb"
|
||||
SERVER_PORT="3200"
|
||||
SECRET="$2b$10$sMuV/fTCGm9CJGamPFvvte"
|
||||
SECRET="$2b$10$2.JkQCRUa3fXESy/WyKVWO"
|
||||
SENDGRID_API_KEY="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"
|
||||
SENDGRID_FROM_MAIL="contact@rampeur.fr"
|
||||
SENDGRID_TO_MAIL="rampeur@gmail.com"
|
||||
AUTHORIZATION_PREFIX="Api-Key"
|
||||
GOLDAPI_URL="https://www.goldapi.io/api"
|
||||
GOLDAPI_TOKEN="goldapi-akasnfrlfiqv0xw-io"
|
||||
COUCHDB_URL="http://couchdb.unespace.com"
|
||||
COUCHDB_DATABASE="headupdb"
|
||||
COUCHDB_DESIGN="headup_app"
|
||||
|
||||
+2
-4
@@ -1,15 +1,13 @@
|
||||
APP_ENV="development"
|
||||
NODE_ENV="development"
|
||||
DEBUG=true
|
||||
DEBUG=false
|
||||
MONGODB_URI="mongodb://localhost:27017/headupdb"
|
||||
SERVER_PORT="3200"
|
||||
SECRET="$2b$10$7LPCMF6razIF744f3k3dLu"
|
||||
SECRET="$2b$10$2.JkQCRUa3fXESy/WyKVWO"
|
||||
SENDGRID_API_KEY="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"
|
||||
SENDGRID_FROM_MAIL="contact@rampeur.fr"
|
||||
SENDGRID_TO_MAIL="rampeur@gmail.com"
|
||||
AUTHORIZATION_PREFIX="Api-Key"
|
||||
GOLDAPI_URL="https://www.goldapi.io/api"
|
||||
GOLDAPI_TOKEN="goldapi-akasnfrlfiqv0xw-io"
|
||||
COUCHDB_URL="http://couchdb.unespace.com"
|
||||
COUCHDB_DATABASE="headupdb"
|
||||
COUCHDB_DESIGN="headup_app"
|
||||
|
||||
@@ -8,8 +8,6 @@ SENDGRID_API_KEY="SG.loEr_gMXRaO6O72zO4u4UA._jb31OOnWApMXfn7e5q9C7lIwzo5FUOoLX4J
|
||||
SENDGRID_FROM_MAIL="contact@rampeur.fr"
|
||||
SENDGRID_TO_MAIL="rampeur@gmail.com"
|
||||
AUTHORIZATION_PREFIX="Api-Key"
|
||||
GOLDAPI_URL="https://www.goldapi.io/api"
|
||||
GOLDAPI_TOKEN="goldapi-akasnfrlfiqv0xw-io"
|
||||
COUCHDB_URL="http://couchdb.unespace.com"
|
||||
COUCHDB_DATABASE="headupdb"
|
||||
COUCHDB_DESIGN="headup_app"
|
||||
|
||||
+2
-4
@@ -2,14 +2,12 @@ APP_ENV="production"
|
||||
NODE_ENV="production"
|
||||
DEBUG=false
|
||||
MONGODB_URI="mongodb://localhost:27017/headupdb"
|
||||
SERVER_PORT="3030"
|
||||
SECRET="$2b$10$t1ma1H6HsGi8tMK4GRH5fu"
|
||||
SERVER_PORT="3200"
|
||||
SECRET="$2b$10$2.JkQCRUa3fXESy/WyKVWO"
|
||||
SENDGRID_API_KEY="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"
|
||||
SENDGRID_FROM_MAIL="contact@rampeur.fr"
|
||||
SENDGRID_TO_MAIL="rampeur@gmail.com"
|
||||
AUTHORIZATION_PREFIX="Api-Key"
|
||||
GOLDAPI_URL="https://www.goldapi.io/api"
|
||||
GOLDAPI_TOKEN="goldapi-akasnfrlfiqv0xw-io"
|
||||
COUCHDB_URL="http://couchdb.unespace.com"
|
||||
COUCHDB_DATABASE="headupdb"
|
||||
COUCHDB_DESIGN="headup_app"
|
||||
|
||||
@@ -58,6 +58,7 @@ if(isProduction){
|
||||
console.log(`${utils.getDateTimeISOString()}`, chalk.red('Unable to connect to the MongoDB database'));
|
||||
});
|
||||
mongoose.set('debug', process.env.DEBUG);
|
||||
console.log(`${utils.getDateTimeISOString()}`, chalk.red('debug :'), chalk.yellow(process.env.DEBUG));
|
||||
}
|
||||
require('./models/mongo/User');
|
||||
require('./models/mongo/Application');
|
||||
|
||||
@@ -10,8 +10,6 @@
|
||||
"SENDGRID_FROM_MAIL": "contact@rampeur.fr",
|
||||
"SENDGRID_TO_MAIL": "rampeur@gmail.com",
|
||||
"AUTHORIZATION_PREFIX": "Api-Key",
|
||||
"GOLDAPI_URL": "https://www.goldapi.io/api",
|
||||
"GOLDAPI_TOKEN": "goldapi-akasnfrlfiqv0xw-io",
|
||||
"COUCHDB_URL": "http://couchdb.unespace.com",
|
||||
"COUCHDB_DATABASE": "headupdb",
|
||||
"COUCHDB_DESIGN": "headup_app",
|
||||
|
||||
+3
-3
@@ -8,16 +8,16 @@
|
||||
"Julien Gautier <rampeur@gmail.com>"
|
||||
],
|
||||
"scripts": {
|
||||
"mongo:start": "docker run --name hu-mongo -p 27017:27017 mongo & sleep 5",
|
||||
"start": "APP_ENV=production node ./app.js",
|
||||
"dev": "APP_ENV=development node ./app.js",
|
||||
"dev": "APP_ENV=development nodemon ./app.js",
|
||||
"local": "APP_ENV=local nodemon ./app.js",
|
||||
"test": "newman run ./tests/api-tests.postman.json -e ./tests/env-api-tests.postman.json",
|
||||
"stop": "lsof -ti :3200 | xargs kill",
|
||||
"mongo:start": "docker run --name hu-mongo -p 27017:27017 mongo & sleep 5",
|
||||
"mongo:stop": "docker stop hu-mongo && docker rm hu-mongo"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^16.20.1 || ^18.16.1 || ^20.3.1"
|
||||
"node": "^16.20.2 || ^18.19.1 || ^20.11.1"
|
||||
},
|
||||
"license": "UNLICENSED",
|
||||
"private": true,
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
const chalk = require('chalk');
|
||||
const nodeFetch = (...args) => import('node-fetch').then(({default: fetch}) => fetch(...args));
|
||||
|
||||
const utils = {
|
||||
getDateString: () => {
|
||||
@@ -31,37 +30,6 @@ const utils = {
|
||||
}
|
||||
|
||||
return dateString;
|
||||
},
|
||||
async fetchApi(price, next) {
|
||||
let url = `${process.env.GOLDAPI_URL}/${price.metal}/${price.currency}`;
|
||||
// url pour provoquer une erreur en dev : url = `https://www.goldapi.ioppppp/api/${price.metal}/${price.currency}`;
|
||||
let options = {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'x-access-token': process.env.GOLDAPI_TOKEN,
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
redirect: 'follow'
|
||||
};
|
||||
try {
|
||||
// Pour tester le retour d'erreur : return { errors: { name: 'error name', message: 'error message', type: 'TYPE', code: 'CODE' } };
|
||||
const response = await nodeFetch(url, options);
|
||||
if (response.status >= 200 && response.status < 400) {
|
||||
console.log(`${utils.getDateTimeISOString()}`, chalk.green(`${price.metal} | ${price.currency} - Réception du prix spot via API`), chalk.magenta(price.price), `${response.status} ${response.statusText}`);
|
||||
price = response.json();
|
||||
price.then(values => {
|
||||
values.timestamp *= 1000;
|
||||
return values;
|
||||
});
|
||||
} else {
|
||||
console.log(`${utils.getDateTimeISOString()}`, chalk.red(`${price.metal} | ${price.currency} - Erreur ${response.status} ${response.statusText} - Réutilisation du prix stocké`), chalk.magenta(price.price));
|
||||
price = { errors: { name: response.statusText, message: `Une erreur ${response.status} '${response.statusText}' est survenue lors de la récupération des prix spots`, type: 'API Error', code: response.status } };
|
||||
}
|
||||
return price;
|
||||
} catch (error) {
|
||||
console.log(`${utils.getDateTimeISOString()}`, chalk.red(`${price.metal} | ${price.currency} - fetchApi error`));
|
||||
return { errors: { name: error.name, message: error.message, type: error.type, code: error.code } };
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user