Brandon Cornejo
11 years ago
50 changed files with 3718 additions and 75 deletions
-
2.gitignore
-
5lib/commands.js
-
83lib/currency.js
-
15lib/initialize.js
-
2lib/irc.js
-
70lib/web.js
-
1node_modules/body-parser/.npmignore
-
3node_modules/body-parser/.travis.yml
-
10node_modules/body-parser/HISTORY.md
-
9node_modules/body-parser/Makefile
-
60node_modules/body-parser/README.md
-
100node_modules/body-parser/index.js
-
6node_modules/body-parser/node_modules/qs/.gitmodules
-
7node_modules/body-parser/node_modules/qs/.npmignore
-
58node_modules/body-parser/node_modules/qs/Readme.md
-
366node_modules/body-parser/node_modules/qs/index.js
-
38node_modules/body-parser/node_modules/qs/package.json
-
1node_modules/body-parser/node_modules/raw-body/.npmignore
-
5node_modules/body-parser/node_modules/raw-body/.travis.yml
-
14node_modules/body-parser/node_modules/raw-body/Makefile
-
96node_modules/body-parser/node_modules/raw-body/README.md
-
164node_modules/body-parser/node_modules/raw-body/index.js
-
1node_modules/body-parser/node_modules/raw-body/node_modules/bytes/.npmignore
-
20node_modules/body-parser/node_modules/raw-body/node_modules/bytes/History.md
-
7node_modules/body-parser/node_modules/raw-body/node_modules/bytes/Makefile
-
54node_modules/body-parser/node_modules/raw-body/node_modules/bytes/Readme.md
-
7node_modules/body-parser/node_modules/raw-body/node_modules/bytes/component.json
-
41node_modules/body-parser/node_modules/raw-body/node_modules/bytes/index.js
-
37node_modules/body-parser/node_modules/raw-body/node_modules/bytes/package.json
-
45node_modules/body-parser/node_modules/raw-body/package.json
-
1node_modules/body-parser/node_modules/type-is/.npmignore
-
4node_modules/body-parser/node_modules/type-is/.travis.yml
-
16node_modules/body-parser/node_modules/type-is/HISTORY.md
-
87node_modules/body-parser/node_modules/type-is/README.md
-
148node_modules/body-parser/node_modules/type-is/index.js
-
19node_modules/body-parser/node_modules/type-is/node_modules/mime/LICENSE
-
66node_modules/body-parser/node_modules/type-is/node_modules/mime/README.md
-
114node_modules/body-parser/node_modules/type-is/node_modules/mime/mime.js
-
36node_modules/body-parser/node_modules/type-is/node_modules/mime/package.json
-
84node_modules/body-parser/node_modules/type-is/node_modules/mime/test.js
-
1588node_modules/body-parser/node_modules/type-is/node_modules/mime/types/mime.types
-
77node_modules/body-parser/node_modules/type-is/node_modules/mime/types/node.types
-
37node_modules/body-parser/node_modules/type-is/package.json
-
41node_modules/body-parser/package.json
-
31web/public/help/instructions.txt
-
16web/templates/fanart.jade
-
4web/templates/index.jade
-
48web/templates/ladder.jade
-
41web/templates/layout.jade
-
6web/templates/stats.jade
@ -0,0 +1 @@ |
|||||
|
test/ |
@ -0,0 +1,3 @@ |
|||||
|
node_js: |
||||
|
- "0.10" |
||||
|
language: node_js |
@ -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 |
@ -0,0 +1,9 @@ |
|||||
|
BIN = ./node_modules/.bin/ |
||||
|
|
||||
|
test: |
||||
|
@$(BIN)mocha \
|
||||
|
--require should \
|
||||
|
--reporter spec \
|
||||
|
--bail |
||||
|
|
||||
|
.PHONY: test |
@ -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. |
@ -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; |
||||
|
} |
@ -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 |
@ -0,0 +1,7 @@ |
|||||
|
test |
||||
|
.travis.yml |
||||
|
benchmark.js |
||||
|
component.json |
||||
|
examples.js |
||||
|
History.md |
||||
|
Makefile |
@ -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 <tj@vision-media.ca> |
||||
|
|
||||
|
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. |
@ -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; |
||||
|
} |
||||
|
} |
@ -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 <tj@vision-media.ca>\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" |
||||
|
} |
@ -0,0 +1 @@ |
|||||
|
test/ |
@ -0,0 +1,5 @@ |
|||||
|
node_js: |
||||
|
- "0.8" |
||||
|
- "0.10" |
||||
|
- "0.11" |
||||
|
language: node_js |
@ -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 |
@ -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. |
@ -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 |
||||
|
} |
@ -0,0 +1 @@ |
|||||
|
test |
@ -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] |
@ -0,0 +1,7 @@ |
|||||
|
|
||||
|
test: |
||||
|
@./node_modules/.bin/mocha \
|
||||
|
--reporter spec \
|
||||
|
--require should |
||||
|
|
||||
|
.PHONY: test |
@ -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 <tj@vision-media.ca> |
||||
|
|
||||
|
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. |
@ -0,0 +1,7 @@ |
|||||
|
{ |
||||
|
"name": "bytes", |
||||
|
"description": "byte size string parser / serializer", |
||||
|
"keywords": ["bytes", "utility"], |
||||
|
"version": "0.2.1", |
||||
|
"scripts": ["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'; |
||||
|
} |
@ -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 <tj@vision-media.ca>\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" |
||||
|
} |
@ -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" |
||||
|
} |
@ -0,0 +1 @@ |
|||||
|
test.js |
@ -0,0 +1,4 @@ |
|||||
|
node_js: |
||||
|
- "0.10" |
||||
|
- "0.11" |
||||
|
language: node_js |
@ -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 |
@ -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. |
@ -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; |
||||
|
} |
@ -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. |
@ -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. |
@ -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; |
@ -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" |
||||
|
} |
@ -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
File diff suppressed because it is too large
View File
@ -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 |
@ -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" |
||||
|
} |
@ -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" |
||||
|
} |
@ -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) |
||||
|
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue