Tagged Questions

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
0answers
10 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
18 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
42 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
121 views

Mongodb making efficient and healthy db call

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
45 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
40 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
46 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
31 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 ...
1
vote
1answer
56 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
85 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
41 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
0answers
81 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 ...
3
votes
0answers
51 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
25 views

RESTful API parsing DBF data HSET in Redis

I have this working code, but would like your review: sync.coffe ...
2
votes
2answers
70 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
18 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
76 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
30 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
44 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
36 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
387 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
68 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
143 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 ...
1
vote
0answers
28 views

Stats generator may be too slow

There is one MongoDB database with two collection, one for web and one for mobile (sadly, I can't change that and have to deal with it). I fear that the function passing, wrapper and the some return ...
6
votes
1answer
47 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
48 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: ...
3
votes
1answer
65 views

Shorten my asynchronous DB queries, using async.js module

I am using Node.js Express.js node-mysql.js async.js I am making multiple asynchronous queries to my DB, but every query relies on the previous one's results, so I decided to use the ...
1
vote
1answer
25 views

Generating Passwords with a Secure PRNG

What's the best way to approach generating a password using a secure prng? In Python, I could simply use os.urandom. Any suggestions on this? ...
4
votes
1answer
50 views

If vs try/catch

The following code, written in synchronous Node.js and intended to be used as a shell script, nests a try/catch inside a conditional. Because both the conditional and the try/catch serve a similar ...
3
votes
2answers
97 views

Read multiple files async

I want to read multiple files simultaneously and apply the same function on data. This code works correctly, but can someone please suggest any better way of writing this? ...
0
votes
0answers
20 views

nodejs async to read multiple files [duplicate]

I want to read multiple files simultaneously and want to apply same function on data. Right now, here the code which I'm using ...
2
votes
1answer
68 views

Node.js JSON searching & updating

I'm working on a web-based on/off controller for multiple switches. I'm looking for a good way to manage the current state of a switch and updating the current state on change. So far I've got a ...
2
votes
0answers
64 views

NodeJS, status propagation to interface

If you have an interface served by a NodeJS API, what is the most clean way to propagate status changes to the interface? For example, I have a page that has 2 statuses, user logged in and guest. How ...
1
vote
2answers
41 views

ChunkerTransformStream, a transform stream to take arbitrary chunk sizes and make them consistent

I have some code to interface with a wire protocol that requires data to be inserted into a stream at regular byte intervals. Every 8KB (or at some other definable interval), a small chunk will be ...
8
votes
1answer
156 views

Proper prototypal programming with Node.JS

Practicing Prototypal Code I'm focusing on practicing a very prototypal structure with my code (non library oriented) to begin learning to reuse large portions of my application infrastructures where ...
0
votes
1answer
53 views

Logger module with JavaScript

I'm new to JavaScript, and in Java I probably would do this as a singleton. I need something that I can call from anywhere and instantiate only once. This is what I have done, but I need some advice ...
3
votes
1answer
70 views

User-logging authentication

I'm little frustrated because I don't know how well I can refactor this script. I wrote the authentication function but it's too complicated, maybe too large in one function, and seems like spaghetti ...
4
votes
3answers
76 views

Building SQL from multiple combinations of query parameters

I have a node.js/express.js based REST application. In one GET service I am querying data based on different set of request parameters. I am looking for a better way to implement it. ...
2
votes
0answers
37 views

Namespace handling on nodejs and inheritance managing

It should solve the following issues: Handle namespaces; Be a class factory from Pojos Be a object factory Create a class with inheritance capabilities from a POJO using john resig inheritance ...
3
votes
1answer
134 views

Optimize way of reading and writing file in node.js

I want to read the content of file then want to make few updates to content and then write that content to another file. I have created the code with node.js as follows. ...
2
votes
1answer
84 views

Can this code utilizing promises be written more succinctly?

I've written the following code to get all .txt files in a directory and read+delete them, repeating every 15 seconds. ...
3
votes
1answer
46 views

Node PSP ISO Scraper

I recently bought a PSP and wanted to know the best ISO files and wrote a scraper to retrieve games ISOs titles that received a high rating and send them to a csv. Any recommendations as to ...
15
votes
3answers
1k views

Converting an IP

I've written a DNS tool in Node and would like to know if there's a better and more efficient way of handling the conversion from an IP to a long. I'm not too good at bitwise just yet and would like ...
3
votes
0answers
64 views

Node.js promises: save results? [closed]

I'm new to Promises and I don't know the best practises. The following code retrieves page history then search history. I want this history to be saved in variables in order to use it later. I wrote ...
2
votes
1answer
55 views

Ensuring client IDs are unique

I'm writing a node.js application that involves handling clients based on their ID without any real way of confirming that the ID a client says it has is its actual ID. That is, it's possible for a ...
2
votes
1answer
67 views

Retaining depth information and recursive traversals

I have been using the pattern below for some time and it has worked well, but more than once I have almost bled my brain out of my ear trying to keep track of: the recursion depth the recursion path ...
3
votes
1answer
81 views

HTTP routing framework

I am new to JavaScript programming and would like to get your comments/input or corrections on this chunk of code. I have tried to emulate patterns from recognized GitHub projects but I still don't ...
4
votes
1answer
186 views

Cleaning if / else mess in Node.js poker game

This is the third rewrite of the poker bot I am writing. The first one was such a mess of if / elses that I could not deal with ...
0
votes
0answers
67 views

NodeJS event tracker written in LiveScript

I need to track the use of JavaScript app and wrote this: server.ls ...