Playing with a node.js app project layout
I'm pleased with this project layout for a node.js-based web client / server app.
โ toothub git:(master) โ tree
โโโ Procfile
โโโ README.md
โโโ app.json
โโโ bin
โย ย โโโ toothub
โโโ config.json-dist
โโโ htdocs
โย ย โโโ css
โย ย โย ย โโโ main.styl
โย ย โโโ index.html
โโโ lib
โย ย โโโ cli
โย ย โย ย โโโ index.js
โย ย โย ย โโโ server.js
โย ย โโโ client
โย ย โย ย โโโ index.js
โย ย โโโ models
โย ย โย ย โโโ Item.js
โย ย โย ย โโโ index.js
โย ย โโโ server
โย ย โโโ index.js
โย ย โโโ static.js
โโโ package.json
โโโ test
โโโ test-index.js
Browserify lets me share a lot of code between client & server, using the same conventions. Though, I have to be careful not to pile too much into the client-side JS bundle. It's really easy to inflate that.
The require-dir module lets me do some lazy things to break up my code into more submodules - at least on the server side. It's a little thing, but I really like it. I first saw it over in this Gulp + Browserify starter kit.
Thanks to the Heroku Button, this thing is cake to get running somewhere out there. Free Heroku is like the Raspberry PI of the cloud. I'm starting to think that anyone who's into indiewebish self-hosting concepts should really be taking a look at this.
I've also been really into Gulp recently, but so far I don't need it here. I'm gratuitously wasting memory and cycles by processing resources on the fly through the app server rather than generating as static assets. Maybe I'll change my mind on that after I've tinkered for awhile.
Anyway, now I guess I should actually start making this thing do stuff.