A small sample app built using Express and Backbone plus a few friends. I've used it as the basis for a few bigger projects, so hope it can help others in this regard too.
Ensure the following are installed:
Install the global dependencies:
$ npm install -g grunt-cli karma istanbul node-inspector bower
Change to your project directory then install the local dependencies:
$ npm install; bower install
- RequireJS is used for file and module loading
- Backbone.js is the client-side MVC framework
- Handlebars is used for client-side templating
- Compass is used for CSS authoring
To start using default options:
$ grunt start
Can be accessed via http://127.0.0.1:3000/
. Node Inspector will also be available via http://0.0.0.0:8080/debug?port=5858
.
Once started, the app will also:
- Watch the server source files, and restart the Node server if any changes are made
- Watch the SASS files, and recompile the dev CSS if any changes are made
- Watch the relevant JS files, and run the relevant JSHint tasks if any changes are made
- Jasmine is used for testing the JS
- The Jasmine SpecRunner.html is automatically generated via grunt
- Karma is used to run the tests against various browsers, as well as providing code coverage via Istanbul
Tests can be run in the browser via http://127.0.0.1:3000/test
.
To run tests only:
$ grunt client:test
To run tests with coverage:
$ grunt client:cover
Coverage information is output to ./coverage/client
.
- Mocha and expect.js are used for testing the Node server JS
- Istanbul is used to run the tests and provide code coverage
To run tests only:
$ grunt server:test
To run tests with coverage:
$ grunt server:coverage
Coverage information is output to ./coverage/server
.
- Docker is used to generate the documentation.
To generate:
$ grunt docs
Can be accessed via http://localhost:3000/docs
.
- Uses the RequireJS optimiser to compress the JS
- Rewrites the index.html file to only include the one script
To generate:
$ grunt dist
- @andrewpmckenzie, whose node-jasmine-dom was a big inspiration for this project
- @smozely, for the scaffolding and eventMediator suggestions
- @timsnadden, for showing me some new npm modules and Backbone helpers
- @appleYaks, whose grunt-express-workflow I leaned heavily on when configuring Istanbul and Karma