Questions tagged [node.js]

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.

Filter by
Sorted by
Tagged with
0votes
2answers
49views

Trying to follow Single Responsibility Principle with download and show progress

Let's get right into it, I have a function downloadFile(url, path); Downloads file and saves it. donwloadFile.js ...
0votes
0answers
16views

REST API server with Typescript, Node.js, express.js and MySQL: A few questions

I'm developing a Conway's Game of Life / generalised cellular automata simulation app for Android using React Native. One of the planned features will be the ability for users to access a catalogue ...
  • 31
0votes
0answers
21views

Correct use of Promise with a HTTPS Request in JavaScript

All, I am new to JavaScript. I am writing a class to communicate with an asp net core web API and I want the code to be as correct as possible. In the below, I make a request to register a user ...
0votes
0answers
21views

comparing two names using fuzzy

I am joining a new company and I want to make a positive impact in regards to my code. I was asked to do compare two fuzzy name and return if the name is valid or not. For this I wrote the following ...
  • 121
2votes
1answer
38views

REST metadata fields generation

I wrote a code to fetch the data present and store it in Array format but I thing I have wrote code multiple times can It be possible to minimize the code as its too long ...
  • 123
2votes
2answers
91views

Javascript/Node: Reducing a sorted array of pairs such that the values corresponding to the same key are summed

System/Language: I'm using plain Javascript to write this algorithm. Environment: Node 17.4.0 with a system that has ~7000 MiB of Memory and ~400GB of Storage. Input Data An (...
1vote
0answers
23views

Implementing a REST API that uploads a document and it's information to the drive and database

I want to develop an applications where users (students in my university) can upload documents (some sort of a GUI for the drive). I have a Vue application and a NodeJS server which is used as a REST ...
  • 271
0votes
0answers
41views

Parse a user's time specification (wide choice of formats)

Scenario I've got a one-line user input command that I need to handle and breakdown with regex. Example: In 7:00 pm In MM/DD, This is suppose to check in on a certain day In 23:11 In -1 Current day ...
  • 1
2votes
0answers
60views

express.js server to resize images

What I have is a simple express js server where user sends an image url with a specific width all in the URL query. the code will get the image stream pipe it into a sharp.js module then send it back. ...
0votes
4answers
191views

High CPU and memory usage iterating over 300K objects

I am trying to run a series of keywords against a series of categories and then within those categories there are some options. So I have ended up doing a forEach ...
  • 177
2votes
1answer
18views

Implementation of a schema-less `AND` query in Node.js against array of objects

Note: I'm still very new to the code-review stack exchange, so if this question does not align with the community guidelines please leave a comment below explaining and I will do my best to modify it ...
  • 147
6votes
1answer
165views

Implementation of exponential backoff algorithm

You can read about the algorithm here. An exponential backoff algorithm retries requests exponentially, increasing the waiting time between retries up to a maximum backoff time. An example is: Make ...
  • 360
1vote
0answers
31views

Is my e-commerce app's code compliant with MVC?

Hi I have spent few days reading about various architectures and decided to use MVC (Model-View-Controller). But I had hard time applying all the theory to my node.js code. I've wrote some minimal ...
  • 11
2votes
1answer
42views

Group By Statuses using reduce

