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)

1
vote
0answers
27 views

Chat server initializer

...
2
votes
0answers
19 views

Log my external IP address using NodeJS

I've been learning NodeJS recently, and have a small program to get the external IP address on my home network from fugal.net, compare it to the previous IP address, and if there is a change update ...
2
votes
1answer
18 views

Arranging this socket namespace

Finally I managed to work with socket.io namespace stuff which I'm using for building a chat module. Here employees of multiple organizations can join & make chat with other employees of the ...
5
votes
0answers
38 views

Simple Linked Hash Map in JS (node/browser)

I needed a simple data structure to cache the most recent few directory contents for this project I was working on. I thought a Linked Hash Map would be the right approach since we will cache only one ...
1
vote
1answer
39 views

Too many conditions in the method

I am new to node.js and I am just wondering what you think about this code. For me, it seems there are too many conditions in the code. Is there any way to refactor it? ...
6
votes
1answer
24 views

Tag Fit: Team based mapping of wearable data

Our company is planning on doing a fitness competition. So as the hackathon project I threw together this team based tracking service. It measure a walk from Seattle to New York Player can log in via ...
4
votes
0answers
99 views
+100

Web socket server which needs to query some API and to pass chunk per chunk of data to its socket clients every M seconds

Let's say that I want to query some API which will respond with array of random numbers: [4, ..., 17, ..., 25] To keep things simple enough, let's say that array has always 10 elements. For ...
0
votes
0answers
13 views

hapi.js + node.js route reply with external data

My code responds to a request with data from an external site – it retrieves data from the internet that gets packaged with any response. I am a javascript beginner and am not used to asynchronous ...
1
vote
0answers
16 views

Bitcoin, detecting deposits to the node.js server

I'm trying to detect deposits that user will made. I explained it with comment lines in below. Can you say are there any flaw in it? ...
1
vote
0answers
30 views

Injecting a variable into a required function

I have a sort of plugin loader in a node-webkit app, but when a file is required using it, it doesn't inherit the window variable. Meaning I'd have to use ...
6
votes
1answer
88 views

Simple Poker Game

I'm building a simple Poker game. It is almost complete, but I want to refactor it early. To calculate hand strength / ranks, I use this library from NPM: poker-evaluator For deck shuffling, I use ...
0
votes
0answers
15 views

Looking for a simpler way of using an asynchronous function without directly using its callback

As the title says "Looking for a simpler way of using an asynchronous function without directly using its callback.". I hate functions and re-writing callbacks by "intercepting" them and passing the ...
2
votes
0answers
60 views
+50

Node module for DRY CRUD endpoints

As a learning project I recently started writing a node module to generate / handle the creation of CRUD endpoints in a DRY way. The problem I was initially wanting to solve was that in my ...
4
votes
1answer
41 views

NodeJS and Express with Promises

I'm relatively new to NodeJS and Express, and I've recently run into the pyramid of Doom while doing stuff that requires multiple steps. I've found that promises are very promising indeed. But I ...
3
votes
1answer
44 views

JavaScript traits implementation

I wanted to step up my JS game, and move on from mostly closure based scripting, so I decided to write an application in node. I don't have much experience with prototype based programming, and I ...
4
votes
1answer
49 views

Querying MongoDB for information on a collection of books

I have this huge chunk of code. Is there any better to write this code, or am I too paranoid that I check every MongoDB query for error? The logic is here: Bookcollection = collection of books Book ...
0
votes
0answers
25 views

Validation in Node.js

I'm building a NodeJS application, but I'm not sure what will be the best way to structure my code. I have the following model: ...
0
votes
0answers
20 views

Signature verifier for a javascript/node.js function

I wrote a function that verifies the arguments against an expected set of arguments. test('hello', 'world'); ...
3
votes
2answers
76 views

Node.js script may have memory leak

I use this node.js script to migrate MongoDB collection to a schema to another. It does work if the collection is <20k documents, but slows down to a crawl and sometime throw a FATAL ERROR: JS ...
5
votes
1answer
44 views

Reading the contents at three URLs using Promises

I'm learning promises and now I'm trying to figure out if something in this code can be improved. This code is expected 3 urls and then async parallel calls should be done. When all requests are ...
2
votes
1answer
29 views

The best way to place callback definition [closed]

In JavaScript we can write callback definition in many different ways: Definition after usage: ...
1
vote
0answers
11 views

NodeJS ReadableStream _read implementation, ArticleReader with changing dates

I have a NodeJS stream.Readable, ArticleReader. It's job is to read articles, Meantime I have to give it a date to signify the ...
3
votes
2answers
23 views

Function that groups rows returned from SQL DB

I have a data set returned from an SQL database contained below, as you can see all data remains the same apart from one property, "name_alt". ...
1
vote
0answers
16 views

General application log

In my Node.js applications, I often find it helpful to have an application log so that should something go wrong in production, I can have more information than I get from a crash stack trace to track ...
2
votes
1answer
51 views

Node js single mongodb connection

I want my entire node application to use one single mongodb connection, at least that's what I think is better. I wrote this little script and want some feedback on it. Especially if what I'm doing ...
1
vote
0answers
19 views

Structuring my MongoDB application documents

