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.
1
vote
0answers
15 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:
...
-1
votes
0answers
9 views
Node.js application file structure [on hold]
Here is one of my node projects file structure.
I'd like to find out the best structure for such kind of server services (API). For example mongoose models stored in ...
1
vote
0answers
17 views
NodeJS authentication function rewrite with promises
I will post both of the modules, some of the code in them may be "irrelevant" for the main concern here, which is Security.prototype.authenticate(). Nevertheless, comments are welcome about all of the ...
0
votes
1answer
32 views
Consuming an API with authentication
I have created a library which consumes the Imgur API.
This is the main file.
...
1
vote
1answer
41 views
Handling callbacks when doing async programming and dealing with scope
I'm using HapiJS to create a little backend for my side-project. In grabbing RSS feeds, I want to loop through my list of website URLs, grab the correct RSS links in the ...
4
votes
2answers
48 views
Command line utility to output modified Markdown
What this command line utility does is to take a text file and update the content a bit before turning it into Markdown. For example, the first for loop searches all the straight quotes and replace ...
-2
votes
1answer
27 views
Multiplayer Tic Tac Toe with Socket.io [closed]
I am trying to learn Socket.io and develop a multiplayer tic tac toe game. Right now, I have developed a game that plays well when hosted locally, but I cannot seem to transmit game moves between the ...
1
vote
0answers
19 views
SQL Server to MongoDB Template
Looking for feedback on a set of templates I've just created. I'm planning on converting them to Yeoman but want to make sure they're ready for prime time before doing so. They are currently in ...
4
votes
0answers
44 views
Creating an async consumable object in Node
Background
I have a situation where I have fixed number of objects with their own routines that would need to be called with the same initial message.
To accomplish this, I have a Factory that ...
1
vote
0answers
15 views
Input a web page with poker events, output a gcal compatible CSV file
This script takes input from poker tournament pages at pokeratlas dot com, and outputs a CSV file that I can import to Google Calendar, listing each of the tournament events, start time, location, and ...
1
vote
0answers
8 views
0
votes
0answers
35 views
Sign-up controller and service
I'm programing server side node for a huge project. And I'm thinking my brains out about the best programming pattern that will be suitable for fast modification and changes.
Tell me what you think ...
2
votes
0answers
32 views
Rewriting authentication controller using promises
I am in the process of refactoring some complex code that uses callbacks to instead use promises. I am trying to figure out if my proposed approaches make sense.
...
4
votes
0answers
43 views
Minimax for Tic-Tac-Toe
I have written AI for Tic-Tac-Toe using Negamax in JavaScript. The Negamax object is translated from an implementation written in Python. The code runs on a Node.js server and the player interacts ...
-1
votes
1answer
32 views
Mixing assignment and expressions- good or bad? [closed]
As far as mixing assignment and expressions.... is it better to do or not to do? For cleaner code and readability.
mixing:
...
2
votes
0answers
41 views
To-do app in node.js
I get the feeling this code for a to-do app is not secure, and as I am just a beginner, I don't know about my coding style, is it conventional/elegant?
Please don't hesitate to criticize me.
...
0
votes
2answers
58 views
2
votes
1answer
52 views
Conditional callback for asynchronous file copy
I'm trying to figure out the most elegant solution to do the following asynchronously using JavaScript (specifically node):
Given a destination file name, check if it is a directory
If it is a ...
1
vote
0answers
27 views
Pagination handlebars helper
I've build a handlebars helper that takes n total pages and currentPage and returns the HTML for the page number links, skipping ...
0
votes
0answers
14 views
3
votes
0answers
28 views
Optimization for better response time to use in analytics application
We are trying to use NodeJS for analytics. The following code gets the parameter from a URL and dumps it into a flat file. Is there any way to optimize it to get better response time?
...
1
vote
0answers
21 views
1
vote
2answers
32 views
Handling with the 'error' parameter inside a callback function in node.js
I have multiple controllers and every controller has this error handler:
if (error) {
res.render('error', {
error: error
});
}
Sometimes I have more ...
0
votes
1answer
20 views
Using app.use only in routes that start with /admin
I have several routes, and I need Facebook authentication only in the routes that start with /admin:
...
1
vote
0answers
41 views
0
votes
0answers
14 views
Code enhancement for existing npm package
I am trying to improve the code in the npm package. I have looked through the code but don't have any ideas how to write proper code.
GitHub
...
5
votes
3answers
58 views
Concise HTTP server
Here's my code for a consise node.js HTTP server.
It does work as intended, but I'd like to ask if there's any glitch or to be improved.
...
4
votes
1answer
88 views
Serial port for Node.js
I am trying to create a class for serial port using Node.js, but I want to know if there is a better way to write my data class code.
In my sample code below, in the ...
5
votes
1answer
145 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
vote
1answer
58 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
41 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
52 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
64 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
41 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
39 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
36 views
2
votes
0answers
108 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
39 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 ...
8
votes
2answers
162 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
47 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
31 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
136 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
62 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
17 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?
...
6
votes
1answer
230 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
26 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
127 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
82 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
61 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
2answers
81 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 ...