104 lines
1.9 KiB
Markdown
104 lines
1.9 KiB
Markdown
# Floriday
|
|
|
|
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.
|
|
This is done using the [node-fetch](https://www.npmjs.com/package/node-fetch) package.
|
|
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.
|
|
|
|
## 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
|
|
#FLORIDAY DATA
|
|
CLIENT_ID = xxxxxxxxxx
|
|
CLIENT_SECRET = xxxxxxxxxx
|
|
API_KEY = xxxxxxxxxx
|
|
|
|
#SEQUELIZE CONFIG
|
|
DB_SCHEMA = schema
|
|
DB_USER = root
|
|
DB_PWD = root
|
|
DB_HOST = localhost
|
|
DB_DIALECT = mariadb
|
|
|
|
#GENERAL CONFIG
|
|
IS_PRODUCTION = false
|
|
SECRETS = true
|
|
FORCE_SYNC = true
|
|
SYNC_SEQUENCE = true
|
|
SYNC_SUPPLIER = true
|
|
SYNC_TRADEITEM = true
|
|
```
|
|
|
|
## Guidelines
|
|
|
|
- In case a new model is created, it should follow the following structure:
|
|
|
|
- /models
|
|
- main.js
|
|
- foo.js
|
|
|
|
### Foo.js
|
|
|
|
```javascript
|
|
import { Sequelize } from "sequelize";
|
|
|
|
const bar = {
|
|
barCharacteristicOne: {
|
|
type: Sequelize.INTEGER,
|
|
},
|
|
barCharacteristicTwo: {
|
|
type: Sequelize.STRING,
|
|
},
|
|
barCharacteristicThree: {
|
|
type: Sequelize.STRING,
|
|
},
|
|
};
|
|
|
|
export default (sequelize) => {
|
|
const Foo = sequelize.define(
|
|
"FDfoo",
|
|
bar,
|
|
{
|
|
timestamps: false,
|
|
freezeTableName: true,
|
|
}
|
|
);
|
|
return Foo;
|
|
};
|
|
```
|
|
|
|
### main.js
|
|
|
|
```javascript
|
|
import foo from "./foo";
|
|
|
|
let models = {
|
|
bar: foo(sequelize),
|
|
};
|
|
|
|
```
|
|
|
|
## Built With
|
|
|
|
* [nodejs](https://nodejs.org/)
|
|
* [sequalize](https://sequelize.org/) |