Latest Node.js Recipes

Looking for Transactions Manager on NodeJS + Redis (or other NoSQL)

I'm looking for some kind of ready system, solution, or advices how to code the system on backend by myself.

Requirements:

  1. There are simple "atomic operations". Each atomic operation has an ID.
  2. Each atomic operation has a callback function which...

Read the entire recipe Recipe added 43 minutes ago

Transfer UDP socket in node.js from Application to HTTP

Is it possible to transfer a Socket coming from a application to http via NodeJS?

I send my socket with a application (in c++) in UDP or TCP(if impossible in UDP...) to NodeJS.

My script from NodeJS:

var server = dgram.createSocket("udp4");...

Read the entire recipe Recipe added 1 hour, 41 minutes ago

How do I catch node.js/express server errors like EADDRINUSE?

This is my code (It's coffeescript and uses colors but that's not relevant)

# If this module is executed
if !module.parent
    # Start server
    try
        hons_server.listen config.port
        console.log 'Listening to port ' + config.port
   ...

Read the entire recipe Recipe added 2 hours, 48 minutes ago

Does underscore's extend function extend recursively (or have the option of doing so)?

jQuery's extend function has the option of recursive extension, which I use when creating json config files. I can see that underscore has an extend function, but it doesn't even mention recursion. I assume this means it doesn't recursively extend,...

Read the entire recipe Recipe added 3 hours, 41 minutes ago

How is request processing with rails, redis, and node.js asynchronous?

For web development I'd like to mix rails and node.js since I want to get the best out of both worlds (rails for fast web development and node for concurrency). I know that some people choose to just use full ruby stack with eventmachine that is...

Read the entire recipe Recipe added 4 hours, 47 minutes ago

npm install forked git with submodule

I'm trying to get npm to install node-gitteh as a dependency via npm install which reads from package.json. Unfortunately this npm package is broken in node 0.6.x, but no problem as there's a forked repo that fixes the issues...

Read the entire recipe Recipe added 5 hours, 43 minutes ago

Specify node.js named-module path

I'm new to node.js - so I think my question is best asked with an example:

The Connect framework requires the mime module - and loads is as such: require('mime')

