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

hapi-kea-config

v0.1.5

Published

Configuration manager for hapi support merging configurations base on Node.js environment, references to other keys and using templates with objects for complex string values

Downloads

2

Readme

hapi-kea-config

Configuration manager for hapi framework. It based on kea-config manager. Main feature of this configuration manager is merging configuration files depending on Node.js environment, support references to other keys and using templates with objects for complex string values. It has perfect performance, fully tested (100% covered by tests).

####Quick example

#####Initialization and usage

    configManager.setup('./config');
    // For process.env.NODE_ENV === 'development';
    configManager.get('web.port'); // 4343
    // For process.env.NODE_ENV === 'production';
    configManager.get('web.port'); // 7474

    // If you don't want to apply changes connected to environment
    // just use init method
    configManager.init('./config/main.conf.js');
    configManager.get('web.port'); // 3005

#####File ./config/main.conf.js

    var config = {}
    
    config.web = {
        port: 3005,
        sessionKey: '6ketaq3cgo315rk9',
        paging: {
            defaultPageSize: 25,
            numberVisiblePages: 10
        },
        mongoDb: {
            username: 'dbUser',
            password: 'strongPassword',
            host: 'localhost',
            port: 27101,
            db: 'database'
        },
        propertyReference: {
            $ref: 'web.paging.defaultPageSize'
        },
        templateReference: {
            $ref: 'web.mongoDb',
            $tmpl: 'mongodb://{username}:{password}@{host}:{port}/{db}'
        }
    };
    
    module.exports = config;

#####File ./config/development.conf.js

    var config = {}

    config.web = {
        port: 4343
    };

    module.exports = config;

#####File ./config/production.conf.js

    var config = {}

    config.web = {
        port: 7474
    };

    module.exports = config;

Installation

npm install hapi-kea-config --save

Usage

To install this plugin on your Hapi server, do something similar to this:


    var Hapi = require('hapi');
    var server = new Hapi.Server();

    var pluginOptions = {
        confPath: './path-to-config-flies',
        decorateServer: true
    };

    server.register({ // for hapi >= 8.0.0 or use server.pack.register for hapi < 8.0.0
        plugin: require('hapi-kea-config'),
        options: pluginOptions }, function(err) {
        if (err) {
            console.log('error', 'Failed loading plugin: hapi-kea-config');
        }
    });

    // Usage in the code
    var configManager = server.plugins['hapi-kea-config'];
    if (configManager.has('web')) {
        var port = configManager.get('web.port');
    }
    // if decorateServer === true
    server.configManager.has('web.port'); // true

    // Usage references
    
    configManager.get('web.propertyReference'); // 25
    
    // Usage templates
    
    configManager.get('web.templateReference'); // 'mongodb://dbUser:strongPassword@localhost:27101/database' - string
    

Plugin Options

confPath

{string} - path to folder with configuration files. Optional parameter.

decorateServer

{boolean} - should plugin decorate server object by configuration manager.

Testing

  • npm test run tests

Licens

MIT