Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

0
votes
0answers
21 views

Load content from files (and sometimes parse) in Sapper

I am making my first Sapper app and the pages are all in routes. I am now extracting the content into a separate directory and unsure if I'm doing anything right. Here is an excerpt from my directory ...
1
vote
0answers
26 views

Node websockets

I have this code I use it for two things connect to lxd instances and emits any operation events it recieves over socket.io to the client Bridge between client and lxd for terminals Its pretty ...
2
votes
1answer
29 views

Retry a Promise resolution N times, with a delay between the attempts

I want some JavaScript code to take 3 things as parameters: A function returning a Promise. The maximum number of attempts. The delay between each attempt. What I ended up doing is using a ...
1
vote
0answers
30 views

Rethrowing Error through several classes

This is a simplified version of my app. It has a bunch of scraper classes, and a Job class, which controls the collection of data, and the saving to the db. During scraping it could happen many ...
0
votes
1answer
27 views

Making two sequential asynchronous requests using promises

The following code is making two asynchronous requests to obtain the desired data. The second request needs to access the data from the first request, hence I need to nest it. I know that it is better ...
1
vote
3answers
41 views

Javascript array_count_values function [on hold]

I am using an array_count_values function since I have translated the code from php to javascript and javascript does not have this function, but not sure on the ...
3
votes
1answer
77 views

AWS Lambda function to update newly added DynamoDB records

Approach All data is submitted into my DynamoDB from another Lambda > API Integration function whereas the lastUpdated row gets inserted as ...
0
votes
1answer
31 views

Handling a PUT API call to write to a database using promises

The following function is accepting PUT connection to a server API, checks authorization to write and then performs write to a database. The eslint linting tool ...
3
votes
1answer
68 views

Given a search string, fetch all movies results from the api

Was told this code was 'weird' and didn't pass the coding test. I tried to split up to show the different levels of abstraction but maybe I went overboard? I told them this in the walk through of the ...
3
votes
1answer
41 views

Separating Fetch Calls and using in Promise Chain

I´m currently working on a small microservice application, which will in it´s simplest form just receive a Request from a Formular and and based on containing information perform several other Server-...
1
vote
0answers
37 views

A CSS Browser Compatibility Checker

I am working on a program that checks for the browser support of a CSS file. Below you can find my working code, so far it supports CSS At-Rules & Properties. In the next few weeks, I will need to ...
0
votes
0answers
15 views

My implementation of page navigation using react-router, babel, webpack

I have written a page navigation using nested navigation in React.js using react-router. The code can be checked out as below, ...
3
votes
1answer
35 views

Node.js http retry do while mechanism

I have implemented a simple do/while loop to handle a http request to a third-party. I don’t know when the data I receive will have elements in its array so I retry up to 10 times until the array ...
0
votes
0answers
35 views

jenkins deployment making the build very slow

I am new to Jenkins. I am doing a build through Jenkins, but the build is very slow. Is there any way I can speed it up? ...
0
votes
0answers
25 views

Gmail API list messages NodeJS

I use the following code to list and trash messages from the Gmail API in NodeJS. I call the getAllMessages method to get all email bodies because the Gmail API ...
3
votes
1answer
34 views

JavaScript that deletes everything inside a folder on Box.com

I just finished a simple script for Node that will delete all the folders and files inside a specified folder ID through Box's API. It works by getting a list of items inside a folder, then generating ...
4
votes
0answers
55 views

Ship placement verification function for Battleship game

I wrote server-side Battleship game simulator in nodeJs/Javascript: A random player who begins is chosen. Both place their ships. Software recognizes if they are placed correctly. One of the players ...
1
vote
0answers
31 views

Batch script to download and extract Node.JS and NPM packages

The following is my first real attempt at batch scripting, and I'm new to it so I'm not sure whether what I've done is to best practice. The code works, and I'm open to suggestions. Basically the ...
5
votes
0answers
68 views

NodeJs crawler for recipes

Here is my try on a crawler made in nodeJs with cheerio, I made it with the idea in mind to use it in a future project I wanna make. Here is the git link: https://github.com/Just4lol/CookCrawler If ...
2
votes
2answers
29 views

Express.js handler to update user fields

I have an express handler which i thought was pretty simple, but CodeClimate flagged this method as having a Cognitive complexity of 6 (5 is the max by default without flagging something) Curious how ...
1
vote
1answer
52 views

Turning simple Node.JS Postgres query and logging into most-functionally-pure-possible code

After reading "How to deal with dirty side effects in your pure functional JavaScript," I've decided to take something I do on a regular basis ("Original approach" below)—connect to a Postgres ...
1
vote
0answers
28 views

Spawning multiple child processes to preview Vue.js projects

Context: I'm making a Codepen-like app but I want it to support sophisticated JS libraries/frameworks like Vue or Angular 2+ for example. I want to have a live preview of my snippet which updates in a ...
1
vote
0answers
31 views

Filtering users in socket.io and seeing who is online

While implementing socket.io on my server, I ran into some problems and eventually fixed them. The code below is fired on the connection event of socket.io: ...
1
vote
1answer
48 views

