Latest Node.js Recipes

Where is the default CA certs used in nodejs?

I'm connecting to a server whos cert is signed by my own CA, the ca's cert had installed into system's keychain.

connecting with openssl s_client -connect some.where says Verify return code: 0 (ok)

but i cant connect with nodejs's tls/https module,...

Read the entire recipe Recipe added 46 minutes ago

Node.js forever with environment variable

The command I run on my server to start my node app is:

sudo IS_PROD=1 node app.js

I have forever installed but can't seem to pass in the environment variable.

sudo IS_PROD=1 forever node app.js

Doesn't seem to do the trick. I have tried...

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

Mongoose distinct query with regex and a limit?

I'm running the following code which returns many results. I want to limit the results to the first 10 docs. How can I add a "limit" to the following mongoose query?

var reg = new RegExp('^'+id,'i');

models.examples.distinct('myId', {myId: reg},...

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

Cannot use 'in' operator to search for '_id' in

I'm trying to get an existing user document using mongoose with express but I only get this:

/webroot/api.domain.com/production/node_modules/mongoose/lib/document.js:162
      if (obj && '_id' in obj) continue;
                          ^
TypeError:...

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

yeoman how to set headers (.htaccess?)

Running yeoman server does not seem to recognize the .htaccess file by default. Is there an additional step to enable reading of the .htaccess file?

Here are the lines I have uncommented with no apparent affect in setting headers after...

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

Homebrew install issues

I am having some trouble with brew installs. So I have done the following:

Uninstalled homebrew with:

$ rm -rf /usr/local/Cellar /usr/local/.git && brew cleanup


Reinstalled homebrew with:

$ ruby -e "$(curl -fsSkL...

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

Updating a variable from within a loop or conditional

I'm trying to update a variable that exists outside of a loop from within the loop like this:

var firstRun = true;
console.log("firstRun is " + firstRun);
if(firstRun == true){
    console.log("This is your first run");
    firstRun = false;
}else{
 ...

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

node crypto decipher final fail

So I am using node crypto library to decipher a binary file that is encrypted by some other software which I have no control over. Using the following code, I am able to decrypt it successfully:

decipher = crypto.createDecipheriv('aes-128-ecb',...

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

Object value undefined

I'm having trouble defining values in a way that I can call them later on.

If i define Search first, then Search.commands[3] is undefined. If i define commandList first then commandList.commands[0] is undefined.

Is there a better way to define these...

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

Accessing old model attribute from Mongoose middleware

I have a Category model which it's only property is name.

There is also a SubCategory model which has a name and a category string field containing the name of it's Category model.

When a Category model's name changes, each SubCategory pointing to...

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

How can I configure npm-gyp on Windows to use gcc instead of VC++?

Is there a way to configure npm-gyp to use gcc (as it appears to on Linux) on a Windows box?

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

NodeJS connect to paradox database

Does anyone know if there's any way to connect to a paradox database with node.js on windows ?

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

Mongoose update without callback

I have a typical schema and model:

var mongoose = require('mongoose');

var userSchema = new mongoose.Schema({
    email: String,
    password: String,
    profile: {
        name: String,
        surname: String,
        photo: String
    },
   ...

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

node.js + azure sql database

i'm struggling with the microsoft's node.js sql client.

I've installed it, without any errors using the guide at the github page, and everything works perfect locally. but when i use git to push it to azure, i get the error:

Native sqlserver module...

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

How to secure a static route with Express and Nodejs

I use Node (latest version) + Express, also latest Version. I have 2 folders, public and secured. The secured folder should only be accessible after login.

I've create a login system by myself, now I wonder how I can secure the route to this...

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

jade template helpers in node.js and browser

I use Jade templates both in express app and in the browser. I need to format data before placing it in inputs.

Should I extend locals with alike both in node.js and in browser?

{ formatDate: function(date) {}, ... }

Or are there any best...

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

Node.js Express Framework Security Issues

I'm looking for modules that should be added to a Node/Express app that address the general security concerns listed below:

  • Injection Vulnerabilities (JavaScript, SQL, Mongo, HTML)
  • Session fixation and hijacking
  • Cross-Site Vulnerabilities...

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

Code coverage in unit tests

I am trying to get what lines of code my unit tests do not cover.

I do my unit tests with mocha, which offers a reporter "json-cov" which should report how many lines I didn't execute.

I have two files, the first one (foo.js):

module.exports =...

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

How do I access OpenSSL using Node.js?

I want to use some OpenSSL functionality from Node.js which is not provided using Node's crypto module, e.g. create a CSR.

The only solution I currently have is using a child process to run the openssl command line utility, but this is not the ideal...

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

How can I get an integer from setTimeout in Nodejs?

The documentation on Timers for nodejs says that setTimeout will return a timeoutId http://nodejs.org/api/timers.html#timers_cleartimeout_timeoutid

When I use javascript in a web broswer, then I get an integer as a return value.

var b =...

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

Can I run a private npm repository without replicating the public repository?

I'm writing a number of pieces of code (for internal use) using node.js and want to store the modules (packaged up for npm) in a package repository for each distribution to the various machines they will be installed on.

Ideally, I'd like a solution...

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

Connecting Node.js and openFrameworks

What is the best way to connecting Node.js code and openFrameworks(oF) code? I though zmq would be nice, because it seemed easy to use (has many wrappers), and light and fast. ofxZmq, the zmq addon for openFrameworks, however, just didn't work well....

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

Encode XML string to EXI and send it through a websocket

First of all I am using a client-server architecture, android for the client and node.js for the server, they are connected through Socket.io library, so, they are using websockets.

The doubt that I have is that I am generating a XML string with...

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

Node.js module loading

I am currently building a web app with Node and I am curious as to how Node loads its required files or modules.

I am using express for view and server config, however I am finding that all the Node examples (I know express offers an MVC example)...

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

Webstorm and testacular integration

What is the simplest way to integrate WebStorm and Testacular?

I'm trying the angular-phonecat tutorial from AngularJs official website and until now i wasn't able to make WebStorm start the Testacular server.

And as far as i researched, there's no...

Read the entire recipe Recipe added 1 day ago