All Questions
923 questions
-3
votes
0
answers
55
views
Can you help me speed up this SQLite query?
I have two tables: month (thread) and company (comments in thread), here is the Better-Sqlite schema:
...
3
votes
1
answer
214
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 ...
3
votes
1
answer
43
views
My surrealdb (1.x) migration script
I'm working on a migration script for surrealdb (currently working with 1.x).
Please review and let me know what I should improve.
...
0
votes
0
answers
23
views
is it better to import data from json file instead of api calls in React Js?
I used different way to load data from wordpress-rest-api for frontend-reactjs as following :
built simple services by node js to communicate with wp rest api and save response into json file in ...
2
votes
0
answers
38
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
1
answer
40
views
Databases, dependency injection and static methods
I'm working on a Next.js app and looking at the best way to structure database access. With Next.js and web based apps in general, there are lots of different "server actions", aka, API ...
1
vote
1
answer
72
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 ...
0
votes
0
answers
44
views
How can I make the webRTC and signaling feature code production ready?
I am learning webRTC and tried to implement signaling service through websockets. I am still a beginner in backend development so not sure how correct my code is. Can you please review it and let me ...
0
votes
0
answers
62
views
The Wacky World of ANSI Escape Sequences?
I just finished creating my first npm package (for learning, not competition) and published it. Now I want to ask some questions, for example:
Is my method of writing code good (for later maintenance ...
0
votes
0
answers
39
views
Construction Permit Web App
I have a Next.js + Node.js + TypeScript + Tailwind + tRPC project whose objective is to allow a construction manager to figure out what permits are required for his renovation based on if it's an ...
1
vote
0
answers
85
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, ...
0
votes
0
answers
52
views
React based Quiz Website
I have recently worked on a quiz application using the MERN stack. The application incorporates various features such as user authentication, quiz creation, scoring functionalities, and data ...
0
votes
0
answers
93
views
Express Auth - Session middleware to check the user is authenticated
I am building an API with Express and NodeJS.
I have made this middleware to check before executing my controller, that the user is logged in. It has taken me quite a while and I would like if another ...
1
vote
0
answers
36
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 ...
0
votes
1
answer
49
views
Updating class method to use data from new weather API endpoint while keeping same return value object structure as with old endpoint
I needed to update a class in Node.js that parses the response from a new weather API endpoint but still preserves the same object structure and key values from having been using the old weather API ...
2
votes
1
answer
108
views
Consuming sharded database using node.js
I think the only big improvement that can be made is to check which shard to query based on the userIds of the followed users. One easy way is to check the last ...
0
votes
0
answers
55
views
Node.js Image Optimization Service Using Sharp Library
I've developed an image optimization service in Node.js, leveraging the Sharp library for image processing. The service is designed to handle various image formats, offering resizing and format ...
1
vote
0
answers
89
views
Nodejs Websocket pulling new data from InfluxDB
I have a nodejs server with websocket which is pulling the new data from InfluxDB and send it to client.
The piece of code is this:
...
0
votes
1
answer
27
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 ...
1
vote
1
answer
77
views
Javascript CLI to boot iOS simulators, install project, extract data, and merge into JSON
I'm a DIY "dev" - so I really create things that I need or think they'll end up helping others.
I wrote this Swift Package so the iOS community could get device bezel radius' to help with UI ...
2
votes
2
answers
224
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 ...
0
votes
1
answer
44
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.
...
2
votes
1
answer
85
views
Session-based authentication using Express.js
I'm currently learning Express.js and I wrote this authentication code. I'm unsure if what i have is correct, how to improve it and if it's secure. For user and session data storage I'm using ...
1
vote
0
answers
36
views
Asynchronous Generic Resource Pooler
A personal project I'm working on needs Worker (thread) pool. The libraries I looked at were too high-level for my needs, as I simply needed access to the Worker itself while the libraries offered ...
2
votes
1
answer
71
views
Automatically extract useful cars from car site
I am using puppeteer to extract data and see when a car that meets my requirements shows up, this is what I did so far. I would like some basic syntax advice, or more advanced tips as well.
I tried to ...
1
vote
2
answers
50
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
...
0
votes
1
answer
127
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 ...
4
votes
1
answer
79
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
171
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 ...
-2
votes
1
answer
66
views
Reducing complexity and making it more readable [closed]
I have this NodeJS code which I need to Reduce complexity and making it more readable coz it has to many repeatable loops, and the api is very slow how do i fix this.
...
3
votes
1
answer
131
views
How can I condense my code in node.js for sorting unique values within an array?
Kattis problem - ("I've been everywhere")
I would highly recommend looking at the problem through the link, however I will summarize it a bit here and explain the functionality of each part ...
3
votes
1
answer
44
views
Generate total property sold for given postcode
I had to implement the below as a coding challenge.
There are two http endpoints. The first http endpoints returns a list of postcodes. The second http endpoint takes a postcode as a parameter and ...
2
votes
2
answers
111
views
Find differences between two arrays
I have to identify added and deleted items between two objects with the same structure.
...
0
votes
1
answer
51
views
Nodejs Module Pattern And Caching
The question is about nodejs module pattern code structure.
My goal is to initialise the module at one time and export the module using module.export
so that, it's ...
1
vote
1
answer
44
views
Function that querys database and then renders a view
Im new at backend development and I'm noticing that my code is very messy and difficult to read. I know this doesn't have a single correct answer but id like to know how I can make my code tidier when ...
1
vote
1
answer
86
views
Optimising a simple graphql mutation resolver
I am writing a resolver for a typical updateUser mutation with node, Apollo Server and mongoDB. I want to make it such that, when the ...
3
votes
1
answer
125
views
A Language Bot: For creating noun declension or verb conjugation tables
I'm a freshman student.
What does my program solve?
This is actually a bot for reddit, and there are language learning subreddits on that website, sometimes when discussing something with people, we ...
4
votes
1
answer
1k
views
NextJS with a root level catchall route for all URLs dynamic middleware that splits into components
Here is the solution that I have. Due to the legacy product we have all of our URLs in one big Slug model in rails that maps URLs to models.
EG
...
0
votes
0
answers
2k
views
Node.js batch processing
Batch processing steps:
When a job is posted, push it to the queue.
Get the required number of items from the queue and put it in the ...
2
votes
1
answer
56
views
the mini js tool library
I am a newbie js "developer" and for practice, I created a tiny (8 methods) JavaScript library. I need you to give me feedback "should I keep expanding my library or switch to something ...
0
votes
1
answer
90
views
Simple websocket chat app, security and efficiency concerns
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 ...
0
votes
1
answer
603
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
1
answer
110
views
Basic node login routes for authentication system
I am building a basic authentication system with a node backend and wonder whether I am using the try-catch block excessively. I have this example controller:
...
1
vote
1
answer
232
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 ...
3
votes
1
answer
211
views
Server code to upload and save images to cloud storage
Is there a way to beautify my code? It works but there repeated blocks and I am not sure that I'm using some functions in the right way. I'm not new to JavaScript but I want to improve it and get rid ...
2
votes
0
answers
693
views
Cows and bulls game in JavaScript
I've been working on this game the last 2 days. The game is working but I need a feedback for my code. Can it be made simpler? Sorry if my code is very complicated or not well written: I am in the ...
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 ...
0
votes
1
answer
113
views
Spawning a child process that is accessible in global scope through use of eval()
So basically my question is what would be a better way to achieve my goal? The code below works fine but looks like it is extremely inefficient and could be achieved in a better way. The code ...
1
vote
1
answer
109
views
Three efficient JavaScript functions that converge to pi extremely fast
I am learning JavaScript and decided to translate my Python scripts into JavaScript.
Approximations of π are extremely popular programming challenges and I am sure they must be a staple of the ...
1
vote
1
answer
217
views
JavaScript function that generates Fibonacci like sequences of given order
Generalizations of Fibonacci numbers
Fibonacci numbers of higher order
A Fibonacci sequence of order \$n\$ is an integer sequence in which each
sequence element is the sum of the previous \$n\$
...