changed so it only inserts the api keys if the sync option is true
This commit is contained in:
parent
8674a12111
commit
45d819c47b
|
@ -88,6 +88,5 @@ DB_USER = root
|
||||||
DB_PWD = root
|
DB_PWD = root
|
||||||
DB_HOST = localhost
|
DB_HOST = localhost
|
||||||
DB_DIALECT = mariadb
|
DB_DIALECT = mariadb
|
||||||
SQLZE_LOGGING = false
|
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
9
index.js
9
index.js
|
@ -57,7 +57,14 @@ async function getClientToken() {
|
||||||
|
|
||||||
const tokenResponse = await tokenRequest.json();
|
const tokenResponse = await tokenRequest.json();
|
||||||
|
|
||||||
console.log('Token response: ', tokenResponse);
|
// If the token request is successful, show a message in the console
|
||||||
|
if (tokenRequest.status === 200) {
|
||||||
|
console.log('Token request successful');
|
||||||
|
} else {
|
||||||
|
throw new Error(
|
||||||
|
`Token request failed with status ${tokenRequest.status}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
const accessToken = tokenResponse.access_token;
|
const accessToken = tokenResponse.access_token;
|
||||||
let now = moment().format('YYYY-MM-DD HH:mm:ss');
|
let now = moment().format('YYYY-MM-DD HH:mm:ss');
|
||||||
|
|
|
@ -5,7 +5,7 @@ dotenv.config();
|
||||||
let sequelize = new Sequelize(process.env.DB_SCHEMA, process.env.DB_USER, process.env.DB_PWD, {
|
let sequelize = new Sequelize(process.env.DB_SCHEMA, process.env.DB_USER, process.env.DB_PWD, {
|
||||||
host: process.env.DB_HOST,
|
host: process.env.DB_HOST,
|
||||||
dialect: process.env.DB_DIALECT,
|
dialect: process.env.DB_DIALECT,
|
||||||
logging: process.env.SQLZE_LOGGING,
|
logging: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
import additionalPricePerPiece from './additionalPricePerPiece.js';
|
import additionalPricePerPiece from './additionalPricePerPiece.js';
|
||||||
|
@ -36,9 +36,12 @@ let models = {
|
||||||
if (process.env.FORCE_SYNC === 'true') {
|
if (process.env.FORCE_SYNC === 'true') {
|
||||||
console.log('Syncing the models...');
|
console.log('Syncing the models...');
|
||||||
await sequelize.sync({ force: true });
|
await sequelize.sync({ force: true });
|
||||||
|
|
||||||
|
await models.clientConfig.create({
|
||||||
|
clientId: process.env.CLIENT_ID,
|
||||||
|
clientSecret: process.env.CLIENT_SECRET,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
import * as insertApiKeys from './insertApiKeys.js';
|
|
||||||
await insertApiKeys.default(models);
|
|
||||||
|
|
||||||
export default models;
|
export default models;
|
||||||
|
|
|
@ -1,17 +0,0 @@
|
||||||
import dotenv from 'dotenv';
|
|
||||||
|
|
||||||
async function insertApiKeys(models) {
|
|
||||||
try {
|
|
||||||
dotenv.config();
|
|
||||||
console.log('Inserting the API keys...');
|
|
||||||
await models.clientConfig.create({
|
|
||||||
clientId: process.env.CLIENT_ID,
|
|
||||||
clientSecret: process.env.CLIENT_SECRET,
|
|
||||||
});
|
|
||||||
} catch (error) {
|
|
||||||
console.log('There was a error while inserting the API keys');
|
|
||||||
console.log(error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export default insertApiKeys;
|
|
Loading…
Reference in New Issue