Node.js is an event based, asynchronous I/O framework that uses Google's V8 JavaScript engine. Node.js is commonly used for heavy client-server JavaScript applications.

learn more… | top users | synonyms (2)

2
votes
1answer
12 views

Saving and loading parts of configuration

I have a piece of code where I have string pairs (eg. 'a' and 'AA'), where both have their own unique ids. Id for first object is configured by user and second id is received at some point during ...
2
votes
0answers
12 views

Optimizing D3 Stream Graph Code

I have two javascript functions that generate a D3 Stream graph. I feel I may be excessively and unnecessarily iterating over my dataset to get it into the desired form. How might I optimize or ...
1
vote
0answers
15 views

Pulling data quickly from mongodb with node.js

I am currently struggling with a request I am making to my server that is taking more than 4 seconds! I am using socket.io, express and mongoDB in the back end. I cut out a lot of the cruft to ...
0
votes
1answer
16 views

Node.js RethinkDB connection wrapper with built in retries

I wrote connection logic for a wrapper around RethinkDB in node.js. While it works, I know it can be cleaned up, and done in a better manner. Essentially the logic is start at the first host in ...
2
votes
0answers
39 views

Mocking the file system within a test

I've been using this method to test file-system functions as an alternative to mock-fs due to its lack of symlink support. I'd love to hear what others think and ...
2
votes
1answer
46 views

Toggle logical NOT operator based on a boolean value

I'm trying to think of a better way to write the below Javascript/NodeJS code without having to check the value of the boolean using an if statement. I know this ...
0
votes
1answer
45 views

How to achieve or ensure efficient and RAM kind Node.js code?

I'm sharing this REST API controller code in order to make it work better, also, to become a better developer. I'm having this issues with the application that API handles and I also need to improve ...
2
votes
0answers
24 views

Modify records at one time

Do you think this works well? I.e, do I need to close the database connection at the end? The goal is to be able to upsert and delete many records in one shoot. Here is is an example HTTP POST ...
0
votes
1answer
27 views

File existence promise

I hate to have to write a custom exists promise every time I need to know if a file exists, so I came up with this. Thoughts? ...
2
votes
1answer
44 views

Function to check that two objects have “equivalent” values

I have two objects, a bet and a match. A match has 2 teams and both teams get a score at the end of the match. A bet has two scores set up before the match begins. Here I need to know if the bet ...
0
votes
0answers
12 views

Chain-able promise file system functions

I'm trying to invent an easier way of working with the file system. Here I chain promise methods together. ...
3
votes
1answer
34 views

Mapping file data to environment variables

This is a follow-on to my previous question: Enforcing set environment variables While learning more about JavaScript, node, and the bluemix environment, I have been using the loading of process ...
7
votes
2answers
144 views

Enforcing set environment variables

Context I have a node.js application that uses many other modules and libraries. Some of these modules pull details from process environment variables, such as URL's for databases, credentials, and ...
5
votes
0answers
51 views

Processing files with streams

I'm using iojs. I have to read some files as a stream, process them with a same function and join them back into a stream. So, I decided to create my own solution with ...
3
votes
1answer
36 views

Updating an incoming PUT query

I have the following spaghetti update method and I would like to improve its coding style. This takes an incoming PUT query for a survey object and updates it accordingly. ...
4
votes
1answer
72 views

Tic-Tac-Toe command line

I created a simple Tic-Tac-Toe. I'm looking for any critiques from a code standpoint: general structure / style / efficiency. Unfortunately I couldn't get a live demo working because of the ...
3
votes
1answer
74 views

sed-like attempt from database

The following code and test data works, but I have had to add delays between writes to MySQL otherwise it acts funny (especially on the target data set which is over 700 rows). The table is simply a ...
4
votes
1answer
99 views

NodeJS logging module

This code is for a NodeJS logging module. I created it because I wanted to find a way to log different type of things but not show them all at the same time. I also wanted to format the logs in a ...
1
vote
1answer
57 views

Node.js Electrolyte constructor [closed]

The code below works, and I'm not that unhappy with it, it just feels a bit awkward. Is there a cleaner way to setup an electrolyte component with multiple methods on the object? The examples don't ...
3
votes
1answer
65 views

Realtime chat service

I am new to Node.js and Socket.io. I implemented a realtime chat service that has a chatroom feature. When the actual product is launched, there will be at least 200 concurrent users with 50 groups of ...
0
votes
1answer
38 views

Separate logic in files node

I have a Node project and am trying to make my code better, so I've created a new folder with a file like following which encapsulates the read and write file. This is working and my question is if ...
0
votes
1answer
62 views

Testing console.log output using assert.deepEqual in NodeJS

I'm new to testing and NodeJS and I'd like to test the output in console.log using assert.deepEqual to test whether or not the result has correct data. For ...
4
votes
1answer
54 views

Event driven timed I/O

The following code is used to access a shield which converts settings written over I2C to Servo output. I make use of the MRAA library since that's the default supported by my hardware. To prevent ...
1
vote
1answer
64 views

DNS lookup function

