This commit is contained in:
2013-01-17 23:23:39 -05:00
parent 7b6a0df4a5
commit ae0f4470bf
26 changed files with 211 additions and 198 deletions

View File

@@ -3,7 +3,8 @@ var mongoose = require('mongoose');
var UserSchema = new mongoose.Schema({ var UserSchema = new mongoose.Schema({
username: {type: String, unique: true, required: true}, username: {type: String, unique: true, required: true},
name: String, name: String,
password: String password: String,
is_admin: {type: Boolean, 'default': false }
}); });
UserSchema.methods.recentArticles = function(callback) { UserSchema.methods.recentArticles = function(callback) {

View File

@@ -1,24 +0,0 @@
{
"frank": {
"username": "frank",
"name": "Frank Sinatra",
"bio": "Singer",
"password": "password"
},
"jobim": {
"username": "jobim",
"name": "Antonio Carlos Jobim",
"bio": "Composer",
"password": "password"
},
"fred": {
"username": "fred",
"name": "Fred Astaire",
"bio": "Dancer and Actor",
"password": "password"
}
}

16
test/node_modules/.bin/express generated vendored
View File

@@ -1 +1,15 @@
../express/bin/express #!/bin/sh
basedir=`dirname "$0"`
case `uname` in
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
esac
if [ -x "$basedir/node" ]; then
"$basedir/node" "$basedir/../express/bin/express" "$@"
ret=$?
else
node "$basedir/../express/bin/express" "$@"
ret=$?
fi
exit $ret

View File

@@ -24,13 +24,8 @@
"engines": { "engines": {
"node": "*" "node": "*"
}, },
"readme": "# buffer-crc32\n\n[![Build Status](https://secure.travis-ci.org/brianloveswords/buffer-crc32.png?branch=master)](http://travis-ci.org/brianloveswords/buffer-crc32)\n\ncrc32 that works with binary data and fancy character sets, outputs\nbuffer, signed or unsigned data and has tests.\n\nDerived from the sample CRC implementation in the PNG specification: http://www.w3.org/TR/PNG/#D-CRCAppendix\n\n# install\n```\nnpm install buffer-crc32\n```\n\n# example\n```js\nvar crc32 = require('buffer-crc32');\n// works with buffers\nvar buf = Buffer([[0x00, 0x73, 0x75, 0x70, 0x20, 0x62, 0x72, 0x6f, 0x00])\ncrc32(buf) // -> <Buffer 94 5a ab 4a>\n\n// has convenience methods for getting signed or unsigned ints\ncrc32.signed(buf) // -> -1805997238\ncrc32.unsigned(buf) // -> 2488970058\n\n// will cast to buffer if given a string, so you can\n// directly use foreign characters safely\ncrc32('自動販売機') // -> <Buffer cb 03 1a c5>\n```\n\n# tests\nThis was tested against the output of zlib's crc32 method. You can run\nthe tests with`npm test` (requires tap)\n",
"readmeFilename": "README.md",
"_id": "buffer-crc32@0.1.1", "_id": "buffer-crc32@0.1.1",
"_engineSupported": true,
"_npmVersion": "1.1.24",
"_nodeVersion": "v0.6.19",
"_defaultsLoaded": true,
"dist": {
"shasum": "738551e25072dd68d88417ad8a662650e33fe49c"
},
"_from": "buffer-crc32@0.1.1" "_from": "buffer-crc32@0.1.1"
} }

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,133 @@
[![build status](https://secure.travis-ci.org/senchalabs/connect.png)](http://travis-ci.org/senchalabs/connect)
# Connect
Connect is an extensible HTTP server framework for [node](http://nodejs.org), providing high performance "plugins" known as _middleware_.
Connect is bundled with over _20_ commonly used middleware, including
a logger, session support, cookie parser, and [more](http://senchalabs.github.com/connect). Be sure to view the 2.x [documentation](http://senchalabs.github.com/connect/).
```js
var connect = require('connect')
, http = require('http');
var app = connect()
.use(connect.favicon())
.use(connect.logger('dev'))
.use(connect.static('public'))
.use(connect.directory('public'))
.use(connect.cookieParser())
.use(connect.session({ secret: 'my secret here' }))
.use(function(req, res){
res.end('Hello from Connect!\n');
});
http.createServer(app).listen(3000);
```
## Middleware
- [csrf](http://www.senchalabs.org/connect/csrf.html)
- [basicAuth](http://www.senchalabs.org/connect/basicAuth.html)
- [bodyParser](http://www.senchalabs.org/connect/bodyParser.html)
- [json](http://www.senchalabs.org/connect/json.html)
- [multipart](http://www.senchalabs.org/connect/multipart.html)
- [urlencoded](http://www.senchalabs.org/connect/urlencoded.html)
- [cookieParser](http://www.senchalabs.org/connect/cookieParser.html)
- [directory](http://www.senchalabs.org/connect/directory.html)
- [compress](http://www.senchalabs.org/connect/compress.html)
- [errorHandler](http://www.senchalabs.org/connect/errorHandler.html)
- [favicon](http://www.senchalabs.org/connect/favicon.html)
- [limit](http://www.senchalabs.org/connect/limit.html)
- [logger](http://www.senchalabs.org/connect/logger.html)
- [methodOverride](http://www.senchalabs.org/connect/methodOverride.html)
- [query](http://www.senchalabs.org/connect/query.html)
- [responseTime](http://www.senchalabs.org/connect/responseTime.html)
- [session](http://www.senchalabs.org/connect/session.html)
- [static](http://www.senchalabs.org/connect/static.html)
- [staticCache](http://www.senchalabs.org/connect/staticCache.html)
- [vhost](http://www.senchalabs.org/connect/vhost.html)
- [subdomains](http://www.senchalabs.org/connect/subdomains.html)
- [cookieSession](http://www.senchalabs.org/connect/cookieSession.html)
## Running Tests
first:
$ npm install -d
then:
$ make test
## Authors
Below is the output from [git-summary](http://github.com/visionmedia/git-extras).
project: connect
commits: 2033
active : 301 days
files : 171
authors:
1414 Tj Holowaychuk 69.6%
298 visionmedia 14.7%
191 Tim Caswell 9.4%
51 TJ Holowaychuk 2.5%
10 Ryan Olds 0.5%
8 Astro 0.4%
5 Nathan Rajlich 0.2%
5 Jakub Nešetřil 0.2%
3 Daniel Dickison 0.1%
3 David Rio Deiros 0.1%
3 Alexander Simmerl 0.1%
3 Andreas Lind Petersen 0.1%
2 Aaron Heckmann 0.1%
2 Jacques Crocker 0.1%
2 Fabian Jakobs 0.1%
2 Brian J Brennan 0.1%
2 Adam Malcontenti-Wilson 0.1%
2 Glen Mailer 0.1%
2 James Campos 0.1%
1 Trent Mick 0.0%
1 Troy Kruthoff 0.0%
1 Wei Zhu 0.0%
1 comerc 0.0%
1 darobin 0.0%
1 nateps 0.0%
1 Marco Sanson 0.0%
1 Arthur Taylor 0.0%
1 Aseem Kishore 0.0%
1 Bart Teeuwisse 0.0%
1 Cameron Howey 0.0%
1 Chad Weider 0.0%
1 Craig Barnes 0.0%
1 Eran Hammer-Lahav 0.0%
1 Gregory McWhirter 0.0%
1 Guillermo Rauch 0.0%
1 Jae Kwon 0.0%
1 Jakub Nesetril 0.0%
1 Joshua Peek 0.0%
1 Jxck 0.0%
1 AJ ONeal 0.0%
1 Michael Hemesath 0.0%
1 Morten Siebuhr 0.0%
1 Samori Gorse 0.0%
1 Tom Jensen 0.0%
## Node Compatibility
Connect `< 1.x` is compatible with node 0.2.x
Connect `1.x` is compatible with node 0.4.x
Connect (_master_) `2.x` is compatible with node 0.6.x
## CLA
[http://sencha.com/cla](http://sencha.com/cla)
## License
View the [LICENSE](https://github.com/senchalabs/connect/blob/master/LICENSE) file. The [Silk](http://www.famfamfam.com/lab/icons/silk/) icons used by the `directory` middleware created by/copyright of [FAMFAMFAM](http://www.famfamfam.com/).

View File

@@ -18,17 +18,8 @@
"bytes": "index.js" "bytes": "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```\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",
"_id": "bytes@0.1.0", "_id": "bytes@0.1.0",
"optionalDependencies": {},
"engines": {
"node": "*"
},
"_engineSupported": true,
"_npmVersion": "1.1.24",
"_nodeVersion": "v0.6.19",
"_defaultsLoaded": true,
"dist": {
"shasum": "a7f244fc349683cf2ce682400be5563dd9bc162c"
},
"_from": "bytes@0.1.0" "_from": "bytes@0.1.0"
} }

File diff suppressed because one or more lines are too long

View File

@@ -13,17 +13,8 @@
"should": "*" "should": "*"
}, },
"main": "index", "main": "index",
"readme": "\n# pause\n\n Pause streams...\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.",
"readmeFilename": "Readme.md",
"_id": "pause@0.0.1", "_id": "pause@0.0.1",
"optionalDependencies": {},
"engines": {
"node": "*"
},
"_engineSupported": true,
"_npmVersion": "1.1.24",
"_nodeVersion": "v0.6.19",
"_defaultsLoaded": true,
"dist": {
"shasum": "9883a36b7474d646efc3bba8efe699127fb5b19a"
},
"_from": "pause@0.0.1" "_from": "pause@0.0.1"
} }

View File

@@ -29,15 +29,8 @@
"engines": { "engines": {
"node": "*" "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",
"_id": "qs@0.5.1", "_id": "qs@0.5.1",
"dependencies": {},
"optionalDependencies": {},
"_engineSupported": true,
"_npmVersion": "1.1.24",
"_nodeVersion": "v0.6.19",
"_defaultsLoaded": true,
"dist": {
"shasum": "85f42958ebbf8efbc79fd5b95f81ed92f5f4e87c"
},
"_from": "qs@0.5.1" "_from": "qs@0.5.1"
} }

File diff suppressed because one or more lines are too long

View File

@@ -17,17 +17,8 @@
"should": "*" "should": "*"
}, },
"main": "index", "main": "index",
"readme": "\n# cookie-signature\n\n Sign and unsign cookies.\n\n## Example\n\n```js\nvar cookie = require('cookie-signature');\n\nvar val = cookie.sign('hello', 'tobiiscool');\nval.should.equal('hello.DGDUkGlIkCzPz+C0B064FNgHdEjox7ch8tOBGslZ5QI');\n\nvar val = cookie.sign('hello', 'tobiiscool');\ncookie.unsign(val, 'tobiiscool').should.equal('hello');\ncookie.unsign(val, 'luna').should.be.false;\n```\n\n## License \n\n(The MIT License)\n\nCopyright (c) 2012 LearnBoost &lt;tj@learnboost.com&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",
"_id": "cookie-signature@0.0.1", "_id": "cookie-signature@0.0.1",
"optionalDependencies": {},
"engines": {
"node": "*"
},
"_engineSupported": true,
"_npmVersion": "1.1.24",
"_nodeVersion": "v0.6.19",
"_defaultsLoaded": true,
"dist": {
"shasum": "6ede2af6c9451bfff73725d4068120542cce7a70"
},
"_from": "cookie-signature@0.0.1" "_from": "cookie-signature@0.0.1"
} }

View File

@@ -26,13 +26,8 @@
"engines": { "engines": {
"node": "*" "node": "*"
}, },
"readme": "# cookie [![Build Status](https://secure.travis-ci.org/shtylman/node-cookie.png?branch=master)](http://travis-ci.org/shtylman/node-cookie) #\n\ncookie is a basic cookie parser and serializer. It doesn't make assumptions about how you are going to deal with your cookies. It basically just provides a way to read and write the HTTP cookie headers.\n\nSee [RFC6265](http://tools.ietf.org/html/rfc6265) for details about the http header for cookies.\n\n## how?\n\n```\nnpm install cookie\n```\n\n```javascript\nvar cookie = require('cookie');\n\nvar hdr = cookie.serialize('foo', 'bar');\n// hdr = 'foo=bar';\n\nvar cookies = cookie.parse('foo=bar; cat=meow; dog=ruff');\n// cookies = { foo: 'bar', cat: 'meow', dog: 'ruff' };\n```\n\n## more\n\nThe serialize function takes a third parameter, an object, to set cookie options. See the RFC for valid values.\n\n### path\n> cookie path\n\n### expires\n> absolute expiration date for the cookie (Date object)\n\n### maxAge\n> relative max age of the cookie from when the client receives it (seconds)\n\n### domain\n> domain for the cookie\n\n### secure\n> true or false\n\n### httpOnly\n> true or false\n\n",
"readmeFilename": "README.md",
"_id": "cookie@0.0.5", "_id": "cookie@0.0.5",
"_engineSupported": true,
"_npmVersion": "1.1.24",
"_nodeVersion": "v0.6.19",
"_defaultsLoaded": true,
"dist": {
"shasum": "45afe11669da9cbf57f8e6d54bac8f0659044ae8"
},
"_from": "cookie@0.0.5" "_from": "cookie@0.0.5"
} }

File diff suppressed because one or more lines are too long

View File

@@ -13,17 +13,8 @@
"mocha": "*", "mocha": "*",
"should": "*" "should": "*"
}, },
"readme": "\n# node-fresh\n\n HTTP response freshness testing\n\n## fresh(req, res)\n\n Check freshness of `req` and `res` headers.\n\n When the cache is \"fresh\" __true__ is returned,\n otherwise __false__ is returned to indicate that\n the cache is now stale.\n\n## Example:\n\n```js\nvar req = { 'if-none-match': 'tobi' };\nvar res = { 'etag': 'luna' };\nfresh(req, res);\n// => false\n\nvar req = { 'if-none-match': 'tobi' };\nvar res = { 'etag': 'tobi' };\nfresh(req, res);\n// => true\n```\n\n## Installation\n\n```\n$ npm install fresh\n```",
"readmeFilename": "Readme.md",
"_id": "fresh@0.1.0", "_id": "fresh@0.1.0",
"optionalDependencies": {},
"engines": {
"node": "*"
},
"_engineSupported": true,
"_npmVersion": "1.1.24",
"_nodeVersion": "v0.6.19",
"_defaultsLoaded": true,
"dist": {
"shasum": "8c68a2ec327d90335bea56a4e4ac112c0cf78da8"
},
"_from": "fresh@0.1.0" "_from": "fresh@0.1.0"
} }

View File

@@ -15,18 +15,6 @@
}, },
"license": "MIT", "license": "MIT",
"_id": "methods@0.0.1", "_id": "methods@0.0.1",
"dependencies": {}, "readme": "ERROR: No README.md file found!",
"devDependencies": {},
"optionalDependencies": {},
"engines": {
"node": "*"
},
"_engineSupported": true,
"_npmVersion": "1.1.24",
"_nodeVersion": "v0.6.19",
"_defaultsLoaded": true,
"dist": {
"shasum": "811cd44be7674b3ca486e51b96dccf1cc5f43594"
},
"_from": "methods@0.0.1" "_from": "methods@0.0.1"
} }

View File

@@ -14,7 +14,7 @@
], ],
"repository": { "repository": {
"type": "git", "type": "git",
"url": "git://github.com/substack/node-mkdirp.git" "url": "http://github.com/substack/node-mkdirp.git"
}, },
"scripts": { "scripts": {
"test": "tap test/*.js" "test": "tap test/*.js"
@@ -26,15 +26,8 @@
"engines": { "engines": {
"node": "*" "node": "*"
}, },
"readme": "mkdirp\n======\n\nLike `mkdir -p`, but in node.js!\n\n[![build status](https://secure.travis-ci.org/substack/node-mkdirp.png)](http://travis-ci.org/substack/node-mkdirp)\n\nexample\n=======\n\npow.js\n------\n var mkdirp = require('mkdirp');\n \n mkdirp('/tmp/foo/bar/baz', function (err) {\n if (err) console.error(err)\n else console.log('pow!')\n });\n\nOutput\n pow!\n\nAnd now /tmp/foo/bar/baz exists, huzzah!\n\nmethods\n=======\n\nvar mkdirp = require('mkdirp');\n\nmkdirp(dir, mode, cb)\n---------------------\n\nCreate a new directory and any necessary subdirectories at `dir` with octal\npermission string `mode`.\n\nIf `mode` isn't specified, it defaults to `0777 & (~process.umask())`.\n\n`cb(err, made)` fires with the error or the first directory `made`\nthat had to be created, if any.\n\nmkdirp.sync(dir, mode)\n----------------------\n\nSynchronously create a new directory and any necessary subdirectories at `dir`\nwith octal permission string `mode`.\n\nIf `mode` isn't specified, it defaults to `0777 & (~process.umask())`.\n\nReturns the first directory that had to be created, if any.\n\ninstall\n=======\n\nWith [npm](http://npmjs.org) do:\n\n npm install mkdirp\n\nlicense\n=======\n\nMIT/X11\n",
"readmeFilename": "README.markdown",
"_id": "mkdirp@0.3.3", "_id": "mkdirp@0.3.3",
"dependencies": {},
"optionalDependencies": {},
"_engineSupported": true,
"_npmVersion": "1.1.24",
"_nodeVersion": "v0.6.19",
"_defaultsLoaded": true,
"dist": {
"shasum": "d2e80b2d8ee40fc80ab21d41ab46f895072e7c0b"
},
"_from": "mkdirp@0.3.3" "_from": "mkdirp@0.3.3"
} }

View File

@@ -13,17 +13,8 @@
"mocha": "*", "mocha": "*",
"should": "*" "should": "*"
}, },
"readme": "\n# node-range-parser\n\n Range header field parser.\n\n## Example:\n\n```js\nassert(-1 == parse(200, 'bytes=500-20'));\nassert(-2 == parse(200, 'bytes=malformed'));\nparse(200, 'bytes=0-499').should.eql(arr('bytes', [{ start: 0, end: 199 }]));\nparse(1000, 'bytes=0-499').should.eql(arr('bytes', [{ start: 0, end: 499 }]));\nparse(1000, 'bytes=40-80').should.eql(arr('bytes', [{ start: 40, end: 80 }]));\nparse(1000, 'bytes=-500').should.eql(arr('bytes', [{ start: 500, end: 999 }]));\nparse(1000, 'bytes=-400').should.eql(arr('bytes', [{ start: 600, end: 999 }]));\nparse(1000, 'bytes=500-').should.eql(arr('bytes', [{ start: 500, end: 999 }]));\nparse(1000, 'bytes=400-').should.eql(arr('bytes', [{ start: 400, end: 999 }]));\nparse(1000, 'bytes=0-0').should.eql(arr('bytes', [{ start: 0, end: 0 }]));\nparse(1000, 'bytes=-1').should.eql(arr('bytes', [{ start: 999, end: 999 }]));\nparse(1000, 'items=0-5').should.eql(arr('items', [{ start: 0, end: 5 }]));\nparse(1000, 'bytes=40-80,-1').should.eql(arr('bytes', [{ start: 40, end: 80 }, { start: 999, end: 999 }]));\n```\n\n## Installation\n\n```\n$ npm install range-parser\n```",
"readmeFilename": "Readme.md",
"_id": "range-parser@0.0.4", "_id": "range-parser@0.0.4",
"optionalDependencies": {},
"engines": {
"node": "*"
},
"_engineSupported": true,
"_npmVersion": "1.1.24",
"_nodeVersion": "v0.6.19",
"_defaultsLoaded": true,
"dist": {
"shasum": "b960842dda491358479bdf39bf6c158d7097405c"
},
"_from": "range-parser@0.0.4" "_from": "range-parser@0.0.4"
} }

View File

@@ -21,21 +21,12 @@
"main": "mime.js", "main": "mime.js",
"name": "mime", "name": "mime",
"repository": { "repository": {
"url": "git://github.com/broofa/node-mime.git", "url": "https://github.com/broofa/node-mime",
"type": "git" "type": "git"
}, },
"version": "1.2.6", "version": "1.2.6",
"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. 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.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/bentomas/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",
"_id": "mime@1.2.6", "_id": "mime@1.2.6",
"optionalDependencies": {},
"engines": {
"node": "*"
},
"_engineSupported": true,
"_npmVersion": "1.1.24",
"_nodeVersion": "v0.6.19",
"_defaultsLoaded": true,
"dist": {
"shasum": "41af4b8b35c1f3d484d4095579305e1b4bf2fd23"
},
"_from": "mime@1.2.6" "_from": "mime@1.2.6"
} }

View File

@@ -27,17 +27,8 @@
"test": "make test" "test": "make test"
}, },
"main": "index", "main": "index",
"readme": "\n# send\n\n Send is Connect's `static()` extracted for generalized use, a streaming static file\n server supporting partial responses (Ranges), conditional-GET negotiation, high test coverage, and granular events which may be leveraged to take appropriate actions in your application or framework.\n\n## Installation\n\n $ npm install send\n\n## Examples\n\n Small:\n\n```js\nvar http = require('http');\nvar send = require('send');\n\nvar app = http.createServer(function(req, res){\n send(req, req.url).pipe(res);\n});\n```\n\n Serving from a root directory with custom error-handling:\n\n```js\nvar http = require('http');\nvar send = require('send');\n\nvar app = http.createServer(function(req, res){\n // your custom error-handling logic:\n function error(err) {\n res.statusCode = err.status || 500;\n res.end(err.message);\n }\n\n // your custom directory handling logic:\n function redirect() {\n res.statusCode = 301;\n res.setHeader('Location', req.url + '/');\n res.end('Redirecting to ' + req.url + '/');\n }\n\n // transfer arbitrary files from within\n // /www/example.com/public/*\n send(req, url.parse(req.url).pathname)\n .root('/www/example.com/public')\n .on('error', error)\n .on('directory', redirect)\n .pipe(res);\n});\n```\n\n## API\n\n### Events\n\n - `error` an error occurred `(err)`\n - `directory` a directory was requested\n - `stream` file streaming has started `(stream)`\n - `end` streaming has completed\n\n### .root(dir)\n\n Serve files relative to `path`. Aliased as `.from(dir)`.\n\n### .index(path)\n\n By default send supports \"index.html\" files, to disable this\n invoke `.index(false)` or to supply a new index pass a string.\n\n### .maxage(ms)\n\n Provide a max-age in milliseconds for http caching, defaults to 0.\n\n## Error-handling\n\n By default when no `error` listeners are present an automatic response will be made, otherwise you have full control over the response, aka you may show a 5xx page etc.\n\n## Caching\n\n It does _not_ perform internal caching, you should use a reverse proxy cache such\n as Varnish for this, or those fancy things called CDNs. If your application is small enough that it would benefit from single-node memory caching, it's small enough that it does not need caching at all ;).\n\n## Debugging\n\n To enable `debug()` instrumentation output export __DEBUG__:\n\n```\n$ DEBUG=send node app\n```\n\n## Running tests\n\n```\n$ npm install\n$ make test\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.",
"readmeFilename": "Readme.md",
"_id": "send@0.1.0", "_id": "send@0.1.0",
"optionalDependencies": {},
"engines": {
"node": "*"
},
"_engineSupported": true,
"_npmVersion": "1.1.24",
"_nodeVersion": "v0.6.19",
"_defaultsLoaded": true,
"dist": {
"shasum": "0ef45803cf185ddc25d2fb3134380ff411f6a7bb"
},
"_from": "send@0.1.0" "_from": "send@0.1.0"
} }

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,9 @@
function isAdmin(req, res, next) {
if (req.session.user.is_admin === false) {
res.redirect('/users/' + req.session.user.username);
} else {
next();
}
}
module.exports = isAdmin;

