2022-12-05 12:58:16 +00:00
|
|
|
# Floriday
|
2022-12-05 12:53:30 +00:00
|
|
|
|
2023-01-16 13:52:08 +00:00
|
|
|
Requires [Node.js](https://nodejs.org/en/) v15.14.0 or higher.
|
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-01-11 12:13:22 +00:00
|
|
|
# EVERY UUID GENERATED IN THIS PROJECT IS PREPENDED W/ 'Vn-' BECAUSE OF A BUG IN SEQUELIZE
|
|
|
|
|
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
|
|
|
|
- index.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;
|
|
|
|
};
|
|
|
|
```
|
|
|
|
|
|
|
|
### Index.js
|
|
|
|
|
|
|
|
```javascript
|
|
|
|
import foo from "./foo";
|
|
|
|
|
|
|
|
let models = {
|
|
|
|
bar: foo(sequelize),
|
|
|
|
};
|
|
|
|
|
|
|
|
```
|
2022-12-05 12:58:16 +00:00
|
|
|
|
2022-12-05 12:53:30 +00:00
|
|
|
To install dependencies:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
npm install
|
|
|
|
```
|
|
|
|
|
|
|
|
To run:
|
|
|
|
|
|
|
|
```bash
|
2023-01-09 10:59:07 +00:00
|
|
|
npm start # run the service
|
|
|
|
npm dev-sync # run and create the db structure
|
|
|
|
```
|
|
|
|
|
|
|
|
### .env file
|
|
|
|
|
|
|
|
```bash
|
|
|
|
CLIENT_ID = floriday-client_id
|
|
|
|
CLIENT_SECRET = floriday-client_secret
|
|
|
|
STATUS = production_or_development
|
|
|
|
|
|
|
|
# SEQUELIZE CONFIG
|
|
|
|
|
|
|
|
DB_SCHEMA = edi
|
|
|
|
DB_USER = root
|
|
|
|
DB_PWD = root
|
|
|
|
DB_HOST = localhost
|
|
|
|
DB_DIALECT = mariadb
|
|
|
|
|
2022-12-05 12:53:30 +00:00
|
|
|
```
|