Tag: node.js

NodeJS 'assert' test fails for json object returned through the express http response

Having recently developed an interest in NodeJS, I finally managed to get my hands on a NodeJS book. A simple example on the book was to create an express server and write a test to verify a simple API exposed as part of the exercise. Please refer to the following code (I am using node […]

node.js + socket.io + express.js: No connection

I’ve been trying to set up a simple socket.io example, but it refuses to work properly. The client runs on Apache2 and should access the node.js-server via the port 3000. There doesn’t seem to be any connection and it doesn’t seem to matter whether the server’s actually running – if the node.js-process is manually stopped […]

Template engine for node.js

I would like to know the best template engine for node.js. Currently I’m using jade engine with node.js. The confusion arise after reading this https://github.com/baryshev/template-benchmark Please suggest me the best Thanks.

mongoose .find() method returns object with unwanted properties

so, I’ve been working with mongoose for some time and I found some really weird stuff going on. It would be great if someone could enlighten me. The thing is, when using the .find() method of mongoose, the object I get as response is full of properties I don’t know where It came from (I’m […]

NodeJS – how to break a function?

Recently had a similar question, but still can’t get it. I have to validate registration page before adding new user. app.post(‘/signup’, function(req, res) { //checking if first name is filled if (req.body.first_name = “” || req.body.first_name = null || req.body.first_name = undefined) { res.render(‘signup’, { “title”: “Ttitle”, “menu”: “signup”, user: req.user, “error” : “empty_first_name” }); […]

Node.js encrypts large file using AES

I try to use following code to encrypt a file of 1 GB. But Node.js abort with “FATAL ERROR: JS Allocation failed – process out of memory”. How can I deal with it? var fs = require(‘fs’); var crypto = require(‘crypto’); var key = “14189dc35ae35e75ff31d7502e245cd9bc7803838fbfd5c773cdcd79b8a28bbd”; var cipher = crypto.createCipher(‘aes-256-cbc’, key); var file_cipher = “”; var […]

nodejs fs.exists()

I’m trying to call fs.exists in a node script but I get the error: TypeError: Object # has no method ‘exists’ I’ve tried replacing fs.exists() with require(‘fs’).exists and even require(‘path’).exists (just in case), but neither of these even list the method exists() with my IDE. fs is declared at the top of my script as […]

Get file created date in node

In node I can get a file’s modified date using the standard file stat object. Is there a way I can also find its created date? I can’t find anything in the http://nodejs.org/api/fs.html#fs_class_fs_stats documentation at all.

How to get the value of data attribute using jquery

I am working on a node.js application which generates a html page. This html page displays a list of associates built according to the data passed onto this page. A list is built something like as follows: <ul class=”notification-body” style=””> //loop for all assocaite id’s passed to this page <li class=”testClass” data-associateid=”<%= assocID %>”> <span> […]

Is TRANSACTION possible using sequelize?

I’m using a script that first sets the status of all my rows to 0, then individually sets the status of some of the rows to different values. This is done once per minute. I’ve already noticed multiple times that I can do a SELECT on my database and get completely incorrect results as many […]