Latest Node.js Recipes

Nodejs include socket.io in router page

I have an express node app, and I'm trying to keep my code neat by not having all the socket.io stuff in app.js

I don't know the best way to go about this. Here is my initial thought which doesn't feel like the cleanest one

// app.js
var express =...

Read the entire recipe Recipe added 15 minutes ago

Export integer values from Node.js C++ module

I am writing a C++ module for Node.js that wraps a C library, so we can use the C library from JavaScript. One of the functions in the C library takes an enum parameter, with the enum values included in the corresponding header file. I would like to...

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

Post array/object with the Request module

I'm trying to make http post request using the request module

text = 'some data';

request.post('http://example.com/read', {form:{data: text}});

This works fine for a simple string, but I need to be able to send an array or object.

When I try to...

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

add data to pre-existing csv file via nodejs and ya-csv

I was hoping someone could shed some light on this for me... I can't for the life of me work out how to append data using nodejs and ya-csv(module) to a pre-existing csv file. (in this case called staff.csv) If I were to run this script twice the csv...

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

Handling text/plain in Express (via connect)?

I am using Express 3, and would like to handle text/plain POSTs.

Express 3 uses connect's bodyParser now (I think the old Express code got moved to connect). The documentation for bodyParser gives some details about how to make it support additional...

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

Is Node.js compatible with Oracle 11g?

I've searching for this, but I couldn't find anything.

In a university project, we should specify the technologies that we're gonna use for a project given to us, and it's a big project, so we consider to use Oracle and for the server, we consider...

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

How to handle get completed POST request if 100:Continue in Express.js?

I have a relatively large (50K) text file being POSTed:

curl -H "Content-Type:text/plain"  -d @system.log http://localhost:8888/

Testing using a proxy, I can see the full contents of the file are being posted.

However Express.JS sees 100:Continue...

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

What is the "__v" field in MongoDB

I'm using Mongoose version 3 with MongoDB version 2.2. I've noticed a __v field has started appearing in my MongoDB documents. Is it something to do with versioning? How is it used?

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

node.js fork function and passing arguments to child-process

I pass arguments when create chlid-processes

if (cluster.isMaster) {
    for (var i = 0; i < os.cpus().length; i++) {
        var new_worker_env = {};
        new_worker_env["WORKER_NAME"] = "worker" + i;

        var new_worker =...

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

How does the operating system load balance between multiple processes accepting the same socket?

I'm reading the docs of the cluster module in Node.js:
http://nodejs.org/api/cluster.html

It claims the following:

When multiple processes are all accept()ing on the same underlying resource, the operating system load-balances across them very ...

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

Two node.js servers?

I want to run two node.js httpservers on different ports:

var http = require('http');        

var dbserver = http.createServer(function (req, res) {
    res.writeHead(200, {'Content-Type': 'text/html'});
    res.write('<html><body><h2...

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

why array.push doesnt work?

i have this code

function imagenesIn(errU,errores)
    {
        if(errU) throw errU;
        var directorios=new Array();
        var origenDir='';
        var destinoDir='';
        if(errores=='')
        {
            if(campos.img instanceof...

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

Converting Ruby's yield inside of nested functions into Node.js

I'm trying to convert a chunk of Ruby code into Node.js. One particular piece has me stumped, concerning yield. The code goes like this:

each_pair(hash["args"][0]) do |key, value, pair|
   # perform operations
end

...


def each_pair(hash)
   ...

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

Adobe Brackets - debugging Node.js &amp; Node-inspector

Quick question: Is it possible to use Adobe Brackets to debug Node.js using Node-inspector. Like be able to step debug in Adobe Brackets?

Thanks
Regards
Chris

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

using dustjs-linkedin templates in node.js and express3.x

I can't figure out how to use the dustjs-linkedin templates for express 3.x

 #app.js
  var dust = require('dustjs-linkedin');

  app.set('view engine', 'dust');

  app.get('/test1', routes.test1);

#./routes/test.js
exports.test1 = function(req,...

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

need a two page example using dust.js or handlebars.js with express3.x and node

I'm trying to decide on a templating engine to use -- I've seen lots of single page examples with template engines...I'm trying to find a realistic example of handling two different pages but re-using the same basic layout for all pages that can also...

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

dump an object in ejs templates from express3.x views?

I'm using ejs templates with node.js and express 3.x...is it possible to dump a data object passed into view?

Something like this in index.ejs:

<%= dump(session) %>

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

Is socket.io.js supposed to return an empty file?

I trying to make a small chat website using node.js and socket.io. To include the socket.io.js on my client-sided files:

    <script src="192.168.0.108:1337/socket.io/socket.io.js"></script>

But is it normal that it returns an empty file? ...

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

NodeJS - Force users to wait until global event is completed

I have a Node server that does the following:

I have a list of URLs in an external server, call it URLServer. When a user hits my NODE server, my node server makes a request to the URLServer and gets a list of say 20 URLs. As soon as we get those 20...

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

Does an ExtJS application share a session with the rest of an HTML page

I've just recently started working with ExtJS and Node.js, and I'm not quite sure how to handle authentication with this new stack. I'm coming from a Grails + Spring Security Core background, where a web page is built with GSPs and the client...

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

Do object literals block in node.js

Do object literals block? I am trying to store the results of other functions in my pagination helper class and my Mocha tests fail due to timeout because the callback is not returned. If I remove local from all my variables (i.e. local.count to...

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

How to organize a node app that uses sequelize?

I am looking for an example nodejs app that uses the sequelize ORM.

My main concern is that it seems next to impossible to define your models in separate js files if those models have complex relationships to one another because of require()...

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

How to send a temporary chunk of html and js to a running app on node.js

I just got my first app up and running on Node.js. As of now, it is simply serving up a static file. But I have a few ideas that will be implemented down the road so I'm going ahead and getting Node setup so I'll be ready for it when that time...

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

authorizing facebook tab app

I need to develop a facebook app which runs inside a page tab. Only users who have liked this page should be able to use the app (and therefore authorize it).

Using the signed_request parameter it is fairly trivial to know if a given facebook user...

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

not able to use express-validator with express 3.x

I am trying to use the express-validator with express 3.0 and it gives and error when I call

expressValidator = require("express-validator") 
app.use(expressValidator)

req.assert(req.body.password,'Enter Password').notEmpty()
errors =...

Read the entire recipe Recipe added 1 day ago