Browse Source

Template updates, ready to branch web

doobs
Brandon Cornejo 11 years ago
parent
commit
a9eda304f3
  1. 2
      .gitignore
  2. 5
      lib/commands.js
  3. 83
      lib/currency.js
  4. 15
      lib/initialize.js
  5. 2
      lib/irc.js
  6. 70
      lib/web.js
  7. 1
      node_modules/body-parser/.npmignore
  8. 3
      node_modules/body-parser/.travis.yml
  9. 10
      node_modules/body-parser/HISTORY.md
  10. 9
      node_modules/body-parser/Makefile
  11. 60
      node_modules/body-parser/README.md
  12. 100
      node_modules/body-parser/index.js
  13. 6
      node_modules/body-parser/node_modules/qs/.gitmodules
  14. 7
      node_modules/body-parser/node_modules/qs/.npmignore
  15. 58
      node_modules/body-parser/node_modules/qs/Readme.md
  16. 366
      node_modules/body-parser/node_modules/qs/index.js
  17. 38
      node_modules/body-parser/node_modules/qs/package.json
  18. 1
      node_modules/body-parser/node_modules/raw-body/.npmignore
  19. 5
      node_modules/body-parser/node_modules/raw-body/.travis.yml
  20. 14
      node_modules/body-parser/node_modules/raw-body/Makefile
  21. 96
      node_modules/body-parser/node_modules/raw-body/README.md
  22. 164
      node_modules/body-parser/node_modules/raw-body/index.js
  23. 1
      node_modules/body-parser/node_modules/raw-body/node_modules/bytes/.npmignore
  24. 20
      node_modules/body-parser/node_modules/raw-body/node_modules/bytes/History.md
  25. 7
      node_modules/body-parser/node_modules/raw-body/node_modules/bytes/Makefile
  26. 54
      node_modules/body-parser/node_modules/raw-body/node_modules/bytes/Readme.md
  27. 7
      node_modules/body-parser/node_modules/raw-body/node_modules/bytes/component.json
  28. 41
      node_modules/body-parser/node_modules/raw-body/node_modules/bytes/index.js
  29. 37
      node_modules/body-parser/node_modules/raw-body/node_modules/bytes/package.json
  30. 45
      node_modules/body-parser/node_modules/raw-body/package.json
  31. 1
      node_modules/body-parser/node_modules/type-is/.npmignore
  32. 4
      node_modules/body-parser/node_modules/type-is/.travis.yml
  33. 16
      node_modules/body-parser/node_modules/type-is/HISTORY.md
  34. 87
      node_modules/body-parser/node_modules/type-is/README.md
  35. 148
      node_modules/body-parser/node_modules/type-is/index.js
  36. 19
      node_modules/body-parser/node_modules/type-is/node_modules/mime/LICENSE
  37. 66
      node_modules/body-parser/node_modules/type-is/node_modules/mime/README.md
  38. 114
      node_modules/body-parser/node_modules/type-is/node_modules/mime/mime.js
  39. 36
      node_modules/body-parser/node_modules/type-is/node_modules/mime/package.json
  40. 84
      node_modules/body-parser/node_modules/type-is/node_modules/mime/test.js
  41. 1588
      node_modules/body-parser/node_modules/type-is/node_modules/mime/types/mime.types
  42. 77
      node_modules/body-parser/node_modules/type-is/node_modules/mime/types/node.types
  43. 37
      node_modules/body-parser/node_modules/type-is/package.json
  44. 41
      node_modules/body-parser/package.json
  45. 31
      web/public/help/instructions.txt
  46. 16
      web/templates/fanart.jade
  47. 4
      web/templates/index.jade
  48. 48
      web/templates/ladder.jade
  49. 43
      web/templates/layout.jade
  50. 6
      web/templates/stats.jade

2
.gitignore

@ -186,7 +186,9 @@ XBucksBot.js
shaneomad.js shaneomad.js
pyrionflax.js pyrionflax.js
testbot.js testbot.js
2gd.js
*.png *.png
*.jpg
web/public/browserconfig.xml web/public/browserconfig.xml
node_modules/.bin node_modules/.bin
web/public/favicon.ico web/public/favicon.ico

5
lib/commands.js

@ -20,6 +20,7 @@ function Commands(irc, db, options) {
__self.config = options || {}; __self.config = options || {};
__self.config.bot_name = options.bot_name || ''; __self.config.bot_name = options.bot_name || '';
__self.config.currency = options.currency || 'coins'; __self.config.currency = options.currency || 'coins';
__self.config.exchange = options.exchange || {};
__self.command_list = []; __self.command_list = [];
} }
@ -66,7 +67,8 @@ Commands.prototype.commands = function(data) {
} }
}); });
} else if (command_check === '!' && command === __self.config.bot_name.toLowerCase()) { } else if (command_check === '!' && command === __self.config.bot_name.toLowerCase()) {
var commands = '> Commands: !' + __self.config.currency.toLowerCase() + ', ';
var commands = '> Commands: !' + __self.config.currency.toLowerCase() + ', !top, !rank, ';
if(Object.keys(__self.config.exchange).length != 0) commands += '!exchange, ';
for (var i = 0; i < __self.command_list.length; i++) { for (var i = 0; i < __self.command_list.length; i++) {
if (i !== __self.command_list.length - 1) { if (i !== __self.command_list.length - 1) {
commands += '!' + __self.command_list[i] + ', '; commands += '!' + __self.command_list[i] + ', ';
@ -74,7 +76,6 @@ Commands.prototype.commands = function(data) {
commands += '!' + __self.command_list[i]; commands += '!' + __self.command_list[i];
} }
} }
console.log("!!!!! Right before EMIT");
__self.irc.emit('message',{message:commands, options:null}); __self.irc.emit('message',{message:commands, options:null});
} }
}; };

83
lib/currency.js

