Giter VIP home page Giter VIP logo

confu's Introduction

confu is a simplistic config parser for node.js


Installation:
  npm install confu

  
Usage:
  var config = require('confu')(__dirname, '../', 'config.json');
  
Also see example.js and config.json in the package

  
Why is this even useful?

Well, if you have a 'paths' hash in your config object, paths are resolved and normalized, relatively to the path of your config file, so you don't have to do it yourself. Also shamelessly adds a paths.root and paths.config path for convenience.

So, in short, put your 'public', 'views' etc. paths in a 'paths' hash.

Also saves you the trouble of requiring 'fs' and 'path' just to read a config file if you don't need them anywhere else.


Example config.json:

  { "name": "myapp"
  , "host": "localhost"
  , "port": 80
  , "paths": 
    { "public": "./public"
    , "views": "./views"
    , "absolute": "/path/to/absolute/thing"
    }
  }

In your app 'config' will look like:

  { name: 'myapp',
    host: 'localhost',
    port: 80,
    paths:
     { public: '/cygdrive/h/work/node/repos/confu/public',
       views: '/cygdrive/h/work/node/repos/confu/views',
       absolute: '/path/to/absolute/thing',
       root: '/cygdrive/h/work/node/repos/confu',
       config: '/cygdrive/h/work/node/repos/confu/config.json' } }

confu's People

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.