1.0.1 • Published 12 months ago

@brevisstudios/config v1.0.1

Weekly downloads
-
License
ISC
Repository
-
Last release
12 months ago

Brevis Studios - Config

Easy no-dependency config library. Will load configuration from a json file. Offers methods to get, set and a middleware function to load the configuration into the views.

How to use

Import the module as early as possible. The module is self-loading, there is no need to explicitely call the load method. Config file must exist in the current working directory (e.g. the root of your project).

Importing

import Config from '@brevisstudios/config'

Get

Use the static Config.get(key, defaultValue = null) method to retrieve any key from the configuration. Key is case insensitive.

Set

Use the static Config.set(key, value) method to retrieve any key from the configuration. Keys will automatically be uppercased.

Save

Call the static async Config.save() method to save all data back to the config.json file.

Middleware

If using Express or similar frameworks, you can use the static express() method as a middleware. This will expose the configuration to the views as variable config.

app.use(Config.express());

1.0.1

12 months ago

1.0.0

12 months ago