Config
The app's configuration
Example:
const config = new Config('./your-config-folder')
Constructor Summary
Public Constructor | ||
public |
constructor(root: String, separator: String) |
Member Summary
Public Members | ||
public |
list: * |
|
public |
parsers: * |
|
public |
paths: * |
|
public |
root: * |
|
public |
separator: * |
|
public |
stores: * |
Method Summary
Public Methods | ||
public |
Use templatly to render thie file, then parse file to Memory
|
|
public |
dotenv(): void Load dotenv `.env.{development|test|production}`
|
|
public |
Get value by key from Config
|
|
public |
* load(): void Load dotenv and app config files
|
|
public |
* loadList(): void Load app.toml app.{development|test|production}.toml
|
|
public |
Parse the file from `.js`, `.json`, `.toml`, `.yml` formatters.
|
|
public |
First, uses native `template-strings` for rendering configuration file
|
|
public |
Assigns setting key to value
|
Public Constructors
Public Members
public list: * source
public parsers: * source
public paths: * source
public root: * source
public separator: * source
public stores: * source
Public Methods
public * compile(filename: String, namespace: String, env: String): nconf.Memory source
Use templatly to render thie file, then parse file to Memory
Return:
nconf.Memory |
Example:
yield config.compile('./your-config.json', 'user', 'test')
public dotenv(): void source
Load dotenv .env.{development|test|production}
Return:
void |
Example:
config.dotenv()
public get(key: String, defaultValue: *): * source
Get value by key from Config
Params:
Name | Type | Attribute | Description |
key | String | ||
defaultValue | * |
|
Return:
* |
Example:
// search: env -> user -> global
config.get('host')
config.get('port', 80) // 80 by default
public * load(): void source
Load dotenv and app config files
Return:
void |
Example:
yield config.load()
// load steps
// 0. config.dotenv()
// 1. yield config.loadList()
public * loadList(): void source
Load app.toml app.{development|test|production}.toml
Return:
void |
Example:
yield config.loadList()
public parse(content: String, filename: String): nconf.Memory source
Parse the file from .js
, .json
, .toml
, .yml
formatters.
Return:
nconf.Memory |
Example:
config.parse(content, filename)
public * render(filename: String, locals: Object): String source
First, uses native template-strings
for rendering configuration file
Example:
yield config.render('./your-config.yml', { name: 'your-app-name' })