Can trunk and express routers work together in an Express application?

I have created several basic applications and appreciate the structure and organization of the code on the client side. I am moving on to developing Node using Express, and I'm not sure how Express and Backbone can work together when processing routes.

+6
source share
3 answers

You need to understand that Node and Backbone are independent of each other.

  • Node for the server side (for example, working with a database, api service, etc.).
  • Backbone is a Javascript MVC client environment that provides you with a framework for organizing your client Javascript application. (application in browser)

You can have a Backbone application on your client side, and it can connect to any server like Node, Rails, PHP, etc.

For more information, check out the MVVM framework and client-side Javascript frameworks.

http://backbonetutorials.com/why-would-you-use-backbone/

http://addyosmani.com/blog/understanding-mvvm-a-guide-for-javascript-developers/

+3
source

A friend gave me the answer:

The backbone network uses hash routes. For example http://yoursite.com/#foo

Express will use the traditional http://yoursite.com/foo

You can use independent routers based on one of them that guides you along the way - a hash route for client functions and a traditional route for server-side functions.

Both routers can coexist.

+2
source

Your question about how to work with Backbone and Express cannot be answered precisely because there are many ways in which they can work together. Hope some of the information below will help you do what you want to do.

First of all, you can use the routes www.example.com/foo (no #) on the client side (Backbone) - see the pushState parameter in Backbone.history.start () . You can integrate routes on the client side and on the server side. However, it is not easy to find how to do this.

Some information on these links may help you:

You wrote that you have experience with Backbone, but now you are switching to Node, so I assume that you are open to other frameworks than Express. You can use for example. restify (in addition to Express) to make a RESTful service that you can integrate with Backbone.

There are also whole structures, such as Derby or Meteor , that span both the client and server sides using a single code base, and you can share much more than just routers.

(In addition, I just found HTML5DevConf talk this year (2013): Surviving robots and old browsers using the server backbone . Have not watched it yet, but it seems very relevant for your problem.)

+1
source

All Articles