I have been using reduce() method to group by Open and Closes statuses (Status_111, ...
0votes
0answers
35views

Improving multiple row creation query in JavaScript

I'm trying to create multiple rows in my db with an array. This array has multiple objects of products chosen by the client. ...
2votes
0answers
63views

Undo/Redo implementation using Memento pattern Javascript

Relatively new to the Design patterns, Generally my works are writing function for the needs. But now i need to implement a undo redo functionality, so i just read about the different patterns which i ...
4votes
3answers
171views

Random matchmaking for a p2p chat application

I'm a back-end developer (in PHP and Python) and I use JavaScript mostly for DOM manipulation. Now I'm writing a chat app in Node.js and I'm not sure if my code is the cleanest. Here is how it works: ...
  • 91
4votes
1answer
400views

Codility's biggest binary gap [100% score]

Task description A binary gap within a positive integer N is any maximal sequence of consecutive zeros that is surrounded by ones at both ends in the binary representation of N. For example, number 9 ...
  • 869
2votes
1answer
47views

iterating a big list of objects throws a memory issue

I'm writing a function which iterate through a list of objects and should return: true if all the items have the attributes (cp and type). false if all the items haven't the attributes (cp and type). ...
  • 123
2votes
0answers
49views

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 ...
2votes
1answer
31views

Arithmetic quiz on the command line

I am writing a program that asks questions, takes the user's input, and responds according to whether the answer they gave is correct or not. I am looking to improve my code with respect to ...
  • 21
2votes
1answer
89views

Learning asynchronous caching by implementing one

After implementing a serial CLOCK second-chance cache in C++ without having enough rope to shoot myself in the foot, decided to dive into Javascript through NodeJs and write an asynchronous one. I ...
0votes
0answers
19views

Socket.io: Pairing from two rooms without repeated pairing?

I'm working on a user-pairing algorithm using socket.io, and it is running on Node.js. I want to make sure that no repeated pairings will happen when people connect in. The steps of the algorithm as ...
1vote
0answers
13views

Getting metadata out of a Shoutcast stream

I have written the following class used to get the metadata out of an internet radio station. It takes a Node Stream and transforms it to grab the metadata out of the mp3 stream and then removes the ...
  • 111
2votes
0answers
29views

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 ...
  • 561
1vote
0answers
23views

basic node.js controller action with get request

...
  • 207
3votes
0answers
25views

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 ...
  • 151
0votes
0answers
25views

Validation handler in node.js

...
  • 207
0votes
0answers
23views

Memory Allocation problem in codewars: Improvements to use less memory : Tribonacci sequence

Consider my following code from the Tribonacci sequence kata. ...
  • 113
1vote
2answers
60views

A function to find all the primes between two numbers whose reverse is also a prime and doesn't include palindrome, in JS

I am trying to solve a challenge in which I have to write a function that takes in two numbers as arguments and returns an array containing numbers between them which are prime and their reverse is ...
  • 113
1vote
0answers
38views

How to implement robust and secure session management (in general, and in Next.js)

I am using Next.js and want to properly implement session management into this serverless architecture. I checked out nextauth but I am not really a fan and it doesn't implement some things I think I ...
  • 269
0votes
0answers
14views

Does using the multiple setTimeout decrease the performance of the nodejs app

Cancel the old timeout for the trip. Find the trip by Id validate it. Find the new driver not in old driver. If driver not found Try again Sent request to the new driver. Update the trip driver. Sent ...
  • 31
1vote
1answer
182views

Common CRUD function in node js using Express

I have created common function for CRUD operations. I am using Sequelize JS, I have created all models in Sequelize I have written stored procedures in mysql for CRUD operations for each module/...
0votes
0answers
20views

manipulate "require" to load files from a "virtual file system"/in-memory

Im trying to implement a plugin system. A plugin is a compressed gzip tarball with files and folders. The tar file gets extractet and stored in memory. (The files are never written to the filesystem) ...
  • 101
1vote
0answers
55views

Genetic Algorithm Typescript

I learnt a little about genetic algorithm. And I made a program from typescript that tries to evolve and match word/sentence using genetic algorithm. But if I give a little longer sentence it takes ...
2votes
2answers
56views

Blog API implementation in node.js

This code is from my blog project. This project is almost done. This is working well. I can create new posts and update and display all saved posts. ...
  • 23
1vote
1answer
109views

Is My Controller too Coupling?

To put it in context, I had the assignment to do for a job interview in Node.JS, which basically making CRUD with products (and it have certain conditions). The assignment was well-understandable, and ...
  • 19
2votes
1answer
76views

Web-browser Tic-Tac-Toe game

I have made the tic-tac-toe game as part of The Odin Project course. I think the code I have written just works but is not properly optimized for performance and it could be made simpler. This is ...
1vote
1answer
55views

Function that decodes all values of a given object from Base64

I have function decodeVals in NodeJS that decodes all of the values of the given object from Base64 to ASCII. This is achieved by traversing the values of said ...
  • 113
5votes
3answers
736views

Employee Model definition without an ORM

I am the author of this code. It's from an actual project, and it returns the desired result. However, I am very concerned that I'm not defining my Model correctly. The Model is instantiated in the ...
3votes
2answers
67views

Javascript best way to filter out empty values and simplify reusable function

Hello I have this function that takes array of objects and takes a specific value from the object and creates array of strings that can make mapped to dropdown selector. ...
2votes
3answers
97views

Is this node.js class returning a json

...
  • 207
2votes
1answer
89views

TypeScript, React and Node app to get 'games' data from a database and display them on a frontend

This is only one of the first apps I've built with Node, React and TypeScript. I was wondering what could be made better. This is at this point the best I've been able to come up with, but I'm not ...
  • 231
0votes
0answers
57views

Commands loader

Loader - load commands files(classes) from directory of commands and module, if the commands are very simple and similar, then I put them in 1 file with the name of the module and load them through ...
3votes
1answer
187views

Sanitation and validation of a user input 10 digits phone number

phoneNumberCheck() is using 2 helper function to check if a users input of a phone number is valid. this is a client side check, if this code is ok should I check the same at the nodeJS back end? is ...
  • 55
1vote
1answer
40views

Node.js Service Registry

...
  • 207
1vote
0answers
17views

Calling promise-returning function within promise-returning function

I am rather new to JavaScript and never really worked with promises before. My code works but I would like to learn if there is a better approach? I want to implement the following functionality: ...
  • 111
0votes
0answers
8views

A recent activity github action written in node.js

I and Abishek Joshi forked a repo, and improved a lot of code in it and published it, we did that because that original repo was last commited on 2020 december. For more info on history you can visit ...
13votes
1answer
1kviews

Simple NAPI wrapper around self written C++ msgpack, horrible performance

I have written a relatively small msgpack implementation in C++, with performance that is not too bad, so I decided to write a NAPI wrapper around it, but the performance is just horrible. I am ...
  • 233
1vote
1answer
37views

Is this file a good starting point for accessing data inside this json file via javascript classes?

I was given a spreadsheet of data that I turned into a CSV file and then converted it into a JSON file. I threw it into my application and I am processing it in the following manner: ...
  • 165

1
2 3 4 5
20