Git Product home page Git Product logo

node-rest-backbone's Introduction

node-rest-backbone

Starter template for Node.js app, using Backbone.js and Bootstrap on the client, local and 3d party OAUTH authentication, RESTful services for integration with the Backbone.js client, and Socket.io for pushing updates to the client.

TODO:

Basic signup/login with a local account and/or a variety of OAUTH providers works. Still much to do including:

  • remember me
  • profile view/edit
  • show/hide alerts
  • graphics for provider login/signup buttons (Github, Google, etc.)
  • error handling
  • test cases
  • sample REST client
  • sample Socket.io connection
  • cleanup this README :-)

Deploying

Get the code:

$ git clone

Update the modules:

$ npm install

Run the app:

$ node app

Open in a browser:

$ http://localhost:3000

Directory Structure

Client based on Backbone.js and Bootstrap

  • /public/css: Stylesheets
  • /public/img: Images
  • /public/js: Client-side javascript
  • /public/lib: Client-side 3rd party modules

Server running on Node.js and mongodb

  • /lib: Custom libraries
  • /models: Mongoose schema
  • /routes: Routes to site pages and REST services
  • /vendor: Server-side 3rd party modules
  • /views: Site page templates

Unit tests

  • /spec: Functional tests
  • /test: Unit tests

How it Works

Node runs app.js, which sets up the server with models, routes, sockets, and views. In addition to serving simple page templates and the single-page Backbone.js client, the server implements RESTful Web services and a listens for WebSocket connections from clients.

Configuration

Environment specific configuration parameters are stored in JSON files located in the config directory. Look at config/default.json.example.

Security

The Backbone.js client will authenticate a user's credentials with the server and establish a session key to authorize subsequent REST requests and WebSocket connections.

OAuth2 (2-legged) for REST services.

Error Handling

A) detect errors by receiving them as parameters to your callback functions. For example:

doSomethingAndRunCallback(function(err) { if(err) { … } });

B) report errors in MIDDLEWARE by calling next(err). Example:

handleRequest(req, res, next) { // an error occurs… next(err); }

C) report errors in ROUTES by calling next(err). Example:

app.get('/home', function(req, res, next){ // an error occurs next(err); });

D) Any middleware that has a length of 4 (4 arguments) is considered error middleware. When one calls next(err) connect goes and calls error based middleware.

app.use(function(err, req, res, next) { // only handle next(err) calls });

License

(The MIT License)

Copyright (c) 2012, The Hackerati, Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

node-rest-backbone's People

Contributors

geoffscott avatar

Watchers

 avatar  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.