| Directory/File | Description | Content |
|---|---|---|
| routes/ | Controllers and routers | |
| views/ | Templates based on Swig | |
| public/ | static files (js, css, img) | |
| config/ | Middlewares | All configuration files |
| test/ | Test units | *.spec.js |
| app.js | Entry point (create express server) | |
| Gruntfile.js | Makefile |
First install Node.js and then run
$ npm install
$ bower installSecond install MongoDB
Test your code.
$ grunt$ grunt servePlease install plugin "editorconfig" to your code editor first EditorConfig
Use config/db's db() method to get an instance of db
var db = require('../config/db').db();
app.route('/test', function(req, res) {
db.collection('holes').find().toArray(function(err, result) {
res.status(200).send(result);
});
});- Choose
Open..., and select the project root. - From
Run->Edit Configuration, click add new configuration and choose Node.js. - Type
app.jsinJavascript file, click...of Environment settings, addPORT=9000andNODE_ENV=development. Clickapply. - Again click add new configuration and choose mocha. Add environment variables
NODE_ENV=test. Clickapply.
** Notes **: you need to run an extern MongoDB service to get this work.