forked from nko2/website
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
initial npm checkin module. nko2#104
- Loading branch information
Visnu Pitiyanuvath
committed
Aug 14, 2011
1 parent
5d0ee6b
commit 4444a25
Showing
3 changed files
with
108 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# node.js knockout deploy check-ins | ||
|
||
So, we need to keep track of your deploys for lots of different reasons. | ||
Because we want to be as deploy-agnostic as possible, we now have this fancy | ||
module that will ping the competition website whenever you deploy. | ||
|
||
## Installation | ||
|
||
Add `nko` to the dependencies section of your package.json: | ||
|
||
"dependencies": { | ||
"nko": "*", | ||
"other-awesome-stuff": "2.1.4" | ||
} | ||
|
||
After that, `npm install`. | ||
|
||
## Usage | ||
|
||
Just require it somewhere in your normal execution path. We recommend at the | ||
top of your `server.js`: | ||
|
||
require('nko')('secretc0deZ'); | ||
|
||
The code parameter is available on [your team page]. It's linked to just your | ||
team, so don't share it with others unless you want them hijacking your | ||
deploys. | ||
|
||
If for whatever reason, you want to know when we've recorded the deploy, you | ||
can pass an optional callback as the second parameter. | ||
|
||
__Important: The module will only ping us if the `NODE_ENV` environment | ||
variable is set to `production`.__ If you're not seeing your deploy get | ||
recorded, make sure it's set correctly. Also, if you happen to have `NODE_ENV` | ||
set to `production` on your development machine, no worries: we'll be making | ||
sure the source IP address looks right before recording a deploy. | ||
|
||
## Problems? | ||
|
||
As always, you can contact us at [all@nodeknockout.com] or [@node_knockout]. | ||
You can also try checking the [issue tracker]. | ||
|
||
[your team page]: http://nodeknockout.com/teams/mine | ||
[all@nodeknockout.com]: mailto:all@nodeknockout.com | ||
[@node_knockout]: http://twitter.com/node_knockout | ||
[issue tracker]: https://github.com/nko2/website/issues |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
var http = require('http'), | ||
qs = require('querystring'), | ||
os = require('os'); | ||
|
||
function ping(code, callback) { | ||
if (typeof code !== 'string') { | ||
throw Error('Go to http://nodeknockout.com/teams/mine to get your code.'); | ||
} | ||
var options = { | ||
host: 'nodeknockout.com', | ||
port: 80, | ||
path: '/teams/' + qs.escape(code) + '/deploys', | ||
method: 'GET' | ||
}, | ||
msg = { | ||
hostname: os.hostname(), | ||
os: os.type() | ||
}, | ||
|
||
req = http.request(options); | ||
req.setHeader('Content-Type', 'application/json'); | ||
req.end(JSON.stringify(msg)); | ||
|
||
if (callback) { | ||
req.on('response', function (res) { | ||
callback(null, res); | ||
}); | ||
req.on('error', function (err) { | ||
callback(err); | ||
}); | ||
} | ||
} | ||
|
||
module.exports = ping; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"name": "nko", | ||
"maintainers": "visnup <visnupx@gmail.com>", | ||
"author": "Danny Coates <dannycoates@gmail.com>", | ||
"description": "node.js knockout deploy check-in", | ||
"version": "0.0.1", | ||
"homepage": "http://nodeknockout.com", | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/nko2/website.git" | ||
}, | ||
"homepage": "https://github.com/nko2/website/tree/master/module", | ||
"keywords": [ "node.js knockout", "knockout", "nko" ], | ||
"bugs" { | ||
"email": "all@nodeknockout.com", | ||
"url": "https://github.com/nko2/website/issues" | ||
}, | ||
"contributors": [ | ||
"Danny Coates <dannycoates@gmail.com>", | ||
"Visnu Pitiyanuvath <visnupx@gmail.com> (http://visnup.com/)" | ||
] | ||
"main": "nko", | ||
"engines": { | ||
"node": "~v0.4.10" | ||
}, | ||
"dependencies": {}, | ||
"devDependencies": {} | ||
} |