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
1
vote
0answers
27 views

How can I better the elegancy of my code that uses axios?

I am trying to migrate from request to axios, since request has been deprecated. Suppose that the url 'https://www.example.com' receives a post request with formdata that contains login information, ...
0
votes
1answer
22 views

Javascript promise optional chaining

i've wrote a piece of code today that really make me sick about. This is the piece of code ...
0
votes
1answer
38 views

Registering a user and login

I have these following controller functions for registering a user and login, in my app, and I want to make it more clean and maintainable. Probably by using ...
1
vote
1answer
34 views

Python-like decorators for caching

I am building an ad-hoc text-editor. I have two functions which use a cache, provideHover and provideCompletionItems. ...
0
votes
0answers
9 views

NodeJs add Methods/Functions to have a better readable code

so i have to use Methods or Functions so my code is "better". I have no clue wich Methods or Function to use or how that exactly works since i am pretty new to NodeJs. I also had a lot of help with my ...
0
votes
0answers
18 views
-1
votes
0answers
47 views

Can this proxy call be done synchronously? [closed]

Here's the summary of the node.js code which does work asynchronously. ...
-3
votes
1answer
62 views

Searching for a user

I'm looking for any advice on the way I have implemented methods (explained below). More specifically, is it a good practice or not? And if not, any suggestions? NOTE - ...
2
votes
2answers
50 views

Is this a good approach for creating pages for multiple content typs with GatsbyJS?

I'm trying to create pages for multiple content types in Gatsby and I was wondering if this is the right approach: My gatsby-node.js file: ...
3
votes
0answers
28 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 ...
1
vote
2answers
120 views

Calculate transaction balances and find duplicate transactions

In an interview I was asked to solve two JavaScript questions. I thought I did pretty well because I: Covered the edge cases Wrote comprehensive tests Documented the code using jsdoc The interviewer ...
3
votes
1answer
124 views

NodeJS CLI script to create React apps

Background I crated a CLI tool which executes an npm command (to create a react app) and modifies the contents of the generated files. It was a practice attempt at ...
0
votes
1answer
57 views

How to refactoring function when I've to do many things in one function

I always want to improve my code by refactoring but when I've to work with complicated function that have many thing to do . How can I refactoring them. Here is my data for example I get data from ...
0
votes
0answers
10 views

ExpressJS user creation in pg-database