View File

@@ -6,12 +6,13 @@ var User = require('../data/models/user');
var notLoggedIn = require('./middleware/not_logged_in'); var notLoggedIn = require('./middleware/not_logged_in');
var loggedIn = require('./middleware/logged_in'); var loggedIn = require('./middleware/logged_in');
var loadUser = require('./middleware/load_user'); var loadUser = require('./middleware/load_user');
var isAdmin = require('./middleware/is_admin');
var restrictUserToSelf = require('./middleware/restrict_user_to_self'); var restrictUserToSelf = require('./middleware/restrict_user_to_self');
var maxUsersPerPage = 5; var maxUsersPerPage = 5;
module.exports = function(app) { module.exports = function(app) {
app.get('/users', loggedIn, function(req, res, next){ app.get('/users', loggedIn, isAdmin, function(req, res, next){
var page = req.query.page && parseInt(req.query.page, 10) || 0; var page = req.query.page && parseInt(req.query.page, 10) || 0;
User.count(function(err, count) { User.count(function(err, count) {
@@ -38,7 +39,7 @@ module.exports = function(app) {
}); });
}); });
app.get('/users/new', notLoggedIn, function(req, res) { app.get('/users/new', notLoggedIn, function(req, res) {
res.render('users/new', {title: "New User"}); res.render('users/new', {title: "New User"});
}); });
@@ -56,7 +57,6 @@ module.exports = function(app) {
}); });
app.post('/users', notLoggedIn, function(req, res, next) { app.post('/users', notLoggedIn, function(req, res, next) {
console.log("/nreq.body" + req.body);
console.log("/nreq.body" + JSON.stringify(req.body)); console.log("/nreq.body" + JSON.stringify(req.body));
User.create(req.body, function(err) { User.create(req.body, function(err) {
if (err) { if (err) {

View File

@@ -13,6 +13,7 @@ block content
p p
a(href="/articles") List Articles a(href="/articles") List Articles
ul ul
- users.forEach(function(user) { - users.forEach(function(user) {
li li

View File

@@ -12,5 +12,8 @@ block content
p p
label(for="password") Password<br /> label(for="password") Password<br />
input#password(type="password", name="password") input#password(type="password", name="password")
p
label(for="is_admin") Admin<br />
input#isadmin(type="checkbox", name="is_admin", unchecked)
p p
input(type="submit", value="Create") input(type="submit", value="Create")

View File

@@ -2,7 +2,7 @@ extends ../layout
block content block content
h1= user.name h1= user.name
- if (session.user) - if (session.user.)
h1 Private View h1 Private View
- else - else
h1 Public View h1 Public View
@@ -14,9 +14,9 @@ block content
a(href="/articles/" + encodeURIComponent(article._id))= article.title a(href="/articles/" + encodeURIComponent(article._id))= article.title
- }); - });
- if (session.user.is_admin = 'true')
form(action="/users/" + encodeURIComponent(user.username), method="POST")
input(name="_method", type="hidden", value="DELETE")
input(type="submit", value="Delete")
form(action="/users/" + encodeURIComponent(user.username), method="POST") a(href="/users/") Back to Userlist
input(name="_method", type="hidden", value="DELETE")
input(type="submit", value="Delete")
a(href="/users/") Back to Userlist