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.
918 questions
1
vote
0
answers
27
views
SvelteKit authentication hook with token refresh and request deduplication
I've implemented a SvelteKit handleFetch hook that manages authentication for API requests with automatic token refresh. The API provides a 15-second grace period where a refresh token remains valid ...
5
votes
0
answers
104
views
Correct abstractions/organisation of a NodeJS GraphQL API
I recently did a quick take-home test for a potential job opportunity. It included building a GraphQL API with nodeJS. I am not an expert in node (mostly use Python at work) but I have used it for ...
0
votes
0
answers
8
views
SafeDelete for Mongodb plugin
Title: Code Review Request: Mongoose Soft Delete Plugin with Query & Aggregate Middleware
Body:
I’ve implemented a soft delete plugin for Mongoose to handle REST API data safely in a MENN stack ...
3
votes
1
answer
258
views
A home server template to securely access personal apps
I have built a Node.js program called serverserver, and it creates a server that you can access remotely on your phone. When you start the program, it prompts you to visit your public IP address. You ...
1
vote
1
answer
132
views
Extract each occurrence from an array of objects
I have a huge list of 4k+ software products.
My goal is simple. I have a list of products. Each of those products has a software value. I would like to extract each software occurrence and covert it ...
2
votes
0
answers
60
views
Redact specific elements from JSON (for logging)
We need to implement a simple redaction function to redact (set to undefined) certain JSON elements when logging the JSON. The requirements are:
We can't modify the current JSON object, as that ...
2
votes
0
answers
108
views
To-do app with TypeScript backend (violations of TS best practices or unidiomatic code)
The working code in full is here.
It's a To-Do App with a TypeScript backend, written as practice for an upcoming 4-hour interview for a TypeScript backend role. My colleague and I would like to know, ...
1
vote
1
answer
3k
views
Process a binary file by chunk using a read stream in nodejs
I want to process a file chunk by chunk to prevent memory exhaustion. I need to consume the file using a read stream. When trying it, this implementation seems to work fine.
I am asking your expert ...
2
votes
2
answers
274
views
Permissions system in MERN app
I am working on a MERN stack app that is a CRM with a couple of modules. Now when the user sends x request to the server to do a supposed action (such as delete something), the server first checks if ...
1
vote
0
answers
57
views
Refactor Node.js Logging Library for Improved Readability
I have a Node.js logging library that applies ANSI styling for text formatting. Currently, the code contains some redundancy and could be refactored for better readability. I'm particularly interested ...
13
votes
1
answer
1k
views
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 ...
0
votes
1
answer
69
views
js template engine
I am building a template engine for js and I need some help refactoring the code for fast and more efficient performance. If you can help modify or suggest some updates I'll be grateful.
...
0
votes
1
answer
163
views
Using JavaScript to interface with REST APIs
The website TryHackMe came up with a challenge that involves using HTTP requests to interface with REST APIs (here, task #14/day 9). The challenge basically involves querying a basic REST API to ...
2
votes
2
answers
1k
views
FizzBuzz in JavaScript (node.js), my first JavaScript program
I had just decided to learn JavaScript, so I wrote this program. I am sure you know what FizzBuzz is so I wouldn't describe it here.
Console output:
...
5
votes
1
answer
95
views
Basic node authentication system
I built a basic authentication system for a node application and I have some security concerns. The username and password the user enters when they log in are stored as plaintext using express-...
2
votes
1
answer
200
views
Command handlers in node.js
Description
This javascript code uses tmi.js to listen for chat messages in a Twitch chat and perform certain actions depending on their content. In the sample code ...
7
votes
1
answer
634
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 ...
0
votes
1
answer
63
views
MVC Pattern - Need to include services file or not?
I am refactoring an old project, made in Nodejs with Express, applying the MVC pattern, today it is a fairly simple project: handling of the FCM and Remote Config tools from Firebase.
Would it be ...
0
votes
1
answer
624
views
Using a RegEx to create a UUID string
I'm writing a Discord bot that sometimes requires a Minecraft account UUID to be looked up so this is the function (and MWE) I have written to do this.
...
2
votes
2
answers
2k
views
Generate all possible unique combinations of positive numbers these have sum equal to N
This is my function to generate all possible unique combinations of positive numbers these have sum equal to N.
For example:
If the input is 4
The output should ...
1
vote
1
answer
253
views
Updating large and heavily nested JSON properties based on existing properties using nested forEach loops
The structure of the JSON is as such:
Each parent record can have many DataGroups and each DataGroup can have many ...
4
votes
3
answers
367
views
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:
...
1
vote
2
answers
100
views
Extend native `Array` instances
I need/want to extend created array instance, to add extra methods that i see as useful.
class.labels.js
...
7
votes
3
answers
315
views
parse date and number from API results
I'm slurping up fields from an API that returns an array of fields. Each field in the array is a String that actually contains two separate fields (a number and a date). The number is enclosed in ...
3
votes
2
answers
2k
views
Send multiple REST requests at the same time. (node)
Below is a (very) simplified version of a function I made that creates multiple REST requests to gather needed information.
Things to note:
One of the REST calls is dependent upon the output of ...