An entire website with node.js and mongodb?


Question

I've build several websites using PHP and mySQL as backend, and believe that I'm fairly familiar with both. However during research for my new website I've come across node.js and mongodb (and socket.io, since the site is gonna contain a chat).

I've decided to use node.js and mongodb to run the chat - but don't know if I should just do the entire site with those two things? Since I'm gonna run a node server anyway should I just run another (seperate) one hosting the website? Or is that an bad idea? - is it stable? I could do the programming in PHP and still be using mongodb - but wouldn't node be way faster?

And another question: I've planned to use ajax to handle all the posts to the page - but since I'm allready using socket.io to the chat - should I do all my post request using that? For the ajax I've planned to use jQuery (also for all frontend effects).

1
30
1/17/2012 1:41:33 PM

Accepted Answer

don't know if I should just do the entire site with those two things?

If you want to learn node.js then there is nothing better than coding it.

Since I'm gonna run a node server anyway should I just run another (seperate) one hosting the website?

You can use existing server and run your node.js app on other free port(o). I think for learning node you don't need to have dedicated machine.

is it stable?

Even versions of node.js are stable releases, however until there is 1.0 with feature freeze there could be breaking changes to its API.

I could do the programming in PHP and still be using mongodb - but wouldn't node be way faster?

It most probably (and definitely) would.

I've planned to use ajax to handle all the posts to the page - but since I'm allready using socket.io to the chat - should I do all my post request using that?

I would recommend stick to MVC model and use express since you can get into lot of time consuming troubles if you would use socket.io for classic stuff. Socket.io is namely for real-time functionality and things related to that.

15
4/17/2012 12:18:32 AM

There are already some solid web frameworks for node.js, in particular check out Express. Here's a really good article outlining some lessons and experiences from building a node.js website:

What it’s like building a real website in Node.js

Regarding your second question, it's probably still best to use AJAX handlers and HTTP with jQuery. I'm not sure that jQuery supports callbacks over raw TCP sockets.


Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon