I have done considerable reading on both Node.js and Backbone.js; I've read some tutorials and done the relevant courses on Code School. I feel that I've got a pretty good idea of the functions that each technology serves in the context of a web application.
My problem is that I don't really know how to integrate the two technologies and use them in tandem. I would really appreciate if someone could point me to a resource which goes through the entire development of an application using Node, MongoDB, and Backbone together.
Many thanks
This is a good tutorial that shows how to setup that entire stack.
http://backbonetutorials.com/nodejs-restify-mongodb-mongoose/
In short...
Node.js
You can use a library like restify to provide a restful API for your client-side Backbone application. It can also serve your static assets for your Backbone application. The example uses restify, but could be accomplished with other libraries like express.
Mongoose
Mongoose is a javascript abstraction layer for MongoDB. This provides an easy way to interact with MongoDB from Node.js.
Backbone
Your Backbone application can utilize your restify node.js backend to handle the model synchronization. You should have plenty of control to setup the routes via restify in a way that makes Backbone happy.
This ebook could be useful (it's on Backbone, but uses Node for the backend):
http://addyosmani.github.io/backbone-fundamentals/
You also may want to look at this book:
http://www.amazon.com/Building-Node-Applications-MongoDB-Backbone/dp/1449337392
There is also Node Cellar Source.
There is not much explanation about the code, but the app is simple enough to get started and understand the basics layouts of node / backbone
It is, i think, just between an 'Hello World' code and a full app.
I use for ap in backbone yeoman https://github.com/yeoman/generator-backbone and you use it with node.js too
create rest api: http://coenraets.org/blog/2012/10/creating-a-rest-api-using-node-js-express-and-mongodb/
code backbone on the client: http://coenraets.org/blog/2012/10/nodecellar-sample-application-with-backbone-js-twitter-bootstrap-node-js-express-and-mongodb/
the backbonetutorials.com restify one is out of date. It's best to use express, especially if you plan to do any authorization. It's also more widely used
This is a comprehensive tutorial on rolling your own blog with Nodejs, Mongodb and expressjs
http://howtonode.org/express-mongodb
It's old but with a little effort you can get it to work and learn at the same time
I have found this to be the most up to date material on using Backbone.js with node
http://amzn.to/1DygKlJ
Related
I have examined and practiced on creating Rest Api's with loopback and ExpressJS seperately
While Using Loopback;
It was really time consuming to read all the documentation and learning loopback specific stuff
It also enables you to create your Api in a short period of time and has lots of magic things inside it.
I saw that if I face problems while developing with loopback. I usually get stuck in finding answers from community.
While Using ExpressJs
You write almost every api endpoint in same format with lots of copied code.
You are comfortable with it and can do anything with ease.
But time consuming if compared with loopback.
My point is to utilize best parts of both ExpressJs and Loopback
So my question is "Does it make sense to use Loopback with ExpressJs and also use Mongoose?"
Related with my question Loopback has a documentation about adding ExpressJS route in Loopback application. Loopback with Express Route
If it makes sense is there any recommendation for folder structuring ?
As #Jspdown wrote in his comment to your question Loopback is really based on Express, so you don't need to make choice between them.
When you work on your application using Express and produce 'lots of copied code', soon you start to optimize it and in fact develop your own framework. So this is exactly what Loopback team already have done for you.
Thus the choice is not Loopback or Express but it is - to invest into study ready-made framework or to develop your own framework. As for me I think that if you are working on relatively simple projects and/or quick prototypes or going to change your programming tools soon - don't study, just do. But if you are working on large, mission critical system in long-lasting project - Loopback is helpful.
I wrote a REST API in Node.js (with Express)that implements a queue with some dequeue/enqueue functionality, and the next step is creating a web view for that API.
I am really new to javascript and Node.js , can i have some pointers on how to implement it? is there a framework I can use to integrate the api.js i built with a front-end?
When you wrote a REST api using nodejs and the expressjs framework, you are perfectly prepared to use the complete MEAN stack, which implements angularJS for frontend services.
Angular offers a complete REST implementation (called ngResource). Install via npm.
With the angular resource service you get your frontend interface (to interact with your backend) out of the box (except a few adaptations you'll have to make, e.g. to make it work with Mongoose, which is used to make the access to your MongoDB more comfortable).
You'll find a few superb tutorials, as this one and others on scotch.io are some of them. Google for 'api rest angular resource mean ...' in different selections ;-)
Other links that helped me a lot:
Tutorial from Angular itself
Thinkster.io - complete MEAN stack overview with examples
a helpful tutorial with good examples from Frederik Dietz
Buecheler comes out with this great tutorial, but its more about the backend side - as you might check your code againt the basic standards of a REST backend implementation.
Those are some of the links I noted and that could find ad hoc.
EDIT:
As your headline suggests you are searching for an UI, I suppose IBM Strongloop might be a good hint for you. IBM is strongly interconnected with the development of ExpressJS and offers this API and UI for probably all data concerning questions of your Webapp.
I want to preface this with saying that I really like sails.js for a simple MVC framework, but feel that it lacks in its documentation and api reference.
I searched all over to try and find any information on a good mssql (SQL server) adapter for Sails.js, but cannot find one. I am hoping someone has come across one, and could recommend it. I also looked into building a custom adapter, but found the documentation to not be helpful. Any help on this topic would be greatly appreciated. Thank you.
We don't currently have a MS SQL Server adapter but it's something I'd love to add. There is a basic definition of the various interfaces and how adapters are created at: API Adapter Interface.
If anyone would like to tackle this you can use the Sails MySQL Adapter or the Sails PostgreSQL Adapter as examples.
I don't have access to a MS SQL Server to build one out but there is an Integration Test library I use to build out adapters that support the CRUD interface: Waterline Adapter Tests.
I have recently started building a sails adapter for MSSQL based on the node-sqlserver module.
It isn't finished yet but I have finished the main parts of the adapter and it still needs testing, but there is enough there to get going.
It can be found at https://github.com/swelham/sails-mssql
There is now: https://github.com/cnect/sails-sqlserver
Complete with sails 0.10 associations support, and fully unit tested against the Waterline spec:
Technically since Sails is base on express.js you could use custom express middleware to specify the use of your an adapter that has already been created.
The first one is the top rated adapter
checkout https://nodejsmodules.org/tags/mysql
Otherwise you can just use the waterline ORM and the MySQL adapter that is provided for sails.js
https://github.com/balderdashy/sails-mysql
For documentation on how to use waterline models checkout the 0.9x docuemntation
http://sailsjs.org/#!documentation/models
sails-mssql is working fine for me on 0.10.x, here's a gist of how to configure it, using sails-mssql 0.10.x
https://gist.github.com/hybrisCole/868f979d8d129247a2da
my package.json has this:
"sails-mssql": "git://github.com/jaredfromsubway/sails-mssql.git#master",
Sails-sql is currently the latest adapter for MySQL/MSSQL (eventually PostgreSQL as well). It's currently safe, fine-tuned, and upgraded for use in production with MySQL and MSSQL. Most developments are primarily pending for PostgreSQL at the moment.
Another current option is https://www.npmjs.com/package/sails-mssql (https://github.com/intel/sails-mssql).
I have built several Backbone apps and appreciate the client-side code structure and organization. I'm moving into Node development, using Express, and I'm uncertain as to how Express and Backbone can work together in the handling of routes.
You need to understand that Node and Backbone are independent from each other.
Node is for server-side (e.g working with a database, api serving etc. ) .
Backbone is a client-side Javascript MVC framework which gives you a structure for organizing your client-side Javascript application. (the application in the browser)
You can have a Backbone application in your client-side and it can hook up to any back-end either Node, Rails, PHP etc...
For more info check MVVM pattern and Javascript frameworks on the client-side.
http://backbonetutorials.com/why-would-you-use-backbone/
http://addyosmani.com/blog/understanding-mvvm-a-guide-for-javascript-developers/
A friend gave me the answer:
Backbone uses hash routes. For instance http://yoursite.com/#foo
Express will use the traditional http://yoursite.com/foo
You can use the routers independent of one another based one which address you path to - a hash route for client-side functions and the traditional route for server side functionality.
Both routers can coexist.
Your question on how Backbone and Express can work together cannot really be answered precisely, because there are really countless ways on which they can work together. Hopefully some of the info below can help you do what you want to do.
First of all, you can use www.example.com/foo (no #) routes on the client side (Backbone) - see the pushState option in Backbone.history.start() documentation. It is possible to integrate the routes on the client side and on the server side. It is not easy to find exactly how to do, though.
Some of the info under those links may help you:
https://github.com/developmentseed/bones
https://github.com/SC5/backbone-serverside
https://github.com/tysoncadenhead/backbone-on-express
http://nerds.airbnb.com/weve-launched-our-first-nodejs-app-to-product
http://blog.andyet.com/2011/feb/15/re-using-backbonejs-models-on-the-server-with-node/
You wrote that you have experience with Backbone but you're moving to Node recently so I assume that you are open to other frameworks than only Express. You may consider using eg. restify (in addition to Express) to make a RESTful service which you can integrate with Backbone.
There are also entire frameworks like Derby or Meteor that cover both client side and server side using one code base and you can share much more than just the routers.
(Also, I've just found this year's (2013) HTML5DevConf talk: Surviving Robots and Old Browsers by Server-side Backbone. I haven't watched it yet but it seems very relevant to your problem.)
I plan to write a rather large-scale web application using JavaScript. I believe I will be developing the webapp using CanJS to organize my client-side pieces.
I am strongly considering using Node.js for my server-side component, but I was wondering what the best way to set up Node to accept and handle REST requests. I did some Googling and came across something called Express. Any comments on this?
Any help/suggestions would be greatly appreciated.
restify is a node.js module built specifically to enable you to build correct REST web services.
http://mcavage.github.com/node-restify/
Express is more directed towards full web application (rendering HTML, etc). Restify is just for web services.
Besides, the guy who created Restify works at Joyent, the company where Ryan Dahl developped Node.js (which is kind of guarantee quality).
For REST request handling, express-resource is a more focused solution than railwayjs that's also built on top of expressjs.
You can try http://railwayjs.com/ it is build on top of http://expressjs.com/
Express is nice and fast :) railway has similar stack to ruby on rails.
http://expressjs.com is the de factor standard, does Sinatra-like routing. If you want real easy automatic generation of resources (sort of Rails-style), try one of those libraries above.
If you want it real simple on top of express, try http://github.com/deitch/booster
Disclosure: I just released Booster this week.