How can I combine multiple DNS lookups without nesting a whole bunch of if else statements? How would this impact performance? I ...
0
votes
1answer
56 views

Running async processes in node.js on multiple cores

Using the async and child_process modules, I can create true asynchronous processing. My question is, how can I ensure that it ...
2
votes
1answer
54 views

Net health monitoring

This is a little net health monitoring project I made in NodeJS. It pings google every second and stores the result (true/false) along with the date in a database (MongoDB). I've collected enough ...
2
votes
1answer
36 views

Dependency Injection with classes which are created often

I have a question about dependency injection and best practices when using simple classes which are meant to be created often, which have dependencies on external services. Here's a (vastly) ...
2
votes
1answer
40 views

Node.JS Twitter Count Module

I would like someone review this code and tell if it can be done better, or if the code is elegant and simple enough for the task at hand. I used code climate and I got 4/4 and my test coverage is ...
4
votes
0answers
126 views

RSS parser for Node.JS

I would like someone review this code and tell if it can be done better, or if the code is elegant and simple enough for the task at hand. I used code climate and I got 4/4 and my test coverage is ...
1
vote
0answers
26 views

Semaphore with Node and Redis

I'm learning Node and Redis and created a semaphore for master/slaves. ...
1
vote
1answer
141 views

Node.js Paging with Mongodb

I want to create variable paging on Node.js with MongoDB. I use MongoJS on client side create a request: ...
0
votes
0answers
25 views

Sharing app methods to routes in Expressjs 4

I would like to know the right way to execute an action(a method) from my app into my routes. I have to do this because I have a POST route waiting to be call from other pages (like an API call) but ...
1
vote
0answers
43 views

Appropriate use of bind for elasticsearch callback

I'm starting a new project with Node. I'm learning the object model, and the code below is my first module. One of the things threw me was the behavior of this ...
5
votes
1answer
140 views

JavaScript 8-bit floating point

To start, I am in the wrong language and I think it is time learn some C++ and compile it as an add-on for NodeJS. For now, though, I have a few code snippets that work that may be interesting or may ...
0
votes
0answers
25 views

Middleware code for preventing repetitive identical requests in Express

I have problems when some of my users starts to frenzy click the save button generating duplicate records on the database. I wanted to create a generic solution so I could reuse it on another projects ...
3
votes
2answers
133 views

Generate URLs from a complex JSON object using recursion

My task is here as follows : Input : A complex/nested JSON object with nested arrays as well objects Output : A JSON object that contains a set of URLs with their titles: ( key,value ) ...
2
votes
0answers
90 views

Exiting a Promise early

I'm using a Promise chain to write some data to a file, execute a command on it, inspect its results, and send the results, using Express.js. The thing about my function is that I need to be able to ...
3
votes
0answers
36 views

Q.js worker pool

I'm building a program to scrape data about hockey games in order to compile statistics. One of the run modes will process all of the games in a single season (1230). Processing a single game consists ...
0
votes
0answers
77 views

Save file from request to database

I am saving (image) files to PostgreSQL database in my Node.js and Express server application. The code is used to upload user images to server (at the moment it is not restricted to image files in ...
3
votes
0answers
82 views

Personal Website

I have written the following code for my personal website, in Jade and Stylus. Can anyone review this code? Are there any tips that you can give me on how to make it better? Here is the main-page.jade ...
4
votes
1answer
61 views

Continuable if error is null

I made a method that I can use to avoid having to handle errors from callbacks. What it does is, call the passed method only if the first argument is null. So essentially it will bypass to the last ...
1
vote
0answers
41 views

Built a database layer for an online / offline Crypto Currency Wallet: Browser Storage

This is largely self contained, iirc the only dependencies are: Bitcore bower install bitcore PouchDb ...
1
vote
2answers
100 views

Parsing sentences to create a chat bot

I am developing a chat bot with Node.Js. I am trying to find efficient way to parsing sentence. ...
3
votes
2answers
94 views

Check if variable is sent

I have this piece of code in my Node.js API and I feel like it could (should) be optimized. ...
1
vote
0answers
25 views

Sourcemap translator service

This is my first attempt to a serious Node.js application, I've tried to follow the async style of Node at my best, but I have several doubts and I am sure that this code can be massively improved. ...
2
votes
1answer
48 views

Database module for node.js

This will get quite clumsy if I continue down the road with this design, so I'm asking you, enlightened ones, is there a way to make this prettier and easier to understand? Primarily the ...
2
votes
1answer
62 views

Parameterized route

Is this approach considered good practice, or should I create separate router.delete functions for all my routes? Please, explain why. ...
1
vote
0answers
43 views

Monitoring a few servers / API endpoints

I am trying to create a simple NodeJS program that monitors few provided servers or machines and provides output in JSON. ...
1
vote
0answers
120 views

Payment Gateway - single payment with credit card (handling path & choosing gateway)

This was an assignment and I am new to Node.js. You can find the complete project here. The code worked fine but was rejected, and wasn't given any reason even after asked. Statement: Create a ...
1
vote
0answers
32 views

NodeJS socket for handling errors

It's the first time managing Mongoose by socket.io and I'm wondering if this could be a good way: ...