{"_id":"nodetoo","_rev":"35-cc9e67fd658c75736ea1229f4b3022c2","name":"nodetoo","description":"Express + MVC = {nodetoo}","dist-tags":{"latest":"1.0.7"},"versions":{"1.0.0":{"name":"nodetoo","description":"Express + MVC = {nodetoo}","version":"1.0.0","author":{"name":"fliptoo","email":"fliptoo.studio@gmail.com"},"main":"./index","bin":{"nodetoo":"./bin/nodetoo"},"dependencies":{"underscore":"*","commander":"*","mkdirp":"*"},"devDependencies":{"jade":"*"},"keywords":["express","framework","mvc","web","rest","restful","router","app","api"],"repository":{"type":"git","url":"git://github.com/fliptoo/nodetoo"},"readme":"{nodetoo}\n=========\nInspired by [Express mvc example](https://github.com/visionmedia/express/tree/master/examples/mvc), nodetoo is a MVC framework built on top of [Express](expressjs.com).\n\n## Installation\n\n    $ npm install -g nodetoo\n\n## Quick Start\n\nAssuming you have created a `project` with Express, please refer [here](http://expressjs.com/guide.html) for the guide.  \n\n- Create the `app/`\n\n```\n$ cd /project\n$ npm install nodetoo\n$ nodetoo\n``` \n\n- Bootstrap nodetoo:\n\n```js\nvar express = require('express');\nvar nodetoo = require('nodetoo');\nvar app = express();\n\n// bootstrap nodetoo\nnodetoo(app, __dirname + '/app');\n\napp.listen(3000);\n```\n\n- Start the server:\n\n```\n$ node app\n```\n\n## Project Structure\n\nnodetoo only work on the `app/` folder\n\n```\napp/\n  controllers/\n    home/\n      index.js\n  models/\n      user.js\n  views/\n    home/\n      index.jade\n  routes.js\n```\n\n## Models\n\nEach js file under `models/` is a model, nodetoo will bootstrap all of them automatically. \n\n```\nmodels/\n  user.js\n  post.js\n  comment.js\n```\n\n## Controllers\n\nEach folder under `controllers/` is a controller, `index.js` represent the js file.  \nLet's take a look at the `controllers/home/index.js` file.\n\n```js\nexports.index = function(req, res) {\n  var user = req.session.user;\n  res.render('home/index', {user: user});\n};\n\nexports.about = function(req, res) {\n  res.render('home/about');\n};\n```\n\n## Actions\n\nAction is a controller method and represent as `[controller].[method]`.\n\n```\nhome.index\nhome.about\n```\n\n## Routes\n\nRoutes are defined in the `app/route.js` file\n\n```js\nmodule.exports = [\n// public routes  \n  { routes : [\n        ['/'                        ,'get'  ,'home.index']\n      , ['/login'                   ,'all'  ,'user.login']\n      , ['/logout'                  ,'get'  ,'user.logout']\n  ]}\n\n// user with any roles\n, { roles  : ['*'],\n    routes : [\n        ['/anyone'                  ,'get'  ,'anyone.index']\n  ]}\n\n// user with admin role only\n, { roles  : ['admin'],\n    routes : [\n        ['/admin'                    ,'get' ,'admin.index']\n  ]}\n]\n```\n\n## Authentication\n\nnodetoo take a 3rd argument as the authentication middleware (authenticator).\n\n```js\nvar auth = function(roles) {\n  return function (req, res, next) {\n    // retrieve user from session\n    var user = req.session.user;\n    if (user === undefined) {\n      res.status(401).render('401');\n    } \n    // asterisk skip authorization\n    else if (!_.contains(roles, '*') \n          && !_.intersection(user.roles, roles).length > 0) {\n      res.status(401).render('401');\n    } else next();\n  }\n}\n\nnodetoo(app, __dirname + '/app', auth);\n```\nBut how you write the authenticator, it is really up to you.\n\n## Examples\n\nClone the nodetoo repo, then install the dev dependencies:\n\n    $ git clone git://github.com/fliptoo/nodetoo.git --depth 1\n    $ cd nodetoo\n    $ npm install\n\nand run whichever examples you want:\n\n    $ node examples/basic\n\n## License\n\n(The MIT License)\n\nCopyright (c) 2013 Fliptoo &lt;fliptoo.studio@gmail.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.\n","readmeFilename":"README.md","_id":"nodetoo@1.0.0","dist":{"shasum":"3ab48e54286736172ec6ba28674b1bd6c599f5a4","tarball":"https://registry.npmjs.org/nodetoo/-/nodetoo-1.0.0.tgz","integrity":"sha512-ADSCIZ11ZTYUjlIzgIMidpO3sLV5diyWNZWH2b3dfoFYDel7SqYCILGwMYfd4r0bBaqA9gbBqpSeBjZl9ALGmQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCvijs+N5CIjm6J8zSlmwbWNkBZlgLk652rOedeWH2LhQIgEKVrPaif9NbmBvV+mvafwYSNpZy/YRy4l/Y10rtEpAM="}]},"_npmVersion":"1.1.66","_npmUser":{"name":"fliptoo","email":"fliptoo.studio@gmail.com"},"maintainers":[{"name":"fliptoo","email":"fliptoo.studio@gmail.com"}],"directories":{}},"1.0.1":{"name":"nodetoo","description":"Express + MVC = {nodetoo}","version":"1.0.1","author":{"name":"fliptoo","email":"fliptoo.studio@gmail.com"},"main":"./index","bin":{"nodetoo":"./bin/nodetoo"},"dependencies":{"commander":"*","mkdirp":"*","underscore":"*","sprintf":"*"},"devDependencies":{"express":"*","jade":"*"},"keywords":["express","framework","mvc","web","rest","restful","router","app","api"],"repository":{"type":"git","url":"git://github.com/fliptoo/nodetoo"},"readme":"{nodetoo}\n=========\nInspired by [Express mvc example](https://github.com/visionmedia/express/tree/master/examples/mvc), nodetoo is a MVC framework built on top of [Express](expressjs.com).\n\n## Installation\n\n    $ npm install -g nodetoo\n\n## Quick Start\n\nAssuming you have created a `project` with Express, please refer [here](http://expressjs.com/guide.html) for the guide.  \n\n- Create the app\n\n```\n$ cd /project\n$ npm install nodetoo\n$ nodetoo\n``` \n\n- Bootstrap nodetoo:\n\n```js\nvar express = require('express');\nvar nodetoo = require('nodetoo');\nvar app = express();\n\napp.configure(function(){\n  ...\n  \n  // boostrap nodetoo\n  require('../../')(app, __dirname + '/app');\n  \n  app.use(app.router);\n  ...\n});\n\napp.listen(3000);\n```\n\n- Start the server:\n\n```\n$ node app\n```\n\n## Project Structure\n\nnodetoo only work on the `app/` and `config/` folder\n\n```\napp/\n  controllers/\n    home/\n      index.js\n  models/\n      user.js\n  views/\n    home/\n      index.jade\nconfig/\n    routes.js\n    setting.js\n```\n\n## Models\n\nEach js file under `models/` is a model, nodetoo will bootstrap all of them automatically. \n\n```\nmodels/\n  user.js\n  post.js\n  comment.js\n```\n\n## Controllers\n\nEach folder under `controllers/` is a controller, `index.js` represent the js file.  \nLet's take a look at the `controllers/home/index.js` file.\n\n```js\nexports.index = function(req, res) {\n  var user = req.session.user;\n  res.render('home/index', {user: user});\n};\n\nexports.about = function(req, res) {\n  res.render('home/about');\n};\n```\n\n## Actions\n\nAction is a controller method and represent as `[controller].[method]`.\n\n```\nhome.index\nhome.about\n```\n\n## Routes\n\nRoutes are defined in the `app/route.js` file\n\n```js\nmodule.exports = [\n// public routes  \n  { routes : [\n        ['/'                        ,'get'  ,'home.index']\n      , ['/login'                   ,'all'  ,'user.login']\n      , ['/logout'                  ,'get'  ,'user.logout']\n  ]}\n\n// user with any roles\n, { roles  : ['*'],\n    routes : [\n        ['/anyone'                  ,'get'  ,'anyone.index']\n  ]}\n\n// user with admin role only\n, { roles  : ['admin'],\n    routes : [\n        ['/admin'                    ,'get' ,'admin.index']\n  ]}\n]\n```\n\n## Authentication\n\nnodetoo take a 3rd argument as the authentication middleware (authenticator).\n\n```js\nvar auth = function(roles) {\n  return function (req, res, next) {\n    // retrieve user from session\n    var user = req.session.user;\n    if (user === undefined) {\n      res.status(401).render('401');\n    } \n    // asterisk skip authorization\n    else if (!_.contains(roles, '*') \n          && !_.intersection(user.roles, roles).length > 0) {\n      res.status(401).render('401');\n    } else next();\n  }\n}\n\nnodetoo(app, __dirname + '/app', auth);\n```\nBut how you write the authenticator, it is really up to you.\n\n## Examples\n\nClone the nodetoo repo, then install the dev dependencies:\n\n    $ git clone git://github.com/fliptoo/nodetoo.git --depth 1\n    $ cd nodetoo\n    $ npm install\n\nand run whichever examples you want:\n\n    $ cd examples/basic\n    $ node app\n\n## License\n\n(The MIT License)\n\nCopyright (c) 2013 Fliptoo &lt;fliptoo.studio@gmail.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.\n","readmeFilename":"README.md","_id":"nodetoo@1.0.1","dist":{"shasum":"7a4c2cd55c698da5032916e61c1d60ef73bda098","tarball":"https://registry.npmjs.org/nodetoo/-/nodetoo-1.0.1.tgz","integrity":"sha512-PXoc7sp7zQAwu9qGXLvMuaBpiIEYBQnV0JMmFjd5mSnRPKA0CU7B/tyHpPH3ktTj+HrsJMO8SJ6gx4ACH1p+Dw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIHysFrCBE5VwD+yYje+bDvazIVeCFApHAecsTZVnzZ1CAiAgiWcrv5jODKlFPNuNKsTCejoXIYv/36XuhrwgVZVGpA=="}]},"_npmVersion":"1.1.66","_npmUser":{"name":"fliptoo","email":"fliptoo.studio@gmail.com"},"maintainers":[{"name":"fliptoo","email":"fliptoo.studio@gmail.com"}],"directories":{}},"1.0.2":{"name":"nodetoo","description":"Express + MVC = {nodetoo}","version":"1.0.2","author":{"name":"fliptoo","email":"fliptoo.studio@gmail.com"},"main":"./index","bin":{"nodetoo":"./bin/nodetoo"},"dependencies":{"commander":"*","mkdirp":"*","xtend":"*","underscore":"*","sprintf":"*","express":"*"},"devDependencies":{"jade":"*"},"keywords":["express","framework","mvc","web","rest","restful","router","app","api"],"repository":{"type":"git","url":"git://github.com/fliptoo/nodetoo"},"readme":"{nodetoo}\n=========\nInspired by [Express mvc example](https://github.com/visionmedia/express/tree/master/examples/mvc), nodetoo is a MVC framework built on top of [Express](expressjs.com).\n\n## Installation\n\n    $ npm install -g nodetoo\n\n## Quick Start\n\nAssuming you have created a `project` with Express, please refer [here](http://expressjs.com/guide.html) for the guide.  \n\n- Create the app\n\n```\n$ cd /project\n$ npm install nodetoo\n$ nodetoo\n``` \n\n- Bootstrap nodetoo:\n\n```js\nvar express = require('express');\nvar nodetoo = require('nodetoo');\nvar app = express();\n\napp.configure(function(){\n  ...\n  \n  // boostrap nodetoo\n  require('../../')(app);\n  \n  app.use(app.router);\n  ...\n});\n\napp.listen(3000);\n```\n\n- Start the server:\n\n```\n$ node app\n```\n\n## Project Structure\n\nnodetoo only work on the `app/` and `config/` folder\n\n```\napp/\n  controllers/\n    home/\n      index.js\n  models/\n      user.js\n  views/\n    home/\n      index.jade\nconfig/\n    routes.js\n    setting.js\n```\n\n## Models\n\nEach js file under `models/` is a model, nodetoo will bootstrap all of them automatically. \n\n```\nmodels/\n  user.js\n  post.js\n  comment.js\n```\n\n## Controllers\n\nEach folder under `controllers/` is a controller, `index.js` represent the js file.  \nLet's take a look at the `controllers/home/index.js` file.\n\n```js\nexports.index = function(req, res) {\n  var user = req.session.user;\n  res.render('home/index', {user: user});\n};\n\nexports.about = function(req, res) {\n  res.render('home/about');\n};\n```\n\n## Actions\n\nAction is a controller method and represent as `[controller].[method]`.\n\n```\nhome.index\nhome.about\n```\n\n## Routes\n\nRoutes are defined in the `app/route.js` file\n\n```js\nmodule.exports = [\n// public routes  \n  { routes : [\n        ['/'                        ,'get'  ,'home.index']\n      , ['/login'                   ,'all'  ,'user.login']\n      , ['/logout'                  ,'get'  ,'user.logout']\n  ]}\n\n// user with any roles\n, { roles  : ['*'],\n    routes : [\n        ['/anyone'                  ,'get'  ,'anyone.index']\n  ]}\n\n// user with admin role only\n, { roles  : ['admin'],\n    routes : [\n        ['/admin'                    ,'get' ,'admin.index']\n  ]}\n]\n```\n\n## Authentication\n\nnodetoo take a 2nd argument as the authentication middleware (authenticator).\n\n```js\nvar auth = function(roles) {\n  return function (req, res, next) {\n    // retrieve user from session\n    var user = req.session.user;\n    if (user === undefined) {\n      res.status(401).render('401');\n    } \n    // asterisk skip authorization\n    else if (!_.contains(roles, '*') \n          && !_.intersection(user.roles, roles).length > 0) {\n      res.status(401).render('401');\n    } else next();\n  }\n}\n\nnodetoo(app, __dirname + '/app', auth);\n```\nBut how you write the authenticator, it is really up to you.\n\n## Examples\n\nClone the nodetoo repo, then install the dev dependencies:\n\n    $ git clone git://github.com/fliptoo/nodetoo.git --depth 1\n    $ cd nodetoo\n    $ npm install\n\nand run whichever examples you want:\n\n    $ cd examples/basic\n    $ node app\n    \n# Credits\n\n- [Express](https://github.com/visionmedia/express)\n- [i18n-node](https://github.com/mashpie/i18n-node/)\n\n## License\n\n(The MIT License)\n\nCopyright (c) 2013 Fliptoo &lt;fliptoo.studio@gmail.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.\n","readmeFilename":"README.md","_id":"nodetoo@1.0.2","dist":{"shasum":"d1f0d48699b3823c4fa02a5b1f507485f2bb294b","tarball":"https://registry.npmjs.org/nodetoo/-/nodetoo-1.0.2.tgz","integrity":"sha512-djFY59njx9srt3hLrrNvCWJFwVNk672Nu4IJNkj6SCvufbhZyqYBUXQDZeOcsq/peTCwb7QA0zjNfmFxxjV0Xw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDEFTldkY1zVal/8mfganvgMn93I2yf76oQiXuEuPhDOgIhAK8r/4SU9paUcXf/kx3X1QUv/3yrdA8fEq0GAk5P2SzW"}]},"_npmVersion":"1.1.66","_npmUser":{"name":"fliptoo","email":"fliptoo.studio@gmail.com"},"maintainers":[{"name":"fliptoo","email":"fliptoo.studio@gmail.com"}],"directories":{}},"1.0.3":{"name":"nodetoo","description":"Express + MVC = {nodetoo}","version":"1.0.3","author":{"name":"fliptoo","email":"fliptoo.studio@gmail.com"},"main":"./index","bin":{"nodetoo":"./bin/nodetoo"},"dependencies":{"commander":"*","mkdirp":"*","xtend":"*","underscore":"*","sprintf":"*"},"devDependencies":{"express":"*","jade":"*"},"keywords":["express","framework","mvc","web","rest","restful","router","app","api"],"repository":{"type":"git","url":"git://github.com/fliptoo/nodetoo"},"readme":"{nodetoo}\n=========\nInspired by [Express mvc example](https://github.com/visionmedia/express/tree/master/examples/mvc), nodetoo is a MVC framework built on top of [Express](expressjs.com).\n\n## Installation\n\n    $ npm install -g nodetoo\n\n## Quick Start\n\nAssuming you have created a `project` with Express, please refer [here](http://expressjs.com/guide.html) for the guide.  \n\n- Create the app\n\n```\n$ cd /project\n$ npm install nodetoo\n$ nodetoo\n``` \n\n- Bootstrap nodetoo:\n\n```js\nvar express = require('express');\nvar nodetoo = require('nodetoo');\nvar app = express();\n\napp.configure(function(){\n  ...\n  \n  // boostrap nodetoo\n  nodetoo.bootstrap(app);\n  \n  app.use(app.router);\n  ...\n});\n\n// remove any existing route\n...\n\napp.listen(3000);\n```\n\n- Start the server:\n\n```\n$ node app\n```\n\n## Project Structure\n\nnodetoo only work on the `app/` and `config/` folder\n\n```\napp/\n  controllers/\n    home/\n      index.js\n  models/\n      user.js\n  views/\n    home/\n      index.jade\nconfig/\n    injections/\n    plugins/\n    routes.js\n    setting.js\n```\n\n## Models\n\nEach js file under `models/` is a model, nodetoo will bootstrap all of them automatically. \n\n```\nmodels/\n  user.js\n  post.js\n  comment.js\n```\n\n## Controllers\n\nEach folder under `controllers/` is a controller, `index.js` represent the js file.  \nLet's take a look at the `controllers/home/index.js` file.\n\n```js\nexports.index = function(req, res) {\n  var user = req.session.user;\n  res.render('home/index', {user: user});\n};\n\nexports.about = function(req, res) {\n  res.render('home/about');\n};\n```\n\n## Actions\n\nAction is a controller method and represent as `[controller].[method]`.\n\n```\nhome.index\nhome.about\n```\n\n## Routes\n\nRoutes are defined in the `config/routes.js` file\n\n```js\nmodule.exports = [\n// public routes  \n  { routes : [\n        ['/'        ,'get'  ,'home.index']\n      , ['/login'   ,'all'  ,'user.login']\n      , ['/logout'  ,'get'  ,'user.logout']\n  ]}\n\n// user with any roles\n, { roles  : ['*'],\n    routes : [\n        ['/anyone'  ,'get'  ,'anyone.index']\n  ]}\n\n// user with admin role only\n, { roles  : ['admin'],\n    routes : [\n        ['/admin'   ,'get' ,'admin.index']\n  ]}\n]\n```\n\nMiddlewares can be use via [injection](#injections)\n\n```\nconfig/\n    injections/\n        check4name.js\n        check4age.js\n```\n\n```js\nmodule.exports = [\n  { routes : [\n        ['/'  ,'get'  ,'home.index', ['check4name', 'check4age']]\n  ]}\n]\n```\n\n## Authentication\n\nWhen roles is configured in `routes.js`, {nodetoo} will ask for an authenticator via [injection](#injections).\n\n```\nconfig/\n    injections/\n        authenticator.js\n```\n\n```js\nmodule.exports = function(roles) {\n  return function (req, res, next) {\n    // retrieve user from session\n    var user = req.session.user;\n    if (user === undefined) {\n      res.status(401).render('401');\n    } \n    // asterisk skip authorization\n    else if (!_.contains(roles, '*') \n          && !_.intersection(user.roles, roles).length > 0) {\n      res.status(401).render('401');\n    } else next();\n  }\n}\n```\nBut how you write the authenticator, it is really up to you. \nPlease refer to the [example](https://github.com/fliptoo/nodetoo/tree/master/examples/auth).\n\n## Injections\n\nAny module under `injections/` folder can be inject with the module filename without the extension.\n\n```\nconfig/\n    injections/\n        module.js\n```\n\n```\nvar module = inject('module');\n```\n\nPS: Actually nothing special with the injection, it is just a global function as `require`.\n\n## Plugins\n\nAny module under `plugins/` folder will be installed as a plugin.\n\n```\nconfig/\n    plugins/\n        extra.js\n```\n\n## Examples\n\nClone the nodetoo repo, then install the dev dependencies:\n\n    $ git clone git://github.com/fliptoo/nodetoo.git --depth 1\n    $ cd nodetoo\n    $ npm install\n\nand run whichever examples you want:\n\n    $ cd examples/basic\n    $ node app\n    \n# Credits\n\n- [Express](https://github.com/visionmedia/express)\n- [i18n-node](https://github.com/mashpie/i18n-node/)\n\n## License\n\n(The MIT License)\n\nCopyright (c) 2013 Fliptoo &lt;fliptoo.studio@gmail.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.\n","readmeFilename":"README.md","_id":"nodetoo@1.0.3","dist":{"shasum":"00bbde9e176fb5ef0bf33c8d91889c13024da59e","tarball":"https://registry.npmjs.org/nodetoo/-/nodetoo-1.0.3.tgz","integrity":"sha512-fwxSR4bSZUafcAmHlNsDfi+OE0KyfAWo29OzqFo7fzMgd+jg4YpY+3H8Tplj3ao4S1UnYIT/19ddOrOJaKir3A==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFgnAizWXqbnyZX3yaO587DjeoMexnjDbvuRdS8QrP50AiAoXGZFiRUh53A8rgoiGSwvzWMxf7CawIG9SkCmVD5Rrg=="}]},"_npmVersion":"1.1.66","_npmUser":{"name":"fliptoo","email":"fliptoo.studio@gmail.com"},"maintainers":[{"name":"fliptoo","email":"fliptoo.studio@gmail.com"}],"directories":{}},"1.0.4":{"name":"nodetoo","description":"Express + MVC = {nodetoo}","version":"1.0.4","author":{"name":"fliptoo","email":"fliptoo.studio@gmail.com"},"main":"./index","bin":{"nodetoo":"./bin/nodetoo"},"dependencies":{"commander":"*","mkdirp":"*","xtend":"*","underscore":"*","sprintf":"*"},"devDependencies":{"express":"*","jade":"*"},"keywords":["express","framework","mvc","web","rest","restful","router","app","api"],"repository":{"type":"git","url":"git://github.com/fliptoo/nodetoo"},"readme":"{nodetoo}\n=========\nInspired by [Express mvc example](https://github.com/visionmedia/express/tree/master/examples/mvc), nodetoo is a MVC framework built on top of [Express](expressjs.com).\n\n## Installation\n\n    $ npm install -g nodetoo\n\n## Quick Start\n\nAssuming you have created a `project` with Express, please refer [here](http://expressjs.com/guide.html) for the guide.  \n\n- Create the app\n\n```\n$ cd /project\n$ npm install nodetoo\n$ nodetoo\n``` \n\n- Bootstrap nodetoo:\n\n```js\nvar express = require('express');\nvar nodetoo = require('nodetoo');\nvar app = express();\n\napp.configure(function(){\n  ...\n  \n  // boostrap nodetoo\n  nodetoo.bootstrap(app);\n  \n  app.use(app.router);\n  ...\n});\n\n// remove any existing route\n...\n\napp.listen(3000);\n```\n\n- Start the server:\n\n```\n$ node app\n```\n\n## Project Structure\n\nnodetoo only work on the `app/` and `config/` folder\n\n```\napp/\n  controllers/\n    home/\n      index.js\n  models/\n      user.js\n  views/\n    home/\n      index.jade\nconfig/\n    injections/\n    plugins/\n    routes.js\n    setting.js\n```\n\n## Models\n\nEach js file under `models/` is a model, nodetoo will bootstrap all of them automatically. \n\n```\nmodels/\n  user.js\n  post.js\n  comment.js\n```\n\n## Controllers\n\nEach folder under `controllers/` is a controller, `index.js` represent the js file.  \nLet's take a look at the `controllers/home/index.js` file.\n\n```js\nexports.actions = {\n  \n  index: function (req, res) {\n    res.render('home/index');\n  },\n\n  about: function (req, res) {\n    res.render('home/about');\n  },\n}\n```\n\n__Filters__ are middlewares that run before the action function.\n\nExports as a function `before`.\n```js\nexports.before = function (req, res, next) {\n    \n  console.log('[BEFORE]: ' + req.url);\n  next();\n}\n\nexports.actions = {\n  \n  index: function (req, res) {\n    res.render('home/index');\n  }\n}\n```\n\nExports as an object `before`, support [injection](#injections).\n\n```js\nexports.before = {\n  \n  all: [\n    {\n      middlewares: ['logger'],\n      except: ['login']\n    }\n  ],\n  only: [\n    { \n      middlewares: ['watcher'],\n      actions: ['login']\n    }\n  ]\n};\n```\n```\nAll actions will use `logger` except `login` action.\nOnly `login` action will use `watcher`.\n```\n\nDefine at action and it will be given priority.\n```js\nexports.actions = {\n  \n  index: {\n    before: ['watcher', 'logger'],\n    action: function (req, res) {\n      res.render('home/index');\n    }\n  }\n}\n```\n\nHere is the injections\n```\nconfig/\n    injections/\n        logger.js\n        watcher.js\n```\n\n__Roles__ are use in [Authentication](#authentication) process.\n\nExports as an object `roles`.\n```js\nexports.roles = {\n\n  all: [\n    {\n      roles: ['*'],\n      except: ['login']\n    }\n  ],\n  only: [\n    {\n      roles: ['user'],\n      actions: ['createUser']\n    },\n    {\n      roles: ['admin'],\n      actions: ['createUser']\n    },\n  ]\n};\n```\n```\nAll actions has role `*` except `login` action.\nOnly `createUser` action has role `user`.\nOnly `createUser` action has role `admin`.\n```\nPS: Role * apply to any roles, but it depend on how you write the authenticator.\n\nDefine at action and it will be given priority.\n```js\nexports.actions = {\n  \n  index: {\n    roles: ['*'],\n    action: function (req, res) {\n      res.render('home/index');\n    }\n  }\n}\n```\n\n## Actions\n\nAction is a controller method and represent as `[controller].[method]`.\n\n```\nhome.index\nhome.about\n```\n\n## Routes\n\nRoutes are defined in the `config/routes.js` file\n\n```js\nmodule.exports = [\n    ['/'                        ,'get'  ,'home.index']\n  , ['/about'                   ,'get'  ,'home.about']\n]\n```\n\n## Authentication\n\nWhen roles is configured, {nodetoo} will ask for an authenticator via [injection](#injections).\n\n```\nconfig/\n    injections/\n        authenticator.js\n```\n\n```js\nmodule.exports = function(roles) {\n  return function (req, res, next) {\n    // retrieve user from session\n    var user = req.session.user;\n    if (user === undefined) {\n      res.status(401).render('401');\n    } \n    // asterisk skip authorization\n    else if (!_.contains(roles, '*') \n          && !_.intersection(user.roles, roles).length > 0) {\n      res.status(401).render('401');\n    } else next();\n  }\n}\n```\nBut how you write the authenticator, it is really up to you. \nPlease refer to the [example](https://github.com/fliptoo/nodetoo/tree/master/examples/auth).\n\n## Injections\n\nAny module under `injections/` folder can be inject with the module filename without the extension.\n\n```\nconfig/\n    injections/\n        module.js\n```\n\n```\nvar module = inject('module');\n```\n\nPS: Actually nothing special with the injection, it is just a global function as `require`.\n\n## Examples\n\nClone the nodetoo repo, then install the dev dependencies:\n\n    $ git clone git://github.com/fliptoo/nodetoo.git --depth 1\n    $ cd nodetoo\n    $ npm install\n\nand run whichever examples you want:\n\n    $ cd examples/basic\n    $ node app\n    \n# Credits\n\n- [Express](https://github.com/visionmedia/express)\n- [i18n-node](https://github.com/mashpie/i18n-node/)\n\n## License\n\n(The MIT License)\n\nCopyright (c) 2013 Fliptoo &lt;fliptoo.studio@gmail.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.\n","readmeFilename":"README.md","_id":"nodetoo@1.0.4","dist":{"shasum":"d40c2091d64b555266638112f774d22e33dcca3c","tarball":"https://registry.npmjs.org/nodetoo/-/nodetoo-1.0.4.tgz","integrity":"sha512-AUz0s9qv+rjMhHBXBtmHfbVqhLWW37al5x4sLioxpPEt5y79MigwAadMbgE+D16ljUmOMNtYY/zUFqZSxOjIPA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDZm0YCfU7dv6MfWp5VoT/xP3GtjnAWmvMGFVVMggki9wIhAOPZ/LRpNynYlg468sh3915wFL19KoLiqHhuC/HpwZrr"}]},"_npmVersion":"1.1.66","_npmUser":{"name":"fliptoo","email":"fliptoo.studio@gmail.com"},"maintainers":[{"name":"fliptoo","email":"fliptoo.studio@gmail.com"}],"directories":{}},"1.0.5":{"name":"nodetoo","description":"Express + MVC = {nodetoo}","version":"1.0.5","author":{"name":"fliptoo","email":"fliptoo.studio@gmail.com"},"main":"./index","bin":{"nodetoo":"./bin/nodetoo"},"dependencies":{"commander":"*","mkdirp":"*","xtend":"*","underscore":"*","sprintf":"*"},"devDependencies":{"express":"*","jade":"*"},"keywords":["express","framework","mvc","web","rest","restful","router","app","api"],"repository":{"type":"git","url":"git://github.com/fliptoo/nodetoo"},"readme":"{nodetoo}\n=========\nInspired by [Express mvc example](https://github.com/visionmedia/express/tree/master/examples/mvc), nodetoo is a MVC framework built on top of [Express](expressjs.com).\n\n## Installation\n\n    $ npm install -g nodetoo\n\n## Quick Start\n\nAssuming you have created a `project` with Express, please refer [here](http://expressjs.com/guide.html) for the guide.  \n\n- Create the app\n\n```\n$ cd /project\n$ npm install nodetoo\n$ nodetoo\n``` \n\n- Bootstrap nodetoo:\n\n```js\nvar express = require('express');\nvar nodetoo = require('nodetoo');\nvar app = express();\n\napp.configure(function(){\n  ...\n  \n  // boostrap nodetoo\n  nodetoo.bootstrap(app);\n  \n  app.use(app.router);\n  ...\n});\n\n// remove any existing route\n...\n\napp.listen(3000);\n```\n\n- Start the server:\n\n```\n$ node app\n```\n\n## Project Structure\n\nnodetoo only work on the `app/` and `config/` folder\n\n```\napp/\n  controllers/\n    home/\n      index.js\n  models/\n      user.js\n  views/\n    home/\n      index.jade\nconfig/\n    injections/\n    plugins/\n    routes.js\n    setting.js\n```\n\n## Models\n\nEach js file under `models/` is a model, nodetoo will bootstrap all of them automatically. \n\n```\nmodels/\n  user.js\n  post.js\n  comment.js\n```\n\n## Controllers\n\nEach folder under `controllers/` is a controller, `index.js` represent the js file.  \nLet's take a look at the `controllers/home/index.js` file.\n\n```js\nexports.actions = {\n  \n  index: function (req, res) {\n    res.render('home/index');\n  },\n\n  about: function (req, res) {\n    res.render('home/about');\n  },\n}\n```\n\n__Filters__ are middlewares that run before the action function.\n\nExports as a function `before`.\n```js\nexports.before = function (req, res, next) {\n    \n  console.log('[BEFORE]: ' + req.url);\n  next();\n}\n\nexports.actions = {\n  \n  index: function (req, res) {\n    res.render('home/index');\n  }\n}\n```\n\nExports as an object `before`, support [injection](#injections).\n\n```js\nexports.before = {\n  \n  all: [\n    {\n      middlewares: ['logger'],\n      except: ['login']\n    }\n  ],\n  only: [\n    { \n      middlewares: ['watcher'],\n      actions: ['login']\n    }\n  ]\n};\n```\n```\nAll actions will use `logger` except `login` action.\nOnly `login` action will use `watcher`.\n```\n\nDefine at action and it will be given priority.\n```js\nexports.actions = {\n  \n  index: {\n    before: ['watcher', 'logger'],\n    action: function (req, res) {\n      res.render('home/index');\n    }\n  }\n}\n```\n\nHere is the injections\n```\nconfig/\n    injections/\n        logger.js\n        watcher.js\n```\n\n__Roles__ are use in [Authentication](#authentication) process.\n\nExports as an object `roles`.\n```js\nexports.roles = {\n\n  all: [\n    {\n      roles: ['*'],\n      except: ['login']\n    }\n  ],\n  only: [\n    {\n      roles: ['user'],\n      actions: ['createUser']\n    },\n    {\n      roles: ['admin'],\n      actions: ['createUser']\n    },\n  ]\n};\n```\n```\nAll actions has role `*` except `login` action.\nOnly `createUser` action has role `user`.\nOnly `createUser` action has role `admin`.\n```\nPS: Role * apply to any roles, but it depend on how you write the authenticator.\n\nDefine at action and it will be given priority.\n```js\nexports.actions = {\n  \n  index: {\n    roles: ['*'],\n    action: function (req, res) {\n      res.render('home/index');\n    }\n  }\n}\n```\n\n## Actions\n\nAction is a controller method and represent as `[controller].[method]`.\n\n```\nhome.index\nhome.about\n```\n\n## Routes\n\nRoutes are defined in the `config/routes.js` file\n\n```js\nmodule.exports = [\n    ['/'                        ,'get'  ,'home.index']\n  , ['/about'                   ,'get'  ,'home.about']\n]\n```\n\n## Authentication\n\nWhen roles is configured, {nodetoo} will ask for an authenticator via [injection](#injections).\n\n```\nconfig/\n    injections/\n        authenticator.js\n```\n\n```js\nmodule.exports = function(roles) {\n  return function (req, res, next) {\n    // retrieve user from session\n    var user = req.session.user;\n    if (user === undefined) {\n      res.status(401).render('401');\n    } \n    // asterisk skip authorization\n    else if (!_.contains(roles, '*') \n          && !_.intersection(user.roles, roles).length > 0) {\n      res.status(401).render('401');\n    } else next();\n  }\n}\n```\nBut how you write the authenticator, it is really up to you. \nPlease refer to the [example](https://github.com/fliptoo/nodetoo/tree/master/examples/auth).\n\n## Injections\n\nAny module under `injections/` folder can be inject with the module filename without the extension.\n\n```\nconfig/\n    injections/\n        module.js\n```\n\n```\nvar module = inject('module');\n```\n\nPS: Actually nothing special with the injection, it is just a global function as `require`.\n\n## Examples\n\nClone the nodetoo repo, then install the dev dependencies:\n\n    $ git clone git://github.com/fliptoo/nodetoo.git --depth 1\n    $ cd nodetoo\n    $ npm install\n\nand run whichever examples you want:\n\n    $ cd examples/basic\n    $ node app\n    \n# Credits\n\n- [Express](https://github.com/visionmedia/express)\n- [i18n-node](https://github.com/mashpie/i18n-node/)\n\n## License\n\n(The MIT License)\n\nCopyright (c) 2013 Fliptoo &lt;fliptoo.studio@gmail.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.\n","readmeFilename":"README.md","_id":"nodetoo@1.0.5","dist":{"shasum":"d87fdd3279ced9290dcc0a71ee26bb8bbfe32c9a","tarball":"https://registry.npmjs.org/nodetoo/-/nodetoo-1.0.5.tgz","integrity":"sha512-V9nJG7FK38jLlfs2P6JaL3WCQJfTSvbfVhhROs0QvGESr06wXSfRSfICiP1wXncKJzPPioNHCKQORFsdCgkjbQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIAh25nJ0DdAtAK5iEAe/gDXNggfsGjmQ4u+tuDXDMFM2AiEA+IPhVQbGtXoKoSWWwoLUWoBzjzXRn86/sIuwe245rug="}]},"_npmVersion":"1.1.66","_npmUser":{"name":"fliptoo","email":"fliptoo.studio@gmail.com"},"maintainers":[{"name":"fliptoo","email":"fliptoo.studio@gmail.com"}],"directories":{}},"1.0.6":{"name":"nodetoo","description":"Express + MVC = {nodetoo}","version":"1.0.6","author":{"name":"fliptoo","email":"fliptoo.studio@gmail.com"},"main":"./index","bin":{"nodetoo":"./bin/nodetoo"},"dependencies":{"commander":"*","mkdirp":"*","xtend":"*","underscore":"*","sprintf":"*"},"devDependencies":{"express":"*","jade":"*"},"keywords":["express","framework","mvc","web","rest","restful","router","app","api"],"repository":{"type":"git","url":"git://github.com/fliptoo/nodetoo"},"readme":"{nodetoo}\n=========\nInspired by [Express mvc example](https://github.com/visionmedia/express/tree/master/examples/mvc), nodetoo is a MVC framework built on top of [Express](expressjs.com).\n\n## Installation\n\n    $ npm install -g nodetoo\n\n## Quick Start\n\nAssuming you have created a `project` with Express, please refer [here](http://expressjs.com/guide.html) for the guide.  \n\n- Create the app\n\n```\n$ cd /project\n$ npm install nodetoo\n$ nodetoo\n``` \n\n- Bootstrap nodetoo:\n\n```js\nvar express = require('express');\nvar nodetoo = require('nodetoo');\nvar app = express();\n\napp.configure(function(){\n  ...\n  \n  // boostrap nodetoo\n  nodetoo.bootstrap(app);\n  \n  app.use(app.router);\n  ...\n});\n\n// remove any existing route\n...\n\napp.listen(3000);\n```\n\n- Start the server:\n\n```\n$ node app\n```\n\n## Project Structure\n\nnodetoo only work on the `app/` and `config/` folder\n\n```\napp/\n  controllers/\n    home/\n      index.js\n  models/\n      user.js\n  views/\n    home/\n      index.jade\nconfig/\n    injections/\n    plugins/\n    routes.js\n    setting.js\n```\n\n## Models\n\nEach js file under `models/` is a model, nodetoo will bootstrap all of them automatically. \n\n```\nmodels/\n  user.js\n  post.js\n  comment.js\n```\n\n## Controllers\n\nEach folder under `controllers/` is a controller, `index.js` represent the js file.  \nLet's take a look at the `controllers/home/index.js` file.\n\n```js\nexports.actions = {\n  \n  index: function (req, res) {\n    res.render('home/index');\n  },\n\n  about: function (req, res) {\n    res.render('home/about');\n  },\n}\n```\n\n__Filters__ are middlewares that run before the action function.\n\nExports as a function `before`.\n```js\nexports.before = function (req, res, next) {\n    \n  console.log('[BEFORE]: ' + req.url);\n  next();\n}\n\nexports.actions = {\n  \n  index: function (req, res) {\n    res.render('home/index');\n  }\n}\n```\n\nExports as an object `before`, support [injection](#injections).\n\n```js\nexports.before = {\n  \n  all: [\n    {\n      middlewares: ['logger'],\n      except: ['login']\n    }\n  ],\n  only: [\n    { \n      middlewares: ['watcher'],\n      actions: ['login']\n    }\n  ]\n};\n```\n```\nAll actions will use `logger` except `login` action.\nOnly `login` action will use `watcher`.\n```\n\nDefine at action and it will be given priority.\n```js\nexports.actions = {\n  \n  index: {\n    before: ['watcher', 'logger'],\n    action: function (req, res) {\n      res.render('home/index');\n    }\n  }\n}\n```\n\nHere is the injections\n```\nconfig/\n    injections/\n        logger.js\n        watcher.js\n```\n\n__Roles__ are use in [Authentication](#authentication) process.\n\nExports as an object `roles`.\n```js\nexports.roles = {\n\n  all: [\n    {\n      roles: ['*'],\n      except: ['login']\n    }\n  ],\n  only: [\n    {\n      roles: ['user'],\n      actions: ['createUser']\n    },\n    {\n      roles: ['admin'],\n      actions: ['createUser']\n    },\n  ]\n};\n```\n```\nAll actions has role `*` except `login` action.\nOnly `createUser` action has role `user`.\nOnly `createUser` action has role `admin`.\n```\nPS: Role * apply to any roles, but it depend on how you write the authenticator.\n\nDefine at action and it will be given priority.\n```js\nexports.actions = {\n  \n  index: {\n    roles: ['*'],\n    action: function (req, res) {\n      res.render('home/index');\n    }\n  }\n}\n```\n\n## Actions\n\nAction is a controller method and represent as `[controller].[method]`.\n\n```\nhome.index\nhome.about\n```\n\n## Routes\n\nRoutes are defined in the `config/routes.js` file\n\n```js\nmodule.exports = [\n    ['/'                        ,'get'  ,'home.index']\n  , ['/about'                   ,'get'  ,'home.about']\n]\n```\n\n## Authentication\n\nWhen roles is configured, {nodetoo} will ask for an authenticator via [injection](#injections).\n\n```\nconfig/\n    injections/\n        authenticator.js\n```\n\n```js\nmodule.exports = function(roles) {\n  return function (req, res, next) {\n    // retrieve user from session\n    var user = req.session.user;\n    if (user === undefined) {\n      res.status(401).render('401');\n    } \n    // asterisk skip authorization\n    else if (!_.contains(roles, '*') \n          && !_.intersection(user.roles, roles).length > 0) {\n      res.status(401).render('401');\n    } else next();\n  }\n}\n```\nBut how you write the authenticator, it is really up to you. \nPlease refer to the [example](https://github.com/fliptoo/nodetoo/tree/master/examples/auth).\n\n## Injections\n\nAny module under `injections/` folder can be inject with the module filename without the extension.\n\n```\nconfig/\n    injections/\n        module.js\n```\n\n```\nvar module = inject('module');\n```\n\nPS: Actually nothing special with the injection, it is just a global function as `require`.\n\n## Examples\n\nClone the nodetoo repo, then install the dev dependencies:\n\n    $ git clone git://github.com/fliptoo/nodetoo.git --depth 1\n    $ cd nodetoo\n    $ npm install\n\nand run whichever examples you want:\n\n    $ cd examples/basic\n    $ node app\n    \n# Credits\n\n- [Express](https://github.com/visionmedia/express)\n- [i18n-node](https://github.com/mashpie/i18n-node/)\n\n## License\n\n(The MIT License)\n\nCopyright (c) 2013 Fliptoo &lt;fliptoo.studio@gmail.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.\n","readmeFilename":"README.md","_id":"nodetoo@1.0.6","dist":{"shasum":"23c2f36a9969e9a4254e1f780371f07610ef217d","tarball":"https://registry.npmjs.org/nodetoo/-/nodetoo-1.0.6.tgz","integrity":"sha512-G5iGcWH/NfbGPyCNV5nCiehMwfpja1xr93CL3sFS9Xb1TXInuuDH34YF78TqLEdHfV7G48WMCfdUGL5Cl5F3Sg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIDetaJmu0sQKDFDgCs/lQwq1TDQR+G4+YOAoPmRCIjGbAiEA0WQa7xAD74yZgKs77uCrNyZoV4rOraWnU17j4GvE4IE="}]},"_npmVersion":"1.1.66","_npmUser":{"name":"fliptoo","email":"fliptoo.studio@gmail.com"},"maintainers":[{"name":"fliptoo","email":"fliptoo.studio@gmail.com"}]},"1.0.7":{"name":"nodetoo","description":"Express + MVC = {nodetoo}","version":"1.0.7","author":{"name":"fliptoo","email":"fliptoo.studio@gmail.com"},"main":"./index","bin":{"nodetoo":"./bin/nodetoo"},"dependencies":{"commander":"*","mkdirp":"*","xtend":"*","underscore":"*","sprintf":"*"},"devDependencies":{"express":"*","jade":"*"},"keywords":["express","framework","mvc","web","rest","restful","router","app","api"],"repository":{"type":"git","url":"git://github.com/fliptoo/nodetoo"},"readme":"{nodetoo}\n=========\nInspired by [Express mvc example](https://github.com/visionmedia/express/tree/master/examples/mvc), nodetoo is a MVC framework built on top of [Express](expressjs.com).\n\n## Installation\n\n    $ npm install -g nodetoo\n\n## Quick Start\n\nAssuming you have created a `project` with Express, please refer [here](http://expressjs.com/guide.html) for the guide.  \n\n- Create the app\n\n```\n$ cd /project\n$ npm install nodetoo\n$ nodetoo\n``` \n\n- Bootstrap nodetoo:\n\n```js\nvar express = require('express');\nvar nodetoo = require('nodetoo');\nvar app = express();\n\napp.configure(function(){\n  ...\n  \n  // boostrap nodetoo\n  nodetoo.bootstrap(app);\n  \n  app.use(app.router);\n  ...\n});\n\n// remove any existing route\n...\n\napp.listen(3000);\n```\n\n- Start the server:\n\n```\n$ node app\n```\n\n## Project Structure\n\nnodetoo only work on the `app/` and `config/` folder\n\n```\napp/\n  controllers/\n    home/\n      index.js\n  models/\n      user.js\n  views/\n    home/\n      index.jade\nconfig/\n    injections/\n    plugins/\n    routes.js\n    setting.js\n```\n\n## Models\n\nEach js file under `models/` is a model, nodetoo will bootstrap all of them automatically. \n\n```\nmodels/\n  user.js\n  post.js\n  comment.js\n```\n\n## Controllers\n\nEach folder under `controllers/` is a controller, `index.js` represent the js file.  \nLet's take a look at the `controllers/home/index.js` file.\n\n```js\nexports.actions = {\n  \n  index: function (req, res) {\n    res.render('home/index');\n  },\n\n  about: function (req, res) {\n    res.render('home/about');\n  },\n}\n```\n\n__Filters__ are middlewares that run before the action function.\n\nExports as a function `before`.\n```js\nexports.before = function (req, res, next) {\n    \n  console.log('[BEFORE]: ' + req.url);\n  next();\n}\n\nexports.actions = {\n  \n  index: function (req, res) {\n    res.render('home/index');\n  }\n}\n```\n\nExports as an object `before`, support [injection](#injections).\n\n```js\nexports.before = {\n  \n  all: [\n    {\n      middlewares: ['logger'],\n      except: ['login']\n    }\n  ],\n  only: [\n    { \n      middlewares: ['watcher'],\n      actions: ['login']\n    }\n  ]\n};\n```\n```\nAll actions will use `logger` except `login` action.\nOnly `login` action will use `watcher`.\n```\n\nDefine at action and it will be given priority.\n```js\nexports.actions = {\n  \n  index: {\n    before: ['watcher', 'logger'],\n    action: function (req, res) {\n      res.render('home/index');\n    }\n  }\n}\n```\n\nHere is the injections\n```\nconfig/\n    injections/\n        logger.js\n        watcher.js\n```\n\n__Roles__ are use in [Authentication](#authentication) process.\n\nExports as an object `roles`.\n```js\nexports.roles = {\n\n  all: [\n    {\n      roles: ['*'],\n      except: ['login']\n    }\n  ],\n  only: [\n    {\n      roles: ['user'],\n      actions: ['createUser']\n    },\n    {\n      roles: ['admin'],\n      actions: ['createUser']\n    },\n  ]\n};\n```\n```\nAll actions has role `*` except `login` action.\nOnly `createUser` action has role `user`.\nOnly `createUser` action has role `admin`.\n```\nPS: Role * apply to any roles, but it depend on how you write the authenticator.\n\nDefine at action and it will be given priority.\n```js\nexports.actions = {\n  \n  index: {\n    roles: ['*'],\n    action: function (req, res) {\n      res.render('home/index');\n    }\n  }\n}\n```\n\n## Actions\n\nAction is a controller method and represent as `[controller].[method]`.\n\n```\nhome.index\nhome.about\n```\n\n## Routes\n\nRoutes are defined in the `config/routes.js` file\n\n```js\nmodule.exports = [\n    ['/'                        ,'get'  ,'home.index']\n  , ['/about'                   ,'get'  ,'home.about']\n]\n```\n\n## Authentication\n\nWhen roles is configured, {nodetoo} will ask for an authenticator via [injection](#injections).\n\n```\nconfig/\n    injections/\n        authenticator.js\n```\n\n```js\nmodule.exports = function(roles) {\n  return function (req, res, next) {\n    // retrieve user from session\n    var user = req.session.user;\n    if (user === undefined) {\n      res.status(401).render('401');\n    } \n    // asterisk skip authorization\n    else if (!_.contains(roles, '*') \n          && !_.intersection(user.roles, roles).length > 0) {\n      res.status(401).render('401');\n    } else next();\n  }\n}\n```\nBut how you write the authenticator, it is really up to you. \nPlease refer to the [example](https://github.com/fliptoo/nodetoo/tree/master/examples/auth).\n\n## Injections\n\nAny module under `injections/` folder can be inject with the module filename without the extension.\n\n```\nconfig/\n    injections/\n        module.js\n```\n\n```\nvar module = inject('module');\n```\n\nPS: Actually nothing special with the injection, it is just a global function as `require`.\n\n## Examples\n\nClone the nodetoo repo, then install the dev dependencies:\n\n    $ git clone git://github.com/fliptoo/nodetoo.git --depth 1\n    $ cd nodetoo\n    $ npm install\n\nand run whichever examples you want:\n\n    $ cd examples/basic\n    $ node app\n    \n# Credits\n\n- [Express](https://github.com/visionmedia/express)\n- [i18n-node](https://github.com/mashpie/i18n-node/)\n\n## License\n\n(The MIT License)\n\nCopyright (c) 2013 Fliptoo &lt;fliptoo.studio@gmail.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.\n","readmeFilename":"README.md","bugs":{"url":"https://github.com/fliptoo/nodetoo/issues"},"_id":"nodetoo@1.0.7","dist":{"shasum":"14b7f84c824873214e954081ddcb7355840ae594","tarball":"https://registry.npmjs.org/nodetoo/-/nodetoo-1.0.7.tgz","integrity":"sha512-KMnWEXXNliELZn75Zo1D8fEq0AByqpvRPHpxWGd6un3SBfWmLl8fZmrPoGffBj+ANwJQ+aG1wWlGkTtHRrrwNQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIHz6MwBR/bqZTAH+grPFNhjpjhImXRGND0HrA2TtIZ/MAiBLBopO6LRSi7HE9hogRzDsw0ftiy6+RHqWZck3nNHt3A=="}]},"_from":".","_npmVersion":"1.3.2","_npmUser":{"name":"fliptoo","email":"fliptoo.studio@gmail.com"},"maintainers":[{"name":"fliptoo","email":"fliptoo.studio@gmail.com"}]}},"readme":"{nodetoo}\n=========\nInspired by [Express mvc example](https://github.com/visionmedia/express/tree/master/examples/mvc), nodetoo is a MVC framework built on top of [Express](expressjs.com).\n\n## Installation\n\n    $ npm install -g nodetoo\n\n## Quick Start\n\nAssuming you have created a `project` with Express, please refer [here](http://expressjs.com/guide.html) for the guide.  \n\n- Create the `app/`\n\n```\n$ cd /project\n$ npm install nodetoo\n$ nodetoo\n``` \n\n- Bootstrap nodetoo:\n\n```js\nvar express = require('express');\nvar nodetoo = require('nodetoo');\nvar app = express();\n\n// bootstrap nodetoo\nnodetoo(app, __dirname + '/app');\n\napp.listen(3000);\n```\n\n- Start the server:\n\n```\n$ node app\n```\n\n## Project Structure\n\nnodetoo only work on the `app/` folder\n\n```\napp/\n  controllers/\n    home/\n      index.js\n  models/\n      user.js\n  views/\n    home/\n      index.jade\n  routes.js\n```\n\n## Models\n\nEach js file under `models/` is a model, nodetoo will bootstrap all of them automatically. \n\n```\nmodels/\n  user.js\n  post.js\n  comment.js\n```\n\n## Controllers\n\nEach folder under `controllers/` is a controller, `index.js` represent the js file.  \nLet's take a look at the `controllers/home/index.js` file.\n\n```js\nexports.index = function(req, res) {\n  var user = req.session.user;\n  res.render('home/index', {user: user});\n};\n\nexports.about = function(req, res) {\n  res.render('home/about');\n};\n```\n\n## Actions\n\nAction is a controller method and represent as `[controller].[method]`.\n\n```\nhome.index\nhome.about\n```\n\n## Routes\n\nRoutes are defined in the `app/route.js` file\n\n```js\nmodule.exports = [\n// public routes  \n  { routes : [\n        ['/'                        ,'get'  ,'home.index']\n      , ['/login'                   ,'all'  ,'user.login']\n      , ['/logout'                  ,'get'  ,'user.logout']\n  ]}\n\n// user with any roles\n, { roles  : ['*'],\n    routes : [\n        ['/anyone'                  ,'get'  ,'anyone.index']\n  ]}\n\n// user with admin role only\n, { roles  : ['admin'],\n    routes : [\n        ['/admin'                    ,'get' ,'admin.index']\n  ]}\n]\n```\n\n## Authentication\n\nnodetoo take a 3rd argument as the authentication middleware (authenticator).\n\n```js\nvar auth = function(roles) {\n  return function (req, res, next) {\n    // retrieve user from session\n    var user = req.session.user;\n    if (user === undefined) {\n      res.status(401).render('401');\n    } \n    // asterisk skip authorization\n    else if (!_.contains(roles, '*') \n          && !_.intersection(user.roles, roles).length > 0) {\n      res.status(401).render('401');\n    } else next();\n  }\n}\n\nnodetoo(app, __dirname + '/app', auth);\n```\nBut how you write the authenticator, it is really up to you.\n\n## Examples\n\nClone the nodetoo repo, then install the dev dependencies:\n\n    $ git clone git://github.com/fliptoo/nodetoo.git --depth 1\n    $ cd nodetoo\n    $ npm install\n\nand run whichever examples you want:\n\n    $ node examples/basic\n\n## License\n\n(The MIT License)\n\nCopyright (c) 2013 Fliptoo &lt;fliptoo.studio@gmail.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.\n","maintainers":[{"name":"fliptoo","email":"fliptoo.studio@gmail.com"}],"time":{"modified":"2022-06-22T03:48:05.194Z","created":"2013-02-25T04:45:29.006Z","1.0.0":"2013-02-25T04:45:32.971Z","1.0.1":"2013-02-26T04:56:05.177Z","1.0.2":"2013-02-28T10:30:18.525Z","1.0.3":"2013-03-01T02:51:55.594Z","1.0.4":"2013-03-19T08:37:38.247Z","1.0.5":"2013-05-26T13:40:06.293Z","1.0.6":"2013-06-18T04:49:10.194Z","1.0.7":"2013-07-25T09:07:21.866Z"},"author":{"name":"fliptoo","email":"fliptoo.studio@gmail.com"},"repository":{"type":"git","url":"git://github.com/fliptoo/nodetoo"}}