fikso
v0.0.2
Published
A minimalistic configuration library for Node.js
Downloads
3
Maintainers
Readme
Fikso
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.