Node.JS Working Techniques - node.js

I am very curious about how node.js works. I have downloaded node.js but I have no idea how to use it. Does node.js work with XAMPP and MYSQL?

Node.js is itslf act as the XAMPP server,Its a platform not the language. You have to write code in JS and run that code on NOde server.
You can can use MYSQL,MongoDB, etc.. with node code as a DB.
Before jumping to Node.js try basic JS scripting and learn what is missing in normal JS then get your hands dirty with Node.js
Start with learning : non blocking IO model, event loop and higer odder functions.
watch this video for better understanding.
Best of luck!
Keep posting Questions :)

Related

I am using Node.js, express, Angular, Postgresql on Windows. What is the best way to mirror and code updates between servers?

I am using Node.js, express, Angular, Postgresql on Windows. What is the best way to mirror and code updates between servers? I have read about rsync. Any other ones out there for the most recent js technologies?
The delivery/deployment/backup of your code is agnostic to the code itself. Therefore a deployment method for "recent js technologies" is nonsensical. I suggest you familiarize yourself with Git as it is the industry standard. It acts a little bit like Dropbox for your code.
Check out this tutorial to quickly get a sense of what git is. https://try.github.io/levels/1/challenges/1
After that, read the official doc to understand how it works under the hood, it'll be easier to deal with issues later if you understand the ins and outs of the tech. https://git-scm.com/doc

Can expressjs be learnt without learning nodejs

I've background in java swing programming with basic working knowledge of spring, javascript, angularjs, http.
I want to learn web server side programming using express js. Will i need to first learn nodejs and then be able to use expressjs or starting express js directly will be possible?
I'm planning on creating rest apis using express and then consuming them with angular js.
I will like to answer this question based on your past experience. Can you learn Java Swing framework without learning Java? No you can't. because you should understand concepts of Java to best use the Swing package. Similarly, you should understand the concepts of Javascript and Node.js to best understand Express Framework.
I would suggest you to start with a small project of setting up a server using express and node.js. And dig deep into node concepts whereever you face problems.

How to connect to Mysql database on XAMPP in AppJS

I am on Linux 32-bit machine and using AppJS for developing desktop application.
After searching for a while,I can't find a way to connect to my Mysql database on XAMPP.
Is it possible to connect or I am wasting my time searching?
Please help.
From this discussion, it seems like you can use available libraries for node to do this. Like node-mysql.
Also I think you should look into this issue.
Quote:
deskshell is the next generation of appjs. Appjs merges nodejs and
chromium's event loop. This is awesome but it means that a long
running nodejs operation will stop animations in the browser and it
means lots of other unexpected side effects. Solution is to run 2
separate binaries (nodejs and chromium) and connect them together
using the chrome remote debugging protocol. Deskshell therefore is
built in javascript rather than C++ and this makes it much more
hackable and quicker to develop. Appjs will be able to be used by
deskshell instead of chromium as the "browser" part of the application
in the future.
But I strongly suggest you look into node-webkit. It is used by apps like Popcorn-Time.

Node.js and socket.io confusion

I so often see titles like "Node.JS + socket.io tutorials." Even in the Node.js Beginner book I've purchased, it tells me to download socket.io so I'm getting really confused.
What's the difference between them? Why can't I code my applications just with Node.JS "OR" Socket.io? If I can code, why do people socket.io plus node.js in titles?
I'm really confused so any kind of replies would be appreciated.
node.js is a platform.
socket.io is just a framework for dealing with websockets if your are building an app on top of node.js.
socket.io needs node.js but node.js does not need socket.io
EDIT: Ryan Dahl's (node.js's creator) intro video is really instructive and helps with this kind of confusion: http://www.youtube.com/watch?v=jo_B4LTHi3I
Socket.io is a framework on node.js for realtime applications. So, both is required if you want to use socket.io. You can code your own to do the same thing but socket.io is cross-browser and by using it can help you save time.
socket.io is a library, addition to actual platform which is node.js.
It is like a software to computer. You can't use software without computer.
Node.js - is platform, that takes care about language - JavaScript visualization using V8 (JavaScript Engine that interpret JS script to understandable form to the computer). And lots of other components of platform.
While socket.io is just using features of platform, implements some cool own features that are addition to node. It is just a library, addition that you use along with the core.
In real world its like hoover - is a node.js, and nozzle is socket.io. Of course it is rough example, and things are much more complicated. But as you can see, nozzle is pointless without core.
Node.js makes your JavaScript running using own features. While socket.io is something you use or not - by your choice.
I am also learning nitt- griities of nodejs , socket.io , express etc . What I have understood so far is that Nodejs is the big backbone of hosting the entire project ( could be both on client and server's end ) with the node command like > node servercode.js etc . It can open ports for websockets server , Http server even https server .
However socketio provides the communication link between the client and server side in an asynchronous event driven manner ( think ajax ) .
Hope it helped

An entire website with node.js and mongodb?

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).
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.
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.
node.js + express + jade + stylus + jQuery is my preferred environment.
Using forever to auto restart the server I've never had any real up-time issues even when I have bugs crashing the server on a regular basis.
As for socket.io + jQuery, they do get along fine, but it's just not as natural as the express + jQuery combo. I'd stick to making ajax calls for most things.
Node.JS can still be a little wild west like, but its improving. It is a very different model from coding in php, but it is very well suited for a lot of websites. You'll probably want to do the thin server (expose a REST API and your websocket endpoints) with a fatter client using something like BackBone.js to keep interactions clean.
The big win from doing the whole thing in node is that you will not have duplication of code between php and js for dealing with the DB or any other services required by both. Node.JS is also fantastic at handling tons and tons of concurrent requests.
Good Luck

Resources