2022-12-05 12:58:16 +00:00
|
|
|
# Floriday
|
2022-12-05 12:53:30 +00:00
|
|
|
|
|
|
|
The Floriday service project should perform the following tasks:
|
|
|
|
|
|
|
|
1. Create / mantain the table structure to allow the storage of the data provided by the Floriday API.
|
|
|
|
This is done using the [Sequelize](https://sequelize.org/) ORM.
|
|
|
|
2. Query the Floriday API and store the data in the database.
|
2022-12-19 12:21:35 +00:00
|
|
|
This is done using the [node-fetch](https://www.npmjs.com/package/node-fetch) package.
|
2022-12-05 12:53:30 +00:00
|
|
|
2.1. The data is requested every minute, but only the data that has changed is stored in the database.
|
|
|
|
This is done using the [Sequelize](https://sequelize.org/) ORM and storing the data as it is received from the API,
|
|
|
|
so it can be compared with the previous data.
|
|
|
|
|
2023-04-04 18:14:20 +00:00
|
|
|
## Requeriments
|
|
|
|
|
|
|
|
* Git
|
|
|
|
* Nodejs (v15.14.0 or higher)
|
|
|
|
|
|
|
|
## Installation
|
|
|
|
|
|
|
|
Pull from repository.
|
|
|
|
|
|
|
|
Run this commands on project root directory to install Node dependencies.
|
|
|
|
|
|
|
|
```bash
|
|
|
|
npm i
|
|
|
|
```
|
|
|
|
|
|
|
|
### .env file template
|
|
|
|
|
|
|
|
```bash
|
2023-05-08 10:18:14 +00:00
|
|
|
#FLORIDAY DATA CONFIG
|
2023-04-04 18:14:20 +00:00
|
|
|
CLIENT_ID = xxxxxxxxxx
|
|
|
|
CLIENT_SECRET = xxxxxxxxxx
|
|
|
|
API_KEY = xxxxxxxxxx
|
2023-04-25 06:09:52 +00:00
|
|
|
API_URL = https://api.staging.floriday.io/customers-api-2023v1
|
2023-04-24 12:11:25 +00:00
|
|
|
API_ENDPOINT = https://idm.staging.floriday.io/oauth2/ausmw6b47z1BnlHkw0h7/v1/token
|
2023-04-04 18:14:20 +00:00
|
|
|
|
|
|
|
#SEQUELIZE CONFIG
|
|
|
|
DB_SCHEMA = schema
|
|
|
|
DB_USER = root
|
|
|
|
DB_PWD = root
|
|
|
|
DB_HOST = localhost
|
|
|
|
DB_DIALECT = mariadb
|
2023-04-06 08:56:52 +00:00
|
|
|
DB_TIMEOUT_RECONECT = 30000
|
|
|
|
DB_MAX_CONN_POOL = 40
|
2023-04-04 18:14:20 +00:00
|
|
|
|
|
|
|
#GENERAL CONFIG
|
|
|
|
IS_PRODUCTION = false
|
2023-04-24 10:46:06 +00:00
|
|
|
MS_PRODUCTION_SCHEDULE = 300000
|
|
|
|
MS_TEST_SCHEDULE = 100000
|
2023-04-04 18:14:20 +00:00
|
|
|
SECRETS = true
|
|
|
|
FORCE_SYNC = true
|
|
|
|
SYNC_SEQUENCE = true
|
|
|
|
SYNC_SUPPLIER = true
|
2023-04-06 08:56:52 +00:00
|
|
|
SYNC_CONN = true
|
2023-04-04 18:14:20 +00:00
|
|
|
SYNC_TRADEITEM = true
|
|
|
|
```
|
2023-01-11 12:13:22 +00:00
|
|
|
|
2022-12-05 12:58:16 +00:00
|
|
|
## Guidelines
|
|
|
|
|
2022-12-19 13:34:39 +00:00
|
|
|
- In case a new model is created, it should follow the following structure:
|
|
|
|
|
|
|
|
- /models
|
2023-04-04 18:14:20 +00:00
|
|
|
- main.js
|
2022-12-19 13:34:39 +00:00
|
|
|
- foo.js
|
|
|
|
|
|
|
|
### Foo.js
|
|
|
|
|
|
|
|
```javascript
|
2023-05-03 17:46:40 +00:00
|
|
|
import { Sequelize } from 'sequelize';
|
2022-12-19 13:34:39 +00:00
|
|
|
|
|
|
|
const bar = {
|
|
|
|
barCharacteristicOne: {
|
|
|
|
type: Sequelize.INTEGER,
|
|
|
|
},
|
|
|
|
barCharacteristicTwo: {
|
|
|
|
type: Sequelize.STRING,
|
|
|
|
},
|
|
|
|
barCharacteristicThree: {
|
|
|
|
type: Sequelize.STRING,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
export default (sequelize) => {
|
|
|
|
const Foo = sequelize.define(
|
2023-05-03 17:46:40 +00:00
|
|
|
"foo",
|
2022-12-19 13:34:39 +00:00
|
|
|
bar,
|
|
|
|
{
|
|
|
|
timestamps: false,
|
|
|
|
freezeTableName: true,
|
|
|
|
}
|
|
|
|
);
|
|
|
|
return Foo;
|
|
|
|
};
|
|
|
|
```
|
|
|
|
|
2023-04-04 18:14:20 +00:00
|
|
|
### main.js
|
2022-12-19 13:34:39 +00:00
|
|
|
|
|
|
|
```javascript
|
|
|
|
import foo from "./foo";
|
|
|
|
|
|
|
|
let models = {
|
|
|
|
bar: foo(sequelize),
|
|
|
|
};
|
|
|
|
|
|
|
|
```
|
2022-12-05 12:58:16 +00:00
|
|
|
|
2023-04-04 18:14:20 +00:00
|
|
|
## Built With
|
2023-01-09 10:59:07 +00:00
|
|
|
|
2023-04-04 18:14:20 +00:00
|
|
|
* [nodejs](https://nodejs.org/)
|
|
|
|
* [sequalize](https://sequelize.org/)
|