Blog Archives

Jade Tags ?

Tweet Any text at the beginning of a line—by default—is interpreted as an HTML tag. The main advantage of Jade is that this text renders both closing and opening tags for the HTML element, as well as the symbols. Therefore,

Posted in Jade Tagged with:

Middleware

Tweet we have used existing middleware (body-parser, cookie-parser, static, and connect-session, to name a few), and we’ve even written some of our own (when we check for the presence of &test=1 in the querystring, and our 404 handler). But what

Posted in Express, Node.Js Tagged with: ,

Developing template engines for Express

Tweet To develop template engines for Express ,Use the app.engine(ext, callback) method to create your own template engine. ext refers to the file extension, callback is the template engine function which accepts the location of the file, the options object,

Posted in Express, Node.Js Tagged with: ,

Response Object ?

Tweet The response object (which is normally passed to a callback, meaning you can name it whatever you want: it is common to name it res, resp, or response) starts its life as an instance of http.ServerResponse, a core Node

Posted in Express, Node.Js

Request Object ?

Tweet The Request Object The request object (which is normally passed to a callback, meaning you can name it whatever you want: it is common to name it req or request) starts its life as an instance of http.IncomingMessage, a

Posted in Express, Node.Js Tagged with: ,

Cluster ?

Tweet A single instance of Node runs in a single thread. To take advantage of multi-core systems the user will sometimes want to launch a cluster of Node processes to handle the load. The cluster module allows you to easily

Posted in Node.Js Tagged with:

Return the response from ajax call ?

Tweet Return the response from ajax call ? : The A in AJAX stands for asynchronous. That means sending the request (or rather receiving the response) is taken out of the normal execution flow. Synchronous : Imagine you make a

Posted in Snippets

HOISTING in JavaScript

Tweet HOISTING in JavaScript :All JavaScript variables are hoist at the top of the scope (function) in which they are defined. To understand it consider the code snippet shows below, var foo = "foo"; console.log(foo); Above code will print foo

Posted in Javascript

Express JS to Deliver HTML Files (1)

Tweet How to load and “display” a basic HTML file : There are many ways to simply send the html file using the node’s core api of using the readfile,but the easy way to do is using the Express Framework

Posted in Express, Node.Js

Convert String into MongoDB BsonDocument

Tweet If you have a long string in JSON format, and you want to convert it into a BSONDocument for insertion into a MongoDB database.You can simply do it by defining the query as string json = "{ 'foo' :

Posted in MongoDB, Snippets