{"id":16293615,"url":"https://github.com/badsyntax/express-project-boilerplate","last_synced_at":"2026-01-20T18:56:36.406Z","repository":{"id":136894246,"uuid":"9737490","full_name":"badsyntax/express-project-boilerplate","owner":"badsyntax","description":"An express/requirejs/grunt/bower project boilerplate","archived":false,"fork":false,"pushed_at":"2016-10-18T04:15:43.000Z","size":319,"stargazers_count":4,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-13T22:51:26.206Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/badsyntax.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-MIT.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2013-04-28T22:45:18.000Z","updated_at":"2018-02-09T23:18:49.000Z","dependencies_parsed_at":"2023-04-14T01:31:14.313Z","dependency_job_id":null,"html_url":"https://github.com/badsyntax/express-project-boilerplate","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/badsyntax%2Fexpress-project-boilerplate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/badsyntax%2Fexpress-project-boilerplate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/badsyntax%2Fexpress-project-boilerplate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/badsyntax%2Fexpress-project-boilerplate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/badsyntax","download_url":"https://codeload.github.com/badsyntax/express-project-boilerplate/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247731529,"owners_count":20986669,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-10T20:11:52.686Z","updated_at":"2026-01-20T18:56:36.374Z","avatar_url":"https://github.com/badsyntax.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# express-project-boilerplate [![Build Status](https://travis-ci.org/badsyntax/express-project-boilerplate.png)](https://travis-ci.org/badsyntax/express-project-boilerplate)\n\nA starter project for building modern JavaScript web applications. \n\nThis project is not intended for others to use, and thus I can offer no support. Feel free to have a \nlook around and steal any code you like that isn't copyrighted. \n\nI built this project as as a starter application for future web projects; as a reference; and as a means to learn new and exciting web technologies.\n\nThis project uses the following technologies:  \n\n* [nodejs](http://nodejs.org/)\n* [npm](https://npmjs.org/)\n* [express](http://expressjs.com/)\n* [grunt](http://gruntjs.com/)\n* [requirejs](http://requirejs.org/)\n* [bower](http://bower.io/)\n* [jasmine](http://pivotal.github.io/jasmine/)\n* [Q](http://documentup.com/kriskowal/q)\n* [uglifyjs](https://github.com/mishoo/UglifyJS)\n* [handlebars](http://handlebarsjs.com/)\n* [sass](http://sass-lang.com/)\n* [compass](http://compass-style.org/)\n* [jquery](http://jquery.com/)\n* [knockoutjs](http://knockoutjs.com/)\n* [director](https://github.com/flatiron/director)\n* [bootstrap](http://twitter.github.io/bootstrap/)\n\n## Installation:\n\n1. Ensure you have all the following software installed on your system:\n    * [nodejs](http://nodejs.org/)\n    * [npm](https://npmjs.org/)\n    * [bower](http://bower.io/)\n    * [nodemon](https://github.com/remy/nodemon)\n    * [sass](http://sass-lang.com/)\n    * [compass](http://compass-style.org/)\n2. Clone the project from github: `git clone git://github.com/badsyntax/express-project-boilerplate.git`\n3. Install node modules: `npm install`\n4. Insall client-side components: `bower install`\n5. Compile the default Sass: `grunt compass`\n6. Compress and concat the default asset files: `grunt uglify \u0026\u0026 grunt concat` \n7. That's all, now run `node app.js` to boot up the basic application\n\n## Running and developing the application\n\n* Run the `grunt watch` task while developing, this will compile your sass when you make changes\n* Run `node app.js` to start the application\n* Run `nodemon app.js` to start the application and reload the application when files change\n\n### Application environment\n\nThe application will perform different tasks based on the application environment. \n\nYou can access the environment value by calling `app.get('env')` which will return either \n'development' or 'production'.\n\nBy default, the application will run in development mode, but you can use the following command to test the application\nin production mode: `NODE_ENV=production node app.js`\n\n## Grunt tasks\n\nRun `grunt` to run the default grunt tasks.\n\nHere are the individual grunt tasks you can run:\n\n* `grunt watch`\n* `grunt test`\n* `grunt compass`\n* `grunt uglify`\n* `grunt jshint`\n* `grunt jasmine`\n* `grunt format`\n* `grunt jsbeautifier`\n* `grunt sass-convert`\n\n## Server-side MVC\n\nThis system extends express to provide a more verbose and automated MVC system. A router handler is used to\nroute requests to controllers. Controllers create the ViewModels and handle user input. ViewModels retrieve data\nmodels and provide that data to the views.\n\n### Routing\n\nRoutes map urls to controllers. The default route will try to map all requests to the relevant controllers. \nHere's an example of this catch-all default route:\n\n```javascript\n{\n  uri: '/:controller?/:action?/:id?',\n  defaults: {\n    controller: 'home',\n    action: 'index'\n  }\n}\n```\n    \nHere's an example of a custom route:\n\n```javascript\n{\n  uri: '/post/:uri',\n  controller: 'post'\n}\n````\n\n### Controller usage\n\nControllers will handle the request and user input, as well as creating ViewModels. For requests that return markup,\nuse the 'ControllerLayout', which will create a 'layout' viewmodel, and all other ViewModels are added to this \nlayout ViewModel.\n\nHere's an example of a custom 'home' controller:\n\n```javascript\nvar ControllerLayout = require('../lib/Controller/ControllerLayout');\nvar ViewModel = require('../lib/ViewModel');\n\nfunction HomeController() {\n  ControllerLayout.apply(this, arguments);\n  this.layout.setGlobalData({\n    title: 'Home'\n  }); \n}\n\nrequire('util').inherits(HomeController, ControllerLayout);\n\nHomeController.prototype.actionIndex = function() {\n  this.layout.setData({\n    body: ViewModel.factory('pages/home').render()\n  });\n};\n````\n\nHere's an example of how to use the default REST controller, for creating an API:\n\n```javascript\nvar ControllerREST = require('../lib/Controller/ControllerREST');\n\nfunction ControllerAPI() {\n  ControllerREST.apply(this, arguments);\n}\n\nrequire('util').inherits(ControllerAPI, ControllerREST);\n\n// GET request (list)\nControllerAPI.prototype.actionIndex = function() {\n  var response = JSON.stringify({\n    hello: 'world'\n  });\n  this.sendResponse(200, 'application/json', response);\n};\n\n// POST request (create)\nControllerAPI.prototype.actionPost = function() {\n  var response = JSON.stringify({\n    hello: 'world'\n  });\n  this.sendResponse(200, 'application/json', response);\n};\n\n// PUT request (update)\nControllerAPI.prototype.actionUpdate = function() {\n  var response = JSON.stringify({\n    hello: 'world'\n  });\n  this.sendResponse(200, 'application/json', response);\n};\n\n// DELETE request (delete)\nControllerAPI.prototype.actionDelete = function() {\n  var response = JSON.stringify({\n    hello: 'world'\n  });\n  this.sendResponse(200, 'application/json', response);\n};\n\nmodule.exports = ControllerAPI;\n```\n\n### ViewModel usage\n\nEvery view should have an associated ViewModel. You should render markup from ViewModels instead of from\nthe views directly.\n\nHere's an example of a basic ViewModel. You need to set the view data using the 'setData' method:\n\n```javascript\nfunction MyViewModel() {\n  ViewModel.apply(this, arguments);\n  this.setData({\n    data: this.getData()\n  });\n}\n\nrequire('util').inherits(MyViewModel, ViewModel);\n\nMyViewModel.prototype.getData = function() {\n  return 'data';\n};\n```\n\n#### Async data retrieval\n\nYou can retrieve data in the ViewModels asyncronously via Q promises.\n\n```javascript\nfunction MyViewModel() {\n  ViewModel.apply(this, arguments);\n  this.setData({\n    people: this.getPeople()\n  });\n}\n\nrequire('util').inherits(MyViewModel, ViewModel);\n\nMyViewModel.prototype.getPeople = function() {\n\n  var deferred = q.defer();\n\n  setTimeout(function() {\n    deferred.resolve([{\n      name: 'Richard',\n      surname: 'Willis'\n    }]);\n  }, 400);\n\n  return deferred.promise;\n};\n```\n\n## Client-side MVC\n\nTODO\n\n## Sublime Text config:\n\nThis is the recommended ST2 user settings:\n\n```javascript\n{\n  \"font_size\": 11,\n  \"tab_size\": 2,\n  \"translate_tabs_to_spaces\": true,\n  \"trim_automatic_white_space\": true,\n  \"trim_trailing_white_space_on_save\": true,\n  \"word_wrap\": false\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbadsyntax%2Fexpress-project-boilerplate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbadsyntax%2Fexpress-project-boilerplate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbadsyntax%2Fexpress-project-boilerplate/lists"}