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.
0
votes
0answers
30 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
votes
0answers
10 views
MongoDB aggregation pipeline with node.js and php [on hold]
I am trying to run the same query in both node and php. The query works fine in node but gives me a cursor timeout issue in php. I suspect I translated the pipeline wrong. Could someone please take a ...
0
votes
0answers
3 views
0
votes
0answers
8 views
Query for multiple timeframe in Mongoose
Here is the code I use to query the number of view (separated by new users and non-new users) with Mongoose:
...
1
vote
2answers
29 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
117 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
25 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
0answers
46 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
58 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
18 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
67 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
50 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
39 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 ...
2
votes
0answers
54 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
36 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
54 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
74 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 ...
1
vote
0answers
78 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
29 views
NodeJS event tracker written in LiveScript
I need to track the use of JavaScript app and wrote this:
server.ls
...
1
vote
0answers
37 views
2
votes
1answer
58 views
JavaScript Node - Private Module Functions
To learn the language of JavaScript, I did a dojo exercise by Roy Osherove. Is there a better way to organize this so that the only method exported is add while ...
3
votes
2answers
180 views
Calculate all possible combinations of an array of arrays or strings
I'm using code adapted from this Stack Overflow question to calculate all possible combinations from an array, which may contains strings.
For example:
...
2
votes
1answer
62 views
nodejs grunt plugin using async module
I'm looking for some code review of my usage of async. Mainly why this does not work without the done = this.async() method and why I don't have to invoke 'done()' ...
1
vote
1answer
144 views
Is this a reasonable way to implement promises in node.js?
I'm using passport to setup login in an express site. The site is just a playground for me to learn. The code inside login was exhibiting the arrow anti pattern so I decided it was time to learn to ...
2
votes
2answers
191 views
Using global variables in my node.js program configuration
I know using global variables in JavaScript is bad practice. Here I am using config, host and port as global variables as I have added a watch function to watch for the changes in the config.json ...
2
votes
1answer
79 views
What is the best approach to cache/memoize Promise results?
One approach it to chain cachedPromise and "regular", thus, if cachedPromise fails, we call a regular one (and caching results).
...
2
votes
2answers
424 views
Exporting routes in node.js Express 4
I'm using Express 4 to provide routes to HTML/Jade files, and as well to provide an API.
I want to separate routes from server file, and go even further- separate API from WWW. My code now looks like ...
1
vote
1answer
34 views
Testing individual nodes launched by naught using supertest
The purpose: an express node.js server which can be launched using naught, with an integration test using supertest. Each worker naught runs will test itself on a unique port, and only if passes it ...
4
votes
1answer
85 views
Socket.IO handshake module
For the server of which this is part, it makes a request to one of our web servers to validate whether the PHP Session ID is actually valid. The location ...
4
votes
1answer
217 views
Modularize this node.js express server code for routes and session handlers?
I have express node.js server code using Passport. It receives a user to authenticate it and ...
3
votes
1answer
53 views
Template function specialization with code duplication
I'm working on a libcurl binding for nodejs, and to get info from a curl handler, using curl_easy_getinfo, I've created a template function, the issue, is that the ...
7
votes
2answers
181 views
Nodejs broker between mongodb and rabbitmq
I wrote a small program that aims to take some data from the mongodb database and put them in the rabbitmq queue.
I tried to use only promise style but I am a beginner in javascript.
Could you please ...
2
votes
1answer
74 views
Looking to optimize Node.js Chat service
I've built a simple chat server/client on Node.js and socket.io that I would like reviewed. My main concern is making the chat.js (client) running as cleanly as possible (OO) and streamlining data ...
1
vote
1answer
45 views
Node.js callback closure/scope
Is it a bad idea to use the notfound callback like this? If so, why not? (bad scope/closure? I'm a noob node.js dev.)
Is it a bad idea to use the ...
1
vote
0answers
50 views
Getting the current chat room ID
I need roomId (an auto_increment primary key) to locate a specific room to update chat info. My way of doing it right now is ...
3
votes
1answer
56 views
Generate [min, max] range from strings
I need to generate a minimum and maximum value for a range of speeds (slow, medium, fast), the user can specify any combination of the 3 values, and receive a range that encompasses all.
Given any ...
2
votes
1answer
70 views
Cleaning up nested promises in Cloud function
I am writing the Cloud function for Parse whose purpose is to update my database with a provided array of data objects. The main problem are the nested promises, which doesn't look right. Any help ...
5
votes
2answers
100 views
Optimizing simple xHTML parser
I'm writing a simple xHTML parser which parses a data without nested tags.
Example input code will look like:
...
0
votes
2answers
80 views
Promises and chained calls
I've realized JS callback hell and I started looking into Promises libraries.
After reading some articles I decided to start with BluebirdJS. I didn't realise how to properly use them yet, because ...
3
votes
1answer
167 views
node.js Passport Wrapper 3
First attempt was done here
Second attempt was done here
Huge comment at top
...
3
votes
1answer
176 views
Recursively reading a directory in node.js
I made a function for recursively reading a directory and it just seems kind of long and complicated. If you could take a look and tell me what's good or bad about it, that would be great.
Reading ...
3
votes
1answer
139 views
Seeding a file with fake records - doing concurrent updates
I need to seed a database with user data.
When trying to write records to a file using sqlite3 with node, I tried writing the logic in a naive manner, without any error checks - but it was failing ...
4
votes
1answer
69 views
Reducing code duplication in a geometric function
Given a large bounding rectangle ("envelope"), a list of points, and a maximal aspect ratio, the goal is to find a rectangle within the envelope, whose aspect ratio is bounded within the given aspect ...
0
votes
0answers
32 views
Properly handling NOT operators for nodejs
Converting assembly code to nodejs,
Having the assembly code:
...
7
votes
2answers
99 views
Handling packets in nodejs for MMORPG
Writing a MMORPG server in nodejs, I have to handle packets. These packets have a structure of
<length> <id> <data>
So what I did was use a ...
1
vote
1answer
96 views
object oriented Node.js class RiddleInfo.js
So I am trying to make a Object oriented Node.js class for store information about riddles.
Please feel free to be harsh as possible. Would love to hear your ideas about how to make this class better!
...
1
vote
1answer
39 views
Remove nodejs/browser specific code in library
I'm the maintainer of the following library on github: https://github.com/edi9999/docxtemplater/blob/master/coffee/docxgen.coffee
I want to maintain a library that works on node and in the browser, ...
3
votes
0answers
319 views
Optimizing async joins for mongodb (mongoose) using async.js
I'm building a media viewer web app for a kiosk in node that uses data in mongo. To render the viewer, it gathers together all the Asset objects (representing video files), each of which belong to a ...
3
votes
2answers
57 views
Node exports, architecture
My project is written in node JS + Express and has the following architecture:
routes (e.g controllers)
models (stateless functional modules)
app
Models objects only doing SQL queries like this:
...