remove comments
This commit is contained in:
parent
0eed231dce
commit
f79662beb6
5
index.js
5
index.js
|
@ -1,7 +1,6 @@
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
import { getClientToken } from './utils.js';
|
import { getClientToken } from './utils.js';
|
||||||
|
|
||||||
// Check the existence of the .env file
|
|
||||||
import dotenv from 'dotenv';
|
import dotenv from 'dotenv';
|
||||||
dotenv.config();
|
dotenv.config();
|
||||||
|
|
||||||
|
@ -9,12 +8,9 @@ import models from './models/index.js';
|
||||||
|
|
||||||
let AccessToken = await getClientToken(models);
|
let AccessToken = await getClientToken(models);
|
||||||
|
|
||||||
// eslint-disable-next-line no-unused-vars
|
|
||||||
let tokenValue = AccessToken[0];
|
|
||||||
let tokenExpirationDate = AccessToken[1];
|
let tokenExpirationDate = AccessToken[1];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Every 30 sec query the database
|
|
||||||
setInterval(async () => {
|
setInterval(async () => {
|
||||||
console.log('Querying the API to check for new data...');
|
console.log('Querying the API to check for new data...');
|
||||||
console.log('Current token expiration date: ', tokenExpirationDate);
|
console.log('Current token expiration date: ', tokenExpirationDate);
|
||||||
|
@ -22,7 +18,6 @@ try {
|
||||||
if (moment().isAfter(tokenExpirationDate)) {
|
if (moment().isAfter(tokenExpirationDate)) {
|
||||||
console.log('Token expired, getting a new one...');
|
console.log('Token expired, getting a new one...');
|
||||||
AccessToken = await getClientToken(models);
|
AccessToken = await getClientToken(models);
|
||||||
tokenValue = AccessToken[0];
|
|
||||||
tokenExpirationDate = AccessToken[1];
|
tokenExpirationDate = AccessToken[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,6 @@ let models = {
|
||||||
characteristics: characteristics(sequelize),
|
characteristics: characteristics(sequelize),
|
||||||
};
|
};
|
||||||
|
|
||||||
// Force sync the models if the enviroment variable "FORCE_SYNC" is set to true
|
|
||||||
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 });
|
||||||
|
|
1
utils.js
1
utils.js
|
@ -27,7 +27,6 @@ async function getClientToken(models) {
|
||||||
|
|
||||||
const tokenResponse = await tokenRequest.json();
|
const tokenResponse = await tokenRequest.json();
|
||||||
|
|
||||||
// If the token request is successful, show a message in the console
|
|
||||||
if (tokenRequest.status === 200) {
|
if (tokenRequest.status === 200) {
|
||||||
console.log('Token request successful');
|
console.log('Token request successful');
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue