fix multiple config lines

This commit is contained in:
Pau 2023-02-07 07:50:05 +01:00
parent e10ee70d4a
commit 559bb6e12c
3 changed files with 19 additions and 14 deletions

View File

@ -149,9 +149,14 @@ if (process.env.FORCE_SYNC == true) {
} }
if (process.env.SECRETS) { if (process.env.SECRETS) {
await models.clientConfig.create({ await models.clientConfig.findOrCreate({
where: {
id: 1,
},
defaults: {
clientId: process.env.CLIENT_ID, clientId: process.env.CLIENT_ID,
clientSecret: process.env.CLIENT_SECRET, clientSecret: process.env.CLIENT_SECRET,
},
}); });
} }

View File

@ -6,4 +6,6 @@ let floraholland = [
8718288004970, 8718288004970,
]; ];
let others = [];
export default {floraholland}; export default {floraholland};

View File

@ -81,20 +81,18 @@ async function getClientToken() {
async function updateClientConfig(clientId, clientSecret, accessToken, tokenExpirationDate) { async function updateClientConfig(clientId, clientSecret, accessToken, tokenExpirationDate) {
try { try {
console.log('Updating the client config with the new token...'); console.log('Updating the client config with the new token...');
await models.clientConfig.update( await models.clientConfig.findOrCreate({
{ where: {
id: 1,
},
defaults: {
clientId: clientId, clientId: clientId,
clientSecret: clientSecret, clientSecret: clientSecret,
currentToken: accessToken, currentToken: accessToken,
tokenExpiration: tokenExpirationDate, tokenExpiration: tokenExpirationDate,
requestLimit : 500 requestLimit: 500,
}, },
{ });
where: {
id: 1,
},
}
);
console.log('Client config updated, new Token set'); console.log('Client config updated, new Token set');
console.log('New token expiration date: ', tokenExpirationDate); console.log('New token expiration date: ', tokenExpirationDate);
} catch (error) { } catch (error) {
@ -397,9 +395,9 @@ async function syncTradeItems(){
headers: headers headers: headers
}); });
let data = await request.json(); let itemdata = await request.json();
let results = data.results; let results = itemdata.results;
if (results.length == 0) { if (results.length == 0) {
console.log('No more trade items to sync'); console.log('No more trade items to sync');