All Questions
155 questions with no upvoted or accepted answers
6
votes
0
answers
586
views
nodejs 401 request retry mechanism
I'm working on a project in which I have a backend in nodejs and from there I need to call external APIs, those APIs require authentication token which is valid for 15 minutes. So if response status ...
5
votes
0
answers
1k
views
Mocking the file system within a test
I've been using this method to test file-system functions as an alternative to mock-fs due to its lack of symlink support. I'd love to hear what others think and ...
4
votes
0
answers
56
views
Fetching data from endpoint, retrieving coordinates, then merging into an output
I'm in no way a skilled developer (or even a developer at that!) but I did want to take a go at writing a script that fetched one endpoint's data, extracted some data, sent if off to be geocoded, then ...
4
votes
0
answers
167
views
HSL Guessing Game in Svelte
The objective of the game is to guess the hue, saturation, and lightness values of a given color swatch across ten rounds.
https://github.com/shreyasminocha/guess-the-hsl
https://guess-the-hsl.now.sh
...
4
votes
0
answers
342
views
JavaScript AVL Tree
I have been working through Introduction to Algorithms 3rd Edition, and have implemented an AVL tree through prototypal inheritance. The code presented here does work as expected based on the tests ...
4
votes
0
answers
342
views
Running a JavaScript program from C# with sandboxing
I am using EdgeJS in my application. The application is used to run a user-provided javascript program from C#. Because we allow execution of user scripts some sandboxing is required. I am using vm2 ...
4
votes
0
answers
412
views
MongoDB BulkWrite - create or update a sub document within an array
I have a series of Events (roughly 10-20 events that will be dynamically created per month):
Event Model:
...
4
votes
0
answers
887
views
Node JS | From Excel to Json
Intro -> I have to convert an excel file, which comes usually in this way:
to a Json file that must looks like this:
...
4
votes
0
answers
178
views
Node.js tool to update Cisco UCCX with CSV data
What this tool does update skills for agents on a Contact Center Cluster (Cisco UCCX). The tool reads a csv file called agents.csv from the current working directory. This file has a list of agents ...
4
votes
0
answers
2k
views
Automatically generate TypeScript classes from database tables
Made a project to generate TypeScript classes from database tables, and I'm looking for input if the code is reasonable. pg and ...
4
votes
0
answers
62
views
Showing a Wikipedia article's changes as Git commits
I created a small-ish NodeJS script which takes as argument the name of a Wikipedia article (and optionally a Wikipedia edition, "en" is default) and creates a Git repository with each change made to ...
4
votes
0
answers
2k
views
Mongoose schema for products and social media posts
Here is my current schema:
Brand:
...
4
votes
0
answers
326
views
Passport user authentication
I'm using Passport in Node.js app to authenticate user by email and password (login) and also by token.
Email and password are used only when user is logging in. Passport local strategy generates ...
4
votes
0
answers
416
views
Restructure of Express CORS middleware for unit test
How should one break this component down to better perform unit test on its behaviors?
Issues:
Authentication middleware component makes external request.
Must recognize preflight and final flight. ...
4
votes
0
answers
138
views
Core class of a JavaScript framework for Single-Page-Applications
A few years ago I started building a tiny (~300 SLOC) JavaScript framework for scalable and maintainable Single-Page-Applications written in CoffeeScript.
GitHub
www.scaleapp.org
It's inspired by ...
3
votes
0
answers
188
views
Simple websocket chat app
I'm coding a simple websocket chat app. I was wondering if my code is secure and efficient.
I also have a question about the way how I'm sending objects and then checking the type, is there anything ...
3
votes
0
answers
204
views
Fetch JSON from several URLs
The exercise is Write a JavaScript package that is able to:
fetch an array of URLs which contain JSON data
return their contents in a promise
I have already made a solution to this exercise, but I ...
3
votes
0
answers
75
views
Simple Markdown Blog
this is my first real website I created after learning about web development.
It's amazing to me that anyone would spare their free time to code review strangers' code. So thank you in advance. I'd ...
3
votes
0
answers
48
views
Node.js Dumbserver
Dumbserver, or the simplest workable HTTP server. It is supposed to operate in the 'traditional' way, that is, mapping paths in requests to the directory structure.
Why did I write it: I needed a ...
3
votes
0
answers
57
views
Right structure, three-layered architecture webdevelopment
My question is have i gotten the three-layered architecture right with error handling etc. I have a webpage containing different resources. The code works but I am not sure if have structured it ...
3
votes
0
answers
303
views
Single Producer/Multiple Consumers in Node
I've done my best to contrive an example of the problem I'm trying to simplify. I have a pool of workers, and each worker can do several tasks at a time. Each task takes an unspecified amount of time. ...
3
votes
0
answers
416
views
Mern stack app on error handling, async await, try-catch and avoiding DRY in controller functions
I'm looking for a review of my backend code on how to keep it more DRY. I see a lot of repetition in validation part of email and password, also I need some advice on if I have used the try-catch and ...
3
votes
0
answers
40
views
Decoding request object before use it in an Insert query
I want to decode a request object before use it in an insert query.
Request object containes the following JSON body:
...
3
votes
0
answers
217
views
Fulfillment webhook with Dialogflow to operate on a Firestore database
I'm currently calling a fulfillment webhook with dialogflow in my node backend, performing crud operations on a firestore db. Is there a better, cleaner way to ...
3
votes
0
answers
88
views
Clean code: Permission with middleware
In my example, I have four models: User, Company, Project, and Plant (though my project technically has more: Plant, Job, Team, etc.).
...
3
votes
0
answers
670
views
Example Multiple Async Await Calls Javascript
I need to make an unknown number of api calls, up to 5 max probably. But most samples I've seen show only a couple of async calls so are effectively hard coded to the number of calls being made.
This ...
3
votes
0
answers
200
views
JSON flattening with object duplication on array property for CSV generation
I am looking for a way to transform JSON data into a flat "csv-like" data object. In some way, I am looking to "sqlirize" a mongodb collection. I have already check some json flat libraries in NPM ...
3
votes
0
answers
78
views
Communication with interactive program using ChildProcess
There is an interactive program, namely Microchip Debugger (Later called MDB), which I want to communicate with from NodeJS program. You can think about it as any console-based debugger - they all do ...
3
votes
0
answers
58
views
Node/Express authenticate Google email address
Trying to set up express server that will authenticate a user's Google email before proceeding.
The code below works, but is there any way to make it more elegant?
The whole ...
3
votes
0
answers
661
views
Scraping StackOverflow's questions with Node.js
I'm new to node and web scraping in general but with some research I've written this working code.
My goal is to get all questions from X Stack Overflow's pages sorted by most rated and save that ...
3
votes
0
answers
1k
views
AWS Lambda Function to Register in Cognito
This is the entire code for a Lambda function that registers a new user in Amazon Cognito.
The email, username, and password are passed to the Lambda function. The client ID is stored in an ...
3
votes
0
answers
32
views
Testing whether pages can be fetched from two ports
I have an endpoint in my API which does a port test on 4455 and 4456 once a client GET's it. This is accomplished by requesting two web pages. The result will respond to the client with a JSON object:
...
3
votes
0
answers
42
views
Test Driven Development in JS and Sinon Stub
I am going through some TDD and BDD tutorials which guide one through implementing a simple beverage-ordering system. While I think I understand the material, I am still wondering about some ...
3
votes
0
answers
1k
views
Redirect to previous page using Passport Facebook strategy in Express
Somehow, I couldn't redirect the user back after its authentication. I was using successReturnToOrRedirect property, but it kept sending it back to ...
3
votes
0
answers
70
views
A function that debits a virtual wallet and calls an API to disburse to a real account
I am trying to determine if there is a better way to handle reversals for this function.
This is how it works:
A user inputs in amount, bank, and account number this would be used to debit his ...
3
votes
0
answers
91
views
Retrieving data to be displayed on a dashboard
I created a dashboard that uses CanvasJS graphs to show data collected by embedded devices. My problem is to get the last ten documents from a cloudant DB for each one of the devices. I've already ...
3
votes
0
answers
313
views
Uploading series of large files to API via Node
I wrote a node script to traverse a folder of hour-long mp3s and upload them to Mixcloud via their API. It works, but I suspect it's fairly inefficient - the computer it's going to run on at our radio ...
3
votes
0
answers
565
views
Recursively list files in provided directory in the style of `npm ls`
I've written a small CLI node program to list the contents of a directory with an output similar to that provided by npm ls but listing both files and directories, ...
3
votes
0
answers
144
views
Gulpfile Optimizations
I'm looking for some advice in how well this gulp file is written out and any suggestions on improving it. Any insight is appreciated
...
3
votes
0
answers
244
views
Wrapping a node.js module using elasticsearch
I need to use elasticsearch in my node.js project, whose API looks like the following:
...
3
votes
0
answers
260
views
Keeping error details out of responses (Restify)
I'd like to make sure error details are never sent out in responses from my restify-powered API. The best way to achieve that seemed to be via wrapping server.formatters in another function which ...
3
votes
0
answers
87
views
Knowledge base app using MEAN stack
I've been working on an app based on the MEAN Framework. I have got the app working but I just wasnt sure whether my coding structure and standard was good enough, meaning does it adhere to the ...
3
votes
0
answers
5k
views
Calculator in Node.JS
I'm new to parsing, and there's only one way to learn anything, and that's to do it yourself. So I did. I wrote what is essentially a calculator. But instead you will send it a string and it will be ...
3
votes
0
answers
47
views
Periodically monitor if record is not updated using Node, Event and setTimeOut
Here is my scenario:
Every user checks in every five minutes.
If some user doesn't check in after 5 minutes, I should be able to keep track of it.
If some user doesn't check in N number of times, an ...
3
votes
0
answers
67
views
RESTful API for serving videos to a client
I'm building an app that serves videos to a front end client. My stack is Express/Angular/SQLite. The db doesn't hold users, only root. I'm concerned that my controllers are too hardcoded, but I'm ...
3
votes
0
answers
4k
views
Depth first search implementation
I've been practicing my algorithms using The Algorithm Design Manual. I've decided to implement the depth first search section (5.8) using javascript. Note you can execute the code here if you don't ...
3
votes
0
answers
132
views
Q.js worker pool
I'm building a program to scrape data about hockey games in order to compile statistics. One of the run modes will process all of the games in a single season (1230). Processing a single game consists ...
3
votes
0
answers
1k
views
Save file from request to database
I am saving (image) files to PostgreSQL database in my Node.js and Express server application. The code is used to upload user images to server (at the moment it is not restricted to image files in ...
3
votes
0
answers
155
views
Sourcemap translator service
This is my first attempt to a serious Node.js application, I've tried to follow the async style of Node at my best, but I have several doubts and I am sure that this code can be massively improved.
...
3
votes
0
answers
184
views
Beginner's To-do app with Node.js
I get the feeling the code for this to-do app is not secure. I am just a beginner, and I don't know much about coding style so do you think it is conventional/elegant?
Please don't hesitate to ...