Skip to content
A minimalistic configuration library for Node.js
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
test
.babelrc
.editorconfig
.eslintrc
.gitignore
.travis.yml
CHANGELOG.md
LICENSE
NOTES.md
README.md
package.json

README.md

Fikso

NPM Version David David Build Status codecov Twitter Follow

Fikso means setting in esperanto.

Fikso is a minimalistic configuration library for Node.js.

It's tested. It works. Beware, it's in alpha.

Installation

npm install fikso --save

Usage

Example

import fikso from 'fikso'

// declare settings in the global scope
fikso.set({
  companyWebsiteUrl: 'http://adrianodigiovanni.com'
})

// declare settings in a nested scope
fikso
  .scope('production')
  .scope('mysql')
  .set({
    user: 'root',
    password: 'root'
  })

// declare settings in a deeply nested
fikso
  .scope('production')
  .scope('mysql')
  .scope('master')
  .set({
    host: 'localhost'
  })

const settings = fikso
  .scope('production')
  .scope('mysql')
  .scope('master')
  .get()

console.log(settings) // { companyWebsiteUrl: 'http://adrianodigiovanni.com', user: 'root', password: 'root', host: 'localhost' }

Scopes

You define and address nested scopes by chaining calls to scope.

Scopes are arbitrary. The example above shows you scopes pertaining to

  • environment (production)
  • service (mysql)
  • instance (master)

Define settings in a scope

You can define settings in a scope by calling set.

If you call set or get on fikso, you define or access settings in the global scope.

It is not permitted to override settings for a scope.

fikso.set({ isGlobal: true }) // it's ok
fikso.set({ isGlobal: true }) // will throw

Retrieve settings

You can retrieve settings in a scope by calling get.

Caching scopes

const scope = fikso
  .scope('production')
  .scope('mysql')
  .scope('master')

scope.set({
  host: 'localhost'
})

console.log(scope.get()) // { host: 'localhost' }

License

The project is licensed under the MIT license.

You can’t perform that action at this time.