refs #4823 Añadido modulo colors y modif. readme

This commit is contained in:
Guillermo Bonet 2023-03-13 14:56:39 +01:00
parent 9acb656501
commit c57916815d
4 changed files with 729 additions and 256 deletions

View File

@ -78,16 +78,16 @@ npm dev-sync # run and create the db structure
### .env file ### .env file
```bash ```bash
# FLORIDAY SERVICE CONFIG
CLIENT_ID = floriday-client_id CLIENT_ID = floriday-client_id
CLIENT_SECRET = floriday-client_secret CLIENT_SECRET = floriday-client_secret
STATUS = production_or_development STATUS = production_or_development
# SEQUELIZE CONFIG # SEQUELIZE CONFIG
DB_SCHEMA = edi DB_SCHEMA = edi
DB_USER = root DB_USER = root
DB_PWD = root DB_PWD = root
DB_HOST = localhost DB_HOST = localhost
DB_DIALECT = mariadb DB_DIALECT = mariadb
FORCE_SYNC = false
``` ```

976
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -11,6 +11,7 @@
}, },
"dependencies": { "dependencies": {
"cli-progress": "^3.11.2", "cli-progress": "^3.11.2",
"colors": "^1.4.0",
"dotenv": "^16.0.3", "dotenv": "^16.0.3",
"mariadb": "^3.0.2", "mariadb": "^3.0.2",
"moment": "^2.29.4", "moment": "^2.29.4",

View File

@ -3,6 +3,7 @@ import fetch from 'node-fetch';
import dotenv from 'dotenv'; import dotenv from 'dotenv';
import { models } from './models/index.js'; import { models } from './models/index.js';
import { v4 as uuidv4 } from 'uuid'; import { v4 as uuidv4 } from 'uuid';
import colors from 'colors';
//import cliProgress from 'cli-progress'; //import cliProgress from 'cli-progress';
dotenv.config(); dotenv.config();
@ -22,6 +23,9 @@ const BASE_CUSTOMER_URL = 'https://api.staging.floriday.io/customers-api/2022v2/
async function getClientToken() { async function getClientToken() {
const clientConfigData = await models.clientConfig.findAll(); const clientConfigData = await models.clientConfig.findAll();
if (!clientConfigData[0])
throw colors.red.bold('Token has expired')
const now = moment().format('YYYY-MM-DD HH:mm:ss'); const now = moment().format('YYYY-MM-DD HH:mm:ss');
const tokenExpirationDate = clientConfigData[0].tokenExpiration; const tokenExpirationDate = clientConfigData[0].tokenExpiration;