Skip to content

Commit

Permalink
Simple example.
Browse files Browse the repository at this point in the history
  • Loading branch information
dshaw committed Nov 28, 2011
1 parent 01501bf commit 33b413f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
5 changes: 5 additions & 0 deletions examples/simple/Readme.md
@@ -0,0 +1,5 @@
## Run

```bash
SERVER_PORT=8888 node index.js
```
3 changes: 3 additions & 0 deletions examples/simple/env.json
@@ -0,0 +1,3 @@
{
"SERVER_PORT": 1
}
18 changes: 18 additions & 0 deletions examples/simple/index.js
@@ -0,0 +1,18 @@
var http = require('http')
, env = require('../..')()

function handleEnv (err) {
if (!err) return
process.exit(1)
}

if (env.ok(handleEnv)) {
var port = env.get('SERVER_PORT')
var server = http.createServer(function (req, res) {
res.end('Thanks, Env\n');
}).listen(port)

server.on('listening', function () {
console.log('Node server listening on :%d', port)
})
}

0 comments on commit 33b413f

Please sign in to comment.