Monday 31 August 2020

Angular vs React vs Vue Which front end framework do you use and why

No text found

Submitted September 01, 2020 at 06:57AM by KingNe0

ES6 Destructuring

My latest #tech #blog 'ES6 Destructuring' https://manisuec.blog/post/2020-09-01-object-destructuring/Request for your reviews and feedback.

Submitted September 01, 2020 at 06:24AM by manisuec

What backend node framework do you use and why?

No text found

Submitted September 01, 2020 at 05:36AM by shiyayonn

Who is downloading my npm packages?

I published a package 2 weeks ago. As of today it had been downloaded several hundred times. I published another today and it was downloaded over 30 times in 15 minutesIs there a "sort by new" on npmjs and folks just download to see what's happening?I don't mind, I'm just surprisedPackages are "quickgitjs" and "quickjsonconfig". Just a couple for my own use, but I wanted to see how npmjs worked

Submitted September 01, 2020 at 05:07AM by MarkFKozel

SSL cert problem with XMLHttpRequest in js script - how insecure is insecure?

I'm running a .js script from a cron job that goes and gets some json from a remote server, and recently it started failing. (I'm not exactly sure how recently!). There's no front end to this project at all. It just grabs the json and emails some of it. (Because of the email part, yes, there's login info involved, if that makes any difference.)In debugging, I've found that, instead of returning the json, my XMLHttpRequest is returning an error with statusText: UNABLE_TO_VERIFY_LEAF_SIGNATURE. (If I open the API url directly in the browser, it shows the json correctly, so there's no problem there.)Google tells me that this is Node being upset about the SSL cert - but I'm not sure if I'm the SSL problem, or the server with the json I'm grabbing. Does anyone know?Either way, I can't update the SSL cert easily. The remote server isn't mine and the local server is controlled by IT. (It would take about a week just to get a response - probably a month to get a new SSL cert - and I'd like to get the script working again sooner than that.)Given that there's no front end for the project, is it safe-ish to disable strict_ssl? eg:process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0"; Another question. Below is my request code.var xhr = new XMLHttpRequest(); xhr.open("GET", url, false); xhr.send(null); If I remove the .send(null), I don't get the SSL error, but I also don't get any json. I thought that was for dealing with old browsers, but apparently not?

Submitted August 31, 2020 at 10:10PM by brakhage

ExpressJS (web/API) best practices: The nitpicks

Hello!I recently had a technical interview with a certain company that instructed me to do a coding challenge in the form of a small PoC. The test was a simple display of a list of Marvel characters based on the official marvel API. The data coming from the Marvel API should be cached on my own server that I use as an API provider to a separate frontEnd that i also have to create.Upon completing my test, i got a lot of complaints about my code not using the best practices. Although i did the following to the letter :separated the business logic from the routingseparated te external api calls from the main routingused environment variables for host, ports and API keysI did falter in some points like not finishing all the needed features in time (the extra features, not the minimum ones).​So now I got a second chance at another interview, this one is supposed to be much harder and more complex. I don't know exactly but it should include :AuthenticationA microService Architecture implementation ( they will ask me to create multiple servers and connect them together with possible synchronization)Load BalancingComplex UI: probably mandatory with reactJSMongoDB database implementationExpressJS based APII would usually not ask about those points, but after the first test, the idea of best practices has been haunting me. I truly don't know what I did wrong there, so I would like to know what are the best practices when it comes to the points above.I would like to know the macro, micro-level, architectural, and coding best practices. Please give me your ideas and experience

Submitted August 31, 2020 at 09:39PM by RARBK

Azure function with node

Need help with an azure function... can anyone help me?

Submitted August 31, 2020 at 09:46PM by eche1978

Recommended npm package for calculating regression and standard deviation from the mean?

Hi. I'm basically looking to create a bot that tells me if a certain metric is 2 standard deviations from its mean. Is there a specific nodeJS package that anybody would recommend?

Submitted August 31, 2020 at 08:26PM by The_Nomadic_Nerd

nut.js - Two years recap

https://blog.s1h.org/nutjs-two-years-recap/

Submitted August 31, 2020 at 08:28PM by s1hofmann

Mongoose plugin for measuring and logging MongoDB query execution time

https://github.com/sabljakovich/mongoose-execution-time

Submitted August 31, 2020 at 07:30PM by malibakito

Not setting cookie correctly JWT Express React

This is my first attempt at authentication. When I test in postman I see a cookie in the cookie tab. When I am on the network tab in the browser I can see in the response headers Set-Cookie. When I copy the cookie and test the protected routes I am good to go. When I check the application tab I do not see a cookie being set and when I console.log the response on my front end, I do not see the cookie or token anywhere. document.cookie is an empty string. What am I missing here?const express = require('express'); const app = express(); const mongoose = require('mongoose'); const dotenv = require('dotenv'); const cors = require('cors'); const cookieParser = require('cookie-parser') // Import Routes const authRoute = require('./routes/auth'); const postRoute = require('./routes/posts'); dotenv.config(); const port = process.env.PORT; // Connect to DB mongoose.connect( process.env.DB_CONNECT, { useNewUrlParser: true, useUnifiedTopology: true }); const db = mongoose.connection; db.on('error', console.error.bind(console, 'connection error:')); db.once('open', () => console.log('connected to db')); //Middleware app.use(cors({credentials: true,})); app.use(express.json()); app.use(cookieParser()); app.use('/api/posts', postRoute) app.use('/api/user', authRoute) app.listen(port, () => console.log(`Listening on port ${port}....`)) router.post('/login', async (req,res) => { //Validate data from user const {error} = validation.login(req.body) if (error) { return res.status(400).send(error.details[0].message) }//Check if user is already in DB const user = await User.findOne({email: req.body.email}); if (!user) { return res.status(400).send('Email or password is incorrect'); }//Check password const validPass = await bcrypt.compare(req.body.password, user.password); if (!validPass) { return res.status(400).send('Email or password is incorrect'); }//Create and assign a token const token = jwt.sign({_id: user._id}, process.env.TOKEN_SECRET) res.cookie("token", token) res.status(200).send('User is logged in') })

Submitted August 31, 2020 at 07:00PM by eurodollars

As my second project using the MERN stack, I created a forum board system! There's still so much to do but I'm already proud of what I learned so far!

https://github.com/henrispkl/MernBB

Submitted August 31, 2020 at 05:27PM by henri_sparkle

Node Js / Express API Challenges,

Pls help me with a website which has lot of challenges related to create a API using node js express. Beginners to hard ...i tired finding online. But Found none..Help me pls

Submitted August 31, 2020 at 03:24PM by DVGY

Newsletter Website

Hi guys, I'm subscribed to some newsletter just like "The Hustle", "Axios" and "Morning Brew" and I would like to know how to build and to handle a newsletter website just like that (emails are good-looking from a graphic point of view, and I don't know how to make those amazing emails and how to manage them and so on). Hope someone helps me. Thank u for your time!

Submitted August 31, 2020 at 03:36PM by Raul_Garcia27

First node project - need help with structure

I’ve been stuck on the same issue for a couple of days. It appears to be an design / structure issue.Am building a Survey Web application with node js/ express. It is essentially a learning exercise for me with basic CRUD operations.Some Context - the survey has n questions (say 10) - once the user answers a question, I then display the next question and so on - when the page first loads I have to somehow know that I have 10 questions in the survey and then I have to get the first question. -The only way I can workout how to do this is via a Module embedded in my HTML. The module does a Get API call and returns 10. - I then do a second GET to retrieve the first question. - the only way I can work out how to display my main HTML is by calling a function from the module called generateHTML() and I send through the survey question data and the total number of questions.The issue is that I don’t know how to persist the “10” outside of the module so that I can access it from my JS file .Basically my front end needs to know how many questions are in the survey and the current question , the next question , the last question etc. Am struggling to work out how to store these as global variables.As soon as I move on to building the second question , I no longer have access to the module as it is only called once .What is the appropriate way to manage user state in a JavaScript application ?All the CRUD examples I come across seem to avoid this by choosing examples such as maintaining master data - rather than an actual web application .

Submitted August 31, 2020 at 02:27PM by PuffOca

Introduction to AWS Lambda. Managing a contact form with Simple Email Service

https://wanago.io/2020/08/31/aws-lambda-contact-form-simple-email-service/

Submitted August 31, 2020 at 02:04PM by _gnx

Question: How to deal with huge amount of images ?

I want to make a website (using MERN) that hosts a huge amount of images ( around 100 GB worth of images) but I haven't dealt with anything on that scale before (in terms of storage). My main concern is where to host them and how to ? I've heard that I can use S3 or Google Drive for that task but I didn't find anything clear online that would help me . So, if you have dealt with something similar or have tips on how to handle that type of data feel free to leave a comment that would be really appreciated .

Submitted August 31, 2020 at 02:10PM by bob_tarhini69

