Skip to content

Commit 1265ad5

Browse files
authored
Mise à jour de la branche (#125)
* Fix Issue 123 (#124) * Fix issue 123 - remove elements from directory * Update readme.md * Update readme.md * Update readme-fr.md * Update CHANGELOG.md * Update readme-fr.md * Update publish.yml
1 parent 655da80 commit 1265ad5

File tree

10 files changed

+141
-13
lines changed

10 files changed

+141
-13
lines changed

.github/workflows/publish.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ jobs:
2020
registry-url: 'https://registry.npmjs.org'
2121
- run: npm install
2222
- name: Publish
23-
run: npm publish --access public --ignore-scripts
23+
run: |
24+
echo "//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}" > .npmrc
25+
npm publish --access public --ignore-scripts
2426
env:
2527
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Changelog
2+
3+
## [Unreleased]
4+
Cancel http request. This functionality is available using the available axios instance as described in the axios instance section of the table of contents.
5+
6+
## [1.0.3] - 2022-01-xx
7+
8+
### Added
9+
Add changelog file
10+
11+
### Fixed
12+
Give the possibility to clean list of queries added in the directory.

docs/readme-fr.md

Lines changed: 58 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,45 @@
99
![React](https://img.shields.io/badge/react-%2320232a.svg?style=for-the-badge&logo=react&logoColor=%2361DAFB)
1010
![React Native](https://img.shields.io/badge/react_native-%2320232a.svg?style=for-the-badge&logo=react&logoColor=%2361DAFB)
1111

12+
## Table of Contents
13+
- [Contexte](#contexte)
14+
- [Fonctionnalités](#fonctionnalit-s)
15+
- [Installation](#installation)
16+
- [Toutes les configurations](#toutes-les-configurations)
17+
* [Initialisation de la librairie](#initialisation-de-la-librairie)
18+
+ [L'application peut être initialisée de 2 manières :](#l-application-peut--tre-initialis-e-de-2-mani-res--)
19+
* [Utilisation des deux hooks](#utilisation-des-deux-hooks)
20+
+ [Hooks sans préchargement](#hooks-sans-pr-chargement)
21+
- [Autre exemple :](#autre-exemple--)
22+
- [Exemple de gestion d'erreur](#exemple-de-gestion-d-erreur)
23+
+ [Hook préchargé](#hook-pr-charg-)
24+
* [Hook avec paramètre](#hook-avec-param-tre)
25+
* [Instances Axios](#instances-axios)
26+
* [Liste des services](#liste-des-services)
27+
+ [Rh2DirectoryService](#rh2directoryservice)
28+
+ [Rh2ConfigService](#rh2configservice)
29+
+ [Rh2AxiosConfigService](#rh2axiosconfigservice)
30+
* [Liste des models Rh2](#liste-des-models-rh2)
31+
+ [Paramètre pour pour les requêtes non pré-chargée](#param-tre-pour-pour-les-requ-tes-non-pr--charg-e)
32+
- [Rh2EffectAxiosConfigHandler](#rh2effectaxiosconfighandler)
33+
- [Rh2EffectData](#rh2effectdata)
34+
+ [AxiosConfig](#axiosconfig)
35+
+ [FetchApi](#fetchapi)
36+
- [ResponseFetchApi](#responsefetchapi)
37+
- [ErreurFetchApi](#erreurfetchapi)
38+
+ [Configuration générale](#configuration-g-n-rale)
39+
- [Rh2InitializationParameter](#rh2initializationparameter)
40+
- [AxiosRequestConfigExtended](#axiosrequestconfigextended)
41+
+ [Rh2InitializationParameter](#rh2initializationparameter-1)
42+
+ [AxiosRequestConfigExtended](#axiosrequestconfigextended-1)
43+
- [Roadmap](#roadmap)
44+
1245
## Contexte
1346

14-
Cette librairie React utilisant les hooks customisés a pour but de faciliter l'utilisateur dans sa manipulation des requêtes HTTP. Il doit simplement configurer la requête qui sera exécutée par Axios, ainsi que le moment du déclenchement.Il est possible d’ajouter des paramètres supplémentaires pour des besoins de l’application cliente. Par exemple, demander qu’une requête soit exécutée seulement une fois via notre système d’historisation; la configuration des traitements à effectuer en cas d’erreurs de requête. Les utilisateurs de redux pourront trouver leur bonheur pour dispatch le résultat de la requête revenue avec succès ou non, celle-ci pourra également être précédée d’un traitement ou non.
47+
Cette librairie React utilisant les hooks customisés a pour but de faciliter l'utilisateur dans sa manipulation des requêtes HTTP. Il doit simplement configurer la requête qui sera exécutée par Axios, ainsi que le moment du déclenchement.Il est possible d’ajouter des paramètres supplémentaires pour des besoins de l’application cliente.
48+
Par exemple :
49+
- Demander qu’une requête soit exécutée seulement une fois via notre système d’historisation; la configuration des traitements à effectuer en cas d’erreurs de requête.
50+
- Les utilisateurs de redux pourront trouver leur bonheur pour dispatch le résultat de la requête revenue avec succès ou non, celle-ci pourra également être précédée d’un traitement ou non.
1551

1652
## Fonctionnalités
1753
- Tout ce que Axios peut faire
@@ -344,6 +380,22 @@ rh2AxiosConfigService.addAuthToConfigAxios(GOOGLE, {
344380

345381
### Liste des services
346382

383+
#### Rh2DirectoryService
384+
385+
Initialise l’application :
386+
387+
- Gestion des requêtes mise en mémoire pour éviter quelles soient de nouveau exécutées
388+
389+
| Méthode | type | Description |
390+
| ------------------------------------------------------------ | ---------------------- | --------------------------------------------- |
391+
| hasConfigQueryParameter(url: string, method: MethodRnhrh, params?: ParamRnhnh) | boolean | Vérifier la présence de la configuration |
392+
| hasConfigQueryParameterByConfigQueryParameter(parameter: ConfigQueryParameter) | boolean | Vérifier la présence de la configuration |
393+
| addConfigQueryParameter(configTmp: ConfigQueryParameter) | void | Ajouter une configuration à l'annuaire |
394+
| getConfigQueryParameters() | ConfigQueryParameter[] | Récupérer la liste des configurations |
395+
| getConfigQueryParameter(url: string, method: MethodRnhrh, params?: ParamRnhnh) | ConfigQueryParameter | Récupérer une configuration spécifique |
396+
| removeQueryDirectory(axiosRequestConfig: AxiosRequestConfig) | void | Supprimer une configuration précise |
397+
| removeAllQueryDirectory() | void | Supprimer toutes les configuration en mémoire |
398+
347399
#### Rh2ConfigService
348400

349401
Initialise l’application :
@@ -400,7 +452,7 @@ export interface Rh2EffectAxiosConfigHandler {
400452

401453
<b>axiosRequestConfig</b> Configuration Axios.
402454

403-
<b>addToDirectory</b> S'utilise si l'on veut exécuter une seule fois la requête durant l'utilisation de l'application. Si true, la valeur pourra être mise à jour avec le service <b>QueryStorageService</b> pour être réinitialisée.
455+
<b>addToDirectory</b> S'utilise si l'on veut exécuter une seule fois la requête durant l'utilisation de l'application. Si true, la valeur pourra être mise à jour avec le service <b>Rh2DirectoryService</b> pour être réinitialisée.
404456

405457
| Attention : La condition pour filtrer les requêtes s'appuie sur l'url, le type de méthode et la propriété params. |
406458
| ------------------------------------------------------------ |
@@ -584,3 +636,7 @@ const initSettings: Rh2InitializationParameter = {
584636

585637
- Modifier une instance Axios pour prendre en compte de nouveaux éléments (Ex : Mise à jour du paramètre «auth» de Axios)
586638
- Gérer l'annulation des requêtes HTTP par le biais de la librairie si nécessaire
639+
640+
641+
642+
<small><i><a href='http://ecotrust-canada.github.io/markdown-toc/'>Table of contents generated with markdown-toc</a></i></small>

exemple/Navigation.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import axios, { AxiosRequestConfig } from 'axios';
2121
import React, { useState } from 'react';
2222
import { Button, Text, View } from 'react-native';
2323
import { useDispatch } from 'react-redux';
24-
import { ResponseFetchApi, Rh2AxiosConfig, rh2AxiosConfigService } from '../src';
24+
import { ResponseFetchApi, Rh2AxiosConfig, rh2AxiosConfigService, rh2DirectoryService } from '../src';
2525
import { Rh2EffectAxiosConfigHandler } from '../src/models/Rh2Effect';
2626
import { useRh2WithName } from '../src/services/Rh2EffectsService';
2727
import { pourTestAction } from './redux/rh2-action';
@@ -182,6 +182,12 @@ const traitementErreur = (data: ResponseFetchApi) => {
182182
const test = useRh2WithName(GOOGLE);
183183
console.log(test);
184184

185+
console.log(rh2DirectoryService.getConfigQueryParameters());
186+
187+
rh2DirectoryService.removeAllQueryDirectory();
188+
console.log(rh2DirectoryService.getConfigQueryParameters());
189+
190+
185191

186192
// rh2ConfigService.setErrorHandler(traitementErreur);
187193

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-http-request-handler",
3-
"version": "1.0.2",
3+
"version": "1.0.3",
44
"private": false,
55
"license": "MIT",
66
"repository": {

readme.md

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,39 @@
1111

1212
[French documentation](https://github.com/Lunotte/react-http-request-handler/blob/Documentation/docs/readme-fr.md)
1313

14+
## Table of Contents
15+
- [Contexte](#contexte)
16+
- [Functionalities](#functionalities)
17+
- [Installation](#installation)
18+
- [Configurations](#configurations)
19+
* [Library usage](#library-usage)
20+
+ [You can initialize your application by :](#you-can-initialize-your-application-by--)
21+
* [Using two hooks](#using-two-hooks)
22+
+ [Hooks without preloading](#hooks-without-preloading)
23+
- [Other example :](#other-example--)
24+
- [Handling error example](#handling-error-example)
25+
+ [Preloaded Hook](#preloaded-hook)
26+
* [Hook with parameters](#hook-with-parameters)
27+
* [Axios instance](#axios-instance)
28+
* [Services](#services)
29+
+ [Rh2DirectoryService](#rh2directoryservice)
30+
+ [Rh2ConfigService](#rh2configservice)
31+
+ [Rh2AxiosConfigService](#rh2axiosconfigservice)
32+
* [Rh2 model list](#rh2-model-list)
33+
+ [Parameters for non-preloaded requests](#parameters-for-non-preloaded-requests)
34+
- [Rh2EffectAxiosConfigHandler](#rh2effectaxiosconfighandler)
35+
- [Rh2EffectData](#rh2effectdata)
36+
+ [AxiosConfig](#axiosconfig)
37+
+ [FetchApi](#fetchapi)
38+
- [ResponseFetchApi](#responsefetchapi)
39+
- [ErreurFetchApi](#erreurfetchapi)
40+
+ [General configuration](#general-configuration)
41+
- [Rh2InitializationParameter](#rh2initializationparameter)
42+
- [AxiosRequestConfigExtended](#axiosrequestconfigextended)
43+
+ [Rh2InitializationParameter](#rh2initializationparameter-1)
44+
+ [AxiosRequestConfigExtended](#axiosrequestconfigextended-1)
45+
- [Roadmap](#roadmap)
46+
1447
## Contexte
1548

1649
This React library using customized hooks is aimed to help users handling HTTP requests. The request and its trigger are simply configured, then executed by Axios. Optional parameters can also be configured depending on the web client needs.
@@ -350,6 +383,22 @@ rh2AxiosConfigService.addAuthToConfigAxios(GOOGLE, {
350383

351384
### Services
352385

386+
#### Rh2DirectoryService
387+
388+
Initialize the app :
389+
390+
- Management of requests stored in memory to prevent them from being executed again
391+
392+
| Méthode | type | Description |
393+
| ------------------------------------------------------------ | ---------------------- | --------------------------------------- |
394+
| hasConfigQueryParameter(url: string, method: MethodRnhrh, params?: ParamRnhnh) | boolean | Check the presence of the configuration |
395+
| hasConfigQueryParameterByConfigQueryParameter(parameter: ConfigQueryParameter) | boolean | Check the presence of the configuration |
396+
| addConfigQueryParameter(configTmp: ConfigQueryParameter) | void | Add a configuration to the directory |
397+
| getConfigQueryParameters() | ConfigQueryParameter[] | Retrieve the list of configurations |
398+
| getConfigQueryParameter(url: string, method: MethodRnhrh, params?: ParamRnhnh) | ConfigQueryParameter | Retrieve a specific configuration |
399+
| removeQueryDirectory(axiosRequestConfig: AxiosRequestConfig) | void | Delete a specific configuration |
400+
| removeAllQueryDirectory() | void | Delete all configurations in memory |
401+
353402
#### Rh2ConfigService
354403

355404
Initialize the app :
@@ -406,7 +455,7 @@ export interface Rh2EffectAxiosConfigHandler {
406455

407456
<b>axiosRequestConfig</b> Axios configuration.
408457

409-
<b>addToDirectory</b> This is used if we want to execute once the request during runtime. This value can be updated with <b>QueryStorageService</b>.
458+
<b>addToDirectory</b> This is used if we want to execute once the request during runtime. This value can be updated with <b>Rh2DirectoryService</b>.
410459

411460
| Caution : The request filter depends on URL, method type and params property. |
412461
| ------------------------------------------------------------ |
@@ -589,3 +638,7 @@ const initSettings: Rh2InitializationParameter = {
589638

590639
- Modifying an Axios instance to handle new éléments (ex : update « auth » parameter from Axios)
591640
- Handling HTTP request cancellation with the library
641+
642+
643+
644+
<small><i><a href='http://ecotrust-canada.github.io/markdown-toc/'>Table of contents generated with markdown-toc</a></i></small>

src/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,5 @@ export type {
2121
ErreurFetchApi, KeyValue, ResponseFetchApi, Rh2AxiosConfig, Rh2EffectAxiosConfigHandler, Rh2InitializationParameter
2222
} from './models';
2323
export { default as InitializerRnhrh } from './Rh2Initializer';
24-
export { rh2AxiosConfigService, rh2ConfigService } from './services';
25-
export { useRh2WithName, useRh2WithParameters } from './services/Rh2EffectsService';
24+
export { rh2AxiosConfigService, rh2ConfigService, rh2DirectoryService, useRh2WithName, useRh2WithParameters } from './services';
2625

src/models/Rh2Effect.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ export interface Rh2EffectData {
3838

3939
/**
4040
* @param keyOfInstance If is not provided, first Axios instance will be used
41-
* @param config Axios settings
41+
* @param axiosRequestConfig Axios settings
42+
* @param addToDirectory Add the query to the directory to prevent a query from running multiple times
4243
* @param onlyResult If true or not defined then return data else all information about http request
4344
* @param errorHandler Method to be executed to handle the errors in the event of an error in the request. If it is not provided, we see if that of the global * configuration is provided otherwise, nothing is done.
4445
* @param successHandler

src/services/Rh2EffectsService.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ async function traitementToManageRequest(
184184
const configAxios = configuration.axiosRequestConfig;
185185
const configTmp = configToManageDirectory(configAxios);
186186

187+
// Requête declenchée si filtre à true et que la requête n'est pas déjà envoyée
187188
if (filter && !rh2DirectoryService.hasConfigQueryParameterByConfigQueryParameter(configTmp)) {
188189

189190
isDebugModeThenDisplayInfo(`State filter is ${filter} and configuration is`, configuration);

src/services/index.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,8 @@
1212
*/
1313

1414

15-
16-
17-
18-
1915
export { default as rh2AxiosConfigService } from './Rh2AxiosConfigService';
2016
export { default as rh2ConfigService } from './Rh2ConfigService';
17+
export { default as rh2DirectoryService } from './Rh2DirectoryService';
18+
export { useRh2WithName, useRh2WithParameters } from './Rh2EffectsService';
2119

0 commit comments

Comments
 (0)