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 🙏

© 2026 – Pkg Stats / Ryan Hefner

confit-plus

v3.0.2

Published

Configuration loader

Readme

adeo-prox-api-confit

Confit is a simple, environment-based configuration. confit loads a default JSON configuration file, additionally loading environment-specific files, if applicable. It will also process the loaded files using any configured shortstop protocol handlers.

confit adds support for adding JavaScript-style comments in your json files as each file is processed by shush before being merged into your config.

adeo-prox-api-confit is confit with a multi-directory configuration. You can create configuration in the app directory, or in an other directory on the server.

Installation

npm install adeo-prox-api-confit

Recherche des fichiers de confs.

La lib commence par charger les fichiers de confs présents dans le répertoire config de l'appli, puis dans les répertoires défini par la variable d'environnement EXTERNAL_CONF_PATH, le nom de l'appli et la version majeur de l'appli.

Pour assurer une compatibilité avec la V1 du framework lmfr-fwk-core, la lib recherche egalement le fichier de conf définis par les variables FR_LM_CONFPATH, FR_LM_PLATFORM, FR_LM_ENV, le nom de l'appli et sa version majeurs

Pour chaque répertoire de configuration présents sur le serveur, adeo-fwk-confit applique la gestion de configuration de Confit, à savoir le chargement du fichier config.json puis le fichier <NODE_ENV>.json

loading logic:

(the latest is the most proritary)

`1 - ${app_directory}/config/config.json` < `${app_directory}/config/${env.NODE_ENV}.json`
`2 - ${env.EXTERNAL_CONF_PATH}/` (if env.EXTERNAL_CONF_PATH is a file) 
`2 bis - ${env.EXTERNAL_CONF_PATH}/config/config.json` < `${env.EXTERNAL_CONF_PATH}/config/${env.NODE_ENV}.json` (if env.EXTERNAL_CONF_PATH is a directory) 
`3 - ${env.EXTERNAL_CONF_PATH}/${app_name}.json`  (if env.EXTERNAL_CONF_PATH is a directory) 
`4 - ${env.EXTERNAL_CONF_PATH}/${app_name}/config.json` 
`5 - ${env.EXTERNAL_CONF_PATH}/${app_name}/${env.NODE_ENV}.json`  
`6 - ${env.EXTERNAL_CONF_PATH}/${app_name}-v${app_majorVersion}/config/config.json` 
`7 - ${env.EXTERNAL_CONF_PATH}/${app_name}-v${app_majorVersion}/config/${env.NODE_ENV}.json` 

Sucharge par les variables d'environnements

chaque paramètre de la configuration peux etre modifié via les variables d'environnement. Pour cela, setter une variable d'environnement de la manière suivante: CONFIG_<parametter_name_en_majuscule>= Pour les objets, les "." sont transformés en "_"

ATTENTION: Seul la modification est possible. L'ajout de paramète ne l'est pas!

example:

CONFIG_EXPRESS_PORT=4000

Permet de modifier la config:

"express": {
    "view cache": true,
    "port": 3080
},

How to use

Pour acceder à la config dans votre code, de manière Asynchrone

const ConfigL=require("./lib/configLoader.lib");
ConfigL.init();
ConfigL.getAsync().then((conf)=>{
    console.log(conf.get("configLoaded"));
    ...
});

=> { base: true, development: true }

Pour acceder à la config dans votre code, de manière synchrone Attention, cette methode ne doit etre utilisé que lorqu'on est sur que l'api a eu le temps de charger la conf comme dans un controleur d'un serveur express par exemple

const ConfigL=require("./lib/configLoader.lib");
ConfigL.init();
console.log(ConfigL.config.get("configLoaded"));

=> { base: true, development: true }

Exemple de configurations multi-files/multi-env

Dans ${app_directory}/config/config.json, On y met la configuration par défaut
ATTENTION: pas de mot passe ;)

{
    ...,

    "authentificationOauth2Config": {
        "oauth2":{
            "clientID": "CORP-GALAXIS",
            "site": "https://ypserveur/oauth-server",
            "tokenPath": "/oauth/token",
            "authorizationPath": "/oauth/authorize"
        }
    },

    "server":{
        "protocole": "https",
        "port": "4443"
    }
}

Dans ${app_directory}/config/development.json, on y met la configuration pour le poste local developpeur.
Pas besoin de redéfinir tous les attributs, juste ce qui est differents ou manquant par rapport à la config par defaut.

{
    "authentificationOauth2Config": {
        "oauth2":{
            "clientSecret": "secretfordevelopment",
            "site": "https://yrserveur/oauth-server"
        }
    },

    "server":{
        "pfx": "file:./ressources/devclé.pck",
        "passphrase": "achanger"
    }
}

Sur le serveur de prod (avec variable NODE_ENV='production' et EXTERNAL_CONF_PATH='/home/nodejs/') dans /home/nodejs/mon-api-v1/production.json, on y met la configuration pour le serveur de prod.
Pas besoin de redéfinir tout les attributs, juste ce qui est differents ou manquant par rapport à la config par defaut.

{
    "authentificationOauth2Config": {
        "oauth2":{
            "clientSecret": "monsupersecretdeprod"
        }
    },

    "server":{
        "pfx": "file: /home2/certs/pmonappli.pck",
        "passphrase": "lacleducertificatdeprod"
    }
}

Sur le serveur de preprod (avec variable NODE_ENV='preproduction' et EXTERNAL_CONF_PATH='/home/nodejs/') dans /home/nodejs/mon-api-v1/preproduction.json, on y met la configuration pour le serveur de prod.
pas besoin de redéfinir tout les attributs, juste ce qui est differents ou manquant par rapport à la config par defaut.

{
    "authentificationOauth2Config": {
        "oauth2":{
            "clientSecret": "lesecretdepreprod",
            "site": "https://yaserveur/oauth-server"
        }
    },

    "server":{
        "pfx": "file: /home2/certs/amonappli.pck",
        "passphrase": "cledepreprod"
    }
}

NOTE:

Dans notre exemple, pour le serveur de prod, nous pouvons stocker la configuration dans:

  • Si on n'installe qu'une seule version de l'aplli sur le serveur :
    /home/nodejs/ma-conf.json (avec variable EXTERNAL_CONF_PATH='/home/nodejs/ma-conf.json') ou
    /home/nodejs/mon-api.json (avec variable EXTERNAL_CONF_PATH='/home/nodejs')

  • Si on n'installe qu'une seule version de l'aplli sur le serveur :
    /home/nodejs/mon-api/config.json
    et/ou
    /home/nodejs/mon-api/production.json
    (avec variable NODE_ENV='production' et EXTERNAL_CONF_PATH='/home/nodejs/')

  • Si on souhaite installer plusieurs versions majeur de l'api sur le serveur:
    /home/nodejs/mon-api-v1/config.json
    et/ou
    /home/nodejs/mon-api-v1/production.json
    (avec variable NODE_ENV='production' et EXTERNAL_CONF_PATH='/home/nodejs/')

  • Si on souhaite installer plusieurs versions majeur de l'api sur le serveur (compatibilité pour framework lmfr-fwk-core V1)
    /home/nodejs/mon-api-v1/BCIT/production/config.json
    (avec variable FR_LM_CONFPATH='/home/nodejs/', FR_LM_PLATFORM='BCIT' et FR_LM_ENV='production')