{
  "attachments": [],
  "title": "Playing with a node.js app project layout",
  "tags": [
    "nodejs",
    "webdev",
    "javascript",
    "gulp",
    "heroku"
  ],
  "year": "2014",
  "month": "10",
  "day": "23",
  "isDir": false,
  "slug": "node-project-layout",
  "type": "entry",
  "date": "2014-10-23T19:00:00.000Z",
  "postName": "2014-10-23-node-project-layout",
  "html": "<p>I'm pleased with <a href=\"https://github.com/lmorchard/toothub/tree/913c4d326ea5a424087899a103301323d46d8086\">this project layout</a> for a node.js-based web client /\nserver app.</p>\n<!--more-->\n\n\n\n<pre><code class=\"language-bash\">➜  toothub git:(master) ✗ tree\n├── Procfile\n├── README.md\n├── app.json\n├── bin\n│&nbsp;&nbsp; └── toothub\n├── config.json-dist\n├── htdocs\n│&nbsp;&nbsp; ├── css\n│&nbsp;&nbsp; │&nbsp;&nbsp; └── main.styl\n│&nbsp;&nbsp; └── index.html\n├── lib\n│&nbsp;&nbsp; ├── cli\n│&nbsp;&nbsp; │&nbsp;&nbsp; ├── index.js\n│&nbsp;&nbsp; │&nbsp;&nbsp; └── server.js\n│&nbsp;&nbsp; ├── client\n│&nbsp;&nbsp; │&nbsp;&nbsp; └── index.js\n│&nbsp;&nbsp; ├── models\n│&nbsp;&nbsp; │&nbsp;&nbsp; ├── Item.js\n│&nbsp;&nbsp; │&nbsp;&nbsp; └── index.js\n│&nbsp;&nbsp; └── server\n│&nbsp;&nbsp;     ├── index.js\n│&nbsp;&nbsp;     └── static.js\n├── package.json\n└── test\n    └── test-index.js\n</code></pre>\n<p><a href=\"http://browserify.org/\">Browserify</a> lets me share a lot of code between client &amp; server, using the same\nconventions.  Though, I have to be careful not to pile too much into the\nclient-side JS bundle. It's really easy to inflate that.</p>\n<p>The <a href=\"https://www.npmjs.org/package/require-dir\">require-dir</a> module lets me do <a href=\"https://github.com/lmorchard/feeder2/tree/9d02e216e4d4e47351a69eece8bece67d2fed550/lib/cli\">some lazy things</a> to break up my\ncode into more submodules - at least on the server side. It's a little thing,\nbut I really like it. I first saw it over in <a href=\"http://viget.com/extend/gulp-browserify-starter-faq\">this Gulp + Browserify starter\nkit</a>.</p>\n<p>Thanks to the <a href=\"https://blog.heroku.com/archives/2014/8/7/heroku-button\">Heroku Button</a>, this thing is cake to get running\nsomewhere <em>out there</em>. Free Heroku is like the Raspberry PI of the cloud. I'm\nstarting to think that anyone who's into indiewebish self-hosting concepts\nshould really be taking a look at this.</p>\n<p>I've also been really into <a href=\"http://gulpjs.com/\">Gulp</a> recently, but so far I don't need it here.\nI'm gratuitously wasting memory and cycles by processing resources on the fly\nthrough the app server rather than generating as static assets. Maybe I'll\nchange my mind on that after I've tinkered for awhile.</p>\n<p>Anyway, now I guess I should actually start making this thing do stuff.</p>\n<!-- vim: set wrap wm=5 syntax=mkd textwidth=78: -->\n",
  "body": "I'm pleased with [this project layout][layout] for a node.js-based web client /\r\nserver app.\r\n\r\n<!--more-->\r\n\r\n```bash\r\n➜  toothub git:(master) ✗ tree\r\n├── Procfile\r\n├── README.md\r\n├── app.json\r\n├── bin\r\n│   └── toothub\r\n├── config.json-dist\r\n├── htdocs\r\n│   ├── css\r\n│   │   └── main.styl\r\n│   └── index.html\r\n├── lib\r\n│   ├── cli\r\n│   │   ├── index.js\r\n│   │   └── server.js\r\n│   ├── client\r\n│   │   └── index.js\r\n│   ├── models\r\n│   │   ├── Item.js\r\n│   │   └── index.js\r\n│   └── server\r\n│       ├── index.js\r\n│       └── static.js\r\n├── package.json\r\n└── test\r\n    └── test-index.js\r\n```\r\n\r\n[Browserify][] lets me share a lot of code between client & server, using the same\r\nconventions.  Though, I have to be careful not to pile too much into the\r\nclient-side JS bundle. It's really easy to inflate that.\r\n\r\n[Browserify]: http://browserify.org/\r\n\r\nThe [require-dir][] module lets me do [some lazy things][lazy] to break up my\r\ncode into more submodules - at least on the server side. It's a little thing,\r\nbut I really like it. I first saw it over in [this Gulp + Browserify starter\r\nkit][starterkit].\r\n\r\n[starterkit]: http://viget.com/extend/gulp-browserify-starter-faq\r\n[require-dir]: https://www.npmjs.org/package/require-dir\r\n[lazy]: https://github.com/lmorchard/feeder2/tree/9d02e216e4d4e47351a69eece8bece67d2fed550/lib/cli\r\n\r\nThanks to the [Heroku Button][], this thing is cake to get running\r\nsomewhere *out there*. Free Heroku is like the Raspberry PI of the cloud. I'm\r\nstarting to think that anyone who's into indiewebish self-hosting concepts\r\nshould really be taking a look at this.\r\n\r\n[Heroku Button]: https://blog.heroku.com/archives/2014/8/7/heroku-button\r\n\r\nI've also been really into [Gulp][] recently, but so far I don't need it here.\r\nI'm gratuitously wasting memory and cycles by processing resources on the fly\r\nthrough the app server rather than generating as static assets. Maybe I'll\r\nchange my mind on that after I've tinkered for awhile.\r\n\r\n[gulp]: http://gulpjs.com/\r\n[layout]: https://github.com/lmorchard/toothub/tree/913c4d326ea5a424087899a103301323d46d8086\r\n\r\nAnyway, now I guess I should actually start making this thing do stuff.\r\n\r\n<!-- vim: set wrap wm=5 syntax=mkd textwidth=78: -->\r\n",
  "parentPath": "./content/posts/archives/2014",
  "path": "2014/10/23/node-project-layout",
  "summary": "I'm pleased with this project layout for a node.js-based web client /\nserver app.",
  "needsBuild": true,
  "prevPostPath": "2014/10/23/thoughts",
  "prevPostTitle": "Random thoughts for 2014 Oct 23",
  "nextPostPath": "2014/10/27/thoughts",
  "nextPostTitle": "Random thoughts for 2014 Oct 27"
}