HOW TO TEST THE AVAILABILITY OF YOUR API SERVER [Node JS Performance Opt...

https://www.youtube.com/watch?v=JwFDEJj3CKM&feature=share

Submitted August 31, 2020 at 12:48PM by johnjardin

Node shebang

https://medium.com/@alexewerlof/node-shebang-e1d4b02f731d

Submitted August 31, 2020 at 11:09AM by pmz

How to create a unique key-value server side, save it server-side & send it to the client?

Hello,I am trying to learn node.js and I would like to know how for each client that hits my web app to generate:A random_number + hash_of_random_number on the server.Send client hash_of_random_number.If the client refreshes the page, they would receive a new random_number + hash_of_random_number.Only when the client hits a button, the random_number + hash_of_random_number is stored securely server-side to be retrieved later.Essentially, i would like to create a random number (I know how to do the random number) which is hashed server side then serve only the hash_of_random_number to the client, the client then does something client side (e.g. clicks a button), which only then stores the random_number + hash_of_random_number server-side. If the client closes the app before clicking the button, the server-side generated random_number + hash_of_random_number are not saved server side and the client would be served a new generated random_number + hash_of_random_number if they refresh the app. Each client and page refresh is treated independently and they each receive their own random_number + hash_of_random_number.What is the best way (secure, stable, reliable) to do this in node.js? I'm not even sure how to word what I am trying to achieve. Can anyone point me to any tutorials which can guide me in the right direction? I'm thinking i would like to eventually save the random_number + hash_of_random_number to a database, but for this example, id be happy to just store it in memory to get me started...Can anybody help me with this? I hope this makes sense? Any help is greatly appreciated in advance. Thank you.

Submitted August 31, 2020 at 08:39AM by asus_wtf

Sunday 30 August 2020

My tags of type Mongoose.Schema.ObjectId is not getting updated.

When I try to give the id of the tag , it is still showing empty in the postman .create bookmark post route.​Here is how my model and controller looksconst mongoose = require('mongoose');//bookmark modelconst bookmarkSchema = mongoose.Schema(  {link: {type: String,required: [true, 'Bookmark URL or Link is required'],unique: true,    },title: String,createdAt: Number,updatedAt: Number,Publisher: String,tags: [      {type: mongoose.Schema.ObjectId,ref: 'Tag',      },    ],  },  {    // Make Mongoose use Unix time (seconds since Jan 1, 1970)timestamps: { currentTime: () => Math.floor(Date.now() / 1000) },  });const Bookmark = mongoose.model('Bookmark', bookmarkSchema);module.exports = Bookmark;//tag modelconst mongoose = require('mongoose');const tagSchema = mongoose.Schema(  {title: {type: String,unique: true,},createdAt: Number,updatedAt: Number,  },  {// Make Mongoose use Unix time (seconds since Jan 1, 1970)timestamps: { currentTime: () => Math.floor(Date.now() / 1000) },  });const Tag = mongoose.model('Tag', tagSchema);module.exports = Tag;Bookmark controller jsexports.createBookmark = async (req, res) => {  const { link } = req.body;  try {    const newBookmark = await Bookmark.create({      link,    });    res.status(201).json({ data: newBookmark, status: 'successfull' });  } catch (err) {    console.log(err);    res.status(400).json({ error: err, status: 'fail' });  }};

Submitted August 31, 2020 at 04:37AM by DVGY

Fullstack MERN Authentication Tutorial

If you want to learn about MERN Stack authentication. This video can help you understand in learning it. This looks educative and informative.https://www.youtube.com/channel/UCS3-MF_4ADqglU2OSly4vIw?sub_confirmation=1

Submitted August 31, 2020 at 04:03AM by Ishan_2016

Not sure how to export a library meant to be used in front-end code...

I've written a library called When. It's a keyboard shortcut library, meant for front end use, not in back end code.In my code, I make a function called When() globally available on the window object so that you can just call that anywhere in your code.Currently, my instructions for installation/use with a bundler like webpack (after installing via NPM) are to import 'when-key-events', then either use window.When() or do const When = window.When in order to use it, otherwise you get errors like "When is not defined" even though it's a global.Obviously other libraries get around this somehow but I'm not sure how exactly...since all the code is targeted for use in the browser, I can't do a node style export or a module.exports = When can I? I tried doing similar things but it doesn't seem to be working.What am I missing? How would I achieve something like import { When } from 'when-key-events' while keeping the code browser compatible for use over the CDN?For reference, the source is written in Typescript, and bundled using Webpack into a single dist file.

Submitted August 31, 2020 at 04:08AM by PM_ME_A_WEBSITE_IDEA

The best way to assert that there is a server is running on a specified port.

I'm familiarizing myself with the net module by writing a simple ftp server, and I've been trying to write a test that will assert that the server has established a tcp connection on the specified port.Here is my first pass:const getConnection = (port, cb) => { return new Promise((resolve, reject) => { const connection = Net.createConnection({ port }, cb); connection.on('error', (err) => reject(err)); resolve(connection); }); }; it('establishes a TCP connection on the specified port', async () => { let connected = false; const port = 8080; const cb = () => { connected = true; }; const server = new FtpSrv({ port }); await server.start(); const connection = await getConnection(port, cb); await sleep(100); expect(connected).to.equal(true); connection.destroy(); server._netServer.close(); }); There's a couple of things that I don't like with this solution:Mixing of promises and callbacksHaving to sleep for a specified time so that the "connection" event can be emitted and my callback can resolve to result in the reassignment of the connected variable.​Here is my second pass:it('establishes a TCP connection on the specified port', async () => { const port = 8080; const server = new FtpSrv({ port }); await server.start(); const { stdout } = await exec(`lsof -i TCP:${port} | grep node`); // figured I could run some regex against stdout connection.destroy(); server._netServer.close(); }); While I like that this is less code and simpler, it seems a bit hacky.

Submitted August 31, 2020 at 12:45AM by la_li_lu_le_lo-rp

Why is only one entry being added to this list when using websockets?

I want to add players to a list called "players" once they join a game. Once they click a button it starts a function on the client side that emits "joinGame" which is received on the server side like so:socket.on("joinGame", (data) => { waitRoom++; if (waitRoom === 2) { let lobbyLoop = setInterval(() => { lobbyClock++; console.log(lobbyClock); if (waitRoom > 10 || lobbyClock > 3) { waitRoom = 0; lobbyClock = 0; socket.join(roomno); io.sockets.in(roomno).emit("connectToRoom", roomno); roomno++; clearInterval(lobbyLoop); } }, 1000); } }); This logic is for matchmaking. After two people join it starts a countdown and if the timer reaches 3 or if there are more than 10 players in the wait room it assigns them to a room number. Then it emits "connectToRoom" to the client:socket.on("connectToRoom", function (data) { roomno = data; socket.emit("addPlayer", { mousePosX, mousePosY, radius, playerID, roomno, }); }); This sends the room number to client which is stored in a local variable. Then it sends the players information to the server which is received here:socket.on("addPlayer", (data) => { players.push(data); console.log(players); }); The bug is that in "addPlayer" only one entry is present when I log it. I'm wondering if any of you can find out why this behavior is happening. I want players to fill up with everyone who was in the wait room.

Submitted August 30, 2020 at 10:13PM by TheSlothJesus

How to load a library into a CLI instance, or other temp environment?

I have little instances where it would be nice to access a library outside of my project for some side reason. At the moment, I would like to open node CLI, run bcrypt with my hash secret (or whatever it's called), and get the actual hash of my password for an external service, so that i can use it to test my API connection including initial account setup, to that service.Is there any way to do it?Or do you guys use another sandbox project for this kind of thing?

Submitted August 30, 2020 at 09:53PM by embar5

A book I'm writing with O'Reilly, Distributed Systems with Node.js, will be available soon!

https://thomashunter.name/distributed-systems-with-nodejs

Submitted August 30, 2020 at 08:27PM by nucleocide

How do you publish node website?

Very basic, beginner question lol but I googled and couldn't find the answer anywhere.Basically, I have a simple ecommerce website made with node, express and mongoDB that I am serving locally now but how can I ''hook up'' this website to domain? I have an interview tomorrow and even if they know that I'm junior and they listed this skill as desirable I'd like to at least know the basics.I'm good with JS and just started learning node, if anyone is interested to be my mentor i'd highly appreciate it.

Submitted August 30, 2020 at 07:22PM by baby-faceee

What are the vague references in this Error call stack

How do you restrict access to your nodejs based backend source code if you have to deploy it on a client's environment or where people other than you may have admin access to the server?

Since nodejs code cannot be compiled/built like languages like c# (.net) etc and the files need to placed as is on the server, anyone who can access the project folder can basically read all your code, use it themselves in other projects, make changes to it without your knowledge.Say you had a product which can be used by a client but he wants it to be installed and accessible only on his intranet and you basically don't have full authority over the server, what would you to keep your nodejs based code from being accessed by them as you cannot compile the source code like you can in .net based projects.

Submitted August 30, 2020 at 05:04PM by thatsInAName

promise.all is running before for loop ends.

https://i.imgur.com/rahEwwu.png

Submitted August 30, 2020 at 04:33PM by reddit-_-reddit-_-

Nodejs noob doubt

I am having a problem with nodejs. I just started to learn and decided to create a simple app.I am having a problem when i create a new post sometimes after rendering the new post does not appear on the page... The code is here: https://imgur.com/a/4nHeuoaBasically after creating a post i redirect to /dashboard but sometimes in the GET method the page renders before getting all posts even with the await there (the console log shows the posts are empty). Can anyone help me?

Submitted August 30, 2020 at 04:14PM by motapinto

I built a Positive News App with Nodejs!

Few months ago, I asked in r/AppIdeas about it and got a good response.And here it is! Its live and opensource now: https://medium.com/@ujjwalkr/day-2-xenon-the-positive-news-app-f04b97aeafdc

Submitted August 30, 2020 at 02:35PM by kr-ujjwal

CyberCode Online: A mmorpg web game that looks like (disguised as) VS Code

https://i.redd.it/als0cezp75k51.png

Submitted August 30, 2020 at 02:36PM by Dexter-Huang

compare-pdf: What’s New?

https://medium.com/mdacanay/compare-pdf-whats-new-bf9d40d6fb8b?source=friends_link&sk=ce2af3280905ed3383dbd318edfd8b9c

Submitted August 30, 2020 at 02:12PM by Fewthp

Node-Casbin: An authorization library that supports access control models like ACL, RBAC, ABAC in Node.js

https://github.com/casbin/node-casbin

Submitted August 30, 2020 at 12:46PM by EquivalentAd4

Permanent webhook

I was asked to develop a demo RCS chatbot so I copied this node.js demo from github which listens on localhost:300. I now need to provide a permanent webhook for it.I found something called ngrok which automatically creates a webhook URL that points to my pc on port 3000 but it only lasts for 8 hours!Is there a way to create a permanent webhook URL?Thanks ahead!

Submitted August 30, 2020 at 10:56AM by HeadTea

Best way to upload files in S3 Bucket.

Whenever I am trying to upload heavy files more than 2GB. I am getting error like " file size is greater than possible Buffer:".I know there is stream method, but I don't know how to implement it.I am using https://gist.github.com/joshbedo/47bab20d47c1754626b5 method. This one only works upto 2GB.Can anyone please help me as I am trying to upload files which are above 10GB.

Submitted August 30, 2020 at 10:52AM by samy_here

Getting hired based on your skills.

Hello everyone!Recently, I have started working on a problem of getting a job in big project based companies, that many undergrad students face during their final and pre-final years. The idea aims to make students work/projects get recognized to the recruiters, and also give them valuable insights to upskill them and try hands-on new technologies in the industry domain. To learn more about the idea and features check out our page at : https://skillhire.co.in/We would love to hear your feedback in the comments below. Also, please share your thoughts what more features can be included for better scalaility, flexibility using node.js as backend

Submitted August 30, 2020 at 10:23AM by mudassir2700

Saturday 29 August 2020

Vue.js component to wrap embeded iframes from Vimeo and YouTube

Hello,In the past week i published a npm package.It's a wrapper for Vimeo and YouTube embeded videos, where you can use their events and methods.Feel free to contribute. I hope it be usefull for someone. :)npm github

Submitted August 30, 2020 at 06:30AM by Portogabriel

How is .length calculated?

Lets say I have two arrays, with millions of objects in each. Before adding to one or the other I want to see which is smaller. Does .length go through each array counting each individual object and take forever or does it already know or perhaps get the index of the last object and add one?var arrayA = [millions of objects]; var arrayB = [millions of objects]; function doThing(variable){ var math = .......; var math2 = .......; if(arrayA.length < arrayB.length){ arrayA.push({data1:math , data2:math2 }); }else{ arrayB.push({data1:math , data2:math2}); }; return math; }; function blahBlah(blah){ blah blah blah; }; exports.doThing = doThing; exports blahBlah = blahBlah;

Submitted August 30, 2020 at 05:33AM by omato2468

Is node_modules still bloated? If so, is there a simple way to slim it down some?

Okay so I've done things like create-react-app for example and I end up with almost 20k files. This was probably a year ago. I'd like to give the node ecosystem a revisit, coming from a background of php and c#, but this is kind of a bugaboo for me. I've heard that in recent versions, it's not as bad. Can anyone confirm, or give your experience/opinion in working with it?

Submitted August 30, 2020 at 01:12AM by DontLickTheScience

Linking a node.js backend to gatsby

Hey everyone! I am working on a project right now, and everything is going very well except I have one problem and I was wondering if any of you could help me out! I have a good working front end of my website, and I have a separate node.js script using the Google APIs to POST data to a google sheet online for a client. I was wondering how I could link the two, and make it so when a user fills out a form on the site, it goes to the google sheet.Sorry, I am not that good with backend development, and have never linked a front end to a backend before! I have a feeling I am going to have to learn redux and that sort of thing but I have no clue where to go from here. Thanks!!

Submitted August 30, 2020 at 12:35AM by timkauai

Sequelize plural problem

All my Models and Controllers are following the pattern with singular and plural. For instance if I have a users database, my model is called User and so on.But I have a table on my database called deliverymen and my model is called Deliveryman and I'm having problems with it, because of the plural. How do you guys deal with this type of situation?Thanks in advance.

Submitted August 30, 2020 at 12:44AM by Daniel_Marques

Voice call system

Hey guys, im trying to implement a voice call system using react-native and node js. Im not sure if this system is a webrtc or webhook etc. The end goal is to have a voip system where the users phone numbers are not involved strictly like facebook messenger etc. If any of u have any experience with such systems could u pls guide me?

Submitted August 30, 2020 at 12:05AM by hasansultan92

async API calls

What’s the best way to tail a huge log database table?

I maintain a node API that logs to a Postgres database table and I have nearly two years of logs saved in that table, which you can imagine has gotten huge. My first thought was to just run a migration that would issue a query to delete older records, but that would only run once because of sequelizes meta table. Then I thought about setting up a chron job to delete old records on a 24 hour sequence and that sounds better to me. But should an api be running a chron job? Would it block anything? I am also open to suggestions.

Submitted August 29, 2020 at 09:34PM by Turdsonahook

Replacing XAMPP with node on my Windows machine - a few questions (hosts, GUIs etc)

So I made the move from PHP to JS a while ago. On my local machine I have XAMPP as well as npm/node installed. Up until a few months ago I was still using MySQL in XAMPP as my database but I want to uninstall XAMPP and move entirely to nodeJS on my local dev setup.So I will need to install node (done), mysql and expressJS.Questions: -Now that express is replacing apache, how I do configure it to run with domains redirected to localhost via the Windows hosts file? This was previously done via the apache conf file. Do I need to run a node server.js script that picks up the incoming request and then serves the request by running a server.js file from that domain's (www.mylocaldev.com) directory?Is there a GUI available for starting and stopping the mysql service? No big deal if there isn't, I will just use command line.If there is anything else I might have missed, please point it out. Thanks.

Submitted August 29, 2020 at 09:04PM by U4-EA

Question for y'all regarding API keys and secrets

I'm building a web app with a node.js backend. I've built the backend API using JWT authentication and it's all working. The question isn't about how to store the bearer token on the FE (there's plenty documentation).The question I have is how do I store user's API keys for other services on my backend?The users will be allowed to upload an API key, the secret, and password for an alternate service to my backend API. At first I was thinking in storing them all as ENV, but then I don't think that'll be a reliable solution because I'm also going to be using Docker to spin up new instances of the app when necessary. Then I thought about maybe storing them in MongoDB as hashed strings, but I also don't think that's a good solution because I'm storing user's API keys on a DB.Can anyone point me in the proper direction so I can do this the right way?

Submitted August 29, 2020 at 08:32PM by MrPicklePop

webpacking server-side node.js code, yes or no?

I am working on my third project where my boss has asked me to add a build stage to the server-side portion of our app that obfusicates and minifies the app into a single file. the reasons being that we are contracted to do development for our clients, where we'll be running our code on their hardware (some VPS, some on-prem) and he doesn't want them to have access to our source code so that they can't reverse-engineer it and steal our IP (of which we honestly don't have much of value... most of our "magic" is just open-source npm packages). not to mention that uglify doesn't do much to stop a reasonably dedicated reverse-engineer.the problem here is, as many of you are familiar, node.js is really not designed to be webpacked in the way that popular browser frameworks and libraries are. many of them use native modules (sharp), some dymanically require() files expecting a specific folder structure (threads.js), others rely on node module system quirks which webpack doesn't play nice with (typeorm).twice now, I've been able to pull it off, with the caveat of making substantial changes to the original source code. as our development team gets better and our apps become more complex, bundling our server-side code becomes harder and harder. I'm currently struggling on the third app I've been asked to webpack, and I've managed to work around the native modules (shoutout to webpack-node-externals and generate-package-json-webpack-plugin), typeorm's exploitation of the node.js module system makes it really crippled under the webpack runtime and I'm not sure how much further I can take it without crippling the DX of our app.I guess my question is, is webpacking a node.js app a reasonable thing to ask, how often is this actually done in the industry, and is there some "one weird trick" I'm missing to make this work?

Submitted August 29, 2020 at 07:52PM by 800_db_cloud

(Google Meet) clone, a meeting/video chatting application with source code (socket.io, webRtc)

Today I recreated google meet because I thought it was interesting and I want to be more comfortable with socket.io and see really how real-time stuff works.I used Halfmoon a CSS framework more like bootstrap but with built-in dark mode.Check out the Demo here.Full source code GitHubAny feedback would be greatly appreciated. Thank youhttps://preview.redd.it/l1r9lpfmnyj51.png?width=1906&format=png&auto=webp&s=7ff5807383e6ab5e5045db264da30361cea492df

Submitted August 29, 2020 at 04:32PM by meerbahadin

web scraping with cheerio

I am newbie at JS and I am trying to do web scraping using cheerio. What I trying to do is getting an specific classes texts into an array like:​​`["file name 1", "file name 2", "file name 3"]` ​, however what I am getting is:​`"file name 1file name 2file name 3"` ​``` const axios = require("axios"); const cheerio = require("cheerio"); const url = "site"; axios(url) .then((response) => { const html = response.data; const $ = cheerio.load(html); let title = $("div[class='col-md-8 col-xs-3'] >span").text(); let content = $("div[class='col-md-2 col-xs-4'] > span[class='badge badge-primary']").text(); let date = $("div[class='col-md-2 col-xs-5'] > span").text(); console.log(title); console.log(content); console.log(date); }) .catch(console.error); ``` ​stackoverlow link can be found here

Submitted August 29, 2020 at 03:13PM by FurtunB

PopovMP/mocha-tiny

Mocha-tiny - straightforward unit testing: describe and it without dependencies.GitHub: mocha-tinyJust uploaded a tiny unit testing helper for node.js. It uses Mocha syntax and is a sort of drop-in replacement.Synopsisconst { strictEqual } = require('assert'); const { describe, it } = require('@popovmp/mocha-tiny'); describe('Test Math', () => { describe('Math.sum(a, b)', () => { it('is a function', () => { strictEqual(typeof Math.sum, 'function'); }); it('accepts two args', () => { strictEqual(Math.sum.length, 2); });

Submitted August 29, 2020 at 02:17PM by Miroslav_Popov

Quick Intro to path module - nodejs

https://webstar-codes.blogspot.com/2020/08/quick-intro-to-path-module-node.html?m=1

Submitted August 29, 2020 at 01:32PM by Frosty-Relative

Manage your agile development backlog using markdown files

I wanted a self-hosted and simple way to manage an agile development backlog so I built a static blog todo just that.Its not super fancy:blogging + agile + markdown + gitBut it probably won’t break because of software upgrades, and it’s simple to use.Uses eleventy: https://www.11ty.devCould be interesting for solo devs out there. See the demo site.Let me know what you think.https://github.com/mjgs/eleventy-agile-blog

Submitted August 29, 2020 at 12:31PM by mjgs1000

Problems setting baseURL for Axios

Hello!I'm having a few problems using baseURL in Axios…When using Vue:Vue.prototype.$axios = axios.create({ baseURL: process.env.ROOT_API }) … this works.But in Node (14.7), this won't:const axios = require('axios') let instanceOfAxios = axios.create({ baseURL: process.env.ROOT_API, timeout: 1000 }) ... instanceOfAxios.post('/assets', { ... } … or these:axios.post(`${process.env.ROOT_API}/assets`, { ... } axios.post(process.env.ROOT_API + '/assets', { ... } Each time, I get the same error message:UnhandledPromiseRejectionWarning: Error: connect ECONNREFUSED 127.0.0.1:80The actual value of process.env.ROOT_API is: http://localhost:3000I've also declared the instance in an external file and imported it, but the same problem persists.I'm using process.env.ROOT_API elsewhere in the application (and have been since the beginning of development) without a problem.Any ideas?

Submitted August 29, 2020 at 09:57AM by WayneSmallman

Learn JWT by reverse engineering (a demo node app)

https://github.com/gitcommitshow/auth-jwt

Submitted August 29, 2020 at 09:41AM by gitcommitshow

after installing nodejs on my windows, pip no longer works on my git bash. tried reinstalling through python. incredibly frustrating on how nodejs messed up my environment. what's the issue?

as the title says. python works fine, but i can't use pip aynmore

Submitted August 29, 2020 at 09:01AM by V3Qn117x0UFQ

Making a ExistsConstraint with class-validator

Does Nest js + React make sense?

Hey!I'm starting a side project and I want to use Nest js instead of raw Express. I'm very into typescript and I feel Express too permissive.My question, as in the title is: doe is make sense to combine Nestjs and React in the for this project since I enjoy using it more? People in my work say that Angular is more "similar" to nest than React and my idea is a mistake and can lead to confusion.Any opinions on that?Thanks

Submitted August 29, 2020 at 08:38AM by sagatj

Timeouts from Windows Express.js server

I'm running a simple Express.js server that just sends "Hello, World" on a Windows machine. I can get a response from the server through Chrome and curl on the Windows machine. I then try curling the server from my Raspberry Pi. I've ensured their on the same network, however the Pi gets no response from my Windows machine. I checked the Windows firewall but it was properly set already. I read about using the hostname "0.0.0.0" when starting the server, however that also yielded no results. Not sure what could possibly be causing this, anyone ever experienced this before or have any tips?

Submitted August 29, 2020 at 08:47AM by prussianapoleon

nodejs-how-to-download-a-pdf-file-from-a-rest-api

https://stackoverflow.com/questions/63644613/nodejs-how-to-download-a-pdf-file-from-a-rest-api

Submitted August 29, 2020 at 08:49AM by RenjithVR4

How do you guys deal with testing you API endpoints and seeding?

Hey guys,​Im working on a typescript/graphql backend currently and am writing some tests for my services/endpoints as i go. Im primarily a front end developer who is migrating to full stack. I've come across some issues when trying to "seed" inside my test files...From resources i can find online, most recommend to NOT run general fixtures before running your tests, and instead seed the database for each individual test to avoid mutating the same data/guaranteeing the use case is covered no matter what was done to the database prior.However, my database schema is getting pretty complex, with relationships being a few levels deep.For example, my database consists of relationships such as:`organization` has a `session` which has a `course`, and users can be added to these courses.It is seeming to be a bit too much boilerplate and repeating my code by manually creating an organization, then a session, then a course, and THEN my user that i want to use for the test. Do you guys create some kind of helper functions or test service for seeding or how do you guys go about with seeding your API integration tests?

Submitted August 29, 2020 at 07:25AM by cinco_cinco_cinco

Friday 28 August 2020

I am facing problem with puppeteer with custom fonts loading in handlebars

The issue is, In our application, we are trying to create a resume PDF from HTML using puppeteer,nodeJS, handlebars.we are able to generate the PDF with the binded data from API, but whenever we trying to load the custom fonts to generate the PDF with custom fonts, the font-family is not loading and it's not changing the fonts while generating the PDF. Any other ways to solve this or bind the custom fonts to the pdf. Can anyone help us to get out of this issue??

Submitted August 29, 2020 at 06:58AM by Ravinkishore

Node Youtube Tutorials MADE FREE!

How to create a bot for Bitcoin Trading​https://www.youtube.com/watch?v=XkHkOen9FhM&list=PLOw-F7H53TS4W7TnftW61v2m-gJP7Yr1r​How to Test Smart Contracts with Truffle​https://www.youtube.com/watch?v=PjRdsp-B4Og&list=PLOw-F7H53TS6OgnkANZ91v0xf_a6rq-i5​How to Port a Crypto Trading Bot from Bitmex to Deribit​https://www.youtube.com/playlist?list=PLOw-F7H53TS7mSXc6U1He5WdTXxV5IiXc​How to build and use Truffle.js MultiSig contract for Ethereum and all of its network tokens​https://www.youtube.com/playlist?list=PLOw-F7H53TS47zlJUOi5Vl2-wYwqsd6_L​How to build your own Ethereum Network​https://www.youtube.com/playlist?list=PLOw-F7H53TS66CCB0mDG5EIM5HIxkRBFm​Building an SMS chatbot on Twilio tied to Zendesk for ticketing using Python and NLTK​https://www.youtube.com/playlist?list=PLOw-F7H53TS7FTTLtkav_pv2_4djSRNRC​How to build a dApp on Ethereum​https://www.youtube.com/playlist?list=PLOw-F7H53TS4aQOroz9UabqQkyYoN7qYL​Building a payment dApp on Ethereum using truffle framework​https://www.youtube.com/playlist?list=PLOw-F7H53TS4fsiXi6mwtKV2RhDPpyP3o​How to build an integration with Steemit using Facebooks JS SDK​https://www.youtube.com/playlist?list=PLOw-F7H53TS4XFus7WHNguP7-6wUnRiLt​How to Analyze Ethereum Gas usage and other fees on Blockchain​https://www.youtube.com/playlist?list=PLOw-F7H53TS7nNAgAq2UIQXhYd9e8X1wK​Building and Backtesting a Trading Bot on Interactive Broker TWS API via QuantConnect​https://www.youtube.com/playlist?list=PLOw-F7H53TS4XLkn7qX97vAUtzUG4_y8F​How to use Amazon and eBay APIs to perform automated retail arbitrage​https://www.youtube.com/playlist?list=PLOw-F7H53TS7ySbB1tFSHCM0Hsc_nPwZR

Submitted August 29, 2020 at 04:36AM by Weak-Leadership-7067

Anybody searching for contributors?

Go share your projects in the comments section so other people can contribute! 😉

Submitted August 29, 2020 at 12:55AM by mkenzo_8

How can I make the option log in (iniciar sesion) disappear and change to log out (cerrar sesion) after verifying password and user?

https://www.reddit.com/gallery/iif4lq

Submitted August 28, 2020 at 09:43PM by jabrahamSC

Why Node and Not...

Hey all, I work for a company that's considering a major redo of their e-commerce platform. We're considering a bunch of frameworks for this: Rails, Laravel, Django, and Node. So I thought I'd ask the community here what would be some good reasons for Node over these others? Thanks so much in advance. :)

Submitted August 28, 2020 at 05:50PM by boob_the_bird

How do I create multiple player instances with Socket.io?

I am creating a simple socket.io application that broadcasts everyone in the rooms mouse coordinates to each other which is represented by a circle. Currently it works but only for two players. If a third player joins it takes over the most recently not used circle.​Here is my client side code so far:var socket = io(); var canvas = document.getElementsByClassName("arena")[0]; var ctx = canvas.getContext("2d"); var opps = new Array(); //All the properties of the canvas canvas.width = window.innerWidth; canvas.height = window.innerHeight; ctx.fillStyle = "white"; ctx.fillRect(0, 0, canvas.width, canvas.height); /* Gets mouse position and them emit it to server */ var mousePosX = 1; var mousePosY = 1; var radius = 10; function getMousePos(canvas, evt) { var rect = canvas.getBoundingClientRect(); return { x: evt.clientX - rect.left, y: evt.clientY - rect.top, }; } canvas.addEventListener( "mousemove", function (evt) { let mousePos = getMousePos(canvas, evt); ctx.beginPath(); ctx.clearRect( mousePosX - radius - 1, mousePosY - radius - 1, radius * 2 + 2, radius * 2 + 2 ); ctx.closePath(); mousePosX = mousePos.x; mousePosY = mousePos.y; ctx.arc(mousePosX, mousePosY, radius, 0, 2 * Math.PI, false); ctx.fillStyle = "black"; ctx.fill(); socket.emit("pos", { mousePosX, mousePosY, radius, }); }, false ); socket.on("connection", () => console.log("connected")); //Draws other players var previousX = 1; var previousY = 1; socket.on("pos", drawPlayers); function drawPlayers(data) { ctx.beginPath(); ctx.clearRect( previousX - data.radius - 1, previousY - data.radius - 1, data.radius * 2 + 2, data.radius * 2 + 2 ); ctx.closePath(); previousX = data.mousePosX; previousY = data.mousePosY; ctx.arc(data.mousePosX, data.mousePosY, data.radius, 0, 2 * Math.PI, false); ctx.fillStyle = "black"; ctx.fill(); } Towards the bottom I have my function that will draw other players. For the client it draws its circle and then emits its location to everyone else whenever its position changes. The drawPlayers method receives that data on position changes and draws them. What I want it to do is only update the position of the player that is moving and give them their own representative circle.​​EDIT: Also while thinking through this, would including some sort of id when I send the "pos" data and then updating the data before sending it back on server side be a solution?

Submitted August 28, 2020 at 04:36PM by TheSlothJesus

Is there an Open Source Project available which generates Artifacts of a specified Architecture for a REST-API? (e.g. CI/CD with Docker for Deployment, Reverse Proxy for SSL/Compression, Caching, Logging, Monitoring)

You specify your wanted architecture/components in conjunction with the OpenAPI specification and it generates deployable artifacts. Except for the logic implementation of the interface, which is later implemented by the developer.Any recommendations in this direction are very welcome!

Submitted August 28, 2020 at 04:27PM by QuickTurtle9

When creating your own libraries, should I run my build script before committing or add a "prepare" script to package.json to build the lib on install?

Is there a correct way to do this? I can either build from /src to /lib before committing or have it built on installation of the package. Is this more about personal preference?

Submitted August 28, 2020 at 04:14PM by U4-EA

What's next?

Hello Everyone. My goal is to be a full stack developer. I'm totally JavaScript depended. I've learned React for front-end. And node, express and MongoDB for back-end. Simply you can say MERN stack. I connect front-end and back-end with REST api. As I'm a self learner, I don't have CS background. Now, actually I don't know what is next to do. Anyone can explain?

Submitted August 28, 2020 at 03:35PM by ahnafX

Minimal Node API Template with Fastify to spin up a development-friendly server real quick

https://github.com/mehmetsefabalik/fastify-template

Submitted August 28, 2020 at 02:29PM by mehmetsefa

Don't be afraid of test automation

https://blog.twn.ee/en/dont-be-afraid-of-test-automation#434343

Submitted August 28, 2020 at 02:39PM by better_call_saruman

Express Template Engines - Mastering JS

https://masteringjs.io/tutorials/express/template-engine

Submitted August 28, 2020 at 02:00PM by code_barbarian

GraphQL tools and libraries

https://blog.graphqleditor.com/graphql-tools-partone/

Submitted August 28, 2020 at 01:59PM by oczekkk

Why I'm getting a Map with only 0 arrays?

node memory issue

Hi,I am trying to connect nodejs server to the Postgres server. I am using the LTS nodejs version and often run into the following JS memory heap failure.I tried to set the env variable "--max-old-space-size" but it does not help. Any thoughts?[Info]: {"id":"MAIN","memoryUsage":{"rss":65130496,"heapTotal":28188672,"heapUsed":24918560,"external":136

Submitted August 28, 2020 at 01:34PM by git_world

[V8 Deep Dives] Understanding Map Internals

https://medium.com/@apechkurov/v8-deep-dives-understanding-map-internals-45eb94a183df?source=friends_link&sk=0cf8f438d54e6bbeaee816305775fa56

Submitted August 28, 2020 at 01:00PM by kiarash-irandoust

How does Hosting work with Node

I have a question that still confuses me. I made my own webpage with nodejs Express etc. And I'd like to host my website but im confused? where do I host it? I understand that I have to host the server somewhere but I also have to buy a domain right? where my webpage pretty much works on. Can someone give me a quick explanation how/where to start? When I buy a nodejs server host can I add a domain into it ?

Submitted August 28, 2020 at 12:29PM by Cebrail_h

"JSON Web Token (JWT) — the only explanation you’ll ever need" @ Medium (my first ever article)

https://medium.com/@weinberger.ariel/json-web-token-jwt-the-only-explanation-youll-ever-need-cf53f0822f50

Submitted August 28, 2020 at 12:51PM by WeinAriel

How & When to choose a Node framework?

We've a lot of frameworks.. How can I choose between them?Also, when should I stop using bare express and use higher level framework?- Nest- Sails- Adonis- Keystore- Meteor

Submitted August 28, 2020 at 10:20AM by AhmedHossam01

From PHP to Node.js. Need advice

Hi folks,I've decided to change the stack to Node.js from PHP. I have 5+ years of commercial development with PHP (modern frameworks, DDD, TDD, microservices). Can please someone give advice with a behavior strategy? (e.g. You should get a junior node.js developer work or you should or something like this)

Submitted August 28, 2020 at 09:06AM by xenmayer

Introducing Gemini, an aesthetic now playing screen for Spotify!

https://i.redd.it/igfwttmztoj51.png

Submitted August 28, 2020 at 07:31AM by Isokya

Thursday 27 August 2020

Has anyone of your ever worked with fluent-ffmpeg ?

Hi so I have developed a discord bot to record voice chat, everything works fine but my output is MP3, which makes the audio sound a bit muffled. I think I can fix this if the output is a .wav file or a FLAC file..I needed some help with configuring to get .wav file while using fluent-ffmpeg.If theres anyone that can help, that would be amazing.

Submitted August 28, 2020 at 07:00AM by ayezinzu

The npm Blog — Release: v7.0.0-beta.7

https://blog.npmjs.org/post/627451891844055040/release-v700-beta7

Submitted August 28, 2020 at 05:58AM by pareek-narendra

Electron 10.0.0 Release | Electron Blog

https://www.electronjs.org/blog/electron-10-0

Submitted August 28, 2020 at 05:58AM by pareek-narendra

Database to choose

Hello!I am currently creating something which requires persistent storage ( on disk ). Currently using SQLite however, it is EXTREMELY slow. I currently need to make 120 calls per minute and something which can be really really fast. I do not mind something memory-based, however, there should be a way to store the data gathered in a disk format.Currently using SQLite, its really too slow. I need something which is fast since speed is somewhat key in what i am doing.Any suggestions?

Submitted August 28, 2020 at 04:04AM by SagaanSoEpic

Live Python Output to Node.js Parent Process

Hi everyone,I'm trying to send the live output of a child Python process, launched in Node.js, to the parent process. I've tried piping the child's output, but receive errors (see below), or inheriting the child's stdio to parent. In either case, I send the terminal output with socket.io.I'm able to spawn a Python process successfully, and the Python's script output is sent live (have tried synchronous and asynchronous varieties) to Node's console. However, I'm unable to display this on a web page (I'm using Socket.io for the server-client communication), without the web page being nothing but raw text (res.send).The two examples below refer to the same python script launched and the same webpage hosted on a node server (using Express).Example 1:app.post('/webpageoutput', function(req,res) { var io = require('socket.io')(http); var child = require('child_process'); var events = require('events'); var eventEmitter = new events.EventEmitter(); eventEmitter.on('logging', function(message) { io.emit('log_message', message); }); io.on('connection', function(socket) { console.log('Continuing node activities while process spawns'); var python_process = child.spawn( 'python3', ['pythonscript.py'], {stdio: 'pipe'}); python_process.stdout.on('data', function (data) { process.stdout.write(data.toString()); }); python_process.stderr.on('data', function (data) { process.stdout.write(data.toString()); python_process.on('close', function (code) { console.log("Process finished " + code); }); }) }); // Emit console.log var existingconsoleLog = console.log; console.log = function(python_process) { eventEmitter.emit('logging', python_process); existingConsoleLog(python_process); }; res.render('webpageoutput'); }); As expected, using "stdio: 'inherit", throws a "TypeError: Cannot read property 'on' of null" (for stdout) and using "stdio: 'pipe' " prevents the child Python process from starting at all. I've also tried both, as well as exec, execSync, and spawnSycn (although I require asynchronous launching of processes as both parent and child must run in parallel) but piping the child's output to the parent is as far as I've gotten.Example 2:io.on('connection', function(socket){ console.log('Continuing node activities while process spawns'); var python_process = child.spawn( 'python3', ['pythonscript.py'], {stdio: 'pipe'}); var chunk = ''; python_process.stdout.on('data', function(data) { chunk += data socket.emit('newdata', chunk); }); python_process.stderr.on('data', function (data) { console.log('Failed to start child process.'); }) }) // Emit console.log (same as above, console.log & render; skipped to save space) 2 Questions (Only need 1 solution)Is there anyway to send new messages/terminal output using socket.io from the parent process using {stdio: 'inherit'}? I understand that STDOUT and STDERR can't be used with 'pipe', and I've launched python processes using 'inherit', but although its the parent process which receives the output I can't display this to the webpage.Why does "Example 1" fail to launch the process completely?

Submitted August 28, 2020 at 01:11AM by empathyman-1234

What is the best way to learn Node.js in 2020

In past 6-7 months I've been learning web development and till this point I got comfortable with JS. I want to learn full stack, I already learned reactjs from freecodecamp , scrimba and other udemy courses. But I'm very confused what to learn in nodejs. Can you suggest any good tutorial which, goes from the basics of node and express to the advanced concepts.

Submitted August 27, 2020 at 06:32PM by pratham82

Please Help With App Post 404 Error

I have two files in my htdocs xampp folder: one is an html form, and the other is a node file in which I want to receive the posted information from the form. Both files are on the same folder, and on the same level. But for some reason I keep getting the "Object not found" 404 error. I have tried everything and nothing seems to work. Does anyone have any idea how I could fix this?Here´s my code if it helps:​This is the form:
​And this is the node javascript file:var express = require('express'); var app = express(); app.listen(80, function(){ console.log("Hello whatsup"); }) app.post('/submit-form', function(req,response){ console.log("All great"); }) ​Any help will be greatly appreciated!

Submitted August 27, 2020 at 06:37PM by epistemicmind

Autocode REPL: Free Online Editor for Node.js, Helps with Webhooks + API Integration

https://autocode.com/repl/

Submitted August 27, 2020 at 06:02PM by keithwhor

DELETE Works in postman but not with Angular frontend

Hi all!I am trying to make a delete request to my NodeJS server running with CORS enabled.This is how I have set up my CORS:app.use(cors({ origin: settings.CORS, allowedHeaders: '*' })); Deleting with postman works fine, no problems, no errors, item gets deleted that's it. However, when I'm trying to make the delete request from my browser it doesn't come through. Im not getting any errors, the frontend function runs fine up until the http delete request which just isnt coming through.My frontend request: delete(user) { let headers = new HttpHeaders({ 'Content-type': 'application/json', 'Access-Control-Request-Headers': 'DELETE', }); return this.http.delete(this.baseApi.baseAPI + `users/${user._id}`, { headers: headers, }); } If anyone knows whatsup I'd like to know cuz its driving me nuts :PThanks in advance!

Submitted August 27, 2020 at 04:51PM by rexorbrave

Node v14.9.0 (Current)

https://nodejs.org/en/blog/release/v14.9.0/

Submitted August 27, 2020 at 04:19PM by dwaxe

Wrap every route in a try catch block; is it a good idea?

Sometimes there is logic in your code that might error out without having full control over them.Think about making request to APIs, hashing a password, etc.Right now I wrap almost every route on my server in a try-catch block and create relevant error handlers within the try part like: if (X) return res.status(X).send(X).However, I can't figure out if this is good practice or not. To me it seems like a sort of safety net where you can be assured that if something errors out, the server will at least send a response. I would like to hear your thoughts.

Submitted August 27, 2020 at 03:16PM by CryptoScience

Fix "Permission Denied" Error From Github

https://maximorlov.com/fix-permission-denied-error-from-github/

Submitted August 27, 2020 at 03:21PM by _maximization

Looking for a simple real-world project using Typescript, Express and Jest for testing

Hi guys,I am currently looking for a real-world project (not too big) to learn about best practices, have examples on how I could test my middleware efficiently (auth with jet for example), mongoose implementation, and maybe in which socket.io websockets are also tested.Is there any open source repo that could help me ?

Submitted August 27, 2020 at 03:36PM by nitneuqedue

Making a CLI tool for internal usage

Hi folks,I'm making an internal CLI tool to finally codify some of our internal workflows. I'm wondering if there is something that could become a problem down the line.Is there a problem that you haven't anticipated when making CLI tools? Have you built in the JS with nodejs?What was your experience with distribution, updating, maintenance, or discoverability? What can I do now so it won't bite me later?Maybe a CLI is not the best way to have the workflows accessible and the changes trackable. I'm not sure what's the better option though.Thank you for your advice

Submitted August 27, 2020 at 02:19PM by ValentaTomas

What are my options for a crossword puzzle project I'm working on?

I'm working on a small application so that me and my family can do crossword puzzles together as we're now all living far apart. I need help thinking through some decisions. I built a web scraper to get crossword data in the format:{ across: [ { clue: "xxx" length: 5 cell#: 3 } ... ] down: {...} } But I'm not sure how I'm going to build this out. Some things I want for the application:1) I don't want any log-in username/password stuff. I just want my family to be able to go to the website, and their first time on it'll ask for their first name. Every time after it'll just remember their name. I do want some kind of database to map user/name to a recorded answer. Everyone playing can see the answers that other players recorded with each person getting their own color to differentiate.2) What's the best way to store the crossword data? I have a few different thoughts in my head. Should I store that entire object above , and just recreate the crossword puzzle with people's responses? Where would I even store an object like that? Can it go into a SQL database? Is it possible to pre-render the HTML page of just the crossword puzzle since the DOM elements will always be the same but just fill it in with user's answers? If so, what's the best way of storing a pre-rendered html page?3) It's a pretty simple application. My backend is nodejs but not sure what's my best frontend option. I'm used to working the SPA frameworks like angular, react, etc. But would something like this make more sense to use a templating engine and just serving all the HTML/JS/CSS files from the backend?Here's currently what I'm thinking: User goes to www.example.com for the first time. Backend will receive request, see no cookie has been set, and delivers the page asking user for firstname. User enters firstname and submits. Request comes to backend, backend will get the cached HTML page of just the latest crossword and clues, query the database for any response to the latest crossword and layer that on top of the cached HTML page. An express-session will be created for the user and the associated name will be attached to it, possible also stored in DB? Cookie will be attached to server response.Does that all make sense?

Submitted August 27, 2020 at 02:29PM by ididntwin

Please help with koa-jwt, koa-session

In my app i put signed jwt into session like this:const user = await newUser.save().then((user) => user);const token = createToken(user.id);ctx.session = { token };​In postman i can see that there are 2 tokens "session" and "session.sig", probably because I set session name to "session" in koa-session.I use koa-jwt like middleware and assign to it secret and cookie: "session".const validateToken = koaJwt({ secret, cookie: 'session', });And this doesnt work, when I console log ctx.cookies.get("session") i get base64 encoded session like this :eyJ0b2tlbiI6ImV5SmhiR2NpT2lKSVV6STFOaUlzSW5SNWNDSTZJa3BYVkNKOS5leUpwWkNJNklqUTBNMlExWWpVekxXSXpZekl0TkRKaE9DMDVNamsyTFRWak16YzROMk14T1RBNU1TSXNJbWxoZENJNk1UVTVPRFV6TWpFeE1Dd2laWGh3SWpveE5UazROVE15TkRFd2ZRLmd3THBUbmhkRmdTTzMxOTUyLTQzQnJIeUFSbVFHVUlvck53SjB6cHllWDAiLCJfZXhwaXJlIjoxNTk4NTM1NzEwMDY1LCJfbWF4QWdlIjozNjAwMDAwfQ%3D%3DWhen I decode it I get:{"token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjQ0M2Q1YjUzLWIzYzItNDJhOC05Mjk2LTVjMzc4N2MxOTA5MSIsImlhdCI6MTU5ODUzMjExMCwiZXhwIjoxNTk4NTMyNDEwfQ.gwLpTnhdFgSO31952-43BrHyARmQGUIorNwJ0zpyeX0","_expire":1598535710065,"_maxAge":3600000}Can someone help me what am I doing wrong and why koa-jwt doesnt read my token properly.Thanks.

Submitted August 27, 2020 at 02:02PM by Puzzleheaded-Stage44

How to convert stream consumer to stream pass through?

Hi, I’m trying to read the metadata of a audio file while it’s moving through my stream pipeline.I’m using the music-metadata library, fortunately it works with streams. But unfortunately I can pipe data into a function but I am unable to pipe that same data out when the metadata is read.Here is the example snippet the library owner provided.https://github.com/Borewit/music-metadata/blob/master/example/javascript/stream.jsI’m just wondering how I would go about turning this stream consumer into something I can implement into my pipeline then use a callback function to get the audio metadata?I’m considering duplicating the stream using .data but I’m imagining that would cause massive memory bloat.Thanks.

Submitted August 27, 2020 at 01:24PM by haulwhore

Callback vs Promises vs Async Await

https://www.loginradius.com/engineering/blog/callback-vs-promises-vs-async-await/

Submitted August 27, 2020 at 01:13PM by mohammedmodi

Ever wondered what changed your object? Now, it is just a few seconds to discover when debugging with time-traveling and data breakpoints - just set a breakpoint and press run backward.

https://v.redd.it/svb017h8ajj51

Submitted August 27, 2020 at 12:52PM by njiv

Javascript Debugging Best Practices

https://blog.bitsrc.io/javascript-debugging-best-practices-e28a09b4528a

Submitted August 27, 2020 at 12:39PM by CompetitiveFan

AdminBro version 3 released with the design system, Features (TM :)) and more

https://softwarebrothers.co/blog/adminbro-version-v3-released/

Submitted August 27, 2020 at 11:35AM by hotcto

Check for new revision a Bazaar Branch

Hi I want to create a script that will check a remote bazaar repository and notify me for any updates or revision changes etc...As I am totally new to this kind of things could you please help me on how could this be implemented?

Submitted August 27, 2020 at 10:59AM by umbaman

Midway Serverless - A Node.js framework for Serverless - Interview with Harry Chen

https://github.com/midwayjs/midway/wiki/Midway---A-Node.js-framework-for-Serverless---Interview-with-Harry-Chen

Submitted August 27, 2020 at 09:13AM by Midwayjs

Bookshelf.js - Sub Query

Hi, Does Bookshelf support these kind of subqueries now ?select * from Table1 where user_id IN ( select follower_id from Table2 where user_id = 16 );Need help.

Submitted August 27, 2020 at 09:31AM by akhil4755

What do you think about this Microservice Boilerplate ?

Hello internet, I created template repo for my ideas with Nodejs, MongoDb and Redis. You can freely use it or fork, that would be great if you can share you feedbacks.ErenYatkin/microservice-base Boilerplate

Submitted August 27, 2020 at 09:18AM by erenyatkin

Undici - an HTTP/1.1 client written from scratch, for Node.js

https://github.com/nodejs/undici

Submitted August 27, 2020 at 09:01AM by pimterry

Midway - A Node.js framework for Serverless - Interview with Harry Chen

https://github.com/midwayjs/midway/wiki/Midway---A-Node.js-framework-for-Serverless---Interview-with-Harry-Chen

Submitted August 27, 2020 at 09:07AM by Midwayjs

Wednesday 26 August 2020

is it necessary to limit number of parameters/body per route? or size of each parameter?

if so how to you do it per route?

Submitted August 27, 2020 at 03:06AM by KommSur

Looking for tips on building a multiplayer game with Socket.io and node

I want to build a demo for my portfolio where everyone on a web page can see everyone's mouse location. This will be my first time using socket.io for a project so I was wondering if anyone would mind sharing some tips before I jump into it. I also have very little experience working with canvas. Here are my thoughts on how I would build it:On the client side:Run a loop in JS that checks the users mouse location on a canvas, stores the data in a JSON object and send it to the server.At the same time parse the incoming JSON object from the server that contains everyone's location and draw circles where they are.On the server side:Handle incoming JSON packages that contain individual user locations and combine them all into one JSON object before sending them out to all the clients again.Thank you! Also sorry if my explanation shows a lack of understanding of sockets. That is because I do not understand sockets!

Submitted August 26, 2020 at 08:19PM by TheSlothJesus

Does anyone have some example code for doing migrations with middleware for MongoDB and Mongoose?

I was reading about how to migrate data after changing a MongoDB schema. I saw this thread:https://www.reddit.com/r/node/comments/9lruth/question_how_do_you_deal_with_mongodb/That mentions that you can do it using middleware by checking the schema version by checking the versionKey or __v, and if the a version of a document needs to be updated you can write some code to do so in a middleware function.However, I didn't see any actual code on how to do this on Stackoverflow or Reddit. Does anyone have an example on how to do so, or can someone tell me which Mongoose middleware I'm supposed to use to check a document's __v and update it if need be?I'm also aware I can query the entire DB and update documents that way, but I think this approach is an interesting idea.

Submitted August 26, 2020 at 07:05PM by taimoor_apps

Angular, JavaScript, NodeJS, CSS, Html quick Concepts...

https://www.tutorialslogic.com/angular?.ng.10.

Submitted August 26, 2020 at 07:17PM by ukmsoft

Where is the best place to find a senior node engineer for a 3-6 month contract?

I'm currently the solo developer working on a web application and I just got the go ahead that we now have the funds to bring on another developer. Other than Upwork, where is the best place to find a senior Node developer for a 3-6 month contract?

Submitted August 26, 2020 at 06:38PM by bluescreen85

Error: Can't set headers after they are sent to the client

Mongo Express Node Template Feedback

Hello all!I am working on a template to help kickstart development for applications that use Mongo, Express, and Node as the backend. I would love any feedback as I work on this so I can course correct as I go rather than when I finish. A link the repository can be found here: https://github.com/cdthomp1/mongo-express-node-templateThanks in advance for all your help!

Submitted August 26, 2020 at 05:26PM by null-ref-err

The Pros and Cons of AWS Serverless Express

https://medium.com/@ac052790/the-pros-and-cons-of-aws-serverless-express-789996e4be32

Submitted August 26, 2020 at 04:34PM by acdota0001

CodingGarden is developing right now with React !!

codinggarden is making a led matrix for his twitch chat react http://www.twitch.tv/codinggarden?sr=a

Submitted August 26, 2020 at 04:48PM by jamie337nichols

Warning Advice when i Install a packpage

Hi,I've been learning Node for a few weeks, and I would like to understand why some packages that I install with both npm and Yarn trigger this yellow warning in the terminal?​https://preview.redd.it/gydt6t2m2dj51.png?width=961&format=png&auto=webp&s=0382594d31d3ebdace36d002825f59efe27b0e13

Submitted August 26, 2020 at 03:57PM by LupusDaemonis

Security Best Practices for Node.js

https://blog.appsignal.com/2020/08/12/security-best-practices-for-nodejs.html

Submitted August 26, 2020 at 03:37PM by mmaksimovic

[Yarn] I can't get the right dev/peer dependency version installed for one of my monorepo package's dependencies.

If this isn't the right place to ask Yarn-related questions, please let me know.I’m new to Yarn and monorepos in general, but I’m trying to manage a project with 3 packages under the root. In package A, there is a dependency - let’s call it dependency1. dependency1 has a dev dependency of dependency1a (version ^0.7.3) and a peer dependency of dependency1a (version >= 0.6.0). I have hoisting disabled in package A for right now to simplify things.When I run yarn install and run my app, I get an error that basically says dependency1a wasn’t found in module dependency1. And this is correct because dependency1a isn’t present in dependency1’s node modules folder. It looks like dependency1a already exists in the root node modules, but the version is ^3.1.6. I guess a higher version is required elsewhere in the project.I guess my question is, what do I need to do to get dependency1a installed in dependency1’s node modules? Or, how do I ensure that dependency1 has access to the right version of dependency1a? I’d be happy to provide any additional information about the project structure.

Submitted August 26, 2020 at 03:23PM by sadelbrid

How to make express-session/serializeuser/etc. only apply to one passport Strategy

I have two GitHub passport strategies for two use cases. One doesn't need a session at all and one use mongoose and express-session to use a session. How can I make the session stuff and the serializeuser stuff only apply to one Strategy?

Submitted August 26, 2020 at 02:54PM by EddiesTech

Papyr CMS now supports Postgres and other relational DBs

"I really like it but can I use postgres instead of mongoDB?"Last time I shared Papyr, this was one of the first and highest rated responses I got. At the time, the answer was that only Mongo DB was supported, but then I got to work! Leveraging the Sequelize and Mongoose ORMs, Papyr now supports any databases that these ORMs support (including Postgres).Maybe you weren't here last time I introduced Papyr. Papyr CMS is something of a CMS/Framework hybrid. Using the NextJS React framework, Papyr is designed to be extremely customizable (the CMS part) and extendable (the Framework part). Using a combination of "Content Posts" and "Page Posts", which leverage a series of pre-built Sections, custom landing pages fly together (check out how it works). Because, however, Papyr is built on NextJS, developers can customize their install to their heart's content. Additional Sections can be added to the "components/sections" directory of a project to be included in the list of sections used to build pages, or, using NextJS's "pages" routing, one can simply build their own React component in the "pages" directory that can be as custom and advanced as it needs to be.Besides being a customizable CMS and extendable Framework, Papyr comes with all sorts of functionality that most websites need already baked in. These features include blog, events, ecommerce, quick website initialization, user authentication, Gmail integration, Google Analytics, and more! On top of that, Papyr is designed to be used for free! Every service (hosting, database, image storage, etc) is a "freemium" service, so everything can be used for free, but is very easy to scale for a few dollars once you need to.Check out the home website at https://papyrcms.com or the code at https://github.com/drkgrntt/papyr-cms. You can also see a demo site showcasing many of the front-end features using fake content at https://drkgrntt.herokuapp.com.Do you have any questions or comments? Feature requests? Bug reports? Would you like to contribute? Please feel free to reach out in any way you know now, or via the contact form, and I will get back with you as soon as I can.Thanks for reading!

Submitted August 26, 2020 at 02:20PM by drkgrntt

Making WAVs: Understanding a Binary File Format by Parsing and Creating WAV Files from Scratch in JavaScript

https://www.youtube.com/watch?v=udbA7u1zYfc

Submitted August 26, 2020 at 01:38PM by FrancisStokes

Visualize NodeJS Errors in Real Time with Llama Logs

https://i.redd.it/6w8asiq7fcj51.gif

Submitted August 26, 2020 at 01:47PM by llamalogs

New to using Node and making a POST request and it is coming back blank/ {}

app.post("/api", (request,response) => { console.log(request.body) data = request.body console.log(data) }) This is my post requestfunction submitValues(){ start = document.getElementById("start").value; end = document.getElementById("end").value console.log(start,end) // findShortestPath(graph, start, end) data = {start, end} options = { method: "POST", headers: { "Content-Type":"applcation/json" }, body: JSON.stringify(data) } fetch("/api", options) } This is the function from when pressing a button gets the values then tries the POST request

Submitted August 26, 2020 at 12:28PM by JoshG232

Develop RCS

I've been asked to create a super dummy RCS chatbot with Oranges API. I'm not a developer which makes it really hard for me.I found a simple node.js template (also found in python) for an RCS chatbot that simply returns what the user says. I was hoping I could get some direction as to what I need to change other than the token,api_url, and bot_id which I highlighted in red.At the end I'm expected to fill in this excel spreadshit. This is the list of the API and here it is expanded.Has anyone did something similar? May I ask for some directions on what to change next? Huge thanks ahead.

Submitted August 26, 2020 at 11:27AM by HeadTea

How to get the user IP in express?

I have been trying to identify users based on IP addresses and this is what I am getting from request object :{"x-forwared-for": "10.110.0.5","remoteAddress": "::ffff:10.244.0.160","x-real-ip": "10.110.0.5","ip": "::ffff:10.244.0.160","headers": {"connection": "close","host": "www.footballexclusive.live","x-real-ip": "10.110.0.5","x-forwarded-for": "10.110.0.5","x-forwarded-host": "www.footballexclusive.live","x-forwarded-port": "80","x-forwarded-proto": "http","cache-control": "max-age=0","upgrade-insecure-requests": "1","user-agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.122 Safari/537.36","accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9","accept-encoding": "gzip, deflate","accept-language": "en-US,en;q=0.9,hi;q=0.8","if-none-match": "W/\"317-eb2ITwrZT5q7/tpqrnFedtccXnA\""}}​The IP I am getting is 10.110.0.5 and this does not match with whatsmyip and I have tried it on three different devices and getting the same IP. How do I get actual user IP?

Submitted August 26, 2020 at 08:41AM by GhostFoxGod

Im writing a "secure as possible" express API boilerplate, i think i covered all the obvious basis but im no expert so advice/pr's are always appreciated!

https://github.com/GagePielsticker/Secure-Express-API

Submitted August 26, 2020 at 07:40AM by uberbot69

Tuesday 25 August 2020

What are these hidden mongoose properties in a document??

Hello all!I have a mongoose document retrieved from the database with the following type for example:interface Car { numberOfDoors: number; }If I do a console.log of the Car object retrieved from the database. I get numberOfDoors, _id and __v fields. Perfect until here. However, if I do the following:const aDifferentCar = { ...carFromDB, newProperty: blabla } Then if I console log aDifferentCar I get a bunch of mongoose properties, like $__, isNew, _doc, etc.Why this is not happening in the original console log? Also, what can I use to create another object based on other's properties but without using ...?I know calling lean() in the mongoose find would solve the issue. But I would like to avoid that as I will be using some virtual functions, etc. I have read in the documentations those will not be present with lean.Thank you in advance.

Submitted August 26, 2020 at 06:38AM by dejavits

Data undefined when using Fetch API

I am building a YouTube Video downloader with Node and I am encountering an issue that I cannot seem to figure out. I am sending a response message or error depending on the outcome of the download. I am getting the error TypeError: Cannot read property 'error' of undefined whenever I get a response from my endpoint. Here is the client side code:fetch("/download", { method: "post", headers: { "Content-Type": "application/json", }, body: JSON.stringify({ url, }), }) .then((res) => { res.json(); }) .then((data) => { console.log(data); if (data.error) { console.log(data.error); } else { console.log("success"); } }) .catch((error) => { console.log(error); }); And here is a snippet from server side code:router.post("/download", (req, res) => { res.json({ message: "video downloaded" }); const { url } = req.body; const outputName = "video.mp4"; const outputPath = path.resolve(__dirname, outputName); const video = ytdl(url); console.log(video); video.pipe(fs.createWriteStream(outputPath)); video.once("response", () => { starttime = Date.now(); }); } When I log data in client side code it comes back as undefined when it should contain the message "video downloaded" and pass the error logic. The code works but I need to figure this out for error handling.

Submitted August 26, 2020 at 05:25AM by TheSlothJesus

Write to a file that's hosted somewhere a file is writable.

I already know about fs.writefile. My concern is I want to be able to write to a file that is hosted somewhere on the web. I want to use something like this:fs.writeFile("https://filehoster.com/file.txt", "Hello World!", callback) I guess I am asking for two things. The main question is where, on the web, can I host a writable file? Also, after the file has been uploaded, will the above line of code work how I want it to?

Submitted August 26, 2020 at 04:32AM by Diriector_Doc

Noob question about JWT i know jwt consist of header payload signature are you suppose to send the entire jwt to the client?

header.payload.signatureaaaaaaaaaa.bbbbbbbbbbb.ccccccccccccthe header doesn't seam to change anyway is it better to hide it on the server?​additional questionis a complex secret key and a short expiry enough to protect?

Submitted August 26, 2020 at 04:24AM by KommSur

Does anyone have a public project on github with node and strapi?

If anyone is kind to share a project where strapi is used to create a CMS for some node app it would help to have it as a reference to learn strapi.

Submitted August 25, 2020 at 09:29PM by iMilos_99

How to sync data across distributed systems with the same database?

Hey guys, I'm wondering how you guys sync data across all different systems if they're pulling from the same or a few databases.I'm reading into Kafka and their message bus that would allow messages to be queued up correctly and then sent out to any subscribers to a topic.I'm still not sure what Kafka does.Also, how exactly do you manage which database query gets prioritized so that you don't have potential overlap or have the data sets return two different things to two different consumers?

Submitted August 25, 2020 at 09:51PM by ibeeliot

I there a way to build eCommerce website in Node without security headache?

I mean in PHP they've Magento, WooCommerce and etc...Do we have something like this in Node that at least will handle security stuff for us?

Submitted August 25, 2020 at 08:27PM by AhmedHossam01

A problem that slows me down when learning Node

Whenever I want to start a new challenge and build a new type of website with Node, I spend most of my time building the boilerplate and CRUD operations. Like I've to build:/user GET, POST, DELETE, UPDATE/video GET, POST, DELETE, UPDATEI spend most of the time doing repetitive CRUD stuff and less time doing the actual challenge.So, is there a tool that can do these stuff for me and let me just add on top of them?

Submitted August 25, 2020 at 08:07PM by AhmedHossam01

How to learn more Node?

How to learn more Node in much deeper level? And I mean learning about real world problems.. Like becoming better at security. With another meaning, get the experience that we gain when working with companies in real projects but on my own (without a company).*Don't throw the documentation at me and say memorize more methods :D*

Submitted August 25, 2020 at 07:31PM by AhmedHossam01

Top JavaScript Courses to Learn 2020

https://medium.com/@devexpert/25-best-javascript-courses-to-learn-2020-caf08f019a4f

Submitted August 25, 2020 at 05:40PM by cimmba

Which hardware to choose? Arduino or RaspberryPI

Hi All beautiful people,I want to create a home automation system for my home. I could buy a pre-built service but I always wanted to learn about IoT and this is a use case I can work on.I don't have knowledge of Hardware, so need you guys to help me select hardware through which I can control lights and fans to start with. Also, I should be able to control these from the internet so that I can control it even when I'm not at home.I have read many places about Arduino and Raspberry Pi. People are building some really cool stuff with these.For coding, I will use NodeJS to create connection and API's

Submitted August 25, 2020 at 05:13PM by ghazikhan205

Calling mainframe z/OS services from Node.js

How to Call Low-Level z/OS Services from Node.jsUpdate the repo with a PR if you have ideas for improving the process.

Submitted August 25, 2020 at 05:15PM by ecgdave

cli-badges: Quirky little NodeJS library for generating badges for your CLI Apps.

​https://preview.redd.it/v26xia2gb6j51.png?width=600&format=png&auto=webp&s=ed56b8d1fb9f056173df498307814d299d1cc0b3​Badges / Shields are really popular in the dev community, and wanted something similar but for the console.Github: https://github.com/nombrekeff/cli-badgesnpm: https://www.npmjs.com/package/cli-badges​​Some Samples (look different on different terminals)​​https://preview.redd.it/dg4ogzgob6j51.png?width=296&format=png&auto=webp&s=a271decda22bc085419de48628576dd1aa1d327d​Features:256 Colors Available (cli-color library, if supported by terminal)Multiple Styling Options (bold, dim, underlined, reverse, hidden)Support Links (If Supported by Terminal)Emoji support (kinda)

Submitted August 25, 2020 at 05:17PM by nombrekeff

How to destroy session stored in MongoDB (NodeJS)

Currently I let my ReactJS client make a request to the /logout endpoint on my NodeJS server in order to destroy the session. It looks like this:router.get("/logout", (req, res) => {req.session.destroy();res.clearCookie('connect.sid');res.status(200).send('User has been logged out');});I use connect-mongodb-session to store the session.However, neither the session get's destroyed (it's still visible in MongoDB) and also the cookie connect.sid remains persistent at the client side.Of course I can also remove the session from the DB 'manually', however, I believe this is not the conventional way of doing it.

Submitted August 25, 2020 at 05:25PM by CryptoScience

fastest-levenshtein - extremely fast Levenshtein distance implementation.

Several Levenshtein packages exist on NPM:fast-levenshtein: 12,401,141 weekly downloadsleven: 11,538,628 weekly downloadslevenary: 6,804,036 weekly downloadsdamerau-levenshtein: 4,919,358 weekly downloadsjs-levenshtein: 2,512,578 weekly downloadsI set out to write the fastest implementation of this very popular algorithm. This resulted in a higly optimized bit-parallel implementation that is up to 10x+ faster than the second fastest implementation.Check out the benchmarks:fastest-levenshtein

Submitted August 25, 2020 at 04:11PM by ka-wei

[Node JS / Heroku] Can I use a Background worker to execute CPU intensive tasks and return the data to client? Or, should I use a child process?

I apologize if I mixed up child and background process.I'm fairly new to using background workers with Bull on Node JS, and was hoping to get some help on how to handle this. I'm currently using standard-1x dyno for web and worker process on heroku.I have a process in my server that retrieves the data from a DB and performs calculations on this data (CPU Intensive). The worker process is currently being used for handling background tasks such as database backup, send emails, etc. I'm able to add the CPU intensive task to the Bull queue and execute it on worker thread, but I'm having trouble with returning the data either to the main thread or to the client.I've tried sending the data over sockets from the worker thread, but that fails. Another approach would be to store it in Redis, and poll an endpoint for this result.Is there a better way to do this? Or should I drop moving the exec. to worker threads and use child process instead? If I'm using child process, what does that mean for my dyno? How should I change it's configuration?

Submitted August 25, 2020 at 03:29PM by the-ML-noob

Code-first GraphQL server development powered by Node + TS

https://blog.graphqleditor.com/graphql-nexus-codefirst-graphql-server/

Submitted August 25, 2020 at 01:39PM by oczekkk

Node.js Best Practices — HTTPS

https://medium.com/javascript-in-plain-english/node-js-best-practices-https-a69d8d254426

Submitted August 25, 2020 at 11:12AM by aman_agrwl

Node.js Best Practices — HTTPS

https://medium.com/javascript-in-plain-english/node-js-best-practices-https-a69d8d254426

Submitted August 25, 2020 at 11:18AM by aman_agrwl

Node.js Best Practices — HTTPS

https://medium.com/javascript-in-plain-english/node-js-best-practices-https-a69d8d254426

Submitted August 25, 2020 at 11:27AM by aman_agrwl

E-commerce api using Node.js

https://github.com/AsimZz/E-commerce-api-using-Node.js

Submitted August 25, 2020 at 08:24AM by HeisenbergZzzz

Monday 24 August 2020

Space Ghost JS - make anonymous HTTPS get requests

https://github.com/sm1l3ycorp/spaceghostjs

Submitted August 25, 2020 at 04:34AM by sm1l3ycorp

How to access the JavaScript code that is loaded dynamically on a web page, by using Puppeteer?

I'm trying to access an object that is loaded dynamically on the web page.https://i.stack.imgur.com/Gq7Bz.pngBut the problem is that I can't access that data through the window object, even though it's loaded on the page.https://i.stack.imgur.com/ZNhMQ.pngHere's a simple script I'm using.const browser = await puppeteer.launch(); const [page] = await browser.pages(); await page.goto(pageUrl, {waitUntil: 'networkidle2'}); let data = await page.evaluate(() => { let info = window._wq; return {info}; }); for(i in data){ console.log(i, data[i]) } await browser.close();

Submitted August 25, 2020 at 03:12AM by regression-analysis

How do I use Promise.all with an array of Functions?

I have an array of functions, each representing a frame in an animation, and each one is periodically gets executed my Animator class (asynchronous) and removed from the list.frames = [f1, f2, f3, f4]I want to create a Promise that resolves when all these functions have been executed (when the animation is finished), but the problem is that if I do something like the followingPromise.all([new Promise(f1), new Promise(f2), new Promise(f3), new Promise(f4)])where each f resolves the promise when invoked, then all the functions get executed immediately. I don't want this, I want the functions to be executed individually only when my animator decides to.How do I create a promise that resolves when each frame of my animation has been executed?

Submitted August 25, 2020 at 01:00AM by santoso-sheep

How to put in user input from a Python script running in NodeJS using child_process?

Hi. I have a Google Chrome extension which sends the user's current mouse coordinates to the ExpressJS server (currently on localhost:3000). I use the in-built fetch to send these requests to the server. When the express server receives these coordinates from the req.body, it starts a Python script (which uses Selenium) using child_process and spawning it. The Python script needs the coordinates each time it is sent to the server. The way I try to implement this is to ask for user in a while loop, using coordinates = input("Coordinates: "). However, from the server, I am not sure how to input the coordinates sent from the server each time to the running script.My current code:server.jsconst express = require('express') const app = express() const port = 3000 var hasSpawnedPythonProcess = false var pythonProcess = null var x = 0 var y = 0 app.use(express.json()) app.use((req, res, next) => { res.header('Access-Control-Allow-Origin', '*') res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept"); next(); }); app.post('/mouse', (req, res) => { x = req.body.xCor y = req.body.yCor if (!hasSpawnedPythonProcess) { console.log("Spawn python process!") hasSpawnedPythonProcess = true const spawn = require("child_process").spawn; pythonProcess = spawn('python', ["-u", "./script.py"]); pythonProcess.stderr.on('data', (data) => { console.log(data.toString()) }) pythonProcess.stdout.on('data', (data) => { console.log(data.toString()) // Don't know how to put string for user input }) } res.send({success: true}) }) app.listen(port) script.py// import selenium libraries and sys if __name__ == "__main__": // Sets path and creates browser object // Get canvas element and other stuff coordinates = input("Coordinates (maxWidth: "+str(canvas.size["width"])+", maxHeight: "+str(canvas.size["height"])+"): ") while coordinates: xCor = int(coordinates.split(",")[0]) yCor = int(coordinates.split(",")[1]) ActionChains(browser).move_to_element_with_offset(canvas, xCor, yCor).click().perform() coordinates = input("Coordinates (maxWidth: "+str(canvas.size["width"])+", maxHeight: "+str(canvas.size["height"])+"): ")

Submitted August 25, 2020 at 12:14AM by Strikerzzs

Office 365 API

Hi, I have an external application that is currently using Google Sheets to store data. I would like to port it to Office 365 for my organization.If you have worked with the Office 365 api before or have knowledge, can you point me to the simplest way to get started?The authentication with Google is dead simple. All of the Microsoft docs and tutorials seem to be focused on more complicated projects. I am looking to access a speadsheet in my office 365 account, read rows, and post new rows.

Submitted August 24, 2020 at 09:37PM by Jitsu24

Newbie needs help! 👉👈

So, i have link for tumblr api that gives the tagged posts with the given tag , i want to just get the content of the , I want just the links inside , when i make a get request it loads the whole thing , I've tried puppeteer , fetch , document.getelementbyId , miserably failed..How can i get just the links inside the :''(

Submitted August 24, 2020 at 09:39PM by Antiihope

Affordable alternative to ELK

We are looking for an alternative to ELK, main requirements are logs, apm and request & response content(ip, location, body, params, etc...), rotation 2-7 days, active users count < 5, also it will be good to have some alerting systemOur environment is NodeJs application running with pm2 on Azure Vm, also in some places we are using containers, we need logs also for thoseWhat is your recommendations? Can you share your experience ?Thank you

Submitted August 24, 2020 at 08:48PM by Grigsuv

Can someone explain what problem Graphql is solving?

I see it as an implementation of a pattern (API Query Language but I'm not clear about why it's worth the implementation overhead. Does it handle api versioning? Or is it just a standardized way to call Rest apis?

Submitted August 24, 2020 at 08:06PM by badbrownie

npm package for controlling crypto wallet(s)

Greetings!I've been building a browser pokersite for homegames over the past months, and it's getting decent now.I'd like to add support for some crypto currencies, but I can only find a few libraries for bitcoin and bitcoin cash.Since my entire backend is written in Node I would prefer using Node for the crypto aspect too.Does anyone have experience controlling wallets for various crypto currencies through Node.js? It's pretty hard for me to gauge what is solid

Submitted August 24, 2020 at 07:39PM by ihufa

Do parameters in function affect performance?

As per my code I have a base file. for exampleconst module = require(./apps/module); module.get(request, response, variable); In apps/module.js I use the same function multiple times. Should I use doThing1() or doThing2()? Both do the same thing but doThing2() has fewer paramaters. Does passing so many variables affect anything?function doThing1(request, response, variable, variable2){' blah blah blah...; }; function get(request, response, variable){ function doThing2(variable2){ blah blah blah...; }; if(){ doThing1(request, response, variable, 'data'); doThing2('data'); }else if(){ doThing1(request, response, variable, 'data'); doThing2('data'); }; };

Submitted August 24, 2020 at 07:47PM by omato2468

Node-Gyp???

What is this bs? Ever since I update npm it has been cluttering my terminal every time I need to install something. What is it for? Why was it included? It seems to be a pain in the ass so far

Submitted August 24, 2020 at 03:01PM by LilRee12

How to make sure my variables are initialised when used by different routes?

My API has 2 different routes :1 for the end user where they post the data they want and then trigger GitLab pipelines where I fetch the triggered pipeline id and the job id's within the pipeline.1 is for the GitLab webhook I've integrated.I got 2 variables : pipelineId and jobId.They're global variables since I use them in both routes. They are both initially empty, but then initialised in the first route.The first route fetches them within the response body after the trigger and I want to use them to fetch a specific job's logs in the 2nd route. However, I end up with empty variables since both routes are executing themselves in parallel. Now, my question is how to make sure my variables are initialised by the 1st route when used in the 2nd route.This is the code I'm working on

Submitted August 24, 2020 at 03:02PM by TheMemeExpertExpert

light-date ⏰ - Blazing fast & lightweight (173 bytes) date formatting for Node.js and the browser.

https://github.com/xxczaki/light-date

Submitted August 24, 2020 at 02:05PM by xxczaki

if i put .env in gitignore will it be a problem on heroku deployment?

.env file conatains mongodb Atlas cradentials, jwt secret key, firebase cradential etc

Submitted August 24, 2020 at 02:17PM by ahnafX

Node.js Lesson 1: Introduction and Modules

https://blog.soshace.com/1-lessons-nodejs-modules/

Submitted August 24, 2020 at 12:03PM by tech_blog_88

Web Dev YouTube Channel

Hey guys i recently started a YouTube channel about web development i try to make high quality content about topics such as react, JavaScript, tailwind and more and would love some feedback[15-Year Old Programmer ](https://www.youtube.com/channel/UCMu3gqtmi_f0u8fA8g6DBgg

Submitted August 24, 2020 at 12:08PM by haardikg

How do you write tests for node commands?

Maybe I'm using the wrong tools for this, but I've been working on a front end tooling running through Gulp. Basically compiles javacript, sass and a whole bunch of other stuff.I want to add some automated tests that can be run with Node and I've looked into using Mocha.js for this but I've been struggling figuring out how I can tell Mocha to run various gulp tasks and all my google searches just lead me to running mocha through gulp which is not what I want.I guess my question is, whats the best way to test Gulp.js tasks?I know an alternative would be to do this outside of the project, through something like gitlab-ci or jenkins but I would want to include it within the project if possible.

Submitted August 24, 2020 at 11:50AM by -noveltyhero-

Why NodeJs isn't as good as like Laravel?

Every time I see Laravel's ecosystem that help you literally build any website with just using tools, save you much time and save you from security and performance hassle, I become really impressed and feel like I wasted time in Node.js and the MERN Stack!https://preview.redd.it/y2eckmxn5xi51.png?width=1344&format=png&auto=webp&s=43c1e45e91d8a0a77cf2865ea7281197e94d72d4Why isn't NodeJs like it? Can you provide a NodeJs alternative for every tool in the Laravel's ecosystem?Also, Laravel has many freelancing opportunities while NodeJs almost has no opportunities at all (at Freelancer website). Where can I find freelance opportunities as a MERN Stack developr?I'm asking these questions to decide whether should I switch to Laravel or stay as a MERN Stack Developer, I really like MERN Stack and JavaScript so I don't want to switch at all deep in my heart. But with all these advantages I see in Laravel I fell like I'm wasting time and effort by doing everything (even security) by hand in the MERN Stack. So please tell me if there's something I don't see..For hipster folks who'll say: you can't compare a framework with a runtime environment.. I can. I compare them in accordance to the end goal they achieve. Both of them build websites.NOTE: I'm not saying Laravel is better than NodeJs.. I just feel that so I need someone to guide me and discuss these points that I mentioned earlier so I can stay with Node because I like it.​

Submitted August 24, 2020 at 10:37AM by AhmedHossam01

Best practices for containerizing Node.js

https://medium.com/@nodepractices/docker-best-practices-with-node-js-e044b78d8f67

Submitted August 24, 2020 at 08:25AM by yonatannn

Sunday 23 August 2020

How often do you use express in node js?

For those that have worked with node js in their jobs, how often did you use Express js? Did you have to write pure Node js without any library? Also, did you use react js with node js or did you just use a template engine with node?

Submitted August 24, 2020 at 06:55AM by udbasil

Needing some help of creating my app?

recently i've been learning Reactjs and i've missunderstand some concepts for structure my web app so i just make some basics stuff like i create my react app and doing server part and connecting to mongodb ect there is No probleme but i see some app with various inststrucure and that what make me confiused a little bed like i've found app contain middlewar and controller and validation partinside those files (Controller file ) i fount some thing like thatasync create(req, res) {const task = new TaskModel(req.body);await task.save().then(response => {return res.status(200).json(response);            }).catch(error => {return res.status(500).json(error);            });    }and that make me wondring about why should i use async and await and i have a question herewhy should i use asynchronous function meanwhile i disscover some apps just do thisrouter.route('/add').post((req, res) => {const username = req.body.username;const newUser = new User({username});  newUser.save().then(() => res.json('User added!')).catch(err => res.status(400).json('Error: ' + err));});like this concept just add express router and recieve the body ect.. and he's good with that structurebut i found in first example that routes and validation organized well , but the point here should i use Contoller and seprate the routes part and validateseconde point i do some search about validation body of course i found exprees validation but there is No Turnout for it and that's to make me wondring why there's so much validate thier inputs requestfor knowing i know Monngose doing this part like the max for the propety value and should it req or Not and stuff like that so should i be good with that with No need for validateor sprate routes folder and making middleware and using asynchronous concept and i saw a lot of project course there No one validae with express or use like first example structurei'm disappointed and don't know what should i do , so is there is any way to see the best practise for structure my wep app and what should i do and what shouldn'tthanks ()

Submitted August 24, 2020 at 07:07AM by Adamqaram

How to classify flowers with Tensorflow.js

https://blog-81003.web.app/how-to-classify-flowers-with-tensorflow-js

Submitted August 24, 2020 at 05:28AM by LaCosaNostra-

Can't find my web files!

This will sound silly, but I cleverly spun up a server on port 3000 running on pm2. My nginx server proxies to 3000, and it's ruining fine, so I have not looked in 6 months. Now I want to update, and I can't find where the files are being served from! How can I find the root directory of a process running on port 3000 on Ubuntu?

Submitted August 24, 2020 at 05:11AM by green-raven

Learn Node.Js under the hood

https://medium.com/better-programming/learn-node-js-under-the-hood-37966a20e127

Submitted August 24, 2020 at 04:52AM by aman_agrwl

Seamless integration of Spotify API in Electron app?

So I want to integrate the Spotify API in my Electron app. The issue I can't seem to get around is integrating it in a seamless manner. By this I mean using an external server to handle the Secret as recommended. My setup so far is having a Express server hosted on Heroku for the callback url and following the Authorization Code Flow as presented here.With things being handled on an external server so that the Secret isn't exposed to the client, I don't see a way to do this seamlessly. So after the user is authenticated, the tokens are on the server's callback page. I don't see a way for the app to now know if the authentication process was completed. I don't think it's logical to have the user click the connect to Spotify button in the app again to check.Any ideas for integrating into Electron for a Desktop app?

Submitted August 24, 2020 at 12:54AM by SweatyCubes

Trying to monitor a GET request response until it validates my condition

I'm trying to recursively monitor the response from my GitLab API to check the status of a specific Job.I'm using axios, does anyone have an example?

Submitted August 23, 2020 at 10:27PM by TheMemeExpertExpert

Server paypal transaction verification

Have any of you set up a server to get passed the order ID and verify a Paypal transaction? I am having a lot of trouble getting it working (mainly with getting the package npm install \@paypal/checkout-server-sdk ) working with the rest of the code provided here:https://developer.paypal.com/docs/checkout/reference/server-integration/capture-transaction/#on-the-server​whenever i run it, it cant find various things referenced in that above URL.Have any of you done this before, and if so, could you offer any help? Thanks!

Submitted August 23, 2020 at 09:58PM by ScienceNotBlience

Best ORM for node

What ORM do you use? And why? I've used sequelize and mongoose. Although they did not gave me the same experience as entity framework with .NET. I've got the feeling that node doesn't have the ORM that I'm looking for. I would like to use normal ES6 classes, so that my domain is separated from the ORM that I use. I've seen that typeORM supports something like that, and then you use annotations above your properties. I have no experience with typeORM but I've read that it can be buggy. Do you know an ORM that fits the structure I would like to have?

Submitted August 23, 2020 at 10:15PM by UnlimitedSky23

encrypt/decrypt a binary file

I am trying to asymmetric encrypt /decrypt a binary file. Most of the examples (using crypto) have simple text. However, when I try to feed a file buffer to it , I get error like'code:'ERR_OSSL_RSA_DATA_TOO_LARGE_FOR_KEY_SIZE''any pointers on how to encrypt/decrypt file ?

Submitted August 23, 2020 at 09:42PM by CarefulComputer

Searching for image recognition API

Hi there, I'm attempting to work on a CLI App that will accept a PDF as input and output a list of list of colors found within the image displayed on the PDF by their relative frequency.I realize I'm missing implementation details here, I feel confident enough to figure those out on my own. I'm just hoping for a link to a library capable of solving this problem if anyone is familiar with one.I have found PDF.js which seems to convert a PDF into a canvas element, and I suppose I could brute force something from there but I'm hoping for a little more elegance.

Submitted August 23, 2020 at 09:16PM by TollTrollTallTale

Dice rolling

So I have a dice command but I want it to ask them if they would like roll again I'm using prompt-sync to ask them in the console. I've been trying to use while but to no avail.

Submitted August 23, 2020 at 07:54PM by ajhajajahhshahsj

View Tabular Data in VS Code During Debugging

https://i.redd.it/om8lpu18isi51.gif

Submitted August 23, 2020 at 06:50PM by Gehinnn

what is safest way to store JWT token on React client side?

No text found

Submitted August 23, 2020 at 06:08PM by ahnafX

Minimalistic TypeScript package for REST API project bootstrapping

https://github.com/upgreidas/rest-bootstraphttps://www.npmjs.com/package/rest-bootstrapMinimalistic TypeScript package for anyone who likes building REST APIs wih express.P.S. It's my first published node package so critique is welcome :)

Submitted August 23, 2020 at 05:15PM by Gugis

Node.JS for tracking stock price changes and doing some analysis?

My understanding is that JS sucks for doing math but is there anyway to make this stable and reliable?

Submitted August 23, 2020 at 04:27PM by UpOnCloud9

Node.JS Backend Ticks

Hey there. Maybe someone can help me out. I'm trying to do the backend for my Flutter App with Node.js. The app is a simulation that has vitals for multiple patients in it. So for example Node.js needs to update the heart rate of a patient every X seconds/ticks. I saw that there is a 'tick' built into Node.JS. Is that something i can use? Will it be efficient?

Submitted August 23, 2020 at 04:51PM by Cyclom_

A Yeoman generator for scafolding github actions.

I created a Yeoman generator for scaffolding your javascript-based Github actions.It follows bare minimum dependencies that are quite easy to set up. Initially, this generator was for my personal projects since I've been into Github actions lately a lot. You can check the project in my GitHub.

Submitted August 23, 2020 at 03:23PM by rocktimcodes

A service that helps you exposing your web apps in any environment

Hi everyone! My friend and I made an early version of a load balancer service for devs who need to easily expose web apps without spending too much effort on it. It can run as a command-line application or code dependency, and we plan to opensource most of the code, which is written or Rust.Here's an early version demo: https://youtu.be/uk3BzIN-hEkWould be happy to hear your questions/feedback and if you'd like to try it out when it's ready!

Submitted August 23, 2020 at 02:03PM by _waybetter_