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) {
await models.clientConfig.create({
clientId: process.env.CLIENT_ID,
clientSecret: process.env.CLIENT_SECRET,
await models.clientConfig.findOrCreate({
where: {
id: 1,
},
defaults: {
clientId: process.env.CLIENT_ID,
clientSecret: process.env.CLIENT_SECRET,
},
});
}

View File

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

View File

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