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)

5
votes
1answer
68 views

Creating chat commands properly with Socket.IO

I am developing a chat program (mountreus-chat and GitHub) in Node.js using Socket.io however my code looks awful. I'm starting to use commands and now it's even worse. Here's a code snippet (you can ...
-1
votes
0answers
24 views

About my DB queries (Mongo) [closed]

When a user first visit the site, I'm making a few DB calls and emitting them with socket.io: ...
1
vote
1answer
45 views

DRY code for sending email with SendGrid

I have this code inside a post route: The first one is to alert me when a user registers on my site: ...
1
vote
0answers
27 views

Mocha + should.js, testing for node

I'm new to the world of BDD, but I'd like to get a grip of it as soon as possible. It's one of my first tests: Fluent.js ...
1
vote
0answers
25 views

Node.js log parser for mongoDB

I have developed a log parser, the goal is to take whatever log type I can, and convert them in a mongoDB collection. I think I've done a pretty good job at reading whatever type of log are trhown at ...
1
vote
1answer
50 views

Removing properties and elements set to null in JavaScript

I'm looking for a review of the following code. Is there a better way to remove all properties that evaluate to truthy for a given function? Is there a better way to prevent a stack overflow in the ...
1
vote
0answers
25 views

Using EJS Partial for commonly used <input> layout

I have a lot of <input> elements in my single page app that share a similar style for validation. To decrease the amount of code repeated (following DRY ...
0
votes
0answers
26 views

Secure and optimize Mongoose model component

Please help in deciding if this method for a Mongoose model component for user authentication can be made more secure and optimized, for efficiency and platform independence. ...
1
vote
0answers
35 views

Chat server initializer

...
2
votes
0answers
55 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
26 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 ...
6
votes
1answer
71 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
46 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
28 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
1answer
123 views

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
28 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
111 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
23 views

Using an asynchronous function without directly using its callback

I hate functions and re-writing callbacks by "intercepting" them and passing the original along. This is simple: it uses an existing function, exec, and doesn't ...
4
votes
1answer
99 views

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
53 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
53 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
59 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
36 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
24 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
113 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
46 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
31 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
13 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
21 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
83 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 ...
0
votes
0answers
21 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
177 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, ...
14
votes
1answer
143 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
87 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
84 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
91 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 ...
3
votes
1answer
577 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
149 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
61 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
111 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
108 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
58 views

RESTful API parsing DBF data HSET in Redis

I have this working code, but would like your review: sync.coffe ...
2
votes
2answers
78 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
41 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 ...
2
votes
1answer
41 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
72 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 ...