Code Monkey home page Code Monkey logo

backbone-requirejs-node-boilerplate's Introduction

##Sharing RequireJS modules

This example shows how to reuse code between the client and server. A typical use case would be to use the same validation logic for your models on both sides.

Feel free to use it as a basic template for your applications.

##Project structure This backbone application is divided into a couple of AMD modules. A special shared module is used inside the node.js server. It is possible to test all modules using mocha and expect.js. (Examples included)

The Backbone app is inside the 'client' folder. The server is inside the 'server' folder (obviously...). Any module which should be shared between client and server is in the 'shared' folder and has to start with the amdefine wrapper. The minified client app is in the 'client-build' folder. This folder gets deleted on every build.

##Usage The following steps were tested with the following environment:

MacOS 10.8.2
Node.js 0.8.14
npm 1.1.65

Check out this git repository:

$ git clone [email protected]:NilsLattek/backbone-requirejs-node-boilerplate.git

Remove git history if you want to use this example as a template for your project:

$ cd backbone-requirejs-node-boilerplate
$ rm -rf .git

Install node.js if you haven't already: http://nodejs.org/

Install npm (should already be installed if you are using the latest node setup):

$ curl http://npmjs.org/install.sh | sh

Install node packages for the node.js server:

$ npm install .

Start the development server and navigate to 'http://localhost:8000':

$ node server/server.js

Or use nodemon for watching your server files and automatically restart the server:

$ npm install -g nodemon
$ nodemon server/server.js

Run unittests:

$ make test

Build (concatenate and minify) everything using r.js:

$ cd bin
$ ./build.sh

Start production environment (node will use the client-build folder with the minifed client app):

$ NODE_ENV=production node server/server.js

###Roadmap

  • Provide a coffeescript version
  • Add strict mode: "use strict";

###License MIT license (of course).

backbone-requirejs-node-boilerplate's People

Contributors

nilslattek avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.