Stack Exchange Network

Stack Exchange network consists of 174 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.

1
vote
0answers
22 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: ...
0
votes
0answers
22 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, ...
-1
votes
0answers
15 views

Reftorar código [closed]

Qual melhor forma de refatorar esse código e deixar o mais curto possível em TypeScript sou novo nessa demanda. Ele Recebe um JSON e compara para achar uma imagem em um diretório onde nome da imagem ...
2
votes
1answer
25 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
12 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, ...
0
votes
1answer
24 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
39 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 <...
1
vote
0answers
27 views

MySQL database connector

I want to connect to a MySQL database in JavaScript in an OOP compliant fashion. I'm not sure if I'm trying to adapt my Js code to read like Java too much. I'm wanting to learn how to store 'vars' ...
0
votes
1answer
45 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
131 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
48 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
77 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
41 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 ...
2
votes
3answers
124 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
25 views
1
vote
1answer
150 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
93 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
30 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
64 views

Nodemailer class

I created the following class for sending mail in my node.js API : ...
3
votes
0answers
65 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
31 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
38 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
36 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
51 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
30 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
80 views

Updating entries in a JSON file

I have the following Data.json file and I would like to update some of the values. ...
5
votes
4answers
57 views

Calculating total size of player data

I am writing a function to calculate the total size of a "player appearance". There are various "item slots" the player has, and if they are empty then 1 byte will be sent, otherwise there will be 2. ...
-1
votes
1answer
3k views

NodeJS Module Exports: Export multiple functions vs Exporting a single function [closed]

To update parameters in our main.js file, which has a lot of configurable variables, we can do the following A . ...
4
votes
1answer
59 views

Filter by multiple options - also only if not empty

Here's how my json looks like. I'm trying to write a function which filters based on participantCriteria.criteriaType & participantCriteria._id ...
1
vote
0answers
51 views

Implementation of another NodeJS web framework made for all team members [closed]

I've recently published मुनीम (Muneem) web framework for NodeJS users. As there are hundreds of frameworks already available, the first thing come in mind is "Why another?". Here is the reason why I ...
1
vote
1answer
104 views

DDD model of a purchase in NodeJS

I already have some experience with Java and I'm used to modeling with a DDD approach. Therefore, now I'm beginning with JS and NodeJS and I'd like to know which is the best practice to design with a ...
0
votes
1answer
38 views

MongoDB database connector on NodeJS

What my code does I am building an Express API server with mongoDB as my database. I have a list of players which must be added to 2 mongoDB collections (teamList and countryList). The data schema ...
0
votes
0answers
27 views

Showing empty state via express and ejs

I have this part of my simple app wherein I would call an API when I hit "Submit" on a search textbox. Let's say I search for "onion", so the result would be a random onion recipe. This is the reason ...
4
votes
1answer
132 views

CLI to bump package.json version and add git tags

I'm writing a command line app in node.js. At this stage, the app does the following: Get the version from package.json Update the package.json with a new version ...
1
vote
0answers
45 views

Recursive Generator Exceeds Call Stack

I have this recursive generator that fetches 100 messages from an API and gets the next 100 until there are no more messages to get: ...
0
votes
1answer
21 views

Node.js Data-Completion script

Following task: Customer-data, given in a JSON-file, have to be completed with additional address-data. Given in a second JSON-file. Then these data-stock has to be saved into a MongoDB-database. ...
2
votes
0answers
54 views

Whole Packet Protocol Communication Library in Node

I have built this small class as a small library to be able to talk to a server that uses CapeSoft's NetTalk library as socket library, and which uses the Whole Packet Protocol, which is a simple ...
2
votes
0answers
395 views

Async/await Mysql wrapper

I used MySQL, but it was inconvenient so I made a wrapper. It works, but I'm unsure if there are any issues. Used node module - mysql2, bluebird sqlWarpper.js ...
0
votes
1answer
82 views

Git hook written on JavaScript

As in many teams, me and my coworkers are putting ticket number into beginning of each commit message. If your branches are starting with ticket number it is easy to create ...
1
vote
1answer
212 views

Concurrent fire and forget async task queue

I had to do a lot of IO stuff on my server running Node JS where I did not really care about the result of the operations. The list of incoming tasks could be huge, so I had to limit the number of ...
2
votes
1answer
79 views

Keeping the average user from opening two copies of my program

I know that this is an impossible task against someone determined, but I'd like to keep mid-average users from being able to open more than one copy of my program at a time. Here's the quick code I'...
3
votes
0answers
140 views

Scraping StackOverflow's questions with Node.js

I'm new to node and web scraping in general but with some research I've written this working code. My goal is to get all questions from X Stack Overflow's pages sorted by most rated and save that ...
2
votes
1answer
47 views

Mongoose schema to store items from Wynncraft's API

I am making a Schema to store items from Wynncraft's API. See an example assortment of items here: https://api.wynncraft.com/public_api.php?action=itemDB&search=a I have not finished making the ...
2
votes
0answers
59 views

A Node.js server that create a tunnel to the Internet

I'm creating a Node.js app that allows the user to create their own social network. This code doesn't do anything special yet except creating a basic server and making it available on the Internet via ...
2
votes
0answers
317 views

Lambda@Edge function for handling redirects and rewrites

We're converting the City of Philadelphia's website to be served as static files. In order to support redirects and rewrites (URL masking), we decided to use a Lambda@edge function, which modifies (or ...
6
votes
1answer
451 views

JavaScript telegram bot that sends images based on user search

In my freetime, I did this little Telegram bot in Node.js that provides some basic text-based commands and one command where a user can search for an image in order for the bot to send back an image ...