diff --git a/models/index.js b/models/index.js index e9b3142..32ce29b 100644 --- a/models/index.js +++ b/models/index.js @@ -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, + }, }); } diff --git a/suppliersGln.js b/suppliersGln.js index 0692031..4ba939c 100644 --- a/suppliersGln.js +++ b/suppliersGln.js @@ -6,4 +6,6 @@ let floraholland = [ 8718288004970, ]; +let others = []; + export default {floraholland}; \ No newline at end of file diff --git a/utils.js b/utils.js index 520e93c..9f01908 100644 --- a/utils.js +++ b/utils.js @@ -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');