@ -59,6 +59,7 @@
var https = require('https'), var https = require('https'),
http = require('http'), http = require('http'),
querystr = require('querystring'),
file = require('fs'), file = require('fs'),
utils = require('./utils.js'); utils = require('./utils.js');
@ -77,6 +78,7 @@ function Currency(irc, db, commands, options) {
__self.config.website = options.website || ''; __self.config.website = options.website || '';
__self.config.modpowers = options.modpowers || false; __self.config.modpowers = options.modpowers || false;
__self.config.ignorelist = options.ignorelist || ['jtv']; __self.config.ignorelist = options.ignorelist || ['jtv'];
__self.config.exchanges = options.exchanges || {};
// general settings // general settings
__self.pre_text = '> ' + __self.config.currency + ': '; __self.pre_text = '> ' + __self.config.currency + ': ';
@ -155,6 +157,8 @@ function Currency(irc, db, commands, options) {
// message to new subscribers // message to new subscribers
__self.sub_ty_msg = options.sub_ty_msg || ''; __self.sub_ty_msg = options.sub_ty_msg || '';
// stored twitch stream data
} }
//-------- Methods --------- //-------- Methods ---------
@ -270,10 +274,8 @@ Currency.prototype.commands = function (data) {
// open / close betting system // open / close betting system
if (data[4] === 'bet') { if (data[4] === 'bet') {
console.log("bet command found");
switch (data[5]) { switch (data[5]) {
case 'open': case 'open':
console.log("bet open command found");
if (data[6] && data[7]) { if (data[6] && data[7]) {
__self.bets(true, data); __self.bets(true, data);
} else { } else {
@ -300,10 +302,8 @@ Currency.prototype.commands = function (data) {
// open / close voting system // open / close voting system
if (data[4] === 'vote') { if (data[4] === 'vote') {
console.log("vote command found");
switch (data[5]) { switch (data[5]) {
case 'open': case 'open':
console.log("vote open command found");
if (data[6] && data[7]) { if (data[6] && data[7]) {
__self.votes(true, data); __self.votes(true, data);
} else { } else {
@ -458,6 +458,9 @@ Currency.prototype.commands = function (data) {
case '!rank': case '!rank':
__self.get_rank(__self.irc.caller(data[0]).toLowerCase()); __self.get_rank(__self.irc.caller(data[0]).toLowerCase());
break; break;
case '!exchange':
if(Object.keys(__self.config.exchanges).length != 0)
__self.currency_exchange(__self.irc.caller(data[0]), parseInt(data[4], 10), data[5]);
} }
// place a bet // place a bet
@ -561,6 +564,67 @@ Currency.prototype.get_coins = function (caller) {
} }
} }
}; };
Currency.prototype.currency_exchange = function (name, amount, type) {
console.log('INSIDE CURR EXCHANGE');
var __self = this,
rate = 15,
cost = (amount * (rate / 100))
total = amount + cost;
if( name && amount && type ) {
console.log('ready to post');
if(Object.keys(__self.config.exchanges).indexOf(type) > -1) {
__self.query_coins(name.toLowerCase(), function (rows) {
var message = '',
response = new String();
if(rows[0].points >= total) {
// Prepare for POST
var data = querystr.stringify({'name': name, 'amount': amount});
var opts = {
port: __self.config.exchanges[type],
path: '/api/exchange',
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Content-Length': Buffer.byteLength(data)
}
};
var request = http.request(opts, function(res) {
res.setEncoding('utf-8');
res.on('data', function(chunk) {
response += chunk;
});
res.on('end', function() {
if(response == '1') {
// Exchanged succesfully, let's remove local currency
__self.adjust_currency('remove', total, name);
message = name+' exchanged '+amount+' for '+type+'. Cost '+total;
__self.irc.emit('message', {message:__self.pre_text + message, timer: 1});
}
});
});
request.write(data);
request.end();
}
});
}
} else {
message = '!exchange <amount> <type> [Valid types: ';
keys = Object.keys(__self.config.exchanges);
keys.forEach(function(element, index, array) {
message += keys[index]+', ';
});
message+=']';
__self.irc.emit('message', {message:__self.pre_text + message, timer: 1});
}
};
Currency.prototype.get_rank = function (data) { Currency.prototype.get_rank = function (data) {
var __self = this; var __self = this;
@ -602,7 +666,7 @@ Currency.prototype.get_rank = function (data) {
Currency.prototype.get_top = function (data) { Currency.prototype.get_top = function (data) {
var __self = this; var __self = this;
var limit = 0;
var limit = 5;
function do_work() { function do_work() {
var response = ''; var response = '';
@ -623,12 +687,6 @@ Currency.prototype.get_top = function (data) {
__self.top_flood = []; __self.top_flood = [];
} }
// check that we got a number
( isNaN(data) ) ? limit = 3 : limit = data;
// limit the number
if (limit > 6) limit = 3;
// add flood users to array // add flood users to array
if (__self.top_flood.indexOf(limit) < 0) { if (__self.top_flood.indexOf(limit) < 0) {
__self.top_flood.push(limit); __self.top_flood.push(limit);
@ -892,7 +950,6 @@ Currency.prototype.handout_coins = function () {
if (viewer_idx >= 0) { if (viewer_idx >= 0) {
__self.viewer_list.splice(viewer_idx,1); __self.viewer_list.splice(viewer_idx,1);
} else { } else {
console.log("[*ERROR*] User "+viewer+" PART'ed but was not in viewer_list.");
} }
} }
@ -1769,7 +1826,6 @@ Currency.prototype.collect_votes = function (caller, vote, amount) {
__self.votes_flood.push(__self.votes_viewers.length - 1); __self.votes_flood.push(__self.votes_viewers.length - 1);
} }
} }
console.log(__self.votes_viewers);
// check if flood has a set amount of requests and output // check if flood has a set amount of requests and output
// if not, set the output timer // if not, set the output timer
@ -2059,7 +2115,6 @@ Currency.prototype.collect_bets = function (caller, bet, amount) {
__self.bets_flood.push(__self.bets_viewers.length - 1); __self.bets_flood.push(__self.bets_viewers.length - 1);
} }
} }
console.log(__self.bets_viewers);
// check if flood has a set amount of requests and output // check if flood has a set amount of requests and output
// if not, set the output timer // if not, set the output timer

15
lib/initialize.js

@ -29,6 +29,7 @@ exports.initialize = function(options) {
}); });
commands = require('./commands.js')(irc, db, { commands = require('./commands.js')(irc, db, {
bot_name : config.twitch.bot.name, bot_name : config.twitch.bot.name,
exchange : config.exchanges,
currency : config.currency.name currency : config.currency.name
}); });
currency = require('./currency.js')(irc, db, commands, { currency = require('./currency.js')(irc, db, commands, {
@ -38,15 +39,17 @@ exports.initialize = function(options) {
website : config.currency.website, website : config.currency.website,
modpowers : config.currency.modpowers, modpowers : config.currency.modpowers,
ignorelist : config.ignorelist, ignorelist : config.ignorelist,
exchanges : config.exchanges,
sub_ty_msg : config.currency.sub_ty_msg sub_ty_msg : config.currency.sub_ty_msg
}); });
web = require('./web.js')(db, currency, { web = require('./web.js')(db, currency, {
port : config.web.port,
title : config.twitch.channel,
slogan : config.web.slogan,
logo : config.web.logo,
twitter : config.web.twitter,
statdir : config.web.statdir
port : config.web.port,
title : config.twitch.channel,
currency : config.currency.name,
logo : config.web.logo,
twitter : config.web.twitter,
fanart : config.web.fanart,
statdir : config.twitch.channel
}); });
//-------- Start ------- //-------- Start -------

2
lib/irc.js

@ -98,8 +98,6 @@ function IRC(options) {
__self.first_check = true; __self.first_check = true;
__self.store_chat = __self.options.chatlog || false; __self.store_chat = __self.options.chatlog || false;
__self.chat_log = ''; __self.chat_log = '';
} }
IRC.prototype = new events.EventEmitter(); IRC.prototype = new events.EventEmitter();

70
lib/web.js

@ -1,4 +1,6 @@
var express = require('express'), var express = require('express'),
bodyParser = require('body-parser'),
utils = require('./utils.js'),
https = require('https'); https = require('https');
//---- Construct ---- //---- Construct ----
@ -10,10 +12,14 @@ function WEB(db, currency, options) {
__self.port = options.port || 9000; __self.port = options.port || 9000;
__self.title = options.title; __self.title = options.title;
__self.slogan = options.slogan;
__self.currency_name = options.currency;
__self.logo = options.logo; __self.logo = options.logo;
__self.twitter = options.twitter; __self.twitter = options.twitter;
__self.fanart = options.fanart;
__self.statdir = options.statdir; __self.statdir = options.statdir;
__self.check_data = 4;//minutes
__self.first_check = true;
__self.slogan = '';
} }
// ---- Methods ---- // ---- Methods ----
@ -22,6 +28,7 @@ WEB.prototype.start = function () {
__self.srv = express(); __self.srv = express();
__self.srv.set('view engine', 'jade'); __self.srv.set('view engine', 'jade');
__self.srv.set('views', 'web/templates'); __self.srv.set('views', 'web/templates');
__self.srv.use(bodyParser());
__self.srv.use(express.static('./web/public')); __self.srv.use(express.static('./web/public'));
__self.render_opts = { __self.render_opts = {
@ -29,8 +36,49 @@ WEB.prototype.start = function () {
slogan: __self.slogan, slogan: __self.slogan,
logo: __self.logo, logo: __self.logo,
twitter: __self.twitter, twitter: __self.twitter,
fanart: __self.fanart,
currency: __self.currency_name,
}; };
// get twitch/twitter data
function update_data() {
var time = utils.make_interval(__self.check_data);
if (time === 0 || __self.first_check) {
if(__self.first_check) __self.first_check = false;
https.get('https://api.twitch.tv/kraken/channels/' + __self.title, function (response) {
var body = '';
// put together response
response.on('data', function (chunk) {
body += chunk;
});
// log file creation
response.on('end', function () {
var json = null;
try {
json = JSON.parse(body);
__self.slogan = json.status;
__self.render_opts.slogan = json.status;
} catch (err) {
console.log('Error grabbing Twitch data in Web.JS: '+err);
}
setTimeout(update_data, 1000);
});
});
} else {
setTimeout(update_data, time);
}
}
// ---- Helpers ----
__self.srv.locals.ucfirst = function(value){
return value.charAt(0).toUpperCase() + value.slice(1);
};
__self.srv.locals.slicelast = function(value){
return value.slice(0, -1);
};
// ---- Routes ----- // ---- Routes -----
__self.srv.get('/', function(req, res) { __self.srv.get('/', function(req, res) {
@ -60,15 +108,15 @@ WEB.prototype.start = function () {
opts.statdir = __self.statdir; opts.statdir = __self.statdir;
res.render('stats', opts); res.render('stats', opts);
}); });
/* Raw data for android app */
__self.srv.get('/fanart', function(req, res) { __self.srv.get('/fanart', function(req, res) {
res.render('fanart', __self.render_opts); res.render('fanart', __self.render_opts);
}); });
/* Raw data for android app */
__self.srv.get('/api/test', function(req, res) { __self.srv.get('/api/test', function(req, res) {
res.send("Hey, its Potatr. This data was pulled from the web."); res.send("Hey, its Potatr. This data was pulled from the web.");
}); });
__self.srv.all('/api/data', function(req, res) {
__self.srv.get('/api/viewer_dump', function(req, res) {
sql = 'SELECT * FROM viewers ORDER BY points DESC;'; sql = 'SELECT * FROM viewers ORDER BY points DESC;';
__self.db.execute(sql, function(rows) { __self.db.execute(sql, function(rows) {
ladder_data = new Object(); ladder_data = new Object();
@ -78,8 +126,22 @@ WEB.prototype.start = function () {
res.send(ladder_data); res.send(ladder_data);
}); });
}); });
__self.srv.post('/api/exchange', function(req, res) {
var name = req.body.name.toLowerCase(),
amount = parseInt(req.body.amount, 10);
if (req.ip == '127.0.0.1') {
if ( __self.currency.viewer_list.indexOf(name) > -1 ) {
__self.currency.adjust_currency('add', amount, name);
res.send('1');
} else {
res.send('0');
}
}
});
__self.srv.listen(__self.port); __self.srv.listen(__self.port);
update_data();
console.log('Started website at '+__self.port); console.log('Started website at '+__self.port);
}; };

1
node_modules/body-parser/.npmignore

@ -0,0 +1 @@
test/

3
node_modules/body-parser/.travis.yml

@ -0,0 +1,3 @@
node_js:
- "0.10"
language: node_js

10
node_modules/body-parser/HISTORY.md

@ -0,0 +1,10 @@
1.0.1 / 2014-04-14
==================
* use `type-is` module
1.0.1 / 2014-03-20
==================
* lower default limits to 100kb

9
node_modules/body-parser/Makefile

@ -0,0 +1,9 @@
BIN = ./node_modules/.bin/
test:
@$(BIN)mocha \
--require should \
--reporter spec \
--bail
.PHONY: test

60
node_modules/body-parser/README.md

@ -0,0 +1,60 @@
# Body Parser [![Build Status](https://travis-ci.org/expressjs/body-parser.png)](https://travis-ci.org/expressjs/body-parser)
Connect's body parsing middleware.
## API
```js
var bodyParser = require('body-parser');
var app = connect();
app.use(bodyParser());
app.use(function (req, res, next) {
console.log(req.body) // populated!
next();
})
```
### bodyParser([options])
Returns middleware that parses both `json` and `urlencoded`. The `options` are passed to both middleware.
### bodyParser.json([options])
Returns middleware that only parses `json`. The options are:
- `strict` <true> - only parse objects and arrays
- `limit` <1mb> - maximum request body size
- `reviver` - passed to `JSON.parse()`
### bodyParser.urlencoded([options])
Returns middleware that only parses `urlencoded` with the [qs](https://github.com/visionmedia/node-querystring) module. The options are:
- `limit` <1mb> - maximum request body size
## License
The MIT License (MIT)
Copyright (c) 2014 Jonathan Ong me@jongleberry.com
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

100
node_modules/body-parser/index.js

@ -0,0 +1,100 @@
var getBody = require('raw-body');
var typeis = require('type-is');
var http = require('http');
var qs = require('qs');
exports = module.exports = bodyParser;
exports.json = json;
exports.urlencoded = urlencoded;
function bodyParser(options){
var _urlencoded = urlencoded(options);
var _json = json(options);
return function bodyParser(req, res, next) {
_json(req, res, function(err){
if (err) return next(err);
_urlencoded(req, res, next);
});
}
}
function json(options){
options = options || {};
var strict = options.strict !== false;
return function jsonParser(req, res, next) {
if (req._body) return next();
req.body = req.body || {};
if (!typeis(req, 'json')) return next();
// flag as parsed
req._body = true;
// parse
getBody(req, {
limit: options.limit || '100kb',
length: req.headers['content-length'],
encoding: 'utf8'
}, function (err, buf) {
if (err) return next(err);
var first = buf.trim()[0];
if (0 == buf.length) {
return next(error(400, 'invalid json, empty body'));
}
if (strict && '{' != first && '[' != first) return next(error(400, 'invalid json'));
try {
req.body = JSON.parse(buf, options.reviver);
} catch (err){
err.body = buf;
err.status = 400;
return next(err);
}
next();
})
};
}
function urlencoded(options){
options = options || {};
return function urlencodedParser(req, res, next) {
if (req._body) return next();
req.body = req.body || {};
if (!typeis(req, 'urlencoded')) return next();
// flag as parsed
req._body = true;
// parse
getBody(req, {
limit: options.limit || '100kb',
length: req.headers['content-length'],
encoding: 'utf8'
}, function (err, buf) {
if (err) return next(err);
try {
req.body = buf.length
? qs.parse(buf)
: {};
} catch (err){
err.body = buf;
return next(err);
}
next();
})
}
}
function error(code, msg) {
var err = new Error(msg || http.STATUS_CODES[code]);
err.status = code;
return err;
}

6
node_modules/body-parser/node_modules/qs/.gitmodules

@ -0,0 +1,6 @@
[submodule "support/expresso"]
path = support/expresso
url = git://github.com/visionmedia/expresso.git
[submodule "support/should"]
path = support/should
url = git://github.com/visionmedia/should.js.git

7
node_modules/body-parser/node_modules/qs/.npmignore

@ -0,0 +1,7 @@
test
.travis.yml
benchmark.js
component.json
examples.js
History.md
Makefile

58
node_modules/body-parser/node_modules/qs/Readme.md

@ -0,0 +1,58 @@
# node-querystring
query string parser for node and the browser supporting nesting, as it was removed from `0.3.x`, so this library provides the previous and commonly desired behaviour (and twice as fast). Used by [express](http://expressjs.com), [connect](http://senchalabs.github.com/connect) and others.
## Installation
$ npm install qs
## Examples
```js
var qs = require('qs');
qs.parse('user[name][first]=Tobi&user[email]=tobi@learnboost.com');
// => { user: { name: { first: 'Tobi' }, email: 'tobi@learnboost.com' } }
qs.stringify({ user: { name: 'Tobi', email: 'tobi@learnboost.com' }})
// => user[name]=Tobi&user[email]=tobi%40learnboost.com
```
## Testing
Install dev dependencies:
$ npm install -d
and execute:
$ make test
browser:
$ open test/browser/index.html
## License
(The MIT License)
Copyright (c) 2010 TJ Holowaychuk &lt;tj@vision-media.ca&gt;
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

366
node_modules/body-parser/node_modules/qs/index.js

@ -0,0 +1,366 @@
/**
* Object#toString() ref for stringify().
*/
var toString = Object.prototype.toString;
/**
* Object#hasOwnProperty ref
*/
var hasOwnProperty = Object.prototype.hasOwnProperty;
/**
* Array#indexOf shim.
*/
var indexOf = typeof Array.prototype.indexOf === 'function'
? function(arr, el) { return arr.indexOf(el); }
: function(arr, el) {
for (var i = 0; i < arr.length; i++) {
if (arr[i] === el) return i;
}
return -1;
};
/**
* Array.isArray shim.
*/
var isArray = Array.isArray || function(arr) {
return toString.call(arr) == '[object Array]';
};
/**
* Object.keys shim.
*/
var objectKeys = Object.keys || function(obj) {
var ret = [];
for (var key in obj) {
if (obj.hasOwnProperty(key)) {
ret.push(key);
}
}
return ret;
};
/**
* Array#forEach shim.
*/
var forEach = typeof Array.prototype.forEach === 'function'
? function(arr, fn) { return arr.forEach(fn); }
: function(arr, fn) {
for (var i = 0; i < arr.length; i++) fn(arr[i]);
};
/**
* Array#reduce shim.
*/
var reduce = function(arr, fn, initial) {
if (typeof arr.reduce === 'function') return arr.reduce(fn, initial);
var res = initial;
for (var i = 0; i < arr.length; i++) res = fn(res, arr[i]);
return res;
};
/**
* Cache non-integer test regexp.
*/
var isint = /^[0-9]+$/;
function promote(parent, key) {
if (parent[key].length == 0) return parent[key] = {}
var t = {};
for (var i in parent[key]) {
if (hasOwnProperty.call(parent[key], i)) {
t[i] = parent[key][i];
}
}
parent[key] = t;
return t;
}
function parse(parts, parent, key, val) {
var part = parts.shift();
// illegal
if (Object.getOwnPropertyDescriptor(Object.prototype, key)) return;
// end
if (!part) {
if (isArray(parent[key])) {
parent[key].push(val);
} else if ('object' == typeof parent[key]) {
parent[key] = val;
} else if ('undefined' == typeof parent[key]) {
parent[key] = val;
} else {
parent[key] = [parent[key], val];
}
// array
} else {
var obj = parent[key] = parent[key] || [];
if (']' == part) {
if (isArray(obj)) {
if ('' != val) obj.push(val);
} else if ('object' == typeof obj) {
obj[objectKeys(obj).length] = val;
} else {
obj = parent[key] = [parent[key], val];
}
// prop
} else if (~indexOf(part, ']')) {
part = part.substr(0, part.length - 1);
if (!isint.test(part) && isArray(obj)) obj = promote(parent, key);
parse(parts, obj, part, val);
// key
} else {
if (!isint.test(part) && isArray(obj)) obj = promote(parent, key);
parse(parts, obj, part, val);
}
}
}
/**
* Merge parent key/val pair.
*/
function merge(parent, key, val){
if (~indexOf(key, ']')) {
var parts = key.split('[')
, len = parts.length
, last = len - 1;
parse(parts, parent, 'base', val);
// optimize
} else {
if (!isint.test(key) && isArray(parent.base)) {
var t = {};
for (var k in parent.base) t[k] = parent.base[k];
parent.base = t;
}
set(parent.base, key, val);
}
return parent;
}
/**
* Compact sparse arrays.
*/
function compact(obj) {
if ('object' != typeof obj) return obj;
if (isArray(obj)) {
var ret = [];
for (var i in obj) {
if (hasOwnProperty.call(obj, i)) {
ret.push(obj[i]);
}
}
return ret;
}
for (var key in obj) {
obj[key] = compact(obj[key]);
}
return obj;
}
/**
* Parse the given obj.
*/
function parseObject(obj){
var ret = { base: {} };
forEach(objectKeys(obj), function(name){
merge(ret, name, obj[name]);
});
return compact(ret.base);
}
/**
* Parse the given str.
*/
function parseString(str){
var ret = reduce(String(str).split('&'), function(ret, pair){
var eql = indexOf(pair, '=')
, brace = lastBraceInKey(pair)
, key = pair.substr(0, brace || eql)
, val = pair.substr(brace || eql, pair.length)
, val = val.substr(indexOf(val, '=') + 1, val.length);
// ?foo
if ('' == key) key = pair, val = '';
if ('' == key) return ret;
return merge(ret, decode(key), decode(val));
}, { base: {} }).base;
return compact(ret);
}
/**
* Parse the given query `str` or `obj`, returning an object.
*
* @param {String} str | {Object} obj
* @return {Object}
* @api public
*/
exports.parse = function(str){
if (null == str || '' == str) return {};
return 'object' == typeof str
? parseObject(str)
: parseString(str);
};
/**
* Turn the given `obj` into a query string
*
* @param {Object} obj
* @return {String}
* @api public
*/
var stringify = exports.stringify = function(obj, prefix) {
if (isArray(obj)) {
return stringifyArray(obj, prefix);
} else if ('[object Object]' == toString.call(obj)) {
return stringifyObject(obj, prefix);
} else if ('string' == typeof obj) {
return stringifyString(obj, prefix);
} else {
return prefix + '=' + encodeURIComponent(String(obj));
}
};
/**
* Stringify the given `str`.
*
* @param {String} str
* @param {String} prefix
* @return {String}
* @api private
*/
function stringifyString(str, prefix) {
if (!prefix) throw new TypeError('stringify expects an object');
return prefix + '=' + encodeURIComponent(str);
}
/**
* Stringify the given `arr`.
*
* @param {Array} arr
* @param {String} prefix
* @return {String}
* @api private
*/
function stringifyArray(arr, prefix) {
var ret = [];
if (!prefix) throw new TypeError('stringify expects an object');
for (var i = 0; i < arr.length; i++) {
ret.push(stringify(arr[i], prefix + '[' + i + ']'));
}
return ret.join('&');
}
/**
* Stringify the given `obj`.
*
* @param {Object} obj
* @param {String} prefix
* @return {String}
* @api private
*/
function stringifyObject(obj, prefix) {
var ret = []
, keys = objectKeys(obj)
, key;
for (var i = 0, len = keys.length; i < len; ++i) {
key = keys[i];
if ('' == key) continue;
if (null == obj[key]) {
ret.push(encodeURIComponent(key) + '=');
} else {
ret.push(stringify(obj[key], prefix
? prefix + '[' + encodeURIComponent(key) + ']'
: encodeURIComponent(key)));
}
}
return ret.join('&');
}
/**
* Set `obj`'s `key` to `val` respecting
* the weird and wonderful syntax of a qs,
* where "foo=bar&foo=baz" becomes an array.
*
* @param {Object} obj
* @param {String} key
* @param {String} val
* @api private
*/
function set(obj, key, val) {
var v = obj[key];
if (Object.getOwnPropertyDescriptor(Object.prototype, key)) return;
if (undefined === v) {
obj[key] = val;
} else if (isArray(v)) {
v.push(val);
} else {
obj[key] = [v, val];
}
}
/**
* Locate last brace in `str` within the key.
*
* @param {String} str
* @return {Number}
* @api private
*/
function lastBraceInKey(str) {
var len = str.length
, brace
, c;
for (var i = 0; i < len; ++i) {
c = str[i];
if (']' == c) brace = false;
if ('[' == c) brace = true;
if ('=' == c && !brace) return i;
}
}
/**
* Decode `str`.
*
* @param {String} str
* @return {String}
* @api private
*/
function decode(str) {
try {
return decodeURIComponent(str.replace(/\+/g, ' '));
} catch (err) {
return str;
}
}

38
node_modules/body-parser/node_modules/qs/package.json

@ -0,0 +1,38 @@
{
"name": "qs",
"description": "querystring parser",
"version": "0.6.6",
"keywords": [
"query string",
"parser",
"component"
],
"repository": {
"type": "git",
"url": "git://github.com/visionmedia/node-querystring.git"
},
"devDependencies": {
"mocha": "*",
"expect.js": "*"
},
"scripts": {
"test": "make test"
},
"author": {
"name": "TJ Holowaychuk",
"email": "tj@vision-media.ca",
"url": "http://tjholowaychuk.com"
},
"main": "index",
"engines": {
"node": "*"
},
"readme": "# node-querystring\n\n query string parser for node and the browser supporting nesting, as it was removed from `0.3.x`, so this library provides the previous and commonly desired behaviour (and twice as fast). Used by [express](http://expressjs.com), [connect](http://senchalabs.github.com/connect) and others.\n\n## Installation\n\n $ npm install qs\n\n## Examples\n\n```js\nvar qs = require('qs');\n\nqs.parse('user[name][first]=Tobi&user[email]=tobi@learnboost.com');\n// => { user: { name: { first: 'Tobi' }, email: 'tobi@learnboost.com' } }\n\nqs.stringify({ user: { name: 'Tobi', email: 'tobi@learnboost.com' }})\n// => user[name]=Tobi&user[email]=tobi%40learnboost.com\n```\n\n## Testing\n\nInstall dev dependencies:\n\n $ npm install -d\n\nand execute:\n\n $ make test\n\nbrowser:\n\n $ open test/browser/index.html\n\n## License \n\n(The MIT License)\n\nCopyright (c) 2010 TJ Holowaychuk &lt;tj@vision-media.ca&gt;\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n'Software'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",
"readmeFilename": "Readme.md",
"bugs": {
"url": "https://github.com/visionmedia/node-querystring/issues"
},
"homepage": "https://github.com/visionmedia/node-querystring",
"_id": "qs@0.6.6",
"_from": "qs@~0.6.6"
}

1
node_modules/body-parser/node_modules/raw-body/.npmignore

@ -0,0 +1 @@
test/

5
node_modules/body-parser/node_modules/raw-body/.travis.yml

@ -0,0 +1,5 @@
node_js:
- "0.8"
- "0.10"
- "0.11"
language: node_js

14
node_modules/body-parser/node_modules/raw-body/Makefile

@ -0,0 +1,14 @@
NODE ?= node
BIN = ./node_modules/.bin/
test:
@${NODE} ${BIN}mocha \
--harmony-generators \
--reporter spec \
--bail \
./test/index.js
clean:
@rm -rf node_modules
.PHONY: test clean

96
node_modules/body-parser/node_modules/raw-body/README.md

@ -0,0 +1,96 @@
# Raw Body [![Build Status](https://travis-ci.org/stream-utils/raw-body.svg?branch=master)](https://travis-ci.org/stream-utils/raw-body)
Gets the entire buffer of a stream either as a `Buffer` or a string.
Validates the stream's length against an expected length and maximum limit.
Ideal for parsing request bodies.
## API
```js
var getRawBody = require('raw-body')
app.use(function (req, res, next) {
getRawBody(req, {
length: req.headers['content-length'],
limit: '1mb',
encoding: 'utf8'
}, function (err, string) {
if (err)
return next(err)
req.text = string
next()
})
})
```
or in a Koa generator:
```js
app.use(function* (next) {
var string = yield getRawBody(this.req, {
length: this.length,
limit: '1mb',
encoding: 'utf8'
})
})
```
### getRawBody(stream, [options], [callback])
Returns a thunk for yielding with generators.
Options:
- `length` - The length length of the stream.
If the contents of the stream do not add up to this length,
an `400` error code is returned.
- `limit` - The byte limit of the body.
If the body ends up being larger than this limit,
a `413` error code is returned.
- `encoding` - The requested encoding.
By default, a `Buffer` instance will be returned.
Most likely, you want `utf8`.
You can use any type of encoding supported by [StringDecoder](http://nodejs.org/api/string_decoder.html).
You can also pass `true` which sets it to the default `utf8`
`callback(err, res)`:
- `err` - the following attributes will be defined if applicable:
- `limit` - the limit in bytes
- `length` and `expected` - the expected length of the stream
- `received` - the received bytes
- `status` and `statusCode` - the corresponding status code for the error
- `type` - either `entity.too.large`, `request.size.invalid`, or `stream.encoding.set`
- `res` - the result, either as a `String` if an encoding was set or a `Buffer` otherwise.
If an error occurs, the stream will be paused,
and you are responsible for correctly disposing the stream.
For HTTP requests, no handling is required if you send a response.
For streams that use file descriptors, you should `stream.destroy()` or `stream.close()` to prevent leaks.
## License
The MIT License (MIT)
Copyright (c) 2013 Jonathan Ong me@jongleberry.com
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

164
node_modules/body-parser/node_modules/raw-body/index.js

@ -0,0 +1,164 @@
var StringDecoder = require('string_decoder').StringDecoder
var bytes = require('bytes')
module.exports = function (stream, options, done) {
if (typeof options === 'function') {
done = options
options = {}
} else if (!options) {
options = {}
} else if (options === true) {
options = {
encoding: 'utf8'
}
}
// convert the limit to an integer
var limit = null
if (typeof options.limit === 'number')
limit = options.limit
if (typeof options.limit === 'string')
limit = bytes(options.limit)
// convert the expected length to an integer
var length = null
if (options.length != null && !isNaN(options.length))
length = parseInt(options.length, 10)
// check the length and limit options.
// note: we intentionally leave the stream paused,
// so users should handle the stream themselves.
if (limit !== null && length !== null && length > limit) {
if (typeof stream.pause === 'function')
stream.pause()
process.nextTick(function () {
var err = makeError('request entity too large', 'entity.too.large')
err.status = err.statusCode = 413
err.length = err.expected = length
err.limit = limit
done(err)
})
return defer
}
var state = stream._readableState
// streams2+: assert the stream encoding is buffer.
if (state && state.encoding != null) {
if (typeof stream.pause === 'function')
stream.pause()
process.nextTick(function () {
var err = makeError('stream encoding should not be set',
'stream.encoding.set')
// developer error
err.status = err.statusCode = 500
done(err)
})
return defer
}
var received = 0
// note: we delegate any invalid encodings to the constructor
var decoder = options.encoding
? new StringDecoder(options.encoding === true ? 'utf8' : options.encoding)
: null
var buffer = decoder
? ''
: []
stream.on('data', onData)
stream.once('end', onEnd)
stream.once('error', onEnd)
stream.once('close', cleanup)
return defer
// yieldable support
function defer(fn) {
done = fn
}
function onData(chunk) {
received += chunk.length
decoder
? buffer += decoder.write(chunk)
: buffer.push(chunk)
if (limit !== null && received > limit) {
if (typeof stream.pause === 'function')
stream.pause()
var err = makeError('request entity too large', 'entity.too.large')
err.status = err.statusCode = 413
err.received = received
err.limit = limit
done(err)
cleanup()
}
}
function onEnd(err) {
if (err) {
if (typeof stream.pause === 'function')
stream.pause()
done(err)
} else if (length !== null && received !== length) {
err = makeError('request size did not match content length',
'request.size.invalid')
err.status = err.statusCode = 400
err.received = received
err.length = err.expected = length
done(err)
} else {
done(null, decoder
? buffer + endStringDecoder(decoder)
: Buffer.concat(buffer)
)
}
cleanup()
}
function cleanup() {
received = buffer = null
stream.removeListener('data', onData)
stream.removeListener('end', onEnd)
stream.removeListener('error', onEnd)
stream.removeListener('close', cleanup)
}
}
// to create serializable errors you must re-set message so
// that it is enumerable and you must re configure the type
// property so that is writable and enumerable
function makeError(message, type) {
var error = new Error()
error.message = message
Object.defineProperty(error, 'type', {
value: type,
enumerable: true,
writable: true,
configurable: true
})
return error
}
// https://github.com/Raynos/body/blob/2512ced39e31776e5a2f7492b907330badac3a40/index.js#L72
// bug fix for missing `StringDecoder.end` in v0.8.x
function endStringDecoder(decoder) {
if (decoder.end) {
return decoder.end()
}
var res = ""
if (decoder.charReceived) {
var cr = decoder.charReceived
var buf = decoder.charBuffer
var enc = decoder.encoding
res += buf.slice(0, cr).toString(enc)
}
return res
}

1
node_modules/body-parser/node_modules/raw-body/node_modules/bytes/.npmignore

@ -0,0 +1 @@
test

20
node_modules/body-parser/node_modules/raw-body/node_modules/bytes/History.md

@ -0,0 +1,20 @@
0.3.0 / 2014-03-19
==================
* added terabyte support
0.2.1 / 2013-04-01
==================
* add .component
0.2.0 / 2012-10-28
==================
* bytes(200).should.eql('200b')
0.1.0 / 2012-07-04
==================
* add bytes to string conversion [yields]

7
node_modules/body-parser/node_modules/raw-body/node_modules/bytes/Makefile

@ -0,0 +1,7 @@
test:
@./node_modules/.bin/mocha \
--reporter spec \
--require should
.PHONY: test

54
node_modules/body-parser/node_modules/raw-body/node_modules/bytes/Readme.md

@ -0,0 +1,54 @@
# node-bytes
Byte string parser / formatter.
## Example:
```js
bytes('1kb')
// => 1024
bytes('2mb')
// => 2097152
bytes('1gb')
// => 1073741824
bytes(1073741824)
// => 1gb
bytes(1099511627776)
// => 1tb
```
## Installation
```
$ npm install bytes
$ component install visionmedia/bytes.js
```
## License
(The MIT License)
Copyright (c) 2012 TJ Holowaychuk &lt;tj@vision-media.ca&gt;
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

7
node_modules/body-parser/node_modules/raw-body/node_modules/bytes/component.json

@ -0,0 +1,7 @@
{
"name": "bytes",
"description": "byte size string parser / serializer",
"keywords": ["bytes", "utility"],
"version": "0.2.1",
"scripts": ["index.js"]
}

41
node_modules/body-parser/node_modules/raw-body/node_modules/bytes/index.js

@ -0,0 +1,41 @@
/**
* Parse byte `size` string.
*
* @param {String} size
* @return {Number}
* @api public
*/
module.exports = function(size) {
if ('number' == typeof size) return convert(size);
var parts = size.match(/^(\d+(?:\.\d+)?) *(kb|mb|gb|tb)$/)
, n = parseFloat(parts[1])
, type = parts[2];
var map = {
kb: 1 << 10
, mb: 1 << 20
, gb: 1 << 30
, tb: ((1 << 30) * 1024)
};
return map[type] * n;
};
/**
* convert bytes into string.
*
* @param {Number} b - bytes to convert
* @return {String}
* @api public
*/
function convert (b) {
var tb = ((1 << 30) * 1024), gb = 1 << 30, mb = 1 << 20, kb = 1 << 10;
if (b >= tb) return (Math.round(b / tb * 100) / 100) + 'tb';
if (b >= gb) return (Math.round(b / gb * 100) / 100) + 'gb';
if (b >= mb) return (Math.round(b / mb * 100) / 100) + 'mb';
if (b >= kb) return (Math.round(b / kb * 100) / 100) + 'kb';
return b + 'b';
}

37
node_modules/body-parser/node_modules/raw-body/node_modules/bytes/package.json

@ -0,0 +1,37 @@
{
"name": "bytes",
"author": {
"name": "TJ Holowaychuk",
"email": "tj@vision-media.ca",
"url": "http://tjholowaychuk.com"
},
"description": "byte size string parser / serializer",
"repository": {
"type": "git",
"url": "https://github.com/visionmedia/bytes.js.git"
},
"version": "0.3.0",
"main": "index.js",
"dependencies": {},
"devDependencies": {
"mocha": "*",
"should": "*"
},
"component": {
"scripts": {
"bytes/index.js": "index.js"
}
},
"readme": "# node-bytes\n\n Byte string parser / formatter.\n\n## Example:\n\n```js\nbytes('1kb')\n// => 1024\n\nbytes('2mb')\n// => 2097152\n\nbytes('1gb')\n// => 1073741824\n\nbytes(1073741824)\n// => 1gb\n\nbytes(1099511627776)\n// => 1tb\n```\n\n## Installation\n\n```\n$ npm install bytes\n$ component install visionmedia/bytes.js\n```\n\n## License \n\n(The MIT License)\n\nCopyright (c) 2012 TJ Holowaychuk &lt;tj@vision-media.ca&gt;\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n'Software'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n",
"readmeFilename": "Readme.md",
"bugs": {
"url": "https://github.com/visionmedia/bytes.js/issues"
},
"homepage": "https://github.com/visionmedia/bytes.js",
"_id": "bytes@0.3.0",
"dist": {
"shasum": "741ac2cc6fdac3cd7ee104196aaad35b6d4c8ee5"
},
"_from": "bytes@~0.3.0",
"_resolved": "https://registry.npmjs.org/bytes/-/bytes-0.3.0.tgz"
}

45
node_modules/body-parser/node_modules/raw-body/package.json

@ -0,0 +1,45 @@
{
"name": "raw-body",
"description": "Get and validate the raw body of a readable stream.",
"version": "1.1.4",
"author": {
"name": "Jonathan Ong",
"email": "me@jongleberry.com",
"url": "http://jongleberry.com"
},
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/stream-utils/raw-body.git"
},
"bugs": {
"url": "https://github.com/stream-utils/raw-body/issues"
},
"dependencies": {
"bytes": "~0.3.0"
},
"devDependencies": {
"readable-stream": "~1.0.17",
"co": "3",
"gnode": "~0.0.4",
"mocha": "^1.14.0",
"through2": "~0.4.1",
"request": "^2.27.0",
"assert-tap": "~0.1.4"
},
"scripts": {
"test": "NODE=gnode make test && node ./test/acceptance.js"
},
"engines": {
"node": ">= 0.8.0"
},
"readme": "# Raw Body [![Build Status](https://travis-ci.org/stream-utils/raw-body.svg?branch=master)](https://travis-ci.org/stream-utils/raw-body)\n\nGets the entire buffer of a stream either as a `Buffer` or a string.\nValidates the stream's length against an expected length and maximum limit.\nIdeal for parsing request bodies.\n\n## API\n\n```js\nvar getRawBody = require('raw-body')\n\napp.use(function (req, res, next) {\n getRawBody(req, {\n length: req.headers['content-length'],\n limit: '1mb',\n encoding: 'utf8'\n }, function (err, string) {\n if (err)\n return next(err)\n\n req.text = string\n next()\n })\n})\n```\n\nor in a Koa generator:\n\n```js\napp.use(function* (next) {\n var string = yield getRawBody(this.req, {\n length: this.length,\n limit: '1mb',\n encoding: 'utf8'\n })\n})\n```\n\n### getRawBody(stream, [options], [callback])\n\nReturns a thunk for yielding with generators.\n\nOptions:\n\n- `length` - The length length of the stream.\n If the contents of the stream do not add up to this length,\n an `400` error code is returned.\n- `limit` - The byte limit of the body.\n If the body ends up being larger than this limit,\n a `413` error code is returned.\n- `encoding` - The requested encoding.\n By default, a `Buffer` instance will be returned.\n Most likely, you want `utf8`.\n You can use any type of encoding supported by [StringDecoder](http://nodejs.org/api/string_decoder.html).\n You can also pass `true` which sets it to the default `utf8`\n\n`callback(err, res)`:\n\n- `err` - the following attributes will be defined if applicable:\n\n - `limit` - the limit in bytes\n - `length` and `expected` - the expected length of the stream\n - `received` - the received bytes\n - `status` and `statusCode` - the corresponding status code for the error\n - `type` - either `entity.too.large`, `request.size.invalid`, or `stream.encoding.set`\n\n- `res` - the result, either as a `String` if an encoding was set or a `Buffer` otherwise.\n\nIf an error occurs, the stream will be paused,\nand you are responsible for correctly disposing the stream.\nFor HTTP requests, no handling is required if you send a response.\nFor streams that use file descriptors, you should `stream.destroy()` or `stream.close()` to prevent leaks.\n\n## License\n\nThe MIT License (MIT)\n\nCopyright (c) 2013 Jonathan Ong me@jongleberry.com\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n",
"readmeFilename": "README.md",
"homepage": "https://github.com/stream-utils/raw-body",
"_id": "raw-body@1.1.4",
"dist": {
"shasum": "6bc522a645d7c9939fe2ba2be3bd5ddf29f7f89f"
},
"_from": "raw-body@~1.1.2",
"_resolved": "https://registry.npmjs.org/raw-body/-/raw-body-1.1.4.tgz"
}

1
node_modules/body-parser/node_modules/type-is/.npmignore

@ -0,0 +1 @@
test.js

4
node_modules/body-parser/node_modules/type-is/.travis.yml

@ -0,0 +1,4 @@
node_js:
- "0.10"
- "0.11"
language: node_js

16
node_modules/body-parser/node_modules/type-is/HISTORY.md

@ -0,0 +1,16 @@
1.1.0 / 2014-04-12
==================
* add non-array values support
* expose internal utilities:
- `.is()`
- `.hasBody()`
- `.normalize()`
- `.match()`
1.0.1 / 2014-03-30
==================
* add `multipart` as a shorthand

87
node_modules/body-parser/node_modules/type-is/README.md

@ -0,0 +1,87 @@
# Type Is [![Build Status](https://travis-ci.org/expressjs/type-is.png)](https://travis-ci.org/expressjs/type-is)
Infer the content type of a request.
Extracted from [koa](https://github.com/koajs/koa) for general use.
Here's an example body parser:
```js
var is = require('type-is');
var parse = require('body');
var busboy = require('busboy');
function bodyParser(req, res, next) {
var hasRequestBody = 'content-type' in req.headers
|| 'transfer-encoding' in req.headers;
if (!hasRequestBody) return next();
switch (is(req, ['urlencoded', 'json', 'multipart'])) {
case 'urlencoded':
// parse urlencoded body
break
case 'json':
// parse json body
break
case 'multipart':
// parse multipart body
break
default:
// 415 error code
}
}
```
## API
### var type = is(request, types)
```js
var is = require('type-is')
http.createServer(function (req, res) {
is(req, ['text/*'])
})
```
`request` is the node HTTP request. `types` is an array of types. Each type can be:
- An extension name such as `json`. This name will be returned if matched.
- A mime type such as `application/json`.
- A mime type with a wildcard such as `*/json` or `application/*`. The full mime type will be returned if matched
`false` will be returned if no type matches.
Examples:
```js
// req.headers.content-type = 'application/json'
is(req, ['json']) // -> 'json'
is(req, ['html', 'json']) // -> 'json'
is(req, ['application/*']) // -> 'application/json'
is(req, ['application/json']) // -> 'application/json'
is(req, ['html']) // -> false
```
## License
The MIT License (MIT)
Copyright (c) 2013 Jonathan Ong me@jongleberry.com
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

148
node_modules/body-parser/node_modules/type-is/index.js

@ -0,0 +1,148 @@
var mime = require('mime');
var slice = [].slice;
module.exports = typeofrequest;
typeofrequest.is = typeis;
typeofrequest.hasBody = hasbody;
typeofrequest.normalize = normalize;
typeofrequest.match = mimeMatch;
/**
* Compare a `value` content-type with `types`.
* Each `type` can be an extension like `html`,
* a special shortcut like `multipart` or `urlencoded`,
* or a mime type.
*
* If no types match, `false` is returned.
* Otherwise, the first `type` that matches is returned.
*
* @param {String} value
* @param {Array} types
* @return String
*/
function typeis(value, types) {
if (!value) return false;
if (types && !Array.isArray(types)) types = slice.call(arguments, 1);
// remove stuff like charsets
var index = value.indexOf(';')
value = ~index ? value.slice(0, index) : value
// no types, return the content type
if (!types || !types.length) return value;
var type;
for (var i = 0; i < types.length; i++)
if (mimeMatch(normalize(type = types[i]), value))
return ~type.indexOf('*') ? value : type;
// no matches
return false;
}
/**
* Check if a request has a request body.
* A request with a body __must__ either have `transfer-encoding`
* or `content-length` headers set.
* http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.3
*
* @param {Object} request
* @return {Boolean}
* @api public
*/
function hasbody(req) {
var headers = req.headers;
if ('transfer-encoding' in headers) return true;
var length = headers['content-length'];
if (!length) return false;
// no idea when this would happen, but `isNaN(null) === false`
if (isNaN(length)) return false;
return !!parseInt(length, 10);
}
/**
* Check if the incoming request contains the "Content-Type"
* header field, and it contains any of the give mime `type`s.
* If there is no request body, `null` is returned.
* If there is no content type, `false` is returned.
* Otherwise, it returns the first `type` that matches.
*
* Examples:
*
* // With Content-Type: text/html; charset=utf-8
* this.is('html'); // => 'html'
* this.is('text/html'); // => 'text/html'
* this.is('text/*', 'application/json'); // => 'text/html'
*
* // When Content-Type is application/json
* this.is('json', 'urlencoded'); // => 'json'
* this.is('application/json'); // => 'application/json'
* this.is('html', 'application/*'); // => 'application/json'
*
* this.is('html'); // => false
*
* @param {String|Array} types...
* @return {String|false|null}
* @api public
*/
function typeofrequest(req, types) {
if (!hasbody(req)) return null;
if (types && !Array.isArray(types)) types = slice.call(arguments, 1);
return typeis(req.headers['content-type'], types);
}
/**
* Normalize a mime type.
* If it's a shorthand, expand it to a valid mime type.
*
* In general, you probably want:
*
* var type = is(req, ['urlencoded', 'json', 'multipart']);
*
* Then use the appropriate body parsers.
* These three are the most common request body types
* and are thus ensured to work.
*
* @param {String} type
* @api private
*/
function normalize(type) {
switch (type) {
case 'urlencoded': return 'application/x-www-form-urlencoded';
case 'multipart':
type = 'multipart/*';
break;
}
return ~type.indexOf('/') ? type : mime.lookup(type);
}
/**
* Check if `exected` mime type
* matches `actual` mime type with
* wildcard support.
*
* @param {String} expected
* @param {String} actual
* @return {Boolean}
* @api private
*/
function mimeMatch(expected, actual) {
if (expected === actual) return true;
if (!~expected.indexOf('*')) return false;
actual = actual.split('/');
expected = expected.split('/');
if ('*' === expected[0] && expected[1] === actual[1]) return true;
if ('*' === expected[1] && expected[0] === actual[0]) return true;
return false;
}

19
node_modules/body-parser/node_modules/type-is/node_modules/mime/LICENSE

@ -0,0 +1,19 @@
Copyright (c) 2010 Benjamin Thomas, Robert Kieffer
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

66
node_modules/body-parser/node_modules/type-is/node_modules/mime/README.md

@ -0,0 +1,66 @@
# mime
Comprehensive MIME type mapping API. Includes all 600+ types and 800+ extensions defined by the Apache project, plus additional types submitted by the node.js community.
## Install
Install with [npm](http://github.com/isaacs/npm):
npm install mime
## API - Queries
### mime.lookup(path)
Get the mime type associated with a file, if no mime type is found `application/octet-stream` is returned. Performs a case-insensitive lookup using the extension in `path` (the substring after the last '/' or '.'). E.g.
var mime = require('mime');
mime.lookup('/path/to/file.txt'); // => 'text/plain'
mime.lookup('file.txt'); // => 'text/plain'
mime.lookup('.TXT'); // => 'text/plain'
mime.lookup('htm'); // => 'text/html'
### mime.default_type
Sets the mime type returned when `mime.lookup` fails to find the extension searched for. (Default is `application/octet-stream`.)
### mime.extension(type)
Get the default extension for `type`
mime.extension('text/html'); // => 'html'
mime.extension('application/octet-stream'); // => 'bin'
### mime.charsets.lookup()
Map mime-type to charset
mime.charsets.lookup('text/plain'); // => 'UTF-8'
(The logic for charset lookups is pretty rudimentary. Feel free to suggest improvements.)
## API - Defining Custom Types
The following APIs allow you to add your own type mappings within your project. If you feel a type should be included as part of node-mime, see [requesting new types](https://github.com/broofa/node-mime/wiki/Requesting-New-Types).
### mime.define()
Add custom mime/extension mappings
mime.define({
'text/x-some-format': ['x-sf', 'x-sft', 'x-sfml'],
'application/x-my-type': ['x-mt', 'x-mtt'],
// etc ...
});
mime.lookup('x-sft'); // => 'text/x-some-format'
The first entry in the extensions array is returned by `mime.extension()`. E.g.
mime.extension('text/x-some-format'); // => 'x-sf'
### mime.load(filepath)
Load mappings from an Apache ".types" format file
mime.load('./my_project.types');
The .types file format is simple - See the `types` dir for examples.

114
node_modules/body-parser/node_modules/type-is/node_modules/mime/mime.js

@ -0,0 +1,114 @@
var path = require('path');
var fs = require('fs');
function Mime() {
// Map of extension -> mime type
this.types = Object.create(null);
// Map of mime type -> extension
this.extensions = Object.create(null);
}
/**
* Define mimetype -> extension mappings. Each key is a mime-type that maps
* to an array of extensions associated with the type. The first extension is
* used as the default extension for the type.
*
* e.g. mime.define({'audio/ogg', ['oga', 'ogg', 'spx']});
*
* @param map (Object) type definitions
*/
Mime.prototype.define = function (map) {
for (var type in map) {
var exts = map[type];
for (var i = 0; i < exts.length; i++) {
if (process.env.DEBUG_MIME && this.types[exts]) {
console.warn(this._loading.replace(/.*\//, ''), 'changes "' + exts[i] + '" extension type from ' +
this.types[exts] + ' to ' + type);
}
this.types[exts[i]] = type;
}
// Default extension is the first one we encounter
if (!this.extensions[type]) {
this.extensions[type] = exts[0];
}
}
};
/**
* Load an Apache2-style ".types" file
*
* This may be called multiple times (it's expected). Where files declare
* overlapping types/extensions, the last file wins.
*
* @param file (String) path of file to load.
*/
Mime.prototype.load = function(file) {
this._loading = file;
// Read file and split into lines
var map = {},
content = fs.readFileSync(file, 'ascii'),
lines = content.split(/[\r\n]+/);
lines.forEach(function(line) {
// Clean up whitespace/comments, and split into fields
var fields = line.replace(/\s*#.*|^\s*|\s*$/g, '').split(/\s+/);
map[fields.shift()] = fields;
});
this.define(map);
this._loading = null;
};
/**
* Lookup a mime type based on extension
*/
Mime.prototype.lookup = function(path, fallback) {
var ext = path.replace(/.*[\.\/\\]/, '').toLowerCase();
return this.types[ext] || fallback || this.default_type;
};
/**
* Return file extension associated with a mime type
*/
Mime.prototype.extension = function(mimeType) {
var type = mimeType.match(/^\s*([^;\s]*)(?:;|\s|$)/)[1].toLowerCase();
return this.extensions[type];
};
// Default instance
var mime = new Mime();
// Load local copy of
// http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types
mime.load(path.join(__dirname, 'types/mime.types'));
// Load additional types from node.js community
mime.load(path.join(__dirname, 'types/node.types'));
// Default type
mime.default_type = mime.lookup('bin');
//
// Additional API specific to the default instance
//
mime.Mime = Mime;
/**
* Lookup a charset based on mime type.
*/
mime.charsets = {
lookup: function(mimeType, fallback) {
// Assume text types are utf8
return (/^text\//).test(mimeType) ? 'UTF-8' : fallback;
}
};
module.exports = mime;

36
node_modules/body-parser/node_modules/type-is/node_modules/mime/package.json

@ -0,0 +1,36 @@
{
"author": {
"name": "Robert Kieffer",
"email": "robert@broofa.com",
"url": "http://github.com/broofa"
},
"contributors": [
{
"name": "Benjamin Thomas",
"email": "benjamin@benjaminthomas.org",
"url": "http://github.com/bentomas"
}
],
"dependencies": {},
"description": "A comprehensive library for mime-type mapping",
"devDependencies": {},
"keywords": [
"util",
"mime"
],
"main": "mime.js",
"name": "mime",
"repository": {
"url": "https://github.com/broofa/node-mime",
"type": "git"
},
"version": "1.2.11",
"readme": "# mime\n\nComprehensive MIME type mapping API. Includes all 600+ types and 800+ extensions defined by the Apache project, plus additional types submitted by the node.js community.\n\n## Install\n\nInstall with [npm](http://github.com/isaacs/npm):\n\n npm install mime\n\n## API - Queries\n\n### mime.lookup(path)\nGet the mime type associated with a file, if no mime type is found `application/octet-stream` is returned. Performs a case-insensitive lookup using the extension in `path` (the substring after the last '/' or '.'). E.g.\n\n var mime = require('mime');\n\n mime.lookup('/path/to/file.txt'); // => 'text/plain'\n mime.lookup('file.txt'); // => 'text/plain'\n mime.lookup('.TXT'); // => 'text/plain'\n mime.lookup('htm'); // => 'text/html'\n\n### mime.default_type\nSets the mime type returned when `mime.lookup` fails to find the extension searched for. (Default is `application/octet-stream`.)\n\n### mime.extension(type)\nGet the default extension for `type`\n\n mime.extension('text/html'); // => 'html'\n mime.extension('application/octet-stream'); // => 'bin'\n\n### mime.charsets.lookup()\n\nMap mime-type to charset\n\n mime.charsets.lookup('text/plain'); // => 'UTF-8'\n\n(The logic for charset lookups is pretty rudimentary. Feel free to suggest improvements.)\n\n## API - Defining Custom Types\n\nThe following APIs allow you to add your own type mappings within your project. If you feel a type should be included as part of node-mime, see [requesting new types](https://github.com/broofa/node-mime/wiki/Requesting-New-Types).\n\n### mime.define()\n\nAdd custom mime/extension mappings\n\n mime.define({\n 'text/x-some-format': ['x-sf', 'x-sft', 'x-sfml'],\n 'application/x-my-type': ['x-mt', 'x-mtt'],\n // etc ...\n });\n\n mime.lookup('x-sft'); // => 'text/x-some-format'\n\nThe first entry in the extensions array is returned by `mime.extension()`. E.g.\n\n mime.extension('text/x-some-format'); // => 'x-sf'\n\n### mime.load(filepath)\n\nLoad mappings from an Apache \".types\" format file\n\n mime.load('./my_project.types');\n\nThe .types file format is simple - See the `types` dir for examples.\n",
"readmeFilename": "README.md",
"bugs": {
"url": "https://github.com/broofa/node-mime/issues"
},
"homepage": "https://github.com/broofa/node-mime",
"_id": "mime@1.2.11",
"_from": "mime@~1.2.11"
}

84
node_modules/body-parser/node_modules/type-is/node_modules/mime/test.js

@ -0,0 +1,84 @@
/**
* Usage: node test.js
*/
var mime = require('./mime');
var assert = require('assert');
var path = require('path');
function eq(a, b) {
console.log('Test: ' + a + ' === ' + b);
assert.strictEqual.apply(null, arguments);
}
console.log(Object.keys(mime.extensions).length + ' types');
console.log(Object.keys(mime.types).length + ' extensions\n');
//
// Test mime lookups
//
eq('text/plain', mime.lookup('text.txt')); // normal file
eq('text/plain', mime.lookup('TEXT.TXT')); // uppercase
eq('text/plain', mime.lookup('dir/text.txt')); // dir + file
eq('text/plain', mime.lookup('.text.txt')); // hidden file
eq('text/plain', mime.lookup('.txt')); // nameless
eq('text/plain', mime.lookup('txt')); // extension-only
eq('text/plain', mime.lookup('/txt')); // extension-less ()
eq('text/plain', mime.lookup('\\txt')); // Windows, extension-less
eq('application/octet-stream', mime.lookup('text.nope')); // unrecognized
eq('fallback', mime.lookup('text.fallback', 'fallback')); // alternate default
//
// Test extensions
//
eq('txt', mime.extension(mime.types.text));
eq('html', mime.extension(mime.types.htm));
eq('bin', mime.extension('application/octet-stream'));
eq('bin', mime.extension('application/octet-stream '));
eq('html', mime.extension(' text/html; charset=UTF-8'));
eq('html', mime.extension('text/html; charset=UTF-8 '));
eq('html', mime.extension('text/html; charset=UTF-8'));
eq('html', mime.extension('text/html ; charset=UTF-8'));
eq('html', mime.extension('text/html;charset=UTF-8'));
eq('html', mime.extension('text/Html;charset=UTF-8'));
eq(undefined, mime.extension('unrecognized'));
//
// Test node.types lookups
//
eq('application/font-woff', mime.lookup('file.woff'));
eq('application/octet-stream', mime.lookup('file.buffer'));
eq('audio/mp4', mime.lookup('file.m4a'));
eq('font/opentype', mime.lookup('file.otf'));
//
// Test charsets
//
eq('UTF-8', mime.charsets.lookup('text/plain'));
eq(undefined, mime.charsets.lookup(mime.types.js));
eq('fallback', mime.charsets.lookup('application/octet-stream', 'fallback'));
//
// Test for overlaps between mime.types and node.types
//
var apacheTypes = new mime.Mime(), nodeTypes = new mime.Mime();
apacheTypes.load(path.join(__dirname, 'types/mime.types'));
nodeTypes.load(path.join(__dirname, 'types/node.types'));
var keys = [].concat(Object.keys(apacheTypes.types))
.concat(Object.keys(nodeTypes.types));
keys.sort();
for (var i = 1; i < keys.length; i++) {
if (keys[i] == keys[i-1]) {
console.warn('Warning: ' +
'node.types defines ' + keys[i] + '->' + nodeTypes.types[keys[i]] +
', mime.types defines ' + keys[i] + '->' + apacheTypes.types[keys[i]]);
}
}
console.log('\nOK');

1588
node_modules/body-parser/node_modules/type-is/node_modules/mime/types/mime.types
File diff suppressed because it is too large
View File

77
node_modules/body-parser/node_modules/type-is/node_modules/mime/types/node.types

@ -0,0 +1,77 @@
# What: WebVTT
# Why: To allow formats intended for marking up external text track resources.
# http://dev.w3.org/html5/webvtt/
# Added by: niftylettuce
text/vtt vtt
# What: Google Chrome Extension
# Why: To allow apps to (work) be served with the right content type header.
# http://codereview.chromium.org/2830017
# Added by: niftylettuce
application/x-chrome-extension crx
# What: HTC support
# Why: To properly render .htc files such as CSS3PIE
# Added by: niftylettuce
text/x-component htc
# What: HTML5 application cache manifes ('.manifest' extension)
# Why: De-facto standard. Required by Mozilla browser when serving HTML5 apps
# per https://developer.mozilla.org/en/offline_resources_in_firefox
# Added by: louisremi
text/cache-manifest manifest
# What: node binary buffer format
# Why: semi-standard extension w/in the node community
# Added by: tootallnate
application/octet-stream buffer
# What: The "protected" MP-4 formats used by iTunes.
# Why: Required for streaming music to browsers (?)
# Added by: broofa
application/mp4 m4p
audio/mp4 m4a
# What: Video format, Part of RFC1890
# Why: See https://github.com/bentomas/node-mime/pull/6
# Added by: mjrusso
video/MP2T ts
# What: EventSource mime type
# Why: mime type of Server-Sent Events stream
# http://www.w3.org/TR/eventsource/#text-event-stream
# Added by: francois2metz
text/event-stream event-stream
# What: Mozilla App manifest mime type
# Why: https://developer.mozilla.org/en/Apps/Manifest#Serving_manifests
# Added by: ednapiranha
application/x-web-app-manifest+json webapp
# What: Lua file types
# Why: Googling around shows de-facto consensus on these
# Added by: creationix (Issue #45)
text/x-lua lua
application/x-lua-bytecode luac
# What: Markdown files, as per http://daringfireball.net/projects/markdown/syntax
# Why: http://stackoverflow.com/questions/10701983/what-is-the-mime-type-for-markdown
# Added by: avoidwork
text/x-markdown markdown md mkd
# What: ini files
# Why: because they're just text files
# Added by: Matthew Kastor
text/plain ini
# What: DASH Adaptive Streaming manifest
# Why: https://developer.mozilla.org/en-US/docs/DASH_Adaptive_Streaming_for_HTML_5_Video
# Added by: eelcocramer
application/dash+xml mdp
# What: OpenType font files - http://www.microsoft.com/typography/otspec/
# Why: Browsers usually ignore the font MIME types and sniff the content,
# but Chrome, shows a warning if OpenType fonts aren't served with
# the `font/opentype` MIME type: http://i.imgur.com/8c5RN8M.png.
# Added by: alrra
font/opentype otf

37
node_modules/body-parser/node_modules/type-is/package.json

@ -0,0 +1,37 @@
{
"name": "type-is",
"description": "Infer the content type if a request",
"version": "1.1.0",
"author": {
"name": "Jonathan Ong",
"email": "me@jongleberry.com",
"url": "http://jongleberry.com"
},
"license": "MIT",
"repository": {
"type": "git",
"url": "git://github.com/expressjs/type-is"
},
"dependencies": {
"mime": "~1.2.11"
},
"devDependencies": {
"mocha": "*",
"should": "*"
},
"scripts": {
"test": "mocha --require should --reporter spec --bail"
},
"readme": "# Type Is [![Build Status](https://travis-ci.org/expressjs/type-is.png)](https://travis-ci.org/expressjs/type-is)\n\nInfer the content type of a request. \nExtracted from [koa](https://github.com/koajs/koa) for general use.\n\nHere's an example body parser:\n\n```js\nvar is = require('type-is');\nvar parse = require('body');\nvar busboy = require('busboy');\n\nfunction bodyParser(req, res, next) {\n var hasRequestBody = 'content-type' in req.headers\n || 'transfer-encoding' in req.headers;\n if (!hasRequestBody) return next();\n \n switch (is(req, ['urlencoded', 'json', 'multipart'])) {\n case 'urlencoded':\n // parse urlencoded body\n break\n case 'json':\n // parse json body\n break\n case 'multipart':\n // parse multipart body\n break\n default:\n // 415 error code\n }\n}\n```\n\n## API\n\n### var type = is(request, types)\n\n```js\nvar is = require('type-is')\n\nhttp.createServer(function (req, res) {\n is(req, ['text/*'])\n})\n```\n\n`request` is the node HTTP request. `types` is an array of types. Each type can be:\n\n- An extension name such as `json`. This name will be returned if matched.\n- A mime type such as `application/json`.\n- A mime type with a wildcard such as `*/json` or `application/*`. The full mime type will be returned if matched\n\n`false` will be returned if no type matches.\n\nExamples:\n\n```js\n// req.headers.content-type = 'application/json'\nis(req, ['json']) // -> 'json'\nis(req, ['html', 'json']) // -> 'json'\nis(req, ['application/*']) // -> 'application/json'\nis(req, ['application/json']) // -> 'application/json'\nis(req, ['html']) // -> false\n```\n\n## License\n\nThe MIT License (MIT)\n\nCopyright (c) 2013 Jonathan Ong me@jongleberry.com\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n",
"readmeFilename": "README.md",
"bugs": {
"url": "https://github.com/expressjs/type-is/issues"
},
"homepage": "https://github.com/expressjs/type-is",
"_id": "type-is@1.1.0",
"dist": {
"shasum": "013fbfeb3955944bae8bf3b632df4ed807aefbbd"
},
"_from": "type-is@~1.1.0",
"_resolved": "https://registry.npmjs.org/type-is/-/type-is-1.1.0.tgz"
}

41
node_modules/body-parser/package.json

@ -0,0 +1,41 @@
{
"name": "body-parser",
"description": "Connect's body parsing middleware",
"version": "1.0.2",
"author": {
"name": "Jonathan Ong",
"email": "me@jongleberry.com",
"url": "http://jongleberry.com"
},
"license": "MIT",
"repository": {
"type": "git",
"url": "git://github.com/expressjs/body-parser"
},
"dependencies": {
"type-is": "~1.1.0",
"raw-body": "~1.1.2",
"qs": "~0.6.6"
},
"devDependencies": {
"connect": "*",
"mocha": "*",
"should": "*",
"supertest": "*"
},
"scripts": {
"test": "make test"
},
"readme": "# Body Parser [![Build Status](https://travis-ci.org/expressjs/body-parser.png)](https://travis-ci.org/expressjs/body-parser)\n\nConnect's body parsing middleware.\n\n## API\n\n```js\nvar bodyParser = require('body-parser');\n\nvar app = connect();\n\napp.use(bodyParser());\n\napp.use(function (req, res, next) {\n console.log(req.body) // populated!\n next();\n})\n```\n\n### bodyParser([options])\n\nReturns middleware that parses both `json` and `urlencoded`. The `options` are passed to both middleware.\n\n### bodyParser.json([options])\n\nReturns middleware that only parses `json`. The options are:\n\n- `strict` <true> - only parse objects and arrays\n- `limit` <1mb> - maximum request body size\n- `reviver` - passed to `JSON.parse()`\n\n### bodyParser.urlencoded([options])\n\nReturns middleware that only parses `urlencoded` with the [qs](https://github.com/visionmedia/node-querystring) module. The options are:\n\n- `limit` <1mb> - maximum request body size\n\n## License\n\nThe MIT License (MIT)\n\nCopyright (c) 2014 Jonathan Ong me@jongleberry.com\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n",
"readmeFilename": "README.md",
"bugs": {
"url": "https://github.com/expressjs/body-parser/issues"
},
"homepage": "https://github.com/expressjs/body-parser",
"_id": "body-parser@1.0.2",
"dist": {
"shasum": "a5ef66df81af3d2a204ac2c03f1b44c630a70643"
},
"_from": "body-parser@",
"_resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.0.2.tgz"
}

31
web/public/help/instructions.txt

@ -0,0 +1,31 @@
TwitchBot Commands List
=======================
Public Commands:
!<currency> Displays how many <currency> you have
!bid <amount> Bid <amount> <currency> on the current auction
!ticket <amount> Buy <amount> tickets for the current raffle
!<option> <amount> Used for voting and betting
!<bot_name> List of available custom commands
!<currency> bet pool Display current betting pool
!<currency> vote pool Display current vote standings
Mod only commands:
!<currency> (on/off) Enables or disables currency requests
!<currency> auction open Opens a new auction
!<currency> auction close Closes the auction and announces winner
!<currency> auction cancel Cancels auction, returns <currency> to users
!<currency> raffle open <price> <max> Opens a raffle, tickets cost <price>, users can buy a max of <max> tickets
!<currency> raffle close/cancel Same as auction functions
!<currency> raffle draw Draws a second ticket (second place or need a new winner)
!<currency> bet open (opt1 opt2 etc) Opens a bet with options !opt1 !opt2 (can have up to 10)
!<currency> bet close Stop accepting new bets
!<currency> bet cancel Cancel bet, give <currency> back to users
!<currency> bet winner (opt1) Makes (!opt1) the winner, pays out to users
!<currency> vote open (opt1 opt2 etc) Opens a vote with options !opt1 !opt2 (can have up to 10)
!<currency> vote close Stop accepting new votes
!<currency> vote cancel Cancel vote, give <currency> back to users
!<currency> vote winner (opt1) Makes (!opt1) the winner (will make this calculate the winner soon)

16
web/templates/fanart.jade

@ -4,25 +4,13 @@ block content
br br
br br
div.uk-width-1-1.uk-text-center div.uk-width-1-1.uk-text-center
h1 Potato Fan Art
h1 #{ucfirst(title)} Fan Art
div.uk-width-1-1 div.uk-width-1-1
div#fan-art.uk-panel.uk-panel-box div#fan-art.uk-panel.uk-panel-box
block postscript block postscript
script. script.
var art = [
{
url: "https://pbs.twimg.com/media/BjxJdEFCcAAO15X.png:large",
user: "Hraugur",
user_link: "https://twitter.com/Hraugur"
},
{
url: "https://pbs.twimg.com/media/BjxJdEFCcAAO15X.png:large",
user: "Hraugur",
user_link: "https://twitter.com/Hraugur"
},
];
var art = !{JSON.stringify(fanart)};
var $holder = $(".uk-panel-box"); var $holder = $(".uk-panel-box");
art.forEach(function(elem) { art.forEach(function(elem) {
var $thumb = $("<a href='"+elem.url+"' class='uk-thumbnail uk-thumbnail-small'></a>"); var $thumb = $("<a href='"+elem.url+"' class='uk-thumbnail uk-thumbnail-small'></a>");

4
web/templates/index.jade

@ -32,11 +32,11 @@ block content
div.uk-width-1-2 div.uk-width-1-2
div.uk-panel.uk-panel-box div.uk-panel.uk-panel-box
table.uk-table.uk-table-hover.uk-table-striped table.uk-table.uk-table-hover.uk-table-striped
caption Top 10 Potato Farmers
caption Top 10 #{ucfirst(currency)} Farmers
thead thead
tr tr
th Viewer th Viewer
th Potatoes
th #{ucfirst(currency)}
tbody tbody
each row in rows each row in rows
tr tr

48
web/templates/ladder.jade

@ -10,22 +10,47 @@ block content
input(class='uk-search-field', type='search', placeholder='Search...') input(class='uk-search-field', type='search', placeholder='Search...')
button(class='uk-close', type='reset') button(class='uk-close', type='reset')
table.uk-table.uk-table-hover.uk-table-striped table.uk-table.uk-table-hover.uk-table-striped
caption Potato Farmer Ladder Rankings
caption #{ucfirst(currency)} Farmer Ladder Rankings (<span id="total_farmers"></span> farmers total)
thead thead
tr tr
th Rank th Rank
th Viewer th Viewer
th Potatoes
th #{ucfirst(currency)}
tbody tbody
ul.uk-pagination ul.uk-pagination
block postscript block postscript
script. script.
var perPage = 20, var perPage = 20,
data = !{JSON.stringify(rows)};
data = !{JSON.stringify(rows)},
lastPage = Math.ceil(data.length/perPage);
$(document).ready(function(){
function minifyPagination() {
var current = parseInt($('li.uk-active').attr('page')),
min = Math.max(current-3, 1),
max = current+3;
$('#page_first, #page_last').remove();
$('ul.uk-pagination > li').addClass('uk-hidden');
for(var x = min; x <= max; x++) {
$('li#'+x).removeClass('uk-hidden');
}
if (min > 1)
$('li#'+min).before("<button id='page_first' class='uk-button'>&lt;&lt;</button>");
if (max < lastPage)
$('li#'+max).after("<button id='page_last' class='uk-button'>&gt;&gt;</button>");
$('#page_first').click(function(){
$('li#'+1).click();
});
$('#page_last').click(function(){
$('li#'+lastPage).click();
});
};
$(document).ready(function(){
// Live search of the ladder listings // Live search of the ladder listings
$('.uk-search-field').keyup(function() { $('.uk-search-field').keyup(function() {
var query = $(this).val(); var query = $(this).val();
@ -44,8 +69,8 @@ block postscript
}); });
// Create pagination buttons // Create pagination buttons
for(var i = 1; i <= Math.ceil(data.length/perPage); i++) {
var button = $('<li page='+i+'></li>').append('<a>'+i+'</a>');
for(var i = 1; i <= lastPage; i++) {
var button = $('<li page='+i+' id='+i+'></li>').append('<a>'+i+'</a>');
button.on('click', function(){ button.on('click', function(){
//get page //get page
var z = $(this).attr('page'); var z = $(this).attr('page');
@ -62,7 +87,7 @@ block postscript
b = perPage*z; b = perPage*z;
data.slice(a, b).forEach(function(element, index, array){ data.slice(a, b).forEach(function(element, index, array){
$('table > tbody').append($('<tr></tr>').append('<td>'+(a+index+1)+'</td><td>'+element.user+'</td><td>'+element.points+'</td>'));
$('table > tbody').append($('<tr></tr>').append('<td>'+(Number(a+index+1).toLocaleString('en'))+'</td><td>'+element.user+'</td><td>'+element.points+'</td>'));
}); });
}); });
@ -76,4 +101,13 @@ block postscript
// Show the first page when we load up // Show the first page when we load up
$('ul.uk-pagination > li').first().click(); $('ul.uk-pagination > li').first().click();
minifyPagination();
$('ul.uk-pagination > li').on('click', function(){
minifyPagination();
});
$('#total_farmers').append(Number(data.length).toLocaleString('en'));
}); });

43
web/templates/layout.jade

@ -8,19 +8,7 @@ html(lang="en")
script(src='/lib/uikit/js/uikit.min.js') script(src='/lib/uikit/js/uikit.min.js')
// Favicon stuff // Favicon stuff
link(rel='apple-touch-icon', sizes='57x57', href='/apple-touch-icon-57x57.png')
link(rel='apple-touch-icon', sizes='114x114', href='/apple-touch-icon-114x114.png')
link(rel='apple-touch-icon', sizes='72x72', href='/apple-touch-icon-72x72.png')
link(rel='apple-touch-icon', sizes='144x144', href='/apple-touch-icon-144x144.png')
link(rel='apple-touch-icon', sizes='60x60', href='/apple-touch-icon-60x60.png')
link(rel='apple-touch-icon', sizes='120x120', href='/apple-touch-icon-120x120.png')
link(rel='apple-touch-icon', sizes='76x76', href='/apple-touch-icon-76x76.png')
link(rel='apple-touch-icon', sizes='152x152', href='/apple-touch-icon-152x152.png')
link(rel='icon', type='image/png', href='/favicon-196x196.png', sizes='196x196')
link(rel='icon', type='image/png', href='/favicon-160x160.png', sizes='160x160')
link(rel='icon', type='image/png', href='/favicon-96x96.png', sizes='96x96')
link(rel='icon', type='image/png', href='/favicon-16x16.png', sizes='16x16')
link(rel='icon', type='image/png', href='/favicon-32x32.png', sizes='32x32')
link(rel='icon', type='image/png', href='/favicon.ico', sizes='32x32')
meta(name='msapplication-TileColor', content='#da532c') meta(name='msapplication-TileColor', content='#da532c')
meta(name='msapplication-TileImage', content='/mstile-144x144.png') meta(name='msapplication-TileImage', content='/mstile-144x144.png')
@ -29,12 +17,12 @@ html(lang="en")
div.uk-width-1-1 div.uk-width-1-1
div.uk-grid div.uk-grid
div.uk-width-1-4 div.uk-width-1-4
img(src='/img/#{logo}')
img(src='/img/#{logo}', style='max-height:180px;')
div.uk-width-2-4 div.uk-width-2-4
// bigimagelogo // bigimagelogo
h1.uk-text-center #{title}<br/>#{slogan} h1.uk-text-center #{title}<br/>#{slogan}
div.uk-width-1-4 div.uk-width-1-4
img.flip.uk-float-right(src='/img/#{logo}')
img.flip.uk-float-right(src='/img/#{logo}', style='max-height:180px;')
div.uk-width-1-1 div.uk-width-1-1
nav.uk-navbar nav.uk-navbar
ul.uk-navbar-nav.uk-navbar-center ul.uk-navbar-nav.uk-navbar-center
@ -43,16 +31,31 @@ html(lang="en")
li: a(href='/ladder') Ladder li: a(href='/ladder') Ladder
li: a(href='/stats') Chat Stats li: a(href='/stats') Chat Stats
li: a(href='/fanart') Fan Art li: a(href='/fanart') Fan Art
li: a(href='http://www.twitter.com/#{twitter}'): img(src='/img/twitter.gif', alt='Twitter')
li: a(href='http://www.twitter.com/#{twitter}'): img(src='/img/twitter.png', alt='Twitter')
div.uk-width-1-1 div.uk-width-1-1
div.uk-container.uk-container-center div.uk-container.uk-container-center
block content block content
div.uk-width-1-1 div.uk-width-1-1
footer.uk-text-center footer.uk-text-center
br br
span.tag Visit the potato lord @
a(href='http://www.twitch.tv/shaneomad') Shaneomad
span.tag Visit the #{ucfirst(currency)} Lord @
a(href='http://www.twitch.tv/#{title}') #{title}
br br
span.copyright Potatr (c) DotaNoobs 2014
span.copyright &nbsp;&copy; DotaNoobs & #{title}. All rights reserved.
block postscript block postscript
script.
$(document).ready(function() {
$('span.copyright').prepend(new Date().getFullYear());
});
script.
window._idl = {};
_idl.variant = "modal";
(function() {
var idl = document.createElement('script');
idl.type = 'text/javascript';
idl.async = true;
idl.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'members.internetdefenseleague.org/include/?url=' + (_idl.url || '') + '&campaign=' + (_idl.campaign || '') + '&variant=' + (_idl.variant || 'modal');
document.getElementsByTagName('body')[0].appendChild(idl);
})();

6
web/templates/stats.jade

@ -1,9 +1,6 @@
extends layout extends layout
block content block content
div.uk-grid.uk-height-1-1
br
br
iframe#stats_content.uk-width-1-1(onload="resizeStats(this)")
iframe#stats_content.uk-width-1-1(onload="resizeStats(this)")
block postscript block postscript
script. script.
@ -13,4 +10,5 @@ block postscript
function resizeStats(iframe) { function resizeStats(iframe) {
iframe.height = iframe.contentWindow.document.body.scrollHeight + "px"; iframe.height = iframe.contentWindow.document.body.scrollHeight + "px";
$('div.uk-container.uk-container-center').attr("style", "max-width: 100%!important; padding: 15px 5px;");
} }
Loading…
Cancel
Save