background preloader

Learn

Facebook Twitter

Token-based Authentication with Socket.IO. Introduction Authentication in realtime frameworks can be challenging.

Token-based Authentication with Socket.IO

Perhaps this is because the way these systems work is quite different from a regular web app. The risk of not correctly authenticating your sockets traffic is that you could end up sniffing information on other users streams. The socket server will not automagically know about the logged-in user, thus anyone could join any stream. This first diagram shows this common misconception: It is a common misconception that a user who is authenticated in the hosting web appliction, is also authenticated in the socket stream. Cookie-based and Token-based Auth There are two ways of solving this problem: the traditional cookie-based approach or a token-based approach. In our previous article, we wrote about the benefits of a token-based architecture: Cookies vs Tokens. Coupling: the first issue when using cookies is that you have to couple the web application authentication mechanism with the socket server authentication.

Node.js - Implementing passport-http-bearer token with sails.js. Passport authentication for Sails.js 0.9.x. Sails-social-auth-example/config/middleware.js at master · stefanbuck/sails-social-auth-example. Introduction to Sails.js. Sails is a Javascript framework designed to resemble the MVC architecture from frameworks like Ruby on Rails.

Introduction to Sails.js

It makes the process of building Node.js apps easier, especially APIs, single page apps and realtime features, like chat. To install Sails, it is quite simple. The prerequisites are to have Node.js installed and also npm, which comes with Node. Then one must issue the following command in the terminal: In order to create a new Sails project, the following command is used: Sails will generate a new folder named myNewProject and add all the necessary files to have a basic application built. Sails's default port is 1337, so if you visit you should get the Sails default index.html page. Now, let's have a look at what Sails generated for us. The assets folder contains subdirectories for the Javascript and CSS files that should be loaded during runtime. Contains the files that are publicly available, such as pictures your site uses, the favicon, etc. There are mainly four types of views:

A Node.JS Holiday Season Articles. Using Node.js and Websockets to Build a Chat Service. Node.js and Websockets are the perfect combination to write very fast, lag free applications which can send data to a huge number of clients.

Using Node.js and Websockets to Build a Chat Service

So why don't we start learning about these two topics by building a chat service! Distributed Applications and Node.js. This moth, I gave a talk about distributed applications and Node.js, thanks to Node.js Argentina, at Microsoft User Group de Argentina, Buenos Aires.

Distributed Applications and Node.js

You can see and download my presentation from my Skydrive. Breaking down app.js file. A working draft of the app architecture is in progress, visit the boilerplate wiki Ok, this post is long overdue!

Breaking down app.js file

Tl;dr : This blog post explains how to structure and organize your node.js application. Its an anatomy of nodejs-express-demo app The demo app illustrates the following MVC architecture using expressCustom error handling in expressRouting in expressCRUD operations using mongoose ODMdbref and populate using mongoose ODMuse of flash variables (displaying messaages like "updated successfully" etc)dynamic helpersuser authentication using facebookvalidationsembedded documents in mongooseroute middlewares in expressusing of middlewares in mongoosedeployment on herokuManaging multiple environments (development, staging and production)and many more...

DIY node.js server on Amazon EC2. I’m involved with a project where our ruby/rails developer dropped out, so I decided to take on the job using node.js (rather than learn rails).

DIY node.js server on Amazon EC2

We initially were using services from dotCloud, but it was too flakey from day to day and our demo was coming up. For hosting, Amazon’s EC2 was the obvious candidate, but I’d have to setup and provision the entire server from scratch. This is that story Here’s what we’ll do choose a Linux imagecreate a HelloWorld node.js serveruse git to push code changes to the serverautomatically restart node after pushing with gitset up node to run long term using supervisor Setup a New EC2 Instance launch a new Ubuntu instance First things first, login to your AWS console and launch a new Ubuntu Linux image for your new EC2 server. Essential Node.js patterns and snippets. In this post, I take a look at the different patterns that you need to know when using Node.js.

Essential Node.js patterns and snippets

These came from my own coding and from a look at the code behind Tim Caswell’s flow control libraries. I think it is necessary to know how these basic patterns are implemented even if you use a library.. 1.1 Class pattern If the class is long, then instead of doing a single Class.prototype = {…} assignment, it may be split into multiple Class.prototype.method = function () {..} assignments. Reminder: Assign all your properties some value in your constructor. Node.JS от А до Я. The Node Beginner Book » A comprehensive Node.js tutorial. Node.js Best Practice Exception Handling. Построение полноценного MVC веб-сайта на ExpressJS.

NB: Это материал для тех, кто уже ознакомился с теоретической основой node.js и хочет, как говорится, с места в карьер — поскорей окунуться в разработку с применением этого инструмента.

Построение полноценного MVC веб-сайта на ExpressJS

Никакой дедукции, only coding. Если заинтересовало, не стесняемся, проходим под кат. От переводчика: Я сам начал изучать node.js совсем недавно. Несомненно, в интернете есть много хороших(!) Мануалов для новичков, в частности и здесь, на хабре (например тут и тут). Перевод В этой статье мы будем строить полноценный веб-сайт с клиентской частью, а также панелью управления содержанием сайта. Вступление. Getting Started with Node.js on Heroku. Node Table of Contents This quickstart will get you going with Node.js and the Express web framework, deployed to Heroku.

Getting Started with Node.js on Heroku

For general information on how to develop and architect apps for use on Heroku, see Architecting Applications for Heroku. Prerequisites If you’re new to Heroku or Node.js development, you’ll need to set up a few things first: NowJS and Node.js Tutorial – Creating a multi room chat client. Node.js is a server side environment for Javascript.

NowJS and Node.js Tutorial – Creating a multi room chat client

NowJS is a framework built on top of Node.js that connects the client side and server side Javascript effortlessly. The core of NowJS functionality lies in the now object.The now object is special because it exists on the server and the client.This means variables you set in the now object are automatically synced between client and server. Also server functions can be directly called on the client and client functions can be called directly from the server.All in realtime. Develop a RESTful API Using Node.js With Express and Mongoose...