Calling token API

I'm calling an API to request token, and making sure i'm not leaving any corners for errors and handle the result appropriately. It's a web service POST call in general, The code gets credentials, ...
3
votes
1answer
58 views

json2CSV fails because of lack of RAM memory

I run this code on my Heroku Node.js server in order to get CSV for few hundred rows, but it fails with R14 - Memory Quota Exceeded. It worked fine when there were ...
1
vote
0answers
15 views

Stream wrapper in node.ts

I like Node.js and typescript a lot, but i'm still pretty much a newbie with streams. I know how to use them, but I have trouble understanding how the work, what are the consequences of using them, ...
1
vote
1answer
56 views

Authentication using express-session

I'm making an online shopping store or e-commerce and I use an express session for many things. Example: Shopping Cart, Authentication user* I store the data chart list in the database based on the ...
0
votes
1answer
41 views

NodeJS commit message validator

I wrote a commit message validator + CLI in NodeJS. Notes: My greatest concern is that the patten I use to represent the results of a validation is inadequate. Options: Use adhoc enums Create a <...
0
votes
1answer
68 views

Convert a stream to Promise

I need to collect all the data from the stream and resolve it as promise. I created this stream: ...
4
votes
1answer
137 views

Node.JS Server Queue Processor

I implemented a simple queuing system for my Node.JS app and wanted a critique on it's structure. ...
2
votes
2answers
51 views

Minimizing duplicate routes index.js

I am trying to build a REST API with express router, which contains of nested sub routes. I have mounted these sub routes in my index.js file. I have defined it as ...
0
votes
1answer
37 views

Is this a good way to use Try catch? [closed]

I'm new to handling errors and am not sure how to do it, basically, in a speicific request err.code === 11000 is not actually an error, but expected behaviour. I ...
1
vote
2answers
118 views

ACL express middleware implementation

I come to see you to help me improve an express middleware that allows you to control access resources by checking the rights of the user. The following code is supposed to be as generic as possible ...
-1
votes
1answer
42 views

#Error Handling- Propagating errors to calling function.

Im new to javascript programming and i am required to make a web app. Node.js will be used as the js runtime environment. In order to minimize the amount of time needed for debugging as the app ...
3
votes
3answers
138 views

Upload .JSON product list to MongoDB and upload image to AWS S3

I'm using Node/Express/Mongoose to accept a JSON file containing a list of product details. These products are looped through, the images are uploaded to AWS S3, and the product is either accepted or ...
2
votes
0answers
33 views

Flatten Hierarchical Categories

I have an XLSX file that contains a hierarchical list of categories. Each category has a basic query associated with it. I need to flatten these categories which involves combining the categories. I ...
1
vote
0answers
26 views
1
vote
1answer
249 views

Uploading multiple images to Google Cloud Storage using Node.js

I am no JavaScript expert, and I have managed to hack together a node.js script that does exactly what I want it to do: upload images contained within a folder to Google Cloud Storage for a Firebase ...
1
vote
2answers
96 views

Find if cookie name exists in the cookie string

I need to determine whether a cookie name is available or not in the cookie string. I have achieved this. We can use cookie-parser package but I don't want to use that package so I have written the ...
1
vote
1answer
36 views

Node.js configuration object based on environment variables

In the code below, I am building a NODE_ENV-sensitive config object from environment variables. ...
1
vote
0answers
72 views

Nodemailer class

I created the following class for sending mail in my node.js API : ...
4
votes
0answers
113 views

Automatically generate TypeScript classes from database tables

Made a project to generate TypeScript classes from database tables, and I'm looking for input if the code is reasonable. pg and ...
1
vote
0answers
35 views

Creating a bots with different actions

I am creating a set of bots. Those bots are made to visit websites and perform certain actions automatically on the website. Different actions are available for the bots depending on the website they ...
-1
votes
1answer
32 views

Best Approach for Assignment Code in Node.js (ES6 style) [closed]

Is there any way to improve this code? Using ES6 style i am using latest stable version of node.js. ...
1
vote
1answer
40 views

Allowing users to view and manage articles

This is a controller from an Express app that lets users view and manage articles. There are at least a couple of issues I'd like to address... The program displays a list of articles in a sidebar ...
1
vote
2answers
39 views
1
vote
0answers
44 views

Async API Function with Mongoose

I'm quite new to the language and I just started using async/await. I've written this function for an API that I'm developing. It checks what is sent by the user, specially the status that he wants to ...
-1
votes
1answer
53 views

Nodejs Interview - API calls and exchange rate

I did an initial technical phone screening with this company which went ok, they then sent me a programming exercise to complete and send back to them. The goal of the exercise: -take input as a ...
1
vote
1answer
32 views

JS/Node.js .env loader

I needed an environment values loader for a random node project, and instead of just using dotenv, decided to just make one myself and see how it'll turn out. To make this meaningful, here's a rough ...
2
votes
1answer
83 views

Updating entries in a JSON file

I have the following Data.json file and I would like to update some of the values. ...