npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@metarisc/metarisc-js

v0.0.1-alpha.72

Published

La librairie Metarisc JS offre un accès simple et pratique à l'API Metarisc à partir d'applications écrites en langage JS. Elle comprend un ensemble de classes et de fonctions pour l'ensemble des ressources de l'API.

Downloads

799

Readme

Metarisc JS

La librairie Metarisc JS offre un accès simple et pratique à l'API Metarisc à partir d'applications écrites en langage JS. Elle comprend un ensemble de classes et de fonctions pour l'ensemble des ressources de l'API.

NPM

Vous pouvez installer la librairie en utilisant NPM. Exécutez la commande suivante dans votre projet :

npm i @metarisc/metarisc-js

Pour utiliser la librairie, il suffit de l'importer comme ceci :

import { Metarisc } from "@metarisc/metarisc-js";

Utilisation

Requêtes

Pour effectuer une requête sur Metarisc, il faut tout d'adord initialisé le client metarisc de cette manière :

const m = new Metarisc({
    metarisc_url: "https://api.metarisc.fr",
    client_id: "CLIENT_ID",
    client_secret: "CLIENT_SECRET"
});

m.dossiers.getDossier("123456");

Ensuite vous pouvez faire vos requêtes.

Requêtes simple

Pour faire un appel API après initialisation du client, vous pouvez utiliser l'accès rapide à l'API souhaitée.

Exemple :

m.dossiers.getDossier("123456");

Le type de retour d'une requête simple est :

Promise<AxiosResponse<T>>;

(voir les documentations suivantes Promise et AxiosResponse)

Requêtes paginées

Pour récupérer des résultats paginés Metarisc (voir la documentation), il suffit de faire appel à l'api souhaitée de la même manière que pour une requête simple.

Exemple :

const m = new Metarisc(config);
m.NotificationsAPI.paginateNotifications();

Le type de retour d'une requête paginée est :

AsyncGenerator<T>;

(voir la documentation suivante AsyncGenerator)

Écouteur d'événements pour les requêtes

Il est possible d'ajouter un écouteur d'événements sur chaque requête effectuée par le client Metarisc. Pour ce faire, vous pouvez utiliser la méthode on() de l'objet core, en spécifiant le nom de l'événement on("request", function)

m.on("request", (config: Event): void => {
    //Action à effectuer à chaque requête
});

Cet écouteur est particulièrement utile pour effectuer des vérifications, comme la validation du token d'authentification avant l'envoi de chaque requête.

La fonction de rappel (callback) reçoit en paramètre un objet Event. Cet objet contient une propriété detail, où sont stockées toutes les informations relatives à la requête entrante.

m.on("request", (config: Event): void => {
    console.log(config.detail); // Retourne un objet de type RequestConfig
    //{
    //body?: any;
    //headers?: { [name: string]: string | string[] };
    //params?: { [param: string]: string | string[] };
    //endpoint?: string;
    //method?: string;
    //}
});