Sunday 30 June 2019

Knex JS tutorial

​Hi everyone, sorry to bother you today but I am part of a boot camp and they teach us Node/Express sqlite3 and knex. I love Node, Express, and knex but I found out sqlite3 was horrible for production and etc so I am trying to figure out how to create a postgresql database and connect it to knex. I have searched Udemy and google and the google searches all date back to 2015. I was hoping someone here may know of a good tutorial for this? I tried the documentation and it is not the most new user-friendly. Thank you for your time.

Submitted July 01, 2019 at 04:06AM by CodedCoder

Using WebRTC and Node. Sending MediaRecording to node server to client.

Designing, Coding, and Marketing a Node.js App in 57 Hours (playdate.gg)

https://youtu.be/ESZQN3RzylQ

Submitted July 01, 2019 at 02:04AM by voidupdate

how to make a html button execute nodejs function?

I want to execute a function in nodejs with a button on my html page, I've searched all over the internet but couldn't really find what I was looking for, I tried a bunch of stuff but nothing works the way I want it toI just want to press a button on my html website and it'll execute a function in nodejs where my packages are still active in

Submitted June 30, 2019 at 09:54PM by Shy_Cryptic

use exports.run in a function?

is it possible to use exports.run in a functionit would work like thisfunction html() {exports.run = async (client, message, args, tools) => {message.channels.get("").send("test");}}​this doesn't work but I hope it gives you an idea of what i'd like to achieve

Submitted June 30, 2019 at 10:23PM by Shy_Cryptic

Can you suggest app's best database structure to store thousands of users entities ( MongoDB ) ?

I'm making a forum, with chat system and upvote/downvote system. Could someone suggest best way to structurize database, for best optimization to handle thousands of users ?I have several sections to think about:- Chat ( messages and dialogues ). In my case I'm just made two collections for dialogues and messages.- Upvotes, Downvotes. I'm storing them inside users record, in "upvoted", "downvoted" fields arrays.Also I will apreciate if you advise best practicies for app's database structure. Thank you!

Submitted June 30, 2019 at 11:26PM by woyshie

EONET error when I can see the file it says is missing in it's folder!

I'm trying to learn node.js using this program and I'm super stuck at asynchronous I/O. Specifically, I'm using fs.readFile on a file named number.txt (saved in the same directory I'm currently in), and the code is running, but when I console.log(err) it says [Error: ENOENT: no such file or directory, open 'C:\Users\myname\javascripting\number.json'].I have a file named number.json saved in the path, C:\Users\myname\javascripting so I don't know why the program can't find it.My code aio.js:var fs = require('fs') var myNumber = undefined function addOne() { fs.readFile('number.json', function doneReading(err, fileContents) { if (err){ console.log('fuck'); console.log(err); } else{ myNumber = parseInt(fileContents) myNumber++ console.log(myNumber)} }) } addOne(); The result when I run in the console C:\Users\myname\javascripting> node aio.js :fuck{ [Error: ENOENT: no such file or directory, open 'C:\Users\myname\javascripting\number.json']errno: -4058,code: 'ENOENT',syscall: 'open',path: 'C:\\Users\\myname\\javascripting\\number.json' }​edit: I've tried the same thing but with number.txt as well

Submitted June 30, 2019 at 06:03PM by reallyageek

How am I supposed to make a timer_

Well, first of all I want to tell you what I am trying to make.​Basically I am making a monthly subscription monthly paying but I don't know who to check that the user paid again.I thought in making a scheduler for each user and after the scheduler is done, check the database or something. The end date would be saved to db in case a shutdown, so I can retrieve the information again to start the scheduler again.​I hope any of you know the correct way to make this.Thanks.

Submitted June 30, 2019 at 04:16PM by ricardorm0

Tanos - Telegram Bot Builder Framework

We had lots of clients who asked us to create the telegram bot. During the process, we got a common pattern and turned out a useful tool for other purposes.You can separate the telegram bot building process in 2 different types of work:layout - can be done by non-developerapp - can be one by the developer ( code less, get more)Check it out:https://github.com/web3space/tanos

Submitted June 30, 2019 at 02:16PM by askucher

Help with massive streaming data approach

Hey all!I’ve developed a node system that pulls data from multiple high traffic websocket channels, and am running into a backpressure problem.On each websocket payload receipt from various classes that talk to the websockets, I emit an event with said payload, the events then being received by a single class that then pushes the message payload onto a stream. This stream is then piped to another stream that throws the message onto a Kinesis stream via the kinesis-streams package. I did see that the author of that package switched to Kafka but thus far I’ve been happy with it and fine with the java dependency.I believe the backpressure and resulting crash from being out of memory is the stream that is piped to the Kinesis writer. The Kinesis writer is batched though, and have tried a highwatermark at various levels; same result. My questions:1) is emitting all the websocket messages as events (to be received by the single class) a bad idea? Am I possibly filling up the event bus? 1a) should I just expose the input stream to the websocket pulling classes instead of emitting as events? Can multiple classes write to a single input stream?I’ve been googling all over the place but haven’t really found another case of a successful massively high traffic data stream implementation in node.. just others with similar problems.Thank you!

Submitted June 30, 2019 at 01:17PM by favabeanzzz

Should I learn es5/es6?

I programmed in client side js for years up to 2012. Was away from IT for 5 years until 2017. Came back and learned Typescript and Angular. I enjoy it and I'm not bad at it.Recently I needed to write an API and the most viable option was to use NestJS, which I did. Worked out okay.What other options are there for using typescript on Express or Node, or should I dive into es5/es6 to give me more options on Node?

Submitted June 30, 2019 at 12:46PM by maybeonmars

Is there anything you would want to know when you start with Node.js?

Like something that would help you on the begining?

Submitted June 30, 2019 at 10:59AM by mrkafr

Saturday 29 June 2019

Node.js Web App Ideas [Change my mind]

To start with, i'm into Node.js for a while and i really enjoy it. I thought i should open this thread here since we're all into node js and exchange some ideas, so i'll start straight with the question:What app in Node.js do you think would generate the highest revenue atm? (for an independent programmer ofc)

Submitted June 29, 2019 at 10:01PM by blackrat13

Nodejs Design Patterns / Frameworks

What should one look into when starting with more than just a simple API.Working with express I feel like is very useful in many ways. But I can't shake the feeling that , the more I write , the less organized the whole thing essenetially will becomeAny guides to structure a nodejs api ... any framework recommendations ? THe goto ways /aproaches?Thoughts on Meteor? Or others ?Thoughts on MVC & how / when to use ?Scaling / Hosting / Building Apps for real. More than just a couple of routes.Im kinda leaving the todo app phase & aproach building things

Submitted June 29, 2019 at 11:09PM by MedyGames

Can a stream piped into process.stdout() destroy it? Is there a way to restart process.stdout?

I'm starting a child process and piping his output into process.stdout, and somehow sometimes the console goes silent and not even console.log() works, so my guess is that stdout is being destroyed.After a lot of troubleshooting with the limited data I have, I arrived at the conclusion that the stream termination seems to happen when the child process spits "™".Setting the end parameter to false did not help:this.fxChild.stdout.pipe(process.stdout, {end: false}); Do you guys have any ideas on how to prevent the stream termination without having to modify the data?

Submitted June 29, 2019 at 11:42PM by tabarra

Why am I getting lots of nulls? Am I not using promises properly? (See comments in code)

https://www.reddit.com/r/Firebase/comments/c72p28/why_am_i_getting_lots_of_nulls_am_i_not_using/

Submitted June 29, 2019 at 07:55PM by enexorb

Completed App??

I am brand new to software and coding and finally am close to a completed app on electron. Is there any negatives to packaging the app and sending it to my site to be available for purchase directly from my home computer? Is there more safety precautions i should take before releasing it?

Submitted June 29, 2019 at 04:39PM by cowefy

SEQUELIZE

how do people on here feel about sequelize.js ?

Submitted June 29, 2019 at 01:56PM by darealbjamesy

How to specify NodeJS 'child_process' dependencies / version?

I have a full stack web application with a React frontend and NodeJS backend. I'm using child_process to spawn a python process that calculates some values then returns those values to the JS parent process via print lines. This all works as expected.​The issue I'm having, or moreso my area of confusion, is where does the child_process script get it's PY source code from? I suspect that child_process is currently taking the PY version local to my machine somewhere in usr/bin (I'm on a Mac Air 10.13.2 if that matters)​I'd like to be able to specify the python version and have all dependencies/libraries installed inside of the server directory, so that I have them available to the PY process when the server is deployed- as opposed to the PY process just using whatever is on my machine.​I've looked into implementing some sort of pyenv but I'm confused as to how I can execute PY processes from my server application from Node in such a way that they refer to packages inside the server for source code and external libraries.​TLDR: How can I use child_process in such that it's child process refers to something like node_modules for dependencies.​// how I call the child_process spawn functionlet py = spawn( 'python', ['path_to_py_file', arguments])// normal handling of input/output

Submitted June 29, 2019 at 11:58AM by big_guzi

New Vue Admin Dashboard Template integrated with Node.JS Backend

https://flatlogic.com/admin-dashboards/sing-app-vue-node-js

Submitted June 29, 2019 at 10:22AM by ZestycloseChocolate

global-agent: global HTTP/HTTPS proxy agent configurable using environment variables

https://github.com/gajus/global-agent

Submitted June 29, 2019 at 10:43AM by gajus0

Free Udemy Course - NestJS Zero to Hero (top Node.js course on Udemy)

Dislaimer: Free coupons to this course were already published here, and about 3000 free coupons were given. I was amazed by how people reacted and reviewed my course, and it's now a featured course on Udemy (as well as a 250 upvotes post on Udemy). That's why I chose to give some more free coupons. It really helps!​Why are you doing this every weekend?The reddit community is amazing, constructive and actually - some people bought the course. Those who didn't, contributed (somehow) to the Udemy algorithm which made my course become the #1 featured course in the Node.js category!), with a 4.7* rating and over 4K students. That's why I want to give out more free copies - you are awesome.​---​Finally! Finally I have released my "NestJS - Zero to Hero" course to Udemy.I spent over 100 hours on this course, in parallel to my full-time work as a Software Engineer at DAZN.The course (currently) consists of over 100 lectures and 6 hours of video. More is coming.​Throughout the course, the students build a real-world application (REST API) using the NestJS Framework - a framework used to develop modern back-end applications using TypeScript.The course covers the most important topics of back-end development - authorization, authentication, security, storing sensitive information, configuration management, performance and so much more.​Since you guys were so amazing with your feedback, I've added 800 more FREE coupons. The coupon code is REDDIT_GO_AGAIN​If you'd like to pay anyway, that's greatly appreciated. Here is a $9 coupon code: REDDIT_PROMO​Udemy: NestJS - Zero to Hero by Ariel Weinberger​P.S: If you know CS/Software Engineering/Bootcamp students who'd like to learn this technology, please tell them to send me a message and I'll give them a free copy (after this promo has expired).​Sharing is greatly appreciated! Enjoy my content! And please please, leave a genuine review.

Submitted June 29, 2019 at 10:35AM by WeinAriel

Friday 28 June 2019

Need help with async Firebase function! (See code and comments!)

