0
votes
0answers
13 views
Jade include template based on a variable
I would like to add a template with a name based on a variable.
Something like that:
include= templateName
0
votes
1answer
25 views
How to Post and Get Data Unique to Each Logged In User with Express and Mongoose?
I am currently working on a small single page app that lets users login with PassportJs and Mongoose.
One of the things I am trying to do is allow users to login and each user has a unique todo/task ...
0
votes
0answers
14 views
Testing an EventEmitter subclass using sinon-chai and mocha
After upgrading to node version 0.10.5 my tests got broken. I'm trying to figure out what is going on. I include three files in the gist http://goo.gl/i5oK1
fswalker.js : File System Walker, ...
0
votes
1answer
43 views
JavaScript callbacks function object
i try to learn node.js and try to create a new TCP Server connection. The code
var server = require('net').createServer(function(socket) {
console.log('new connection');
...
-1
votes
1answer
31 views
nodejs return from callbacks
guys. I cant resolve some prolem with js callback return.
So, we have next func:
//Функция получения контакт листа пользователя
function get_contact_list(data) {
//Берем ID ...
0
votes
0answers
7 views
NodeJS nTwitter Demo
Is there any sample Demo for Streaming Tweets from Twitter using nTwitter?
I have configured my access and secret keys from dev.twitter.com.
But still a fully guided Tutorial would Help
I referred ...
1
vote
5answers
55 views
Split a pipe delimited key-value pair separated by '=' symbol
We are receiving an input parameter value as a pipe-delimited key-value pair, separated with = symbols. For example:
"|User=0101|Name=ImNewUser|IsAdmin=0|RefId=23ae2123cd223bf235|"
So the format ...
2
votes
2answers
59 views
node.js / javascript — nested callbacks
function MyClass() {
this.a = "me a";
this.b = "me b";
};
MyClass.prototype.changeB = function(callback) {
this.a = "now me A";
doAnotherFunction(function(err, data) {
this.b ...
0
votes
0answers
18 views
Node Thrift Deserialization
I'm trying to do a simple thrift serialize/deserialize however my deserialization if failing with the following message:
...
0
votes
1answer
46 views
Javascript choose biggest more often than smaller
I'm busy with nodejs a bit for modding a game, but I'd like to know how to do something like this:
var zombieDirector =
{
zombieBison = 1
zombieChicken = 2
zombie = 3
skeleton = 3
}
and those ...
0
votes
1answer
20 views
Throwing exception on mongoose callback
I'm developing a Node.js + Express. My database is Mongo, and I'm using Mongoose to connect to this database.
I'm trying to throw an exception in a Mongoose query callback this way:
...
0
votes
2answers
43 views
How to correctly modularize a node.js project?
I'm creating a node.js project following the class constructor pattern:
function my_class(x,y){
this.x = x;
this.y = y;
}
The starting point of the project is the main.js file. Any class of ...
-1
votes
0answers
15 views
How to debug grunt in PHPStorm (WebStorm)
Has anobody a good idea about debugging grunt (for example an event listener function) in PHP Storm.
There is Node.js support in storm but I'm not sure how to configure debug settings if I'd like to ...
1
vote
1answer
31 views
What is the best way to determine Tomcat has started with node.js
I am building an application using node.js and that application communicates with a Tomcat server. While the tomcat server is launching, I am not sure if Tomcat is ready and has come up or not, for ...
1
vote
1answer
35 views
Node JS Socket IO Chat issue
I am developing a one to one chat application using node js and socket .io
but when i try running my chat.html it gives an error "Reference Error io is not defined".
I googled this issue and i ...
0
votes
1answer
78 views
Mongoose - Self-referential deep populate error
I'm trying to populate a self-referential model a few times recursively. Here's my schema:
var TestSchema = new Schema({
title: { type: String },
counter: { type: Number },
children: [ { type: ...
0
votes
0answers
29 views
Mongoose $pushAll overwrites current array objects
so I have this document that im trying to update the comments on and when I do so, it seems to overwrite the array with the new information coming in. Any idea why?
Confession.findOne({_id: ...
1
vote
1answer
29 views
Correct variable on server gets passed as an incorrect variable to client via socket.io
I am attempting to pass a variable from the server to the client via socket.io. I'm saving data to MongoDB and using Mongoose. The goal is to save some data from the client into the database, then ...
0
votes
1answer
14 views
PhantomJS updating resource file path
I have a nodejs+phantomjs setup. I am trying to generate html and serve it to the bot for seo. The app currently works but I want to improve the performance. Since a lot of js files are loaded, I am ...
0
votes
1answer
28 views
Node.js crypto module
I am trying to implement encryption in node.js using the crypto module. Below is a snippet of my code:
var SECRET_KEY = "RANDOMKEY";
var crypto = require("crypto");
var MD5 = ...
1
vote
1answer
28 views
understanding the node.js event queue and process.nextTick
I'm having trouble understanding exactly how process.nextTick does its thing. I thought I understood, but I can't seem to replicate how I feel this should work:
var handler = function(req, res) {
...
0
votes
0answers
44 views
Serializing and Deserialzing of Thrift Messages Using Nodejs and RabbitMQ
I need to send a thrift encoded message from a client to a server via RabbitMQ. The RabbitMQ part works just fine as I'm able to send JSON across no problem. Here is the code responsible for sending ...
0
votes
0answers
19 views
How to modify node.js stream
I am streaming an xml file from S3. I need to build a new xml file with a different structure for sphinx search engine. I am already streaming the file from S3, piping it into my SAX parser but now I ...
1
vote
1answer
26 views
Node.js Reference error while passing an object to a require module
I am trying to develop a Node.js web application and I am trying to delegate some initialization steps to a different module
my server.js file
var express = require('express')
var app = express();
...
0
votes
2answers
45 views
Unable to figure out whether to use “,” or “+” in console.log in node.js
This is the config.json file:
{
"username": "myname",
"api-key": "test",
"name": "testname",
"version": 1
}
This is the node.js file
var fs=require("fs");
console.log("Start");
var ...
0
votes
4answers
36 views
how to pass a variable to a regex
I have a find statement like this
collSession.find({"Venue.type": /.*MT.*/}).toArray(function (err, _clsSession)
{
console.log(_clsSession);
});
It is giving answer.But ...
0
votes
0answers
27 views
Upload Base64 Image Facebook Graph API
Im trying to upload a base64 image to a FaceBook page using Node.js. I have managed to get the upload working with all the multipart data etc should I read the file from the filesystem (ie. using ...
3
votes
2answers
76 views
Javascript Convert String to Array of Objects
I have a NodeJS App that accepts a a string (uploaded input!) I have No Control over the input I am merely building a REST Service to Processes the data.
That string is meant to be an Array of JSON ...
0
votes
1answer
22 views
Http get multiple json files from different API endpoints using node express
I'm looking into the most efficient way to get multiple JSON files from different API endpoints using node.
Basically i'd like to store each JSON object in a variable, and send them all to Jade ...
1
vote
2answers
24 views
How can I embed a CSRF token in a JavaScript file?
I have a Node.js application in which I have implemented CSRF. It's working fine, and when I had some JavaScript inline in a JADE file, I simply used #{token} to get the token into the JavaScript.
...
0
votes
2answers
28 views
Accessing json objects within objects with Jade and express
I'm pulling my hair out a bit at the moment. I can't seem to figure out how to access the "media" content within the following json object using Jade.
{
"summary":"Jose Mourinho names his ...
0
votes
3answers
37 views
Socket.IO - How to figure out who disconnected?
I'm building simple web application using HTML5 and Javascript on the front end and Node.js on the back end. I'm also using Socket.IO to pass data back and forth between the client and server. Say I ...
1
vote
0answers
44 views
+300
getting “websocket connection invalid” error using socket.io on an ec2 instance?
I have this web app written with express and socket.io using node.js, the app works brillantly on localhost, but when i push to my ec2 server, it connects for like 20 seconds then disconnects, and ...
2
votes
3answers
48 views
How to use NodeJS + ExpressJS to pass an array to Jade for display?
I come from a very "functional" style of programming (PHP, Lua, C) and I'm trying to transition my thinking to the MVC model NodeJS uses. Currently, this is a very steep learning curve for me.
I've ...
2
votes
2answers
45 views
Modify value using a lambda
Let's say for an intance I have this template I wanted to render with hogan.js:
var template = '{{#numbers}}'
+ '{{#capitalize}}{{percentage}}{{/capitalize}} complete.\n'
...
0
votes
0answers
18 views
supervisord running node as a service
I am trying to run a node application as a service using supervisord.
If I go to /opt/uptime and run:
node app.js
My application starts in the foreground. As soon as I hit ctrl+c it dies.. As ...
1
vote
1answer
65 views
Passport-github js, user-agent error
Yesterday I could successfully login in my application via Passport.js and Passport-github module, today I received such an error:
500 failed to fetch user profile (status: 403 data: ...
1
vote
1answer
36 views
Is there a Node.js equivalent of Perl's WWW::Mechanize?
I'm searching a module for Node which would be similar to WWW::Mechanize for Perl. Or even better to WWW::Mechanize::Firefox.
The main functionality would be to find and submit form by name,
class ...
0
votes
1answer
18 views
EMFILE error in Async file reading
Today when I tried to implement an example of using async/sync I/O methods in NodeJs, I faced an strange problem. When I'm trying to send requests with ab, I get this error in Async method:
{ [Error: ...
0
votes
0answers
17 views
Mongoose subdocuments sort
This is actually two questions.
Using MongooseJS
Can you set the default sort order for a Schema?
can you control how subdocuments are sorted?
1
vote
1answer
28 views
Reading data from arduino with nodejs and socketio
I have this simple code that I'm running in arduino
char inp;
void setup(){
Serial.begin(9600);
}
void loop(){
while(Serial.available()>0){
inp = Serial.read();
Serial.print(inp);
}
...
2
votes
1answer
34 views
Add a length value to the beginning of a Buffer
I'm sending a binary value over a socket using node, and would like to send a 4 byte length value in front of the data so the receiver knows how much data to expect.
How can I accomplish this using ...
0
votes
0answers
47 views
Nodejs installed older version?
So, when I was installing nodejs, I used the
https://npmjs.org/install.sh | sh
And when I do node -v I get v0.5.11-pre. Am I correct in assuming this is the wrong node I want to be running ...
0
votes
0answers
24 views
Socket.io emit doesn't work after lost connection
"Emit" event is not working after lost connection and reconnect. The reconnect is successful, but the event "emit" is not working. The event "send" is working normally.
0
votes
1answer
38 views
What tools exist for manipulating HTML in Node.js?
I have a Node.js/Express application which takes user input as HTML, and I need to make it both well-formed and remove or replace all but a small subset of allowed tags. What are the existing options ...
2
votes
1answer
44 views
Is there a single function to check an array contains another array?
[1,2,3].CONTAINS([1,2]) ==> true
[1,2,3].CONTAINS([1,2,3,4]) ==> false
or
{a:1,b:2,c:3}.HASKEYS([a,b]) ==> true
{a:1,b:2,c:3}.HASKEYS([a,b,c,d]) ==> false
Is there a single function ...
0
votes
1answer
16 views
Javascript Query Selectors DSL as an Independent Library
I really like mongodb's json dsl for querying the database.
I was wondering if there is any stand alone library for node.js/browser that can convert that kind of json expressions into, maybe, js ...
0
votes
1answer
48 views
CHALLENGE: Get b without calling `test`
I am currently thinking about implementing a virtual machine inside of node.js that wraps up other apps. For that I am going to override some basics but there is one point I am not sure of. My ...
2
votes
1answer
74 views
Javascript simplifier?
I would like to eliminate functions that are unused or not related to the given context. Let's say we have:
function a(){ console.log('this is an unrelated function'); }
function b(){ ...
0
votes
1answer
40 views
Finding values in an Array in Javascript
I'm trying to find out if a value exists in an array. The following code is giving me an error each time I run saying Object has no replace method.
var fruits = ['apples', 'pears', 'bananas'];
...