I created a table within a postgres database ( https://www.postgresql.org/ ) by executing the following SQL ...
0
votes
0answers
10 views

NodeJs Pub/Sub Implementation for concurrent messages

I have a csv-parser program and has execute() function which listens the messages and processes them. To make it concurrent I added ...
2
votes
2answers
33 views

Asynchronous array methods chaining

I am trying to check that a list of files are all images using functional programming. Some actions I go through are asynchronous, so I have to wait for them to completely finish before passing to a ...
4
votes
0answers
55 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 ...
2
votes
0answers
100 views

Rust/WebAssembly VS pure JavaScript benchmark in Node.js

I've wanted to try Rust and WebAssembly for a while. I recently realized that I could try both at the same time by compiling Rust to WebAssembly. I wanted to know what the performances of something ...
0
votes
0answers
32 views

Implicitly passing client context to services in Node.js

In node.js I have been trying to find a way to pass client context from the Express routes into the services without every service function to have a context. By ...
2
votes
0answers
25 views

Best way to catch API errors and log responses when calling via helper function

I'm trying to add error handling and response logging for API calls. The way I have my application (chatbot) set up is that a helper function is called from the main dialog, and that helper function ...
3
votes
1answer
72 views

Crypto createCipheriv and createDecipheriv for authentication

I'm not an expert in authentication, so I want to make sure I have done everything right. I am using crypto.createCipheriv and ...
2
votes
0answers
9 views

npm package as amqp client helper

I would like to build a common helper for my application that will manage all the amqplib calls from all of my nodeJS microservices. I would like to import my amqplibHelper to every microservice and ...
3
votes
0answers
33 views

Searching all new Reddit comments for comments matching regular expressions and notify of matches

This program constantly sends an https request to Reddit's API for new comments. Using a PostgreSQL Database containing Regular Expressions, find comments of interest and notify about them using faye....
2
votes
1answer
44 views

NodeJS APIs folder structure [closed]

I am going to have multiple APIs in routes folder should I put them in in the same file API or separate them? ...
2
votes
1answer
48 views

API using NodeJS to recive data from client and send it to a server

Hello I have a NodeJS which act like an interface it connects the client(mobile app) to the actual server My node JS API receives data from the client to verify it and send it to the server. I want ...
1
vote
0answers
41 views

Process data from mongodb and upload result to S3

I'm working on an AWS lambda function that take data from two mongodb databases, find the matching records between two collections by 'id' and calculate each record commission by fixed rate. Then ...
2
votes
1answer
39 views

Express Rest API Async and Scaling

I am currently learning how to create nodejs express rest api using async making it fully scaleable and secure. My goal is to ensure maximum functionality and speed, currently I am using MVC ...
4
votes
0answers
31 views

Browser and Node.js compatible code require

The Reason The reason I designed this code was that in many cases, when I wanted to test code in the browser that would be running on a Node instance, the code that I was copying (Don't worry, ...
2
votes
2answers
38 views

Function to get current timestamp in node

I have this code to get the current timestamp so that I can save it as a part of the key in leveldb database. ...
2
votes
0answers
23 views

Backend application to bookmark GitHub repository

The backend part has the following purposes. An endpoint that takes a search term and returns a list of repositories. An endpoint that allows bookmarking a repository by its id. An endpoint to get ...
1
vote
0answers
25 views

Check nodejs class optimisation

i am new with nodejs, and i am trying to ameliorate, not only my experience but the power of my code, so i would like to ask you today to give : some way to optimise my code note on 10 (?? / 10) for ...
1
vote
0answers
25 views

Splitting environments: prod and dev modes

I've decided on splitting my environments keeping them in .js files in an environment folder and keep all the sensitive information in .env file (use a third-party module 'DOTENV'). That's what I've ...
5
votes
1answer
61 views

Class for Switch statements

This is more to get clarity on an implementation that I did. I am working on a React, Node, and Electron application that essentially has a form that a user inputs values that will update some content ...
1
vote
0answers
116 views

Handle aws lambda function containing multiple axios call

I have written an aws lambda function in NodeJS which has 2 async axios call. ...
4
votes
1answer
54 views

discord.js/node : filter().map() best method

I'm learning javascript with discord.js and node and I'm always looking for the "best" code. Is this the "best code" for my map() ? ([role] required, (role) optional) ...
4
votes
0answers
206 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 ...
2
votes
1answer
55 views

Reduce the number of code if possible when creating a folder

My code below creates a folder based on the passed data from my client-side(VueJs) and checks if there's already an existing folder and deletes it if there is otherwise it will create a new one. My ...
5
votes
0answers
58 views

Return probability (Javascript)

I've been working on a personal project. There's this game called TFT which is an autochess game. Each match is played by 8 players and there's a shared pool of champions, each champion have their ...
1
vote
0answers
51 views

Repetitive code for an event listener

So I'm using the event emitter as some sort of an event bus(If I'm allowed to call it that). The problem I've stumbled upon is that my listeners might want different data than another listener. Since ...
2
votes
0answers
51 views

socket.io / jwt [closed]

I am studying socket.io and ended up making a connection using react as front end js and how to back end node js I was successful but I have a question as to how I made my code I don't know if it's "...
2
votes
0answers
125 views

How to apply best practices to javascript code

Hello I have recently started studying javascript, nodejs, and reactjs front end, and I have some questions about best practices to apply in this javascript world, I would like to ask for opinions ...
5
votes
1answer
40 views

Adding users for login

I have some questions about best practices to apply in JavaScript. I would like to ask about my code and how I could improve. Starting with an example, I have 2 functions with different ways of ...
5
votes
1answer
73 views

Writing a BitTorrent client in JavaScript

I'm trying to write a JavaScript BitTorrent client in Node.js to get more familiar with the language and ecosystem. I don't know how often people use classes in JavaScript since I feel like the ...
4
votes
2answers
51 views

A JavaScript class, which finalises the HTML of each page of my NodeJS (Express) website

Background A request (req in the code) is made to my server, and a response (res) returned. By the time the response has ...
1
vote
0answers
30 views

Proper imports and exports for nodejs and the browser

The Library is meant to be re-used for both the browser and the nodejs runtime environment, publishing this code for a code review to make it better and concise. Question: How to build a library in ...
4
votes
1answer
80 views

Uploading a file from web-based platform to S3 bucket using NodeJS - Callback Hell

This code checks user permissions for uploading file, and if user can upload, then the file undergoes a check to see if it exists in SharePoint. If so then the file is pulled and uploaded to S3 bucket....
6
votes
0answers
103 views

Node.JS Protobuf socket client with TLS support

I'm working with one environment which allows me to execute node.js code from single file without installing additional modules. My task is to write simple ssl socket client which will send protobuf ...
4
votes
1answer
51 views

Compile SASS files in a directory via Gulp.js tasks, one of which produces logging output

If the default task is executed here, the file name to be compiled is passed to the argument of the CompileSass function. When ...
4
votes
1answer
56 views

JSON to CSS in JavaScript

I'm working on a JSON to CSS converter in NodeJS, which takes a .json file and generates a .css file with its utility classes from it. .json example ...
3
votes
1answer
45 views

Reading a text file, manipulating it and saving it to a mongo database

We have an upcoming project at work which is going to require working with express.js. I have no prior experience with node.js, so I thought I'd try and do something aside from some courses. Are there ...

1
2 3 4 5
18