If I wanted to make this a local module (i.e. I've placed the mime module within my...

Read the entire recipe Recipe added 6 hours, 42 minutes ago

Node.js: Is there a synchronous version of the `http.get` method in node.js?

Is there a synchronous version of the http.get method in node.js?

Something like:

http.getSync({
    host: 'google.com', 
    port: 80, 
    path: '/'
}, function(response){  

});

console.log(response)

Sometimes it would be very useful.

Read the entire recipe Recipe added 7 hours, 42 minutes ago

Show progress on node.js child_process.exec?

I recently asked/accepted an answer to a question I had earlier: How can I replicate the functionality of a wget with nodejs.

Now, my script is functioning perfectly, but I'd like to be able to show the user the percentage that's downloaded. I'm not...

Read the entire recipe Recipe added 8 hours, 43 minutes ago

How can I replicate the functionality of a wget with node.js?

Is it possible to essentially run a wget from within a node.js app? I'd like to have a script that crawls a site, and downloads a specific file, but the href of the link that goes the file changes fairly often. So, I figured the easiest way to go...

Read the entire recipe Recipe added 9 hours, 43 minutes ago

nodejs - How to read and output jpg image?

I've been trying to find an example of how to read a jpeg image and then show the image.

var http = require('http'), fs = require('fs');

http.createServer(function (req, res) {
    res.writeHead(200, {'Content-Type':...

Read the entire recipe Recipe added 10 hours, 42 minutes ago

Changed LESS-files not automatically recompiling in node/express/coffee setup

After finally getting LESS-compiling into a Node.js app with express running on coffee, I ran into a problem where I seem to be running out of ideas:

Changes to the LESS-files will not invoke re-rendering from the LESS-compiler called by express.

In...

Read the entire recipe Recipe added 11 hours, 48 minutes ago

npm 'connect' version

I'm unable to install "connect" package with npm. npm says that the latest valid version is 1.0.1 but on npm server it's 2.0.1

npm version is 1.1.4 and node is 0.7.6pre

npm install connect@'>=2.0.1'
npm http GET...

Read the entire recipe Recipe added 12 hours, 43 minutes ago

Node.Js + Socket.IO vs SignalR vs C# WebSocket Server

I currently have a TCP server application written in .Net that receives and submits messages to clients. I am looking at building a web application so need the communication layer.

I have built a Node.JS + Socket.IO app which connects to my TCP...

Read the entire recipe Recipe added 13 hours, 47 minutes ago

Get a cookie with nodejs

I am doing a Rest call in nodejs to get a report from JasperSoft Server. And I need to get a cookie to stay connected but I don't know how to do get it

var http = require('http');
var options = {
  host: '127.0.0.1',
  port: 8080,
  path:...

Read the entire recipe Recipe added 14 hours, 47 minutes ago

cloudfoundry: how to use filesystem

I am planning to use cloudfoundry paas service (from VMWare) for hosting my node.js application. I have seen that it has support for mongo and redis in the service layer and node.js framework. So far so good.

Now I need to store my mediafiles(images...

Read the entire recipe Recipe added 15 hours, 47 minutes ago

jade not executing javascript functions

I have this jade file

- if (transactions != "")
    table
        th Site Name
        th Deadline
        th Delete Transaction

        each item in transactions
            tr
                td= item.item_name
                td
                 ...

Read the entire recipe Recipe added 16 hours, 44 minutes ago

How do I store persistent data with xhr-polling in Socket.IO?

I'm writing a multi-room chat app with Node.js and Socket.IO and I'm wondering how to handle data that needs to persist for the duration of a session, when the transport is xhr-polling.

Currently, on the client I'm sending a "join" event on...

Read the entire recipe Recipe added 17 hours, 48 minutes ago

Jade template rendering tags without order

I have this jade file:

- if (transactions != undefined)
    table
        th Site Name
        th Deadline
        th Delete Transaction

        each item in transactions
            tr
                td= item.item_name
                td
         ...

Read the entire recipe Recipe added 18 hours, 42 minutes ago

Creating query(join) or correct the design?

I am having problem with building up some simple queries with this design. The problem is simple I want get the posts with included user information, which should be all in one array so i can pass it to the express view.

Simple and for me it seems...

Read the entire recipe Recipe added 19 hours, 48 minutes ago

Nodejs and Sphinx data query issue

I have been using limestone module and Nodejs to query sphinx index. The limestone is out-dated in my npm so i downloaded from github and it is got connected to the sphinx server successfully. But i am now facing the issue as follows,

When i tried to...

Read the entire recipe Recipe added 20 hours, 42 minutes ago

how to include external models in mongoose?

i have a problem when i want to include my models with mongoose in nodejs, i'm create a models with schema like this

var mongoose = require('mongoose')
  , Schema = mongoose.Schema;

var Users = new Schema({
    idUser  : {type:String},
   ...

Read the entire recipe Recipe added 21 hours, 48 minutes ago

net.Socket.writable, net.Socket.readable properties aren't part of the official node.js API

I wonder why are net.Socket.writable and net.Socket.readable properties not part of the official node.js API? Does it mean that it's better not to use these properties since it's an internal stuff which can change in the future?

Read the entire recipe Recipe added 22 hours, 41 minutes ago

How to avoid create a new socket connection in socket.io after html page refresh?

I have tried socket.io, I found when client html page load, a new socket connection created.When I refresh the page, I found a new socket connection create, and then the old connection disconnect.

My problem is how to avoid this? Because I am...

Read the entire recipe Recipe added 23 hours, 46 minutes ago

socket.io client namespace authorization

Node.js seems to have a knack for acquiring useful modules with insufficient or no documentation. socket.io is one such module. I would like to use the built-in authorization feature, for namespaces, but I don't know how that would work, on the...

Read the entire recipe Recipe added 1 day ago