Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ environment variables.
found in the environment. This should be used sparingly.

```js
var habitat = require('habitat')
habitat.load()
var env = new habitat('airsupport', { port: 1024 })
// will try the environment first, then fall back to 1024
var port = env.get('port');
Expand All @@ -59,6 +61,8 @@ like a `boolean`, `number` or `json`, so you can do things like this:
export APP_ADMINS='["[email protected]", "[email protected]"]'
```
```js
var habitat = require('habitat')
habitat.load()
var env = new habitat('app');
var admins = env.get('admins');
console.log(admins.indexOf('[email protected]')) // 1
Expand All @@ -77,6 +81,8 @@ export APP_REDIS_PORT=6379
```

```js
var habitat = require('habitat')
habitat.load()
var env = new habitat('app');
var db = env.get('db');
var options = env.get(db);
Expand All @@ -93,6 +99,8 @@ export APP_SOME_LONG_KEY='great'
```

```js
var habitat = require('habitat')
habitat.load()
var env = new habitat('app');
console.log(env.get('someLongKey')) // 'great'
```
Expand All @@ -103,6 +111,8 @@ You can also use `get` directly from the habitat object to get
unprefixed things from the environment.

```js
var habitat = require('habitat')
habitat.load()
var path = habitat.get('path');
var nodeEnv = habitat.get('nodeEnv');
```
Expand Down