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
-3 votes
0 answers
23 views

Fastify crashing on route registration [closed]

Why the Fastify app is crashing when I register a route? app.register( import( "./Routes/UserRoutes.js" ), { prefix: '/user' } ) UserRoutes.js ...
Marvix's user avatar
  • 85
-1 votes
0 answers
62 views

Merging objects recursively

Would like to ask if my function to merge two objects recursively is correct. Whenever an item of newObject is an object/array and the same document item is not, ...
user280307's user avatar
0 votes
0 answers
17 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 ...
Enrique Moreno Tent's user avatar
1 vote
0 answers
29 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 ...
Dinesh Basnet's user avatar
0 votes
1 answer
41 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 ...
Aaron Goldsmith's user avatar
2 votes
1 answer
85 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 ...
Sayaman's user avatar
  • 341
1 vote
0 answers
40 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 ...
David Chochol's user avatar
-1 votes
0 answers
19 views

Optimal updating strategy for Expo packages

Is this update strategy (^major, ~minor, exact version) reasonable for Expo 49? ...
Slazer's user avatar
  • 119
1 vote
0 answers
47 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: ...
KunLun's user avatar
  • 111
0 votes
1 answer
26 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 ...
JRR's user avatar
  • 47
1 vote
1 answer
59 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 ...
markb's user avatar
  • 171
1 vote
0 answers
45 views

Functional style dependency injection to make business logic unit-testable

My project is a blogging app, which is a recruitment assignment. It is now finished and working. Following function handles updating a comment votes, very similar as on StackExchange sites, preventing ...
jirkamat's user avatar
  • 111
2 votes
2 answers
165 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 ...
Syed M. Sannan's user avatar
0 votes
1 answer
43 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. ...
ahmed qoreichi's user avatar
2 votes
1 answer
62 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 ...
Krneki123's user avatar
0 votes
0 answers
54 views

small app with bad practices on node.js and vue.js

Can someone help me to understand and give me code review of my small todos APP, why my code in backend is bad? Also give me a answers for some of my questions, please: Where my code is bad? Where do ...
Олег Лазорик's user avatar
0 votes
0 answers
44 views

Detecting the content type of a given http body/string

I am trying to detect the content/mime type of a given Buffer/string. In other words, I am trying to guess what on earth is a given string. My approach is somewhat brute-force: ...
Dimitrios Desyllas's user avatar
1 vote
0 answers
31 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 ...
Slava Knyazev's user avatar
0 votes
0 answers
48 views

Accumulate chunks of data and consume fixed size buffers

From a stream, I receive buffers of varying length. I want to consume chunks of fixed length from this stream. I build a buffer accumulator to accumulate the chunks in an internal array, then I can ...
Louis Coulet's user avatar
0 votes
0 answers
38 views

Write Node.js code to receive HTTP calls that initialize and update objects stored in JSON files

This is a backend side of Node.js running a simple Http endpoints for a monitring system for a time-related task I recently developed a habit that I would rather spend time to make the code as less as ...
Chase's user avatar
  • 191
1 vote
0 answers
50 views

Weather and health app

This is a weather app that provide health and weather details based on the location you enter. Can someone help me to review my code? ...
Salvius Fernandes's user avatar
3 votes
0 answers
38 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 ...
Mah Neh's user avatar
  • 31
0 votes
0 answers
52 views

Cafegent backend: table management API using Express JS

I a new to coding and certainly new to this site. I apologise advance if I offend anyone or any rules. What should I do to further improve the code. Any suggestions would be appreciated. This code for ...
Debarka Mondal's user avatar
0 votes
0 answers
60 views

EVM Proxy Smart Contract Detector

This code flags potential Ethereum Virtual Machine (EVM) proxy contracts. Almost all proxy contracts are not auditable, since the code can be changed at any moment, and so should be avoided by users. ...
Jonathan's user avatar
  • 141
1 vote
2 answers
46 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 ...
Marc's user avatar
  • 153
-1 votes
1 answer
114 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 ...
Aleksey's user avatar
  • 173
1 vote
0 answers
50 views

Fetch external API currency rates, then save the results to database

The task I'm doing is, fetch external API, then save the results to database. I'm a beginner, I really wanna improve my code, to handle error well, and remove redundant code. The code is working, but ...
hsl's user avatar
  • 11
4 votes
1 answer
73 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-...
HDawG's user avatar
  • 43
2 votes
1 answer
160 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 ...
Patrick Christie's user avatar
-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. ...
Prajwal K Rao's user avatar
3 votes
1 answer
123 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 ...
doroshm's user avatar
  • 33
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 ...
hulike2286's user avatar
2 votes
2 answers
99 views

Find differences between two arrays

I have to identify added and deleted items between two objects with the same structure. ...
Elias Bobadilla's user avatar
0 votes
1 answer
46 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 ...
Sreejith sreeji's user avatar
1 vote
1 answer
38 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 ...
guido's user avatar
  • 13
1 vote
0 answers
174 views

Skyrim API, no previous experience

I recently created my first API, I intend it to be open source so anyone can contribute, what are the best practises I missed? What should I include in the API? For now it only does contain single ...
FColor04's user avatar
1 vote
1 answer
83 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 ...
user8758206's user avatar
3 votes
1 answer
115 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 ...
user9560064's user avatar
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 ...
Romuloux's user avatar
1 vote
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 ...
sg7610's user avatar
  • 370
2 votes
1 answer
52 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 ...
delaklo's user avatar
  • 23
1 vote
0 answers
65 views

Nodejs - Javascript buffer that takes in uint64, enum and string data as input

I am writing a nodejs program that adds some data into a buffer, before it is streamed. The data types are listed in the comments of the code, and there are fixed places in the buffer that these data-...
Barney Chambers's user avatar
0 votes
1 answer
78 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 ...
Jiry_XD's user avatar
  • 31
0 votes
1 answer
485 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. ...
Jake's user avatar
  • 131
2 votes
1 answer
100 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: ...
user8758206's user avatar
1 vote
1 answer
187 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 ...
Faahmed's user avatar
  • 113
1 vote
0 answers
30 views

Creating records in several tables with a single mutation

I'm studying nodejs w/ graphql and I would like to make sure I'm going in the right direction here. My study project is based on a simple ERP with entries, products, orders and users. I have one ...
Ianagos's user avatar
  • 11
3 votes
1 answer
204 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 ...
Denis Cherepanov's user avatar
2 votes
0 answers
652 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 ...
Cristoforos choras's user avatar
1 vote
1 answer
2k 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 ...
Louis Coulet's user avatar

1
2 3 4 5
20