Hey there! I want to go through each play games user ID, get the data associated with it, and store that data in a dictionary. So it's a dictionary of dictionaries. But I don't know how to wait for these to complete before I return the data from the function. Please help me out if you can! :)exports.getBirdieData = functions.https.onCall(async (data, context) => { let birdieData = {}; // For each play games user ID. data.forEach(function(playGamesUserId) { // Get the user reference associated with the play games user ID. let userRef = usersRef.orderByChild("play_games_user_id").equalTo(playGamesUserId); // Get that user's data. userRef.once("value", function(snapshot) { let userData = {}; userData["u"] = snapshot.child("username").val(); userData["c"] = snapshot.child("colour").val(); userData["h"] = snapshot.child("worn_hat_id").val(); userData["b"] = snapshot.child("worn_chest_id").val(); userData["a"] = snapshot.child("worn_accessory_id").val(); // Put the user's data in the dictionary, where their play games user ID is the key. birdieData[playGamesUserId] = userData; }); }); });

Submitted June 29, 2019 at 05:19AM by enexorb

is there a node api for finding coffee shops useing a postcode?

No text found

Submitted June 29, 2019 at 03:45AM by spotwich

URL friendly alternative to uuid

There's any url friendly alternatives to uuid?I've found nanoid, but I don't want to change my db primary key to nanoids...

Submitted June 29, 2019 at 12:23AM by sirluiss

Auth0 support

I'm working with API and login authorization for the first time and got some errors. One thing that called my attention was the lack of questions about auth0 on SO. Do people prefer other plataform?

Submitted June 28, 2019 at 10:52PM by L-ost

Callback Functions - How do they actually work?

I'm a little curious about something, being new to full-stack development. I've written a lot of MATLAB tools, FORTRAN processes, and C/C++ and assembly doing embedded system develoment, but this concept is very new to me.​When I use express and pass a callback function to a route like:appRouter.get("/", function (req,res){ doSomething(); } how are the parameters "req" and "res" actually passed to the callback? I'm declaring the callback function, and somehow also passing those objects through to that function's execution context?Also, when retrieving data from my controller/model, I have to pass a callback function to the asynchronous query method, which somehow has a response object already embedded in it?​How is all of this working, beneath the scenes? Is there an analogy or description that might help me understand how all this works?​Thanks in advance.

Submitted June 28, 2019 at 10:58PM by f6engineer

I'm new to sessions and I am very confused

I send this to my client side res.status(201).send("true") and the browser states unhandled promise rejection(ID:0) Syntax Error: unexpected identifier: "session"In the beginning of my app I added this, using express sessions.app.use(session({name: "gm",secret: "idk what this does lol",cookie: {maxAge: 1000 * 60 * 60 * 80,sameSite: true,secure: true,resave: false,saveUnitialized: false}}));How do I get rid of the unhandled promise rejection?

Submitted June 28, 2019 at 07:49PM by BensonandEdgar

Firebird high-level native client for Node.js / TypeScript updated to v1.0.0 beta 3

https://www.npmjs.com/package/node-firebird-driver-native/v/1.0.0-beta.3

Submitted June 28, 2019 at 01:38PM by mariuz

The economics of open source by C J Silverio | JSConf EU 2019

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

Submitted June 03, 2019 at 02:53PM by ecares

Dockerize a Node.js app with VS Code

https://medium.com/@vladguleaev/bd471710dc22

Submitted June 28, 2019 at 05:42PM by congolomera

DAO.Casino Blockchain Performance Benchmark is hot on the heels after the TestNet release!

https://dao.casino/blog/dao-casino-blockchain-performance-benchmark/

Submitted June 28, 2019 at 02:36PM by MutualBruce

Error handling with GraphQL

I am using the BuildSchema provided by GraphQL, however when something fails it just stops the execution, how could I get and handle the error? Is there a better option then BuildSchema?

Submitted June 28, 2019 at 02:38PM by ForeignEnginer

Question about synchronous functions and blocking behavior

Hi Everyone,I'm using express for a little web api and I was wondering how exactly a synchronous operation would block the node process.Let's take that simple code :const express = require('express') const app = express() app.get('/route1', function (req, res) { res.send('Hello route1!') }) app.get('/route2', function (req, res) { someHeavySyncFunction() //Let's imagine this function is synchronous and take 2 min to complete res.send('Hello route2!') }) app.listen(3000, function () { console.log('Example app listening on port 3000!') }) Would my route2 block the entire node process and therefore preventing people to access my route1 until the function ends ?Thank you

Submitted June 28, 2019 at 02:59PM by wbulot

Getting 403 Forbidden with Request

Hello guys,I'm building a bot where I need to do some HTTP calls to an API ( http://worldtimeapi.org/ ). I'm using the Request library. When I try to get the list of all timezones (http://worldtimeapi.org/api/timezone) it works well. However, when I build up the link to each location (with the base "http://worldtimeapi.org/api/timezone/" and appending the timezones, such us "http://worldtimeapi.org/api/timezone/Europe/Madrid"), I get a 200 on some request and 403 on some others. I'm getting the 200 statuscode on the first ones and then a list of 403 ones.​Here's is the code I'm talking about: https://pastebin.com/ZqQ6P6WF​Any help? May it be some sort of rate limit?Thank you all!

Submitted June 28, 2019 at 03:15PM by a7escalona

How to upload and display Images with KOA and Node Js (MongoDB)

Hi! Like the title says, I wanted to know if there is a way to upload and display images with KOA, Node Js and MongoDB? Like for example if I have a Database with products and I want to upload an image to my product and if I display all informations the image should also appear.Are there some simple examples or some tutorials on how to do it, i couldn't find something useful with KOA and NodeJs.Thanks in advance for your help

Submitted June 28, 2019 at 02:36PM by HQ189

Does a JS execution context persist in memory after it completes (if a reference to a lexical environment created in it remains)?

completes executing*Or is the execution context garbage collected, but lexical environments created within it persist if there's a reference to them?

Submitted June 28, 2019 at 12:20PM by waterloo304

The Future Of OpenJS Foundation With Nodejs and JS Foundation.

https://www.cmarix.com/the-future-of-openjs-foundation-with-nodejs-and-js-foundation/?utm_source=SB

Submitted June 28, 2019 at 10:52AM by Emilie_Tunc

The rise of the NRG stack: Node.js, React and GraphQL

https://medium.com/gitconnected/the-rise-of-the-nrg-stack-node-js-react-and-graphql-6dfba468ba8a?source=friends_link&sk=79dee14f44cb49991890ce4b2bf76d6d

Submitted June 28, 2019 at 09:29AM by treyhuffine

Framework Help!

Hello, I am very new to webdev and wanted to start by making a full stack project. I think I want to make something like a simple login and post for now. Because I feel like I know the basics of html/css/js, I wanted to learn how to use a framework. I was wondering if there are any recommendations for backend and frontend frameworks that are used a lot today. Thank You!

Submitted June 28, 2019 at 09:21AM by telllee

Webpack custom resolution

I have a package that installs corejs@3. I use that package in my application, when I compile my app, I want all the core-js resolution to happen wrt that package instead of node_modules. How can I achieve this?

Submitted June 28, 2019 at 08:46AM by mohsinulhaq001

Thursday 27 June 2019

Suggest me a Node.js tutorial

I'm looking for a good tutorial for my friend(who is based in another country.) He has some programming experience and wants to get started with Node. He has already learned the basics of Javascript. While Google turned up many tutorials, I'm not sure which ones are beginner friendly.I've been working with Node for quite some time now. So I'll be guiding him throughout his learning phase.

Submitted June 28, 2019 at 06:32AM by sbmthakur

Node js with express mongo dB and react-native

Does anyone know a setup that would allow for node js to be used real time with react native?

Submitted June 28, 2019 at 06:08AM by prinse4515

What's the best/correct way to download a video from a URL?

I've tried downloading a video using the request module, but it's not working correctly. Every time I open the downloaded video, it's corrupt. What can I do?var request = require('request'); var fs = require('fs');var videoOutput = fs.createWriteStream('video.mp4'); request({ url: VIDEO_URL_HERE }, (error, response, body) => { response.pipe(videoOutput); });Any help would be appreciated, thanks!

Submitted June 28, 2019 at 02:33AM by Ravenbtw

Authentication password reset

Hey guys,I was hoping to get a few suggestion on password reset flows for authentication. I have some things in mind but not sure if there would be any vulnerabilities or if they are best practice.Thanks!

Submitted June 28, 2019 at 01:01AM by col0rcutclarity

Design patterns in Node.js: a practical guide

https://blog.logrocket.com/design-patterns-in-node-js/

Submitted June 27, 2019 at 09:34PM by humansounding

Need to create a mock API service that sends and recieves dummy data for customer

We have an online vape shop, and our age verification service sucks while developing with it. What would be the best way to start with a custom API service(and bypasses the age verification) that stores a session/cookie in the developers/testers browser and he/she will be age verified, I also need to load in customer information that is associated with the customer name / ID. Is there anything already built that is an open source out there like this? Perhaps on github?​Thank you in advance.

Submitted June 27, 2019 at 05:51PM by bjornforkbeard

Help nodejs

Is there a way to restream live video from one website to mine with node js and angular?

Submitted June 27, 2019 at 05:27PM by Yazumato

Building reusable components using React

https://buttercms.com/blog/building-reusable-components-using-react

Submitted June 27, 2019 at 05:30PM by Modiculous

Async Functions in JavaScript

http://thecodebarbarian.com/async-functions-in-javascript.html

Submitted June 27, 2019 at 05:38PM by code_barbarian

Node v12.5.0 (Current)

https://nodejs.org/en/blog/release/v12.5.0/

Submitted June 27, 2019 at 04:01PM by dwaxe

What is the N+1 Problem in GraphQL?

https://medium.com/p/dd4921cb3c1a?source=friends_link&sk=7fbde894695d4a1810c85fcdd36a9cca

Submitted June 27, 2019 at 03:18PM by jsloverr

Why and How to Use AWS Managed Services

https://thenewstack.io/why-and-how-to-use-aws-managed-services/

Submitted June 27, 2019 at 03:21PM by nshapira

301 Redirects from GoDaddy to AWS

Moving a site from Godaddy namespaces to AWS and I am going to use a devops as a service. Has anyone used the company Opsourced? If you have any experience in this matter, any comments or advice is greatly appreciated. Thank you.

Submitted June 27, 2019 at 01:35PM by zdravococksucker

New React Admin Dashboard Template with NodeJS Backend

https://www.producthunt.com/posts/light-blue-react-node-js

Submitted June 27, 2019 at 12:20PM by ZestycloseChocolate

Examples of Well Structured NodeJS Websites

I’ve been learning NodeJS (and web dev in general) recently and I noticed my structure of my website is okay but could use a ton of improvement.Being a self taught programmer, I’ve never really been around experienced devs to learn from them so most of my toolset comes from YouTube and Stackoverflow. However, I’ve recently noticed by code feels like it’s kind of all over but I don’t know the best way to fix it.I know the usual separation of controllers, views, etc. but I’m having trouble applying OOP to JS specifically.Does anyone have any example repos of well executed oop using Node that I can review to try and learn from?

Submitted June 27, 2019 at 12:40PM by JeffLeafFan

Need Feedback / Suggestions to improve my blog

Hey everyone!I need feedback / suggestions to improve one of my article published on Medium. Here's the link: https://medium.com/@akshaygulhane/next-level-security-for-rest-apis-aa1f19b597c3Thanks in advance!

Submitted June 27, 2019 at 10:56AM by boilerweb

Wednesday 26 June 2019

What does it mean to build an API?

I see in many job offers, that they require developers to have experience building RESTFUL APIs. What does it truly mean to build an API? Is it building APIs for other people to use, like Google maps etc, is it the same as routes we see in express? Some elaboration would be deeply appreciated!

Submitted June 27, 2019 at 07:15AM by Possible_Hawk

Hey, I created this app using the MERN stack.

It is supposed to be a platform to share secrets. You can be able to differentiate between sexes in the secrets by the color/icon.https://fast-fortress-55508.herokuapp.com/Any feedback will NOT be ignored.

Submitted June 27, 2019 at 05:00AM by kirasiris

How to execute a process with node and immediately get the right pid of the process

Hello everyone! I am trying to execute a webpack dev server. I need the pid of the server after I launch it. This is what I have, but the pid I get back does not correspond to the pid of the webpack dev server.const child_process = require("child_process"); x = child_process.exec("npm run webpack-dev-server"); console.log(x.pid);

Submitted June 26, 2019 at 11:37PM by goslingducks

Help a N00B build an E-Wallet App

I am creating a project with User database and identification (email)/(password) log in and sign upWhen the user Signs up for the first time, he creates inside his account a Wallet, the wallet automatically assigns a Random Identification Number just for the wallet itself. Inside the wallet "credits" are stored. The start up value of the credits will be 0 for some users and for lets say premium users will be 20 credits.Then I need those wallets to communicate, lets say User 1 has Wallet A and Wallet B, User 2 has wallet C and wallet DUser 1 can send "credits" from his wallet A to his wallet B and viceversa, also User 1 can send credits from his wallet A to wallet C or D from User 2.BUTUser 1 cannot send "credits from wallet B to wallet C nor D from user 2User 2 cannot send "credits" from wallet D to wallet A nor B.the "credits" being transferred as a encrypted "message" for speed and each transaction stored in an encrypted database.At the end I would need integrate the project into swift so it can run as an iOS App, and then later to Java for Android OS, also need it to run on a website.Thank you for any assistance and help in advance.

Submitted June 27, 2019 at 12:27AM by jpgaviria

Migrating Existing REST APIs to GraphQL

https://blog.bitsrc.io/migrating-existing-rest-apis-to-graphql-2c5de3db647d

Submitted June 26, 2019 at 06:18PM by JSislife

Loggin'JS v1.1.0 ads Plugin support!!!!

Loggin'JS now allows you to create custom plugins, and make it even more expandable!!! I will be expanding the plugin support as its required, for now it should do the job!​You can check some plugins i've made already here:https://github.com/nombrekeff/loggin-js#Oficial-plugins​And check the plugins dos out at:https://github.com/nombrekeff/loggin-js/wiki/Plugins

Submitted June 26, 2019 at 06:31PM by nombrekeff

Can't connect to mongodb cluster from website, but can connect to it locally...

🕵️ Check whether the Do not track (DNT) policy is enabled in user's browser or not

https://github.com/xxczaki/is-dnt

Submitted June 26, 2019 at 04:50PM by xxczaki

Is there a node setup service similar to laravel forge?

I have used laravel and forge in the past, and I absolutely love the simplicity of maintaining my clients sites. I can manage SSL, domains, ssh keys, and way more. I am now currently getting into node development, and I was curious if there was an alternative for node. I want to develop and I'm not very interested in the ngninx setup, firewall, ect. Just curious if it was out there and I haven't found it!

Submitted June 26, 2019 at 03:49PM by gbland777

We released v0.9 of Admin Bro - an automated admin interface for Node.js apps. Check it out!

https://softwarebrothers.co/blog/adminbro-v0-9-released/

Submitted June 26, 2019 at 01:48PM by lysywojtek

Postman now supports GraphQL

https://blog.graphqleditor.com/graphql-postman/

Submitted June 26, 2019 at 02:35PM by oczekkk

Learning Go as a Node developer

Hello guys,​Not sure if it fits here, but after writing and teaching a lot about Node and hearing Ryan Dahl's thoughts about Go I dived deeply into it and I think it is worth the time for us Node developers to broaden our view and learn it too.​https://blog.risingstack.com/golang-tutorial-for-nodejs-developers-getting-started/​In this post I tried to cover my experiences as thoroughly as possible about the basics of setting up a Go development environment and writing a simple "Hello World!" server with net/http, encoding/json, kelseyhightower/envconfig and about Go's dependency management.​What do you guys think? Is it helpful at all, should I continue with the series? Also if you've already started writing Go code, what are your experiences? For me, I like it so far, only when I wrote some low-level programs for hardware management on Linux, testing was way too cumbersome.

Submitted June 26, 2019 at 02:16PM by shadowbeetle

Question about multiple Parameters in Swagger. Link to the Question

https://stackoverflow.com/questions/56769016/how-to-pass-multiple-query-parameters-in-swagger-ui-with-koa-and-nodejs

Submitted June 26, 2019 at 10:04AM by HQ189

The cost of JavaScript in 2019

https://v8.dev/blog/cost-of-javascript-2019

Submitted June 26, 2019 at 08:41AM by ecares

Introducing Build on Standard Library: Zapier-Style Automation for Developers, all backed by Node.js

https://stdlib.com/blog/introducing-build-on-standard-library/

Submitted June 26, 2019 at 08:21AM by keithwhor

Jquery append is not showing the current output with multidimensional array.

I am trying to show some data on the front end comming form the database like this.$.each(data, function (index, item) { step6_counter1 += 1; $('#check_list_items').append(`
${item.main_point}
${item.sub_points}
`); }) the array form the database looks like this.[{"main_point_id": "1","main_point": "Engagement ","sub_points": {"sub_point_id": "1","main_point_id": "1","sub_point": "engagement sub point 1"}}.{"main_point_id": "1","main_point": "Engagement ","sub_points": {"sub_point_id": "1","main_point_id": "1","sub_point": "engagement sub point 1"}}]​wrong output​the output should look like this

Submitted June 26, 2019 at 07:55AM by binoysarker

Tuesday 25 June 2019

How to import from project root (instead of package root)

I'm creating an npm package and I want the user to be able to set configuration files in the root of their project. An example structure might be:- UserProject/ - index.js - config.js - package.json - node_modules/ - package/ - index.js - package.json Inside UserProject/node_modules/package/index.js, I want to be able to import the file UserProject/config.js.I know I could use import config from "../../config.js" but that doesn't seem like a good way to do it.I know many other npm packages are able to do this so I'm wondering how they achieve it. A few examples that do this:Next.js is able to read ./pages/ and ./next.config.js from the project rootJest is able to read ./jest.config.js from the project rootESLint is able to read ./.eslintrc.js from the project rootPrettier is able to read ./.prettierrc.js from the project rootTypescript is able to read ./tsconfig.json from the project rootBabel is able to read ./.babelrc from the project rootI've tried creating a StackOverflow post but got no replies, I've tried googling for it but all I get are results on how to do basic es6 imports, and I've tried looking at the source codes for the above examples but I can't locate the sections on how they do it.Any tips?

Submitted June 26, 2019 at 06:38AM by stupid-sexy-jake

[REQUEST] Real world Node application example with functional programming

Hi everyone! As the title says, I'm looking for a real world project that uses FP. I've been reading and learning a lot about FP in the last months, and putting into practice many of its core concepts with small and isolated exercises, but I need to see them in a real project to have a greater comprehension of how to they are used to solve real world problems, and how they are architetured in a medium to large application. What I have in my mind is a lot of independents concepts and techniques, but I'm missing the big picture. Any suggestion is really appreciated. Thanks!

Submitted June 26, 2019 at 06:07AM by dreaminblack

How to do I know the correct URL to like/unlike a comment in MERN?

First of all, I'm sorry if this is not the place to ask. I will delete the post if requested.Let's say I have the following URL:http://localhost:3000/demo/_idInside that URL I have the entry for said _id and some comments which can receive likes by the user. How can I know what's the current URL to like the comments? Assuming I can already like the parent _id(the entry). Here it is an image of my MongoDB database:​MongoDB Test DatabaseAs you can see in the image above there's a field called likes in the comment. My question is how would I go to make it like-able?.This is what I have in my actions file for liking the entry. Can somebody guide me and tell me how to edit it to like X comment found in the entry?:​https://i.redd.it/r7yno0wrnm631.jpgAnd this is what I have in my API route(again this is for X entry; how can I edit to like a comment):​https://i.redd.it/75h6l7vsnm631.jpgHopefully I could explain myself well enough and thanks for bothering!.

Submitted June 26, 2019 at 05:19AM by kirasiris

In Sinon, what do resolves and rejects mean? What is stubbing in its simplest term?

I’ve read articles on stubbing and mocking but I’m still unsure of what they are. If I’m stubbing a method called sendName and sendName.rejects({}) or sendName.resolves({}), what do they mean? Thanks in advance!

Submitted June 26, 2019 at 03:33AM by reddit_9810

What's the alternative to SOAP?

I am trying to work with TextBroker's API and it's in SOAP.At the bottom of page 13 in the docs they are referencing passing in an array to the client which soap.createClient doesn't support. I can access the SOAP WSDLs on some and .describe() properly, but all requests come back as not logged in even though I send the proper arguments in the request.It looks like it's wanting me to do the doLogin client (wrapper) and then inside do another client for the individual SOAP clients I need.Sorry if I am explaining this poorly, but I am so used to just talking within a REST environment.

Submitted June 26, 2019 at 03:53AM by dadsquatch

Node performance questions

Hi all,Intermediate node dev here, have a few questions about debugging/measuring performance of nodejs apps.Some general questions:Is there an option or flag I to see what the garbage collector is doing or where/when memory allocation is happening, gc pauses etc.Is there a way for me to print out the assembly the v8 compiler generates?To time the code I can just use a timer and run my function or app in the timer 10k times or something, I guess, is there a better way to do this?More specific ones:​(Hypothetical question) Say I have a .csv file with 100k lines. I parse each line in a loop and create an object with a key for each column in the .csv and a value for each row entry in that column.Now i am making 100k objects in a short amount of time.Say my csv header looks likeid, name, location, email, address, phone, number, tags My 100k objects would look something like{ id: UUID name: "Frank N. Stein", location: {lat: 3, long: 1415}, email: "whatmeworry@gmail.com", address: "123 Elm St.", phone: "123 123 1234", number: 1, tags: ["blah", "other tag", "another tag"]} ​They keys would all be the same but the values are different for all the 100k rowsIf I create a new object for every row, I would be creating 100k objects, what happens if I use an object template like:{ id: UUID name: "Frank N. Stein", location: {lat: 3, long: 1415}, email: "whatmeworry@gmail.com", address: "123 Elm St.", phone: "123 123 1234", number: 1, tags: ["blah", "other tag", "another tag"] } and for each row modify the values liketemplate.id = "fdfdf" template.name = "ur mom" then write the template to a file before processing the next row.​Will v8 allocate one object and change the pointers for the new values or will it copy the original? And how can I learn about how this works and see it in action ?​I am streaming a file larger than the available memory on my machine :For each chunk of data that I stream I make an api call and add it to a promises array.I set a batch size of a 100 for the promise array and once I get to a 100 I await all the api calls.(I don't know how many open sockets I have on the open pool so I don't know how many requests are in flight at the same time and how many are queued. Is there a way to check this? I just chose 100 as a nice round number for this example.)Now my code will pause during 2 cases:When I am awaiting for the resolution of all the promises ( I don't know if the stream keeps reading during this time, I don't think so because my await Promise.all() is inside my stream's on.data event handler.When the stream pauses to let the consumer consume more data on the stream because of backpressure.​My whole stream is wrapped in a new Promise() which resolves when the stream.end's or rejects if the stream.errors.Say I want to process 100 such stream in parallel? And i just do something lilke(async () => { const promises = {} files.forEach(file => { promises.push(streamFile(file)) } await Proimse.all(promises) } )() ​What's happening? Is node processing each stream in sequence, is is processing multiple streams at the same time (some chunks from stream 1, some chunks from stream 2? ) How does this work?​Am I thinking about this stuff correctly? How do I see whats going on "under the hood"?​Any resources that have any of this info would help me a lot I just couldn't find anything.​Sorry for the long ass question, thanks!

Submitted June 26, 2019 at 02:57AM by whileAlive_doStuff

Most efficient way to download array of remote file URLs?

I'm working on a Node project where I have an array of files such asvar urls = ["http://web.site/file1.iso", "https://web.site/file2.pdf", "https://web.site/file3.docx", ...];I'm looking to download those files locally in the most efficient way possible. There could be as many as several dozen URLs in this array... Is there a good library that would help me abstract this out? I need something that I can call with the array and the local directory to that will follow redirects, work with http & https, intelligently limit simultaneous downloads, etc.

Submitted June 26, 2019 at 03:13AM by xd1936

I'm trying to install npx for react.

Node -v = 12.4.0Npm -v = 6.9.0Npx -v = command not found.What gives, npx should be automatically included with any npm above 5.2.0I've runsudo npm install -g npx. It says the package is updated, but I cannot use commands.Any help would be appreciated.

Submitted June 25, 2019 at 11:08PM by baris_sonnenfeld

DO guide

I'm really new at this, and I'm adult learner who is learning from tutorials, so I don't have a classroom to fall back on. I'm hoping someone will help me get past this.​So here is my problem: I'm stuck with a 501 error when I tried to deploy my project to a cloud server on DigitalOcean (DO). I followed this DO Guide, and I built a functioning website based off of this tutsplus guide. I got past the CORS blocker that I encountered but now that I have deployed it to DO, I get the 501 and nothing else to go on. I also loosely followed Juriy Bura's Deploying Node tutorials on youtube, but he's using Cent and I'm on Ubuntu.​Do I need to have my js running in something like PM2? Why?If not, why did it serve up pages on localhost in my home machine (virtualbox).? I just used live-server in atom, and the pages loaded fine without PM2 running.

Submitted June 25, 2019 at 11:17PM by virg74

Empty response from mysql query - async callback question

I am writing a small app and trying to query all the users from my mysql database. I'm new to nodejs, express and mysql. I'm able to execute queries, but I am having trouble returning the value of the query to the browser as a json object, using postman.​Here is the code for my userRouter.js file:const usersRouter = require('express').Router(); const userController = require('./usersController');usersRouter.get('/', function(req, res, next) {var testObject = userController.getUsers();res.json(testObject);});module.exports = usersRouter;​And here is from the userController.js file:const db = require('../database/db'); exports.getUsers = function(callback){var allUsers = db.query('SELECT * FROM users', function (err, rows, fields) { if (!err) { if (rows) { callback(null, rows); console.log("userController.getAllUsers - completed query") } else { callback(err, null); console.logo("userController.getAllUsers - error performing query.") } }}) }I obviously get an error that says "callback is not a function"...The reason I have ... function(callback){ .... written like that is because that's what I"ve seen online in forums and answered questions. It doesn't make sense to me to just have "callback" defined as a function parameter, then called later in the function body because the function isn't defined, but nearly every example I see online on how to solve this problem writes the solution in this manner.​What is the smart way to return the response from the query? I know I need to "use a callback" function to do it, I just am not quite sure how.

Submitted June 26, 2019 at 12:25AM by f6engineer

Techstack Backend/Hosting/Database suggestion

Hello Node experts.I have an upcoming big project and need some back-end/host suggestion for an Inventory Management System with user login and user access, barcodes, database management with search, filter, sort, inventory, in-out history, and report generation.Data is hosted in the Cloud, since a mobile app interface with the system and will be used to scan barcodes.No overlapping of data when 2 clients updated the database at the very same time.Complex queries to search, filter, and sort database.In the past I just used Firebase with React and Angular but I don't know how good it is in terms of pricing and how "good" it is for production. I like how the data is always kept in sync with Firebase functions.Front-end will definitely use React. Thank you very much.

Submitted June 26, 2019 at 01:35AM by divinecake

Please Help Me Get Better At Jest (Especially Mocks)

I'm new to Node, and am working on a hobby project that will monitor a site's downtime. In my quest to become a better developer, I am committed to writing tests. However, I am new to Javascript testing, and am having a difficult time with mocks and testing asynchronous code.QuestionHow do I write a test for getResponse() on my Response class. Specifically, I want to ensure the following:getResponse will return a status code if the Response class is provided a urlgetResponse will console log a message if there's an errorCodebaseRepoTestsMockCode``` const rp = require("request-promise");class Response { constructor(url, emails) { this._url = url; this.emails = emails; this._statusCode = null; this._status = null; this._lastChecked; this.screenshot = this._url ? new Screenshot(this._url) : null; }getResponse() { if (!this._url) { throw new Error(You need to pass Response() a URL); } return rp({ uri: this._url, resolveWithFullResponse: true }) .then(response => { return response.statusCode; }) .catch(error => { console.log(There was an error getting data for ${this._url}); }); } ... } ```

Submitted June 25, 2019 at 10:39PM by P013370

I’m doing my first real app with Node. I have years of experience in Cloud Architecture with Python and before that tons of experience in .NET (🤮) My entire career I have been involved in web-centric apps. I’m finding node a bit Janky.

No text found

Submitted June 25, 2019 at 10:49PM by chuxailer

Process communication: event listeners vs http requests

I'm using PM2 to scale up my app and I've added some code to handle communication between the processes.I'm using a lot of `process.on` and other event emitter driven actions, but since I need req/res like flow, the code is starting to feel like spaghetti.If I need to share data from one process to another, is there a big reason to go with process communication rather than just exposing http endpoints?I feel like my code would be much more straight forward to have some express routes, and then make req to localhost than to have all these event handlers everywhere. Also seems easier to test...Thanks in advance for any help!

Submitted June 25, 2019 at 09:46PM by urbanNinjuh

Building a node app that's hidden in tray? Suggestions on how to approach this.

I have an app that runs a node server, and want to hide the app in the system tray when built so user can exit the app from there. I've been searching for a few days and still can't find a decent solution. Do I have to learn a different language to make this possible? The systray node libraries I find are old and bugged so not sure how else to proceed.

Submitted June 25, 2019 at 08:39PM by I_know_HTML

by-node-env: A library to run package.json scripts by NODE_ENV

https://github.com/shian15810/by-node-env

Submitted June 25, 2019 at 08:52PM by shian15810

Open Source Summer Project Sponsorship

I am running a small sponsorship for an open source project this summer. I am hoping to get a few more submissions before the end of the week and thought this may be of interest to the node community!https://www.reddit.com/r/javascript/comments/c3f0ou/javascript_open_source_summer_project/

Submitted June 25, 2019 at 05:58PM by minuit1984

Is it possible to make requests using an existing session?

Let's say I open up Chrome and browse around a website / sign in / whatever.​Let's say I then want to scrape some content that is on pages that require certain cookies / your login.​Is it possible to "hijack" the chrome session and make requests from there (using the request module's jar functionality for instance)?​I usually do this with Puppeteer or by trying to replicate a weird request chain as observed in Google DevTool's Network tab.

Submitted June 25, 2019 at 05:03PM by BobbyBucketsBarks

Deploy a Node.js Application to DigitalOcean with HTTPS

https://coderrocketfuel.com/article/deploy-a-nodejs-application-to-digital-ocean-with-https

Submitted June 25, 2019 at 05:24PM by pmz

Execa 2 release — process execution for humans

https://medium.com/@ehmicky/execa-v2-20ffafeedfdf

Submitted June 25, 2019 at 04:29PM by ehmicky

This is what I have understand about single-thread and synchronous. Do i'm right?

JavaScript is Single Threaded and has Synchronous execution model. Single thread means execution commands run on a single thread and executes one at a time, I imagine as ants marching. i.econsole.log('print1'); console.log('print2'); console.log('print3'); // Output print1 - runs first print2 - runs second and so on. Synchronous means execution command executes (runs) and wait until execution finishes/returns and move to next command. i.efetchUser(); fetchPosts(); // fetchUser() executes and waits until user list return and moves to fetchPosts(); If I have understand it wrong, please comment below

Submitted June 25, 2019 at 03:13PM by Chawki_

have node installed on mac, but not npm, suggestions? is there a way to install npm separately?

Creating your first Node.js REST API with Nest and Typescript

https://medium.com/p/84863db9da13

Submitted June 25, 2019 at 03:08PM by Fewthp

Impementing Audio chat with rooms

I want to integrate an audio chat with rooms in my app.I create a room. Everybody can connect by room id.My app should know online, how many people are in a room and who.In the case of the third API, is it possible to implement it without external auth?​I could not find the right solution in my case.I know, I should use WebRTC, but it seems complicated and overwork for my project to do it from the beginning.I saw a lot of external solution, but I must pay for their service.I think I can build my solution or use appropriate free APIs.​Could anyone help me with advice which solution will be the best?​I'm a little bit new with web/nodeJS and come here from mobile dev.​Thanks in advance.

Submitted June 25, 2019 at 03:04PM by dmelechow

connect-flash help :(

I been trying to get connect-flash to work together with express-validator but for some weird reason it works 10% of the time (Validation message is displayed as html) , the other 90%, HBS isn't displaying anything to me.I read somewhere this has to do with sessions could kindly use some advice. Also, I m really new to node so if my convention is weird or funny, do let me know!​Index​app.use(cookieParser(keys.cookieSecret)) //express session middleware app.use(session({ cookie : { maxAge : 1000 * 60 * 60 * 2, //2 hour session sameSite : true }, name : keys.SESS_NAME, resave : false, saveUninitialized : false, secret : keys.SESS_SECRET })) app.use(flash()); ​​Routerouter.post("/create", authAdmin, announcementValidation, async(req,res) => { if (req.errors.length != 0 ) { req.flash('announcementFail', req.errors); res.redirect("/dashboard") } else { req.flash('announcementSucceed', "Announcement Created") req.session.title = req.body.title; console.log("No errors present") const annoucement = new Announcement(req.body) annoucement.save().then(ann => { req.session.announcement = true; res.redirect("/dashboard") }) } }) announcementValidation.js​const {check, validationResult} = require('express-validator') announcementValidation = [ check('title').not().isEmpty().withMessage('title cannot be empty').trim().isLength({min : 5}).withMessage("title should at least be 5 characters long"), check('body').not().isEmpty().withMessage('body cannot be empty').trim(), (req,res,next) => { req.errors = validationResult(req).errors; next(); } ]; module.exports = announcementValidation Redirects to/dashboard//Display Dashboard Page router.get("/dashboard", authAdmin, async(req,res) => { //code not shown for brevity //just getting data for announcements and categories res.render('admin/dashboard', {announcementSucceed : req.flash('announcementSucceed'), announcementFail : req.flash('announcementFail'), announcements : announcementMap, categories : categories }); }) }) (is this bad convention? to display so many things with render)​dashboard.hbs
This is text ​​Any help would be much appreciated

Submitted June 25, 2019 at 11:02AM by Possible_Hawk

Never knew importance of String.normalize function. Where should I be using it?

I'm surprised I never knew the importance of String.normalize function or even heard of it. I'm trying to figure out where it goes in the application and it looks like it should be used everywhere I accept user input?How are you using String.normalize throughout your apps? Seems like it would be easy to forget to use it somewhere I need it because of all the places it needs to be.Which of the 4 normalization options do you choose and why: NFC, NFD, NFKC, NFKD? https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize#Parameters

Submitted June 25, 2019 at 11:12AM by nowboarding

What Projects/System should i develop to have a higher employment rate?

So lately i have been playing around with Node.js (M.E.R.N Stack) and i like the idea of able to develop a system, from both front-end and back-end with one PL.I really like creating system while learning because i get the flow and how each components works more clearer .​So my question is what kind of system should i develop that literally Node.js is the right tool for it. And after that where to next?I'm still a student and a newbie with Node.js so, sorry if someone got offended with my question. :)

Submitted June 25, 2019 at 09:16AM by Magic-Sarap

Monday 24 June 2019

How to get local variables to be recognized by express-handlebars?

Forgive me I don't really know if I'm asking the question the right way.​I'm using express-handlebars. I have some views that have forms. On those forms I would like to conditionally add extra text columns if certain form options are selected. I understand that I can pass an object in my res.render() function.ie.router.get('/admin/add-race', (req, res, next) => {res.render('admin/add-race', {layout: 'admin',path: '/admin/add-race',pageTitle: 'Add Race Info'});};I could pass in something like isCertainFormOption: false how would I change that to true in the view itself if a form option is selected?

Submitted June 25, 2019 at 06:40AM by BlastHole

Learn Strapi (node headless CMS) in 12 mins

https://youtu.be/hisau__LM-o

Submitted June 25, 2019 at 05:47AM by majesticamera

Difference bw/ Front end framework and Node view engine?

Hi all, I’ve just started learning real web development and am learning about Node and React, Vue, etc. So generally speaking React and Vue are used to display client-side markup while Node is used for backend services and making database queries. So upon watching videos on YT, a node tutorial was describing setting up a view with EJS and that includes an HTML template as well as Routing for different pages in the application. I was confused by this because I would expect this to be reserved for front end frameworks like React. So the tutorial finished creating an app with pure Nodejs (mind you it was a simple application), but that made me question what the point is in using Node vs React to create the client side view. What is the difference? Is it the same thing, only that it’s best practice to separate the back-end with the front-end by using different frameworks? Thank you! Apologies if this is a simple question, I am only beginning my learning.

Submitted June 25, 2019 at 04:15AM by world_wolf

Issue trying to test a http request in a setInterval

Hello, I use Typescript and a class to manage a feature that I'd like to test. This is my simplified code:class Feature { private _names: string[] = []; constructor() { this.fetchNames(); } private fetchNames() { setInterval(() => { MyAPI.getNames() .then(names => this._names = names) .catch(err => console.log(err)); }, 1000) } get names(): string[] { return this._names; } } I use a class to manage my feature but I guess I would have the same problem using a module and functions, because only the names() function would be exported, fetchNames() and _names would be private.​I'd like to test after the first request the names() method returns the correct names. What I tried:describe(`Feature`, () => { let clock: sinon.SinonFakeTimers; beforeEach(() => { clock = sinon.useFakeTimers(); }) afterEach(() => { clock.restore(); }) it(`Should update the names`, async () => { sinon.stub(MyApi, 'getNames').resolves(['Alfred', 'Eve']); const feature = new Feature(); clock.tick(1500); expect(feature.names[0]).equal('Alfred'); }) }) The request is called once and returns the correct names, but I got this error: "AssertionError: expected undefined to equal 'Alfred'".​It'd like to let the _names property and fetchNames() method in private. Thanks for reading, any help appreciated.

Submitted June 25, 2019 at 01:31AM by GreenMonkeyBoy

password-leak: a library (and cli) to check passwords against the HaveIBeenPwned API

https://github.com/mathiscode/password-leak

Submitted June 25, 2019 at 03:57AM by FatherCarbon

10 Things I Regret About Node.js - Ryan Dahl - JSConf EU 2018

https://www.youtube.com/attribution_link?a=2qU461PptI8&u=%2Fwatch%3Fv%3DM3BM9TB-8yA%26feature%3Dshare

Submitted June 24, 2019 at 09:10PM by TheUniqueRelease

Uploading and Downloading Files: Streaming in Node.js

https://jsao.io/2019/06/uploading-and-downloading-files-streaming-in-node-js/

Submitted June 24, 2019 at 08:04PM by dmcghan

NestJS Intercept Outgoing Request and Modify Header

I am using NestJS (v5) for a micro service and I for the life of me cannot figure out how to add a header to all outgoing requests (I can easily get the response headers modified).I created an interceptor that is intercepting all outgoing requests, but even setting the request header, it is not actually getting added on the request. Can anyone help with this?

Submitted June 24, 2019 at 08:27PM by noahmateen

Express Snoowrap Reddit API Starter Project

Hey, everyone! I published some work I've been doing in Node.js with the Snoowrap Reddit API package. My goal with this was to teach myself something new as well as publish a starter project that anyone can learn and build from. This is also my first time putting a GitHub project out to the public so, please let me know if you see anything I'm doing incorrectly. The project only contains a few basic API calls so far but, I plan to continually develop it until all possible API calls and methods are incorporated.My GitHub: https://github.com/extrasyrup/snoowrap-node-express-demoMy Project's YT: https://www.youtube.com/channel/UC2ErUw_bFu4_vghe7cdgMHgSnoowrap GitHub: https://github.com/not-an-aardvark/snoowrapThanks!

Submitted June 24, 2019 at 06:59PM by i_am_extra_syrup

Whats the difference between single threaded and synchronous in javascript?

No text found

Submitted June 24, 2019 at 07:24PM by Chawki_

Windows Electron app always connects to port 2048, need to find where to change the setting.

What are the techonlogies should I learn to become a Nodejs back-end Developer?

What are the skill sets and technologies I should master to apply for a job as a Node.js back-end developer?​Thank you!

Submitted June 24, 2019 at 05:40PM by Chawki_

Nest.JS / TypeORM - Spread operator vs create()

Taking advantage of multithreaded I/O to do fast dead link checking

https://javascriptwebscrapingguy.com/jordan-takes-advantage-of-multithreaded-i-o-in-nodejs/

Submitted June 24, 2019 at 05:04PM by Aarmora

process.exit() noobi question

Hi,​I want to push some data in a mongoDB collection with a simple node script. I'm working with await and async statements.This code work so far. What bothers me is the process.exit().If I remove the exit-statement the script never ends. Is this normal?Do I really need the statement to get my shell back?const mongoose = require('mongoose');const Device = require('./models/device');mongoose.connect('mongodb://mongo/test',{useNewUrlParser: true}).then(async () => {const device = await Device.create({"id": "fba1e835-5b14-4940-b56d-cbfsdbe3","serial": "unknown",});console.log(\Device created`);`process.exit();}).catch(err => {console.error('Could not connect to MongoDB...', err);});

Submitted June 24, 2019 at 03:48PM by 23hurra

Download Manager using Node.js

How can I make a download manager in node.js with abilities of pause and resume downloads?

Submitted June 24, 2019 at 03:58PM by satnam_sandhu

Revddit.com is removeddit for user pages. I could use your help building it!

https://www.reddit.com/r/javascript/comments/c4om5q/i_upgraded_removeddit_to_show_removed_content_by/

Submitted June 24, 2019 at 04:10PM by rhaksw

How to communicate with a C-written subprocess ?

I hope it's ok to post questions like this here.In NodeJS (using Electron, so console.log goes on the window console), I want to spawn a child process that's a C program, and read/write into its stdio to communicate.This is the Javascript :const { spawn } = require('child_process'); var utfEncoder=new TextEncoder("utf-8"); var utfDecoder=new TextDecoder("utf-8"); var process = spawn("./src/test-c"); process.stdout.on('data', (data) => { console.log(utfDecoder.decode(data)); }); model.send = function(s) { model.process.stdin.write(utfEncoder.encode(s)); } And the C :int main() { char buffer[100]; printf("ready !"); fflush(stdout); for (int a = 0; a < 100; ++a) { scanf("%s", buffer); printf("I read: %s", buffer); fflush(stdout); } return 0; } And the "ready !" never appears anywhere. But it works when the program only prints a message every second :int main() { for (int a = 0; a < 10; ++a) { printf("ready !"); fflush(stdout); sleep(1); } return 0; } With this program the message "ready !" appears every second on the window console, but with the first one nothing happens (not even the first message before scanf).What am I doing wrong here ?

Submitted June 24, 2019 at 02:10PM by Amaury__

A JS conference with *only* testing-related talks

https://www.assertjs.com/

Submitted June 24, 2019 at 01:32PM by pauldowman

Why is my CSS and JS file not being read by my server?

The files are in a folder called “public” within the views folder?

Submitted June 24, 2019 at 11:57AM by SimulationV2018

NodeJs vs Java: Multithreading

How is Node different from Java in multithreading context? How is multithreading implemented in Java and in Node? Can we say that Node supports classic multithreading?Edit: I don't want to accomplish anything. I just want to understand how it works under the hood.

Submitted June 24, 2019 at 12:51PM by haykerman

nodejs.org down?

Can't seem to get to the nodejs.org website for the last hour, anyone else seeing this?Don't think it's just me as my azure build's are failing due to a timeout downloading node.Edit: nm seems to be operational again.

Submitted June 24, 2019 at 12:02PM by Dastari

Issue with Horspool algorithm request parser

I've been working on a rebuild of my API generator; Multicolour, and I've tried a few modules that do request parsing using fast string searching algorithms but they either don't test very well or don't search the entire text for all the occurrences of the pattern.So I built my own which works for just about every payload I throw at it (both static and randomly generated data) but every now and again there comes a payload (which I then add to the static list to test) which trips it up.I'm now complete stuck on the latest trouble payload and I think there's a small detail I'm missing in my algorithm. I've read all kinds of papers on it, other libraries that do the same thing but I'm totally stumped. I've asked this question on Stack Overflow but it didn't seem to hit the audience. I'm happy to offer a bounty over there for it. I've actually fixed it for the payload in the question but there is a new payload causing issues.Stack Overflow questionSource codeTest Source code with payloads

Submitted June 24, 2019 at 10:36AM by davemackintosh

Observability Takes Too Much Developer Time, So Automate It

https://epsagon.com/blog/observability-takes-too-much-developer-time-so-automate-it/

Submitted June 24, 2019 at 11:19AM by nshapira

Is it safe to directly use UUID as data transfering identity between players?

It is a little game project.

Submitted June 24, 2019 at 09:54AM by hanley_chen

Is Node.js the right tool?

I'll get right to the point.​I'm an intern with this company and they ask me to build an intranet for them. It's a system comprise of sub-system example are File Management, Form Automation, MeetUp Integration and some internal system integration too. So they want me to use WordPress to build it coz they didn't want to start from scratch which i highly disapproved. For the past week im learning M.E.R.N stack and i was able to get a grasp of the flow.I've been developing web app for 2 years now and have a firm experience in PHP and Python with backend. So my question is Node.js the right tool to use with this project because i really do like to learn more about it since it's quite in demand when searching for jobs.And also i have no one to ask that's why am here. I'm a Web Developer intern inside a Marketing Department and IT/Solution Dept. is no good coz they just ignore me because they a office politics here.

Submitted June 24, 2019 at 06:39AM by Magic-Sarap

Sunday 23 June 2019

Made a random value generation module using Crypto

Hi there, been lurking for a while now and wanted to share one of my projects. I have created a Node module that creates random integers (positive and negative) easily, generates fully random strings of x length, and generates strings of x count random Latin words. All this using Crypto as the base.​On the ToDo list is adding UUID generation, and maybe float support or something.​Please take a look, feedback and/or suggestions would be fantastic!​Github: https://github.com/karnthis/make-randomNPM: https://www.npmjs.com/package/make-random

Submitted June 24, 2019 at 01:02AM by karnthis

API Gateway and Microservices question

Say I work for a company and there are many brands under the company. I have microservces such as userService, emailService, reviewsService, etc.So if I go to a specific brand's website and subscribe to its newsletters, then first I will need to send requests to the API gateway and it will direct me to the database of that particular band. API Gateway will authenticate/authorize if I'm already a user and if I'm authorized to subscribe, etc. Then, API Gateway will serve as an entry point and looks up the microservice (subscribeService) which can serve the request and delivers it to relevant part. Is this the right approach? Would be great if you could explain the whole architecture and flow? Thanks!

Submitted June 23, 2019 at 10:35PM by reddit_9810

Music streaming API

so, I have a client that needs a streaming app (web + mobile), I want to build the an API that servers all the appsi'm having a hard time figuring where to store the music files, I think that the file system option is not valid here because I want to protect the music, so I think that I am between two options, an S3 or storing the music in a normal database (Mongo) as blobs , what do you think?

Submitted June 23, 2019 at 09:59PM by Mumus27

How to ensure someone logged in can only trigger SQL queries relevant to that user?

Hey guys I have a bit of a conceptual block here.The webapp I'm building will let users login, and add stuff to their "profile".My question is how do you ensure that user 123 is only able to send queries using their ID as a user ID? In theory you can't fully trust anything the user has control over, cookies, React states, etc.While a user is logged in, is there some way to store authenticated session variables in the backend or something? That way instead of getting the "user id" variable to use in queries from something the user can edit, it's from a secure place that authenticated them to use that user ID.Or am I just overthinking this?

Submitted June 23, 2019 at 05:38PM by g3t0nmyl3v3l

Node framework for microservices?

Hi all,I'm trying to design an app using the microservice architecture. Ideally, the services would communicate with each other with TCP sockets (not a REST API, as I need pub/sub). What's the best framework to use for the services? I could write the code for the TCP sockets by hand but I'd rather spend my time coding the actual features of the app.The frameworks I've found so far are cote and Nest. Nest seems very feature-rich and possibly too complex for what I'm trying to make, whereas cote only focuses on microservices and seems more lightweight. I've been trying to find some opinions of people using these frameworks in production apps, but I couldn't find anything. Has anyone here used these frameworks or other ones for microservices? If so, what do you think?

Submitted June 23, 2019 at 06:08PM by samjmckenzie

Auto-update your GitHub repository and execute tasks/commands on push

https://github.com/eddiejibson/update

Submitted June 23, 2019 at 04:39PM by m1screant

HELP! express simple login register

hi I wants to make simple login register with dummy email password I've two screen 'login' and 'albums'​users can enter localhost:3000/albums without login the website how can I check this can someone help me I'm not good at backend​login router:const express = require('express'); const router = express.Router(); const loginController = require('../controller/loginController') /* GET login listing. */ router.get('/', (req, res, next) => { res.render('login', { title: 'LOGIN'}); }); //POST Login listing router.post('/', loginController, (req, res, next) => { if(res.locals.islogin) { res.redirect('/album'); } else{ res.send('Wrong user name or password') } }); module.exports = router; loginController middleware:const loginOption = { email: 'example@example.com', password: 'dummy1234', islogin: false, } const loginController = (req, res, next) =>{ const { email, password } = req.body; if(email === loginOption.email && password === loginOption.password) { res.locals.islogin = !loginOption.islogin; } else{ res.locals.islogin = loginOption.islogin; } next(); } module.exports = loginController; album router:const express = require('express'); const router = express.Router(); const loginController = require('../controller/loginController') /* GET home page. */ router.get('/', (req, res, next) => { res.render('index', { title: 'Login' }); }); module.exports = router;

Submitted June 23, 2019 at 02:24PM by teriologia

Created my first full-stack node app. 💳 Stripe Checkout Demo!

https://stripe.glitch.me/

Submitted June 23, 2019 at 12:58PM by mburakerman

Saturday 22 June 2019

Yesterday this got downvoted because it didn't look like a node.js issue. However, I think it is and maybe you guys can give it another shot.

https://www.reddit.com/r/node/comments/c3jyw2/node_http_requests_not_working_for_one_certain/

Submitted June 23, 2019 at 01:18AM by dub4u

What's the use of a proxy server for a company?

My company uses Hapi as a server side backend framework for Node.js for building proxies. What's the use of it?

Submitted June 23, 2019 at 02:46AM by reddit_9810

Fmait: An asynchronous, concurrent library for creating efficient, easy-to-understand promise pipelines.

I've designed a library called Fmait, which allows easy processing of arrays using asynchronous functions and promises. Check it out here:https://www.npmjs.com/package/fmait

Submitted June 23, 2019 at 01:04AM by N8Programs

Should Node.js offer TypeScript support by default?

https://twitter.com/poledesfetes/status/1142550441747763202

Submitted June 22, 2019 at 11:48PM by ecares

Setting custom DNS server when using request

I am working on an application that I want to use my local DNS server instead of some public one.​I am using the request package from NPM to send my requests. I would love it to be set a value in my app.js file and then be able to send requests without some hacky code like I have now (not showing... it's that bad)​I tried doing what this page said but it would not work for me.https://nodejs.org/api/dns.html#dns_dns_setservers_servers​I am kind of stuck with the request package from npm for a variety of reasons one of which is the amount of places I use it and a refactor would take quite a bit of time.​My goal is that I can use request and consul DNS to work together so that I can send a DNS request and get back the address of a service and it would include port if needed.​I have ~10 different services running on multiple ports and would like to run multiple instances of the other services using different ports and still be able to send requests to it using the request package from npm

Submitted June 22, 2019 at 08:17PM by jsdfkljdsafdsu980p

How do you handle thread blocking if you’re running multiple node instances in Docker?

Hey guys, full disclosure, I haven’t worked with Docker and I’m still new to node but I’ve read a lot about both and I’m getting my project rolling.The way I understand it is you can use Kubernetes with Docker to add a lot of scalability to a project by spinning up multiple instances of whatever micro services you need. I think Kubernetes handles load balancing?If my server only has X cores, I’ll always only be able to run X threads simultaneously for async tasks. So what’s the benefit of running multiple load-balances instances with a container based solution? Technically you’ll always be limited by your threads so how does that help with scalability?

Submitted June 22, 2019 at 04:55PM by g3t0nmyl3v3l

Trying to run the server by using mongo DB shows followig error

SyntaxError: Unexpected token .at new Script (vm.js:51:7)at createScript (vm.js:136:10)at Object.runInThisContext (vm.js:197:10)at Module._compile (module.js:613:28)at Object.Module._extensions..js (module.js:660:10)at Module.load (module.js:561:32)at tryModuleLoad (module.js:501:12)at Function.Module._load (module.js:493:3)at Function.Module.runMain (module.js:690:10)at startup (bootstrap_node.js:194:16)[nodemon] app crashed - waiting for file changes before starting...

Submitted June 22, 2019 at 04:17PM by Beouwulf_007

Free Udemy Course - NestJS - Zero to Hero

Dislaimer: Free coupons to this course were already published here, and about 2000 free coupons were given. I was amazed by how people reacted and reviewed my course, and it's now a featured course on Udemy (as well as a 250 upvotes post on Udemy). That's why I chose to give some more free coupons. It really helps!​---​Finally! Finally I have released my "NestJS - Zero to Hero" course to Udemy.I spent over 100 hours on this course, in parallel to my full-time work as a Software Engineer at DAZN.The course (currently) consists of over 100 lectures and 6 hours of video. More is coming.​Throughout the course, the students build a real-world application (REST API) using the NestJS Framework - a framework used to develop modern back-end applications using TypeScript.The course covers the most important topics of back-end development - authorization, authentication, security, storing sensitive information, configuration management, performance and so much more.​Since you guys were so amazing with your feedback, I've added 1000 more free coupons. The coupon code is REDDIT_FREE_JUNE​If you'd like to pay anyway, that's greatly appreciated. Here is a $9 coupon code: REDDIT_PROMO​Udemy: NestJS - Zero to Hero by Ariel Weinberger​P.S: If you know CS/Software Engineering/Bootcamp students who'd like to learn this technology, please tell them to send me a message and I'll give them a free copy (after this promo has expired).​Sharing is greatly appreciated! Enjoy my content! And please please, leave a genuine review.

Submitted June 22, 2019 at 10:15AM by WeinAriel

[Video] Modernizing Applications with Serverless on AWS

https://epsagon.com/blog/modernizing-applications-with-serverless-on-aws/

Submitted June 22, 2019 at 09:30AM by nshapira

Quickstart: Sending and Receiving Messages with AWS SQS

https://wdmr.me/articles/sending-and-receiving-messages-with-aws-sqs/

Submitted June 22, 2019 at 09:42AM by wolle404

Download mp4 Video from url

Given that you have an url like https://example.com/video.mp4 how would you download it in a simple node script?

Submitted June 22, 2019 at 08:48AM by JaniRockz

Learn NestJS - Full Course for Beginners

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

Submitted June 22, 2019 at 07:57AM by Rogers911z

Friday 21 June 2019

Scaling Node JS

Hi, I am working on nodejs and graphql and recently saw a video from JSConf about scaling node js. I wanted to know if sending a keep-alive header a good practice?

Submitted June 22, 2019 at 04:12AM by naseemali925

Node http requests not working for one certain domain

This is driving me crazy. For this whole domain typhoon2000.ph http requests made from node.js do not seem to work, but no error is given. Other domains work just fine. Requesting with curl works just fine also:$ curl -s http://www.typhoon2000.ph/multi/ | wc -l 44 $ cat test-fetch const fetch = require('node-fetch'); fetch('http://www.typhoon2000.ph/multi/') .then(res => res.text()) .then(body => console.log(body)) .catch(err => console.error(err)); $ node test-fetch | wc -l 0 Can someone figure this out?

Submitted June 22, 2019 at 03:17AM by dub4u

Nodejs Proxy Server Pointers Needed

So i have been creating basic node APIs for some time now. And I was thinking about creating a Node Proxy server to learn more. Could you guys give me some pointers on how to proceed on this one ?What I was thinking of is create a end point on the server which takes a parameter like a url and fetches the url document body or something of the sorts in the controller and then return the html or response body. Would that work ?Thanks in advance for your help

Submitted June 22, 2019 at 02:48AM by thelazytester

I have a bot with a lot of REGEX triggers that I would like to make more modular. Is there already a solution to this before I reinvent the wheel?

I'm considering building a simple interface either in JS or Python just to make adding/removing these triggers and responses easier than messing with this ugly code every time. Is there some kind of library or something I should look into that does this?Ps. I'm no professional so I'm just looking for easy solutions, not necessarily the right ones :)

Submitted June 21, 2019 at 11:58PM by GlassActress

downloading a create-react-app speed?

When I create-react-app (and every other npm package download but most of them don't take forever), it takes like 20-30minutes to finish. Is that my machine or my connection? I have a 2015 MacBook with a 1.1 GHz Intel Core M, and my download speed is 110 Mbps.

Submitted June 21, 2019 at 05:44PM by rob_moose

Amsterdam JSNation 2019 Full Playlist

https://www.youtube.com/watch?v=ZrKjgSfpppM&list=PLfIM4SvaiIyygQEe2WPpENwxIf-0agBr9

Submitted June 21, 2019 at 03:47PM by hfeeri

How do I prepare my database for tests using Jest and Knex.js?

I'm trying to write some integration tests for a RESTful API I am writing in Node.I want to setup a test database so that I can can call my API endpoints with Supertest and assert that the correct data is returned.My Jest global hooks are as follows:const knex = require('../../db/setup'); beforeEach(async () => { await knex.migrate.rollback(); await knex.migrate.latest(); await knex.seed.run(); }); afterEach(async () => { await knex.migrate.rollback(); }); The setup file is as follows:const { Model } = require('objection'); const Knex = require('knex'); const environment = process.env.NODE_ENV || 'development'; const configuration = require('./knexfile')[environment]; const knex = Knex(configuration); Model.knex(knex); I currently have two test suites, each with a single test, if I delete my test.sqlite3 file and then run my tests I get one passing test and one failing test, with the following error:SQLITE_ERROR: table `knex_migrations` already exists If I then run my tests again I receive a different error:MigrationLocked: update `knex_migrations_lock` set `is_locked` = 1 - SQLITE_BUSY: database is locked How can I get the database to reset correctly between tests, is there a better approach to doing this (e.g. is my attempt to reset the database between tests incorrect), should I be doing it on a per test suite basis instead?

Submitted June 21, 2019 at 03:02PM by MDTHLN

Parse structured multi-level CSV or Tab separated values using this Node.js module (https://github.com/siara-cc/csv_parser_npmjs)

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

Submitted June 21, 2019 at 03:11PM by siara-cc

How to store user activity log with mongodb and nodejs? Is this possible?

I want to store all the CRUD actions by logged user.

Submitted June 21, 2019 at 02:28PM by zyx422

passport with postgres ???

Morning !Am building a pretty standard webApp with node/express/postgres and was wondering if those who have professional experience would recommend writing my own authentication/authorization middleware or using passport.js.Thanks !!

Submitted June 21, 2019 at 01:00PM by darealbjamesy

I want to learn Node.js streams

are there any good resources to work with streams hands on. I have read some theory but I don't feel confident.

Submitted June 21, 2019 at 12:08PM by MuhammadHasham

Can anyone show me how to spawn child processes or exactly how to be multi threaded.

I have heavy lifting to be done, but I don’t want to block the thread. I thought I understood, I understood wrong.

Submitted June 21, 2019 at 11:11AM by zdravococksucker

Is GraphQL future of the APIs?

https://blog.graphqleditor.com/is-graphql-future-of-api/

Submitted June 21, 2019 at 09:45AM by oczekkk

Any modules for coloring of an image?

Hey,I have a jpg-file showing a world map and I would like to implement a hover for specific countries. Are there any modules that provide functions for my needs?

Submitted June 21, 2019 at 08:01AM by actopozipc

Thursday 20 June 2019

Learn Node.js - Node.js API Development for Beginners

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

Submitted June 21, 2019 at 06:28AM by MasHary911

Node.js/Express performance and best practices: Should I make multiple calls or just one big call?

I have an express server that needs to write about 100 html files into a directory in the project root.​I can build this server in 2 ways: the server can receive the request from the browser then start the 100 requests and send back a 200 when it finishes, or I can send a 200 after every successful file write and just go back and forth like that for every file.​My question is, when using express/node.js, which is better performance wise?​In scenario 1, should the server just be sitting there doing all that work for multiple users? Will I run into memory issues? Because I could put that list of files in the browser and make separate calls to my node server to retrieve and write each file from the external API.​This is what that first scenario sort of looks like. The route gets a list of files, then makes a call for each file.​//this whole request takes about 3 minutes to complete due to rate limiting of the external APIs. router.get('/api/myroute', (req, res, next) => { //contact a remote server's API, it sends back a big list of files. REMOTE_SERVER.file_list.list(USER_CREDS.id).then(files => { //we need to get the contents of each specific file, so we do that here. Promise.all(files.map((item, i) => //they have an API for specific files, but you need the list of those files first like we retrieved above. //more specifically you need a key for each file that is in the file_list object. REMOTE_SERVER.specific_file.get(USER_CREDS.id, { file: { key: files[i].key } }).then(asset => { //write the contents of each file to a directory called "my_files" in the project root. fs.writeFile('./my_files/' + file.key, file.value, function (err) { if (err) { console.log(err); }; }); }))) //send back a 200 only when the entire list has been retrieved and written to our directory. .then(() => { console.log("DONE!!"); res.status(200).send(); }) }); });

Submitted June 21, 2019 at 01:42AM by joWebDev

Anybody want to build or know an open Source Node/ExpressJS website live chat example?

Hello,I am planning to integrate a live chat service to a web application that I am developing. I am using ExpressJS. I would like to learn if there are any open source, simple live chat examples, or if anybody want to build one together to release as open source?​Cheers!Bahadir

Submitted June 20, 2019 at 10:59PM by bbalban

Create App that overlays website - any suggestions?

https://www.reddit.com/r/scala/comments/c3220b/create_app_that_overlays_website_any_suggestions/

Submitted June 20, 2019 at 10:56PM by SaltyVariable

Zipping files in S3 bucket and placing them back in the same "folder"

I'm using this node archiver module https://github.com/archiverjs/node-archiver​I've grabbed the example in the README that attempts to create a zip folder in S3 from a simple string (in the "append a file from string" portion). The only differences between my code and the one shown in the README, is that I've changed the variables to make them specific to my environment (i.e. bucket name, /tmp folder to locally store the zip archive, etc.)​I'm running the code on AWS Lambda and the on close events are not being triggered. Does anyone have any ideas as to what I'm doing wrong?

Submitted June 20, 2019 at 06:55PM by BluBarryPi

Examining an Exploited NPM Package (Jarred Oversson does a thorough breakdown)

https://www.youtube.com/watch?v=2cyib2MgvdM

Submitted June 20, 2019 at 05:07PM by YourQuestIsComplete

Node vs Python 3, Which is fastest?

https://benchmarksgame-team.pages.debian.net/benchmarksgame/fastest/node-python3.html

Submitted June 20, 2019 at 04:20PM by mominriyadh

Don’t Be Surprised by Your Serverless Bill

https://epsagon.com/blog/dont-be-surprised-by-your-serverless-bill/

Submitted June 20, 2019 at 03:57PM by nshapira

Don’t Be Surprised by Your Serverless Bill

https://epsagon.com/blog/dont-be-surprised-by-your-serverless-bill/

Submitted June 20, 2019 at 02:56PM by nshapira

Handling transactions and concurrency in MikroORM

https://medium.com/dailyjs/handling-transactions-and-concurrency-in-mikro-orm-ba80d0a65805

Submitted June 20, 2019 at 02:01PM by B4nan

Socket.io and socket properties

Hi, I a beginner in node and socket.io. Working on the chat to get some experience, I want to store my users names in an array for later use.On the client side I get a string from user input and store it as a name and then I add a property to my socket : Socket. nickname = nameAnd on the server side I have:``` io.on('connect', function (socket) { console.log(socket.nickname != undefined);if (socket.nickname != undefined) { console.log("here") connectedSockets.push([socket.id, socket.nickname]); socket.arrayIndex = connectedSockets.length - 1; console.log(socket.arrayIndex + " " + socket.nickname) console.log(connectedSockets); } });```The problem is that it will print the line only once:console.log(socket.nickname != undefined);And not enter the if once the nickname has been set. I’m obviously missing something there, could you give give me some advices to solve this? Thanks

Submitted June 20, 2019 at 10:57AM by StrenghGeek

Why do you even care about build stage of backend app?

I don't quite get the benefits of building my backend into one file(using webpack).I know about 12 Factor. But I'm not sure if it applies to the Node.js.Still need a list of pros and cons, to make a valid decision.

Submitted June 20, 2019 at 10:10AM by vzhufk

"Separating UI from Service Logic" in Node

Hi Guys,I am new to Node and Web Dev in general. At work (IT dpt of a manufacturer) I am responsible for developing a prototype of a web application that we want to offer to our other departments. We have now started the conversation of what we would need to change or add to make it production ready.One of the guys (he's been in IT for a long time but I don't think he has done much in Web Dev or with Node for that matter) had a quick glance at my project structure and said "You are mixing UI with service logic, and will need a separate web server between the browser and the Node.js server".I am really struggling to understand this and when I asked if he could elaborate he just started to use some terminology I am not familiar with and mentioned that having the app server serving the views would be the standard of 2005.The basic architecture of my app looks like this:Express as Web Framework that handles requests and routesejs as my view / template enginemongoose for DB queries to the underlying Mongo DBFor Front-End I use vanilla JS and very little CSS as I am leveraging Materialize CSSThe App has in theory a very simple scope (the bigger challenge will be to get the correct data from our ERP system) and consists of a handful routes and views. I was able to cover all the UI elements in plain HTML (i.e. ejs) and as such I did not find it necessary to use (and learn in my case) a heavy weight frontend framework like Angular or React.With all this information provided, can you guys help me understand what those statements could mean and more importantly if I am following a bad practice with this architecture?My understanding of Express and view engines like pug or ejs was that they exactly do what that other guy is saying that I should not do: getting requests from the client, doing some DB queries or calling services from our ERP and serving the corresponding views based on the response.The reason I ended up learning and using node for this project to begin with was that after some research I found out that node seems to very good for handling exactly our use case due to its asynchronous and non-blocking nature: be able to handle requests that require you to do something "in between" (ie DB queries or service calls to ERP) whilst not blocking additional client requests.After that conversation I am now starting to doubt if I missed a critical part in my learning and developing journey so far and would like to get your opinions about those statements and my understanding of node.Hope my issue is somewhat understandable. Any input is much appreciated.Thanks

Submitted June 20, 2019 at 08:38AM by mayjay89

What is the differences between node.js cluster and multiple execution of node.js?

No text found

Submitted June 20, 2019 at 08:39AM by hanley_chen

Building a Serverless App Using Athena and AWS Lambda (x-post /r/aws)

https://www.reddit.com/r/aws/comments/c2spcs/building_a_serverless_app_using_athena_and_aws/

Submitted June 20, 2019 at 08:02AM by nshapira

Wednesday 19 June 2019

Node + Handlebars + client side scripting

Hi, I'm new to node and I'm trying to use Handlebars as a templating library. I can't understand how I would be able to use a third party library like cryptojs to encrypt a string on the client side (browser) without needing to add a

Sequelize How to properly create a join table?

Let's say I have two Model: Job and Task. A Job model can have many category and similarly, a Task model can have many category. I have named the category model of Job as JobCategory and similarly I have named the category model of Task as TaskCategory. Now since Job and JobCategory and Task and TaskCategory are in many to many relationships. what should I name the join table of Job and JobCategory and Task and TaskCategory as per naming convention? Or am I doing this all wrong?

Submitted June 20, 2019 at 07:13AM by samratluitel

What’s the use of Bluebird promise instead of using Promise.reject?

Are there any reasons to use Bluebird promise since you can simply just use Promise.reject?

Submitted June 20, 2019 at 06:52AM by reddit_9810

Important missing puzzle pieces added to Node.JS port low.js: https.request, WebSocket client (http/https upgrade) support, npm module installation directly on microcontroller boards!

https://www.neonious-basics.com/index.php/2019/06/19/newsletter-june-19th-2019/

Submitted June 19, 2019 at 03:56PM by neoniousTR

MongoDB alternative

I’m building a web app and a good buddy of mine pointed out that mongoDB is not sufficient for what I’m building since I’ll need a relational Db for the data that I’ll be using.He recommended using Microsoft SQL instead of mongodb.Does anyone have solid resources for setting up Microsoft SQL with node?

Submitted June 19, 2019 at 03:18PM by TB42

Opensource order matching engine with JSON-based RESTful API

https://github.com/r3dh4r7/order-engine​Critiques and improvements are welcome.

Submitted June 19, 2019 at 03:29PM by r3dh4r7

Wrap a function without changing its name/properties (by sindresorhus)

https://github.com/sindresorhus/mimic-fn

Submitted June 19, 2019 at 03:27PM by ehmicky

Authentication Logic - React Native <-> Node

Hey,​I am developing a little app on React Native, using Node as a Backend (w/ MongoDB). On my app there is 3 ways of register/login: Google, Facebook and normal way inserting Username and Password desired.​On front-end side, on React, I am using OAuth to login on Facebook and Google, sucessfully and getting a token, which I am storing on MongoDB. If the User chooses to use the normal way, I generate a token, store it and send it to the User.At the same time, I store these tokens locally, so when I made another request to another node endpoint, I am sending also the User_ID and that token, so I can validate the User before returning something.​Is this correct? Am I doing this too basic?Thanks in advance

Submitted June 19, 2019 at 02:20PM by RevolutionaryDog0

A safer, nicer abstraction over AWS SSM Parameter Store with built-in caching and idempotent preloading.

https://github.com/tallpants/ssm-parameter-store

Submitted June 19, 2019 at 01:55PM by TheTallpants

How does Express fit into an app using Apollo Server?

Hi, I am still understanding the whole, Full-stack JavaScript Architecture. From, what I understand, Express is used for creating REST API endpoints and, GraphQL is a graph replacement for REST API endpoints. So, how does Express fit into the Equation? Is it possible to get rid of Express altogether? Like, is there such a thing as a MARN (Mongo, Apollo{GraphQL}, React, Node) stack?

Submitted June 19, 2019 at 12:36PM by OneDoubt9

A small package to get an active tab in chrome

https://www.npmjs.com/package/chrome-active-tab

Submitted June 19, 2019 at 09:13AM by yoihito

Can a node process intercept all of its stdout?

I know it's possible to intercept console logs using like so. But this and other things I've tried only seem to work on console logs. I'm using child_process.spawn to run a docker image and have {stdio: "inherit"} in order to get one of the processes inside the container to run properly (basically tricking it into thinking that it's running in a TTY). I'd like to be able to capture the output from the child process but I'm not sure if that's even possible.

Submitted June 19, 2019 at 09:28AM by neuromancering

Tuesday 18 June 2019

Why JavaScript is the First Choice of Developers? Node JS and Its Benefits and Drawbacks

https://www.idslogic.com/blog/2019/06/what-is-node-js-and-its-advantages-and-disadvantages-a-complete-guide.html

Submitted June 19, 2019 at 07:09AM by TechnicalRun

A TO-DO List Web Application with User Registration and Authentication

Hey fellas, I some time back built a full-stack to-do application and was hoping you would check ot out. Here's the link > https://github.com/alexnjoroge

Submitted June 18, 2019 at 11:18PM by searchcrab

Reading and modifying an html file in Node

I need to read an html file, check a few attributes and possibly add an attribute in Node. What is the best way to do this? Do you use a third party library?

Submitted June 18, 2019 at 09:54PM by RocketPigWithWig

Json-node-normalizer 1.0.1 released - New easy method to normalize json data

Opensource project to normalize json data types from json schema specifications.https://github.com/benjamin-allion/json-node-normalizer

Submitted June 18, 2019 at 10:17PM by BennyDevnet

Create a Simple and Stylish Node Express App

Hi, there 👋🏻! Check out how to build the foundation of a simple Node.js and Express.js app by creating a user interface and API. → https://auth0.com/blog/create-a-simple-and-stylish-node-express-app/?utm_source=reddit&utm_medium=sc&utm_campaign=nodeexpress_app

Submitted June 18, 2019 at 08:55PM by BachiDegli

Prisma 2 Preview: Type-safe Database Access & Declarative Migrations

https://www.prisma.io/blog/announcing-prisma-2-zq1s745db8i5

Submitted June 18, 2019 at 09:25PM by Ewers

Node/NPM, Windows, and Permissions Errors.

Hello /r/node,My apologies if this is not an appropriate place to post this. Recently at work due to security requirements I had to switch away from Arch Linux dev laptop and start using a Windows OS. This is fine as I am fairly familiar with Windows, however I am NOT familiar with Windows permissions.I installed the latest LTS for Windows. Made sure it was in my path. So I can use node/npm from CMD/Powershell/CMDer etc. However I run into some fairly annoying permissions issues.The first issue is when running ng build --watch with nodemon within an Angular project I will get this error:> concurrently --kill-others "ng build --watch" "nodemon -e js,html,json,ts,map server.js" [1] [nodemon] 1.19.1 [1] [nodemon] to restart at any time, enter `rs` [1] [nodemon] watching: *.* [1] [nodemon] starting `node server.js` [1] [INFO] Running on port: 5000 [0] ENOTEMPTY: directory not empty, rmdir 'C:\Users\user\Dev\admin\dist\admin\assets\fonts' [0] Error: ENOTEMPTY: directory not empty, rmdir 'C:\Users\user\Dev\admin\dist\admin\assets\fonts' [0] at Object.rmdirSync (fs.js:684:3) I can get around this by deleting the `dist/` folder and all it's contents EACH TIME before I run the project. However I shouldn't have to do that, and certainly never had to on Linux/OSX.The other issues are basically any IDE I end up using I can't run the project from the built in terminals, or run their debuggers as they almost always hit a permission issue in the `node_modules` folder.npm ERR! path C:\Users\user\Dev\api\node_modules\propex\package.json.3101012362 npm ERR! code EPERM npm ERR! errno -4048 npm ERR! syscall rename npm ERR! Error: EPERM: operation not permitted, rename 'C:\Users\user\Dev\api\node_modules\propex\package.json.3101012362' -> 'C:\Users\user\Dev\api\node_modules\propex\package.json' I have tried a few things, including looking at the project folders and opening the properties and trying to mess with permissions with zero luck. I have also popped open the linux subsystem and went with the nuclear option of chmod 777 -R ./* in my dev folder. Like I expected though this had no affect since windows doesn't do their permissions like Linux/OSX.tl;dr how do I fix permissions on my dev folder and subfolders in windows to allow my terminals and IDE's to access any of the files without permissions issues.

Submitted June 18, 2019 at 07:29PM by j-cron

What's New in Mongoose 5.6.0: Immutable Properties

http://thecodebarbarian.com/whats-new-in-mongoose-5-6-immutable-properties.html

Submitted June 18, 2019 at 06:41PM by code_barbarian

An alternative to Google Geocoder API (in Node.js)

https://medium.com/@armando.mag95/78728c7b9faa

Submitted June 18, 2019 at 05:59PM by wineandcode

Has anyone written a *good* JSON pretty printer? Ideally in typescript.

We are working with typescript creating a new logging package, and would like logs to be pretty printed when in the development environment. However we have struggled to find a nice package to do this, especially one that has typescript typings.Any hidden gems that google is failing to turn up for me?Thanks

Submitted June 18, 2019 at 04:59PM by Midasx

Recommended execution and authentication of Google Cloud Functions

I'm wondering what the best approach is for the execution and authentication of Google Cloud Functions.The requests will be exclusively from a Compute Engine VM instance, although this could change in the future.The functions themselves are for third party integrations, which will probably make use of a VPC for database connections.the idea I'm tossing around is to send an authorisation authentication request, which directly inserts a token into the db for subsequent use, but I'm wondering if there is a better approach for communication between CF and CE.Ideally I wouldn't be setting up instances of express as the functions themselves are fairly lean.The reason the functions are decoupled from the app inside VM is mainly for seperation of concern but there are other business/personnel factors.Thanks

Submitted June 18, 2019 at 03:52PM by PerniciousAid

Is it possible in node to wait for multiple responses from an url?

When i am sending a request to an url, it sends a response back with status code. But after some time it sends a file to download. Is it possible in nodejs to capture both? How to achieve it?

Submitted June 18, 2019 at 01:54PM by motominator

Monday 17 June 2019

Wait for the address to return a file for download.

When i send a request to a website, it immediately returns a page with status code. But after some time it gives the downloadable file. I am using request module. What will be the nodejs code that can be used to get the file and save in the system?

Submitted June 18, 2019 at 07:40AM by motominator

NestJS vs Loopback vs Sails: what are the major differences?

I started learning NestJS and I love it. But I was wondering: what does it offer/lack relative to Loopback and Sails?

Submitted June 18, 2019 at 04:04AM by bubble_fetish

sending an image from client to server-side in node js

0I am trying to upload an image to the server but keep getting an error in the chrome console "POST http://localhost:3000/images 500 (Internal Server Error) @ main.js:19".it looks like he server side of my application is not receiving the image.when I try to access the file on the server I get undefined([Error: Input file is missing]). When I post using html without the client-side javascript, the image is posted successfully. However, I want to post the image using the client-side js. Can someone help me know what I am doing wrong​​https://i.redd.it/h3phz3m2mz431.png

Submitted June 17, 2019 at 10:46PM by del57748

Question: What is nodejs used most practically for?

No text found

Submitted June 17, 2019 at 11:08PM by WillMargs

crawler-request regex

Im getting text from a pdf with a package called crawler-request.for some reason the simple regex that I apply to the string to remove all newlines (/n):let fixed = response.text.replace(/\n/g, " "); doesnt remove all newlines and creates a mess with tons of newlines left ...If I take the same string from console log & paste it into a online tool apply the same regex ... it works like charm... https://regex101.com/r/O4D9hM/5what is going on here ?????? does node.js have some kind of different regex ????This is the messed up version ... same command like in the online toollet fixed = response.text.replace(/\n/g, " "); https://regex101.com/r/O4D9hM/6

Submitted June 17, 2019 at 10:25PM by MedyGames

Learning Curve of Nestjs without experience with Angular?

Hello Everyone,This is for anyone who has used NestJs. It has marketed itself as being inspired by Angular. For those who have little to no experience with Angular, how has the learning curve been with learning Nestjs?All of my experience is with Vanilla JS, React and Express. I'm contemplating learning Nestjs which has a more opinionated, structured, batteries included approach. Express though nice is too unopinionated at times for my liking.

Submitted June 17, 2019 at 10:24PM by RSpringer242

Uploading and Downloading Files with Node.js and Oracle Database

https://jsao.io/2019/06/uploading-and-downloading-files-with-node-js-and-oracle-database/

Submitted June 17, 2019 at 08:56PM by dmcghan

What Does Peeling An Egg Have To Do With DevOps?

https://hackernoon.com/what-does-peeling-an-egg-have-to-do-with-devops-e55108a4e83c

Submitted June 17, 2019 at 07:45PM by patrickleet

If I have a hex code, can I generate an image/* of that colour on the server?

No text found

Submitted June 17, 2019 at 07:49PM by Jitsu24

8 months since I started learning Node.js and I just realised I don't know how to take input in Node.js as we do in C (scanf()) and Java (sc.nextInt()).

I am laughing at myself. XD

Submitted June 17, 2019 at 06:09PM by Katsuga50

Store db password as encrypted format and when server start it will decrypt the password and db connection start in node.js&Typescript DB=MySQL

- I want to securely store my database credentials in my node js project.- I encrypted the my MySQL Database password and stored in config file but when I start server like node js (npm start/node app.js) it will decrypt the password then give access to MySQL Database.- I successfully encrypted password and I'm trying to decrypt it when trying to access database (using crypto module)- I wrote some decrypt function to decrypt my password.- Example function decrypt(text: string) {some task done here.....}- but it's not working..Can any one help in this.Thank you.

Submitted June 17, 2019 at 03:53PM by RaghunathV

Which is better having one get endpoints or multiple in my case?

I'm building a simple social network clone and I have to fetch posts from multiple sources.Example of one source endpoint that fetches posts from a community source.'/communities/:communityId/posts?limit=25'​Example of multi-source endpoint:'/posts?source=(community,subscription,all)&id=(id of the source)&limit=25)',​One problem I have with the multi-source endpoint is the 'complexity' I'm going to have in one controller.Which way of doing this fits REST guidelines better?Any thoughts?Edit:Typos in the title.

Submitted June 17, 2019 at 04:10PM by Kr7731

Using a thread pool instead of manually multi-threading on a dead link checker

https://javascriptwebscrapingguy.com/jordan-plays-pool-multi-threading-with-a-pool-queue/

Submitted June 17, 2019 at 03:02PM by Aarmora

From kebab-case to camelCase Using Regex: How to Refactor All Your Code in Less Than 30 seconds

Just found a way to change all your kebab-case variables to camelCase in 30 seconds! Should you clean your code or just need to refactor it, find out how I did it!​Please let me know if you have any comment/remark/question :)​https://blog.theodo.com/2019/05/kebab-case-camelcase-using-regex-refactor-code-less-30-seconds/

Submitted June 17, 2019 at 02:17PM by Melbius_

Introduction to Node.js

https://medium.com/p/introduction-to-nodejs-fb9a6f540be9

Submitted June 17, 2019 at 01:16PM by treyhuffine

Combine JWT and Google Oauth

I have a mern stack project in which there is two sign in methods:Sign in with googleSign with email and passwordIn backend I have a route which is accessible to only authenticated user. Using JWT strategy, I am able to access that route after I login using email and password. And using google, I am able to get accessToken. So now, how to use accessToken given by google to get access to that protected route?#nodejs #passportjs

Submitted June 17, 2019 at 12:04PM by bhuwanadhikari

Mini Mocha, An absolutely minimal emulation of Mocha for demos

https://runkit.com/ruwan/5d0747a09ab09c001a62b6ed

Submitted June 17, 2019 at 09:54AM by geeganage

It's 2019, is passport.js still a thing?

If you want to implement oauth 2 in a app you create today, how would you go about it?The dropbox one I planned to use has been untouched for 3 years. Do people still use passport or is there a generic oauth library to recommend?

Submitted June 17, 2019 at 08:44AM by sayurichick

Sunday 16 June 2019

Why is my function called twice?

Hi!My first interaction with nodejs is adding a function that sends a notification with a small payload to Slack when called. I have finally accomplished that! There is a small issue however is when I added my function to a script that handles datastreams, on the exit function dataStream.on('end'...) my function notification('Success!', message, destination)gets called twice. Either the exit function gets ran twice or only my function.​Any idea why this happens?const _ = require('highland') const async = require('async') const { BigQuery } = require('@google-cloud/bigquery') const CIO = require('customerio-node') // init BigQuery const bigQuery = new BigQuery({ projectId: process.env.PROJECT_ID }) let queue = [] function queueProcessor() { async.eachLimit( queue.splice(0, 15), // take 15 elements (since most will have at least 2 calls 5, // 5 at a time processRow, // function that will execute the work, passed (row, callback) err => { if (err) { logger.error(err) } } ) } // Reset interval let queueThrottleProcessor = setInterval(() => { queueProcessor() // Process queue }, 1000) let dataStream = _( bigQuery .dataset(process.env.BIGQUERY_DATASET) .table(process.env.BIGQUERY_TABLE) .createReadStream() ) dataStream .ratelimit(15, 1000) .on('error', err => { logger.error(err) }) .on('data', row => { queue.push(row) }) .on('end', function() { // All rows have been retrieved. var message = `${numSynced} synced, total calls: ${totalCalls}` logger.info(message) notification('Success!', message, destination) clearInterval(queueThrottleProcessor) // Give 15 seconds for all the current processing to go through setTimeout(() => { // Done process.exit(0) }, 15000) })

Submitted June 17, 2019 at 07:13AM by UL_Paper

error

when I go to install node-red, I keep getting "Thrown :ReferenceError: node is not defined"plz help

Submitted June 17, 2019 at 04:33AM by GloomyMusician24

Extract text from PDF

I want to extract text from remote pdf files. Preferably get all the pages into a single string. Any noob friendly way?Only found pdf.js so far & this would probably take me forever to create a script ...Any help would be appreciated.

Submitted June 17, 2019 at 12:18AM by MedyGames