I'm just starting out on an application and I've heard some good things about MongoDB so I thought I'd give it a crack in this new project to see how well it works. Please bear in mind that prior to ...
3
votes
1answer
144 views

Gulpfile.js optimization and image caching

I'm trying to write gulpfile.js, which will follow modern best practices for optimization. This project includes jekyll, SASS and some image optimization tasks. I'm pretty new to JavaScript and Gulp, ...
13
votes
1answer
140 views

Making an efficient and healthy db call for a real-time browser game

I'm doing a calculation for a real-time browser game, where users can invest some of their balances to the site. I need to update their invest's based on ...
2
votes
1answer
73 views

Node.js API route for POSTing a resource. Getting rid of callback pyramid

I'm writing an API for simple GET and POST routes. The app is a shared to-do-list. Users and lists are stored separately. A list can belong to many users, and a user can have many lists. ...
2
votes
2answers
68 views

Is my Node/Express-based authentication implementation with session properly done?

I know that Passport.js exists, however, I wanted to code my own implementation using express-session module. I'm using: Express Mongoose express-session So I basically have 2 routes for handling ...
2
votes
1answer
71 views

ExpressJS easily serve static files

I have a NodeJS package, staticize, which takes an object of HTTP routes -> file locations, then serves them dynamically on each request. Could I get some feedback on the latest rewrite of the main ...
1
vote
1answer
36 views

groupBy implementation in NodeJS

I came across a problem in my NodeJS app, which I solved by creating a method called groupBy. The purpose of this method is simple: take an array, and a function ...
2
votes
1answer
325 views

Mongoose promise & error handling

I search for rails-like way of writing NodeJS code and it's more then hard to find the right way. The code quickly become bloated and unreadable. I would like my code to be as clean as possible. ...
7
votes
1answer
120 views

Node module using promises and the revealing module pattern

Can someone give me some feedback on this pattern? I am writing a node.js module that connects to a remote API, caches JSON, returns it as output. I have a cli wrapper script that uses the module, ...
0
votes
1answer
54 views

Controller making request to an external API

I'm starting on a new node/express backend and really want to keep everything clean and well tested. My previous project got a bit out of hand (in terms of test coverage and highly coupled code). So ...
6
votes
1answer
108 views

Game Server Querying

I made a package for Node.js that allowed the querying of game servers (or any UDP server(untested)) using UDP. What it does is sends the query to the server and adds the query into a queue. When the ...
4
votes
1answer
97 views

Bookmark application AngularJS controller complexity

I am working on a personal project for managing one's Pinboard bookmarks. Since this is already quite a big project, I am not sure if my question fits the guidelines. My main concern is with the ...
2
votes
0answers
50 views

RESTful API parsing DBF data HSET in Redis

I have this working code, but would like your review: sync.coffe ...
2
votes
2answers
77 views

AJAX call to make an HTTP request

I am using node.js with express. There is a button that the user can click, and doing so calls this method on the server: ...
0
votes
0answers
32 views

NoSQL schema for weather data

I am using NodeJS and MongoDB for a weather app that takes the weather info from a logger, saves it to a database, and relays the data to the browser in real-time. It is hosted here with code here ...
0
votes
0answers
115 views

Push-pull pattern with nodejs and zmq

I created the code below to illustrate push-pull pattern with zmq and to benchmark some concurrent job. ...
2
votes
1answer
39 views

Move uploaded file

As I mentioned in Node.JS fs.rename can not move files in right way. And it should be solved with stream piping. Please verify this code and answer questions in comments: ...
3
votes
1answer
62 views

Optimizing a Node.io server code for self-balancing robot

I am building a 3D printed self-balancing robot, and use the attached server script to control it. I coded using node.io, express and socket.io. The system is working, but I would appreciate some ...
2
votes
1answer
50 views

Controller code using the koa framework

I would like to gather ideas on how to refactor the JavaScript/NodeJS controller code below to be more aesthetic. The code is using the koa framework thus I use ...
1
vote
3answers
430 views

Faster way to check for a string in a array of string

I have a array of object, I need to sort them by time (hours, days or months) and separate the number of new IP. result is an array of object with property time (JavaScript timestamp), user IP ...
2
votes
1answer
86 views

Simple web application for benchmark

There is an article where the author tries to compare performance of different web stacks. The result looks pretty controversial. I try to prove that in real use case the difference between scores of ...
2
votes
1answer
40 views

Pyramidal promises

I have a situation in my Node (express) controller where I need to check whether a particular language has a parent language, if it does, I need to do a new DB (SQL) call to retrieve the parent ...
4
votes
1answer
297 views

RESTful API for Todos using Hapi

My goal is to create a simple restful api that will be accessed by an AngularJS front end. Even though it's fairly simple, I'd like understand how to make it more reliable, secure, and best-practices ...
6
votes
1answer
51 views

Creating a server for user Internet orders

I've been learning the basics of node over the last couple of days and finally hooked up what I needed. I'm just after someone to comment on if I have gone the right way around this task. It creates ...
2
votes
1answer
73 views

NodeJS conditional request before the real request

In my code I have to login a user with username and password. But if the user sends his e-mail instead of his username, I have to resolve it with another request. This is what the code looks like: ...