Thursday 28 February 2019

Node.js Tutorials for beginners in hindi | Express Application Generator...

https://www.youtube.com/attribution_link?a=N9psxHyJUJA&u=%2Fwatch%3Fv%3DRC2M3okYmsU%26feature%3Dshare

Submitted March 01, 2019 at 06:26AM by phptutorialswebsite

How to Transfer Files and Data Between Angular Clients and Node.js Backends

http://go.learn4startup.com/4d81106f59

Submitted March 01, 2019 at 03:46AM by GlennMulligan

having a wait in a loop nodejs promises async await

i have an issue, i have a collection, where there are ethereum address stored, around 40 address, so i pick them up from collection and in a foreach loop, i tried to get some data from etherscan, but the etherescan blocks me, if i make quick request, it requires atleast 5 seconds delay, i tried various things to wait for some seconds, but iam not able to get it in for loop any way to have wait in forEacg loop??https://github.com/aminnagpure/test1/blob/master/forchecking​

Submitted March 01, 2019 at 03:59AM by aminnagpure

Simple node plot library

Does anyone know of a quick and simple plotting library for node? I have an array of values I need to plot and don't want to go through all the overhead of plotly or any of the other large plotting libraries. Literally something that just outputs a quick PNG of the values in a simple line plot is perfect.

Submitted March 01, 2019 at 04:05AM by Yummycaptaincrunch

Error when following tutorial

https://www.9lessons.info/2017/02/create-restful-api-nodejs-mysql.html. Can someone help me figure out. I copied their code from Github and installed all the packages mentioned in the tutorial but I get the error code "Error: connect ECONNREFUSED" when running npm start on the command line. issue is?

Submitted March 01, 2019 at 02:36AM by asadqb

Looking for a headless cms name

Hello community!​Sometime ago I created this library: https://github.com/fega/mongo-server. Is a Quick restApi development library​I have been thinking about the posibility of evolving it to a headless Cms, but I'm really bad at naming things.​I'd like to know some of your suggestions and pick the best/more popular.​thanks so much!​​

Submitted March 01, 2019 at 01:00AM by fega01

Async with https streams

Looking for similar profiling tool like "php xhprof" in nodejs

We are running a legacy nodejs app which is using a lot of memory and I would like to start profiling the code so we can start reducing the memory footprint. Coming from php land we could use xhprof to create graphs which were super useful for finding the bottlenecks, but struggling to find what/how i would do that with node.​Any suggestions would be helpful

Submitted February 28, 2019 at 11:46PM by dgbinney

Website speed: Is it better to choose Node or PHP for blog?

I used wordpress, noticed that expensive, "pro" and "optimized" themes weight 1-8mb and are ultra slow with tons of useless requests.Started creating myown Wordpress theme,i almost finished it.However i think i can go one step further and learn Node and create my own small backend+frontend for blog, but only if that gives me more speed.​What you guys think about speed? Which choice will be better for me?

Submitted February 28, 2019 at 10:59PM by justnicepersonhater

Divide and conquer: Scale your Node.js app using distributed queues

https://blog.logrocket.com/divide-and-conquer-scale-your-node-js-app-using-distributed-queues-8231a9486d3a

Submitted February 28, 2019 at 08:53PM by harlampi

My work with nodejs on sails.js vs google cloud function with raw nodejs

Hey guys. I was working on heavy computation stuff in nodejs. It was like some matching algorithm with 3000 users. The aim was with 50k users. But currently we are using that algorithm on just 3000 users. The use case is such that it will create around 90000 rows in database . Now i have to apply my algorithm of matching users on those 90000 rows. Here is my benchmark:Nodejs with sails.js took around 4 to 5 minute. We have tried every possibility and now the end result id 5 mint. Earlier it was 40 to 50 minutes.Nodejs with google cloud function. It took 15 seconds.What the hell. How is this possible. Seriously i have no answers regarding this. And i am here for the answer.

Submitted February 28, 2019 at 07:20PM by monkeyguy2017

Nodejs.org Website Redesign Is Now live

https://nodejs.dev/

Submitted February 28, 2019 at 07:50PM by claOnline

Docker-izing a NodeJS ExpressJS API - Video Tutorial

https://youtu.be/CsWoMpK3EtE

Submitted February 28, 2019 at 05:52PM by elliotforbes

How to handle uploadfilters in Europe? Is there currently a way to implement them?

No text found

Submitted February 28, 2019 at 05:09PM by zSacrety

Is is safe to use mongo.db as global variable?

I'm making a http server using nodejs. Here is a piece of the code:var mongo = new MongoClient(dbUrl);mongo.connect(function(err) {db = mongo.db('geeki')});I use db =, not let db =, so that the variable db can be used in all my functions. I have heard many advices that "don't use global variable in multiple thread nodejs". So my question is, if I use db this way, what problem maybe occur?

Submitted February 28, 2019 at 03:55PM by ypsthelove

Dead simple analytics service for your node.js REST API

Hi redditors!If you are tired of setting up grafana dashboards or maintanting your ELK stack, I have great news for you!Me and my team created a dead simple REST API monitoring and analytics service.See the gif with its dashboard below.If you’re interested to give it a try please PM me.If you think it’s a stupid idea to make yet another APM - please leave your feedback in comments. Processing gif 92zwh1it1cj21...

Submitted February 28, 2019 at 04:09PM by fpd4444

How Might Serverless Impact Node.js Ecosystem?

https://blog.bitsrc.io/how-might-serverless-impact-node-js-ecosystem-b0e312036fcf

Submitted February 28, 2019 at 04:45PM by JSislife

A Tale of Two (Docker Multi-Stage Build) Layers – Production Ready Dockerfiles for Node.js using SSR or Nginx - Hacker Noon

https://hackernoon.com/a-tale-of-two-docker-multi-stage-build-layers-85348a409c84

Submitted February 28, 2019 at 03:48PM by patrickleet

I am a node.js beginner and trying to setup a project but getting an error.Please Help.

I am trying to run a project name StageMate ( https://github.com/Langhalsdino/StageMate ) but getting an error while starting node.js server .When I run the command npm start I got an error " cannot find the path specified" .The content of package.json is as follows:​{ "name": "StageMate", "version": "1.0.0", "description": "Intelligent presentation framework", "main": "index.js", "scripts": { "build-stage-mate": "cd stageMateApp; webpack", "start": "npm run build-stage-mate && node index.js" }, "author": "Timo, Enrico, Frederic, Jonas", "license": "MIT", "dependencies": { "angular": "^1.6.6", "angular-chart.js": "^1.1.1", "body-parser": "^1.18.2", "chart.js": "^2.7.0", "css-loader": "^0.28.7", "express": "^4.16.1", "mustache": "^2.3.0", "node-sass": "^4.5.3", "node-uuid": "^1.4.8", "raw-loader": "^0.5.1", "reveal.js": "^3.5.0", "sass-loader": "^6.0.6", "socket.io": "^2.0.3", "style-loader": "^0.19.0", "webpack": "^3.6.0", "ws": "^3.2.0" } This line ("build-stage-mate": "cd stageMateApp; webpack") is causing problem.And when i remove webpack and change the above line to ("build-stage-mate": "cd stageMateApp") The server gets started but shows a blank page on localhost.Steps I followed so far: 1. Cloned github project. 2. inside node.js directory --> npm installI also installed weback inside node.js directory. But when i tried to do same inside " stageMateApp " directory it shows error related to node-sass.Please guide what i am doing wrong ?? Does webpack needed to be installed separately , as inside stageMateApp directory there is file name webpak.config.js.Please help me to resolve this issue.

Submitted February 28, 2019 at 02:39PM by The_Alchemist_27

newb questions -- package.json -- older node version

There is a github source that I want to clone, https://github.com/MicroFocus/CX/blob/master/ig-overview, but the node version is 6 in the package.json file and my OS currently has 8 installed. The last updates for the project were put out about a year ago. So it is pretty fresh right? Yet node 11 is out.How likely is the code to work if I take every dependency in the package.json file and install each one but with the latest version that my node 8 can install via a npm command?node 11 looks to be out, I am running opensuse leap 15.0 fully patched which includes node 8. I also see the same with java versions, where they versions are just growing quickly with much shorter life cycles. How do we best manage dependencies for a given version and use later code as well? Are we restrained to having a container of one code base and another container for newer code base?​

Submitted February 28, 2019 at 03:08PM by fpatterson55

Serverless Analytics Benchmark of AWS Aurora Performance

https://statsbot.co/blog/serverless-analytics-benchmark-of-aws-aurora-performance/

Submitted February 28, 2019 at 02:57PM by drivebyvitafan

Node v10.15.2 (LTS)

https://nodejs.org/en/blog/release/v10.15.2/

Submitted February 28, 2019 at 01:12PM by dwaxe

Node v11.10.1 (Current)

https://nodejs.org/en/blog/release/v11.10.1/

Submitted February 28, 2019 at 01:12PM by dwaxe

Node v6.17.0 (LTS)

https://nodejs.org/en/blog/release/v6.17.0/

Submitted February 28, 2019 at 01:12PM by dwaxe

How do I add watermark to an existing PDF?

I have searched and tried various tools like jsPDF , image-watermark, nothing works. any idea?

Submitted February 28, 2019 at 07:10AM by SusmithHCK

Respect validation

Why is mongoose not respect validation rules when updating data? Ex: one of the rules forbids the first name to be less than 2 characters, however, when updating from a put request, everything goes unnoticed. How can I change that?

Submitted February 28, 2019 at 07:21AM by r_gui

Wednesday 27 February 2019

An antivirus CLI written in NodeJS on GitHub.

https://github.com/Richienb/rosav

Submitted February 28, 2019 at 06:56AM by Richienb

A Year (plus a little) on TC39

https://medium.com/braintree-product-technology/a-year-plus-a-little-on-tc39-a1acb87eb862

Submitted February 28, 2019 at 02:35AM by fagnerbrack

Issue with creating Model with Mongoose and updating document.

I have the following schema​const TandaSchema = new Schema ({name: {type: String,required: true},secretary: {type: Schema.Types.ObjectId,ref: 'users',required: true},members: [{user : {type: Schema.Types.ObjectId, ref : 'users'},status: {type: String, default: 'waiting'},}],.....}Am I declaring members the correct way? I'm having an issue calling the array method .push on the members after I find a document. The program jumps to the catch block when tanda.members.push is called. Thank you for any help and sorry for formatting errors.​Tanda.find({registrationCodes: {$elemMatch: {code: 'abc', email: '[johndoe@gmail.com](mailto:johndoe@gmail.com)'}}}).then(tanda => {const newMember = {user: req.body.newMemberID,status: 'waiting'}tanda.members.push(newMember);tanda.save();return res.json(tanda);}).catch.....​

Submitted February 28, 2019 at 01:49AM by TalkingToMyselff

Most frequently mentioned words in the top 1000 StackOverflow questions tagged #JavaScript: "Node" appears in the center. [x-post /r/DataArt]

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

Submitted February 27, 2019 at 10:22PM by jmerlinb

Should I Do a Series on Data Structures and Algorithms?

https://youtu.be/86lTyDiJk8s

Submitted February 27, 2019 at 07:42PM by WebDevJourneyWDJ

Generating multi-brand multi-platform icons with Sketch and a Node.js script — Part #1

https://habr.com/en/company/badoo/blog/441040/

Submitted February 27, 2019 at 07:50PM by atomlib_com

Hey @everyone. I'm going to create a DOM canvas for drag and drop html elements. Can you please help me or give me your advices

No text found

Submitted February 27, 2019 at 06:31PM by MYTHiN07

HyronJs, the next powerful framework for server app

Hello everyone, I have just built a new framework and want to introduce it to the community: https://docs.hyron.org​After a period of work, I realized that the problem of code reuse is still a rather complex issue, most of them only stop at the library level. The packaging and use requires that you still have to intervene deeply. It would be hard if you want to plug a module into your product, especially someone else's, or another project. We, or every company, every project, and around the world often meet the same problems, and we are in general reinventing the wheels of other brothers. A significant waste of resources. What if we could build a community, and people could share their code, services, addons, or plugins that could be easily reused so that it could be plugged into the app. like my jigsaw puzzle? Hyron makes packing and reusing quickly much easier, it can help the product development process become much faster!​https://i.redd.it/1g6rvwj7h5j21.pngBesides, managing the modules I see is also a problem to note. With small projects is not a problem, but with a large project size, up to a hundred, thousands of services, why, when products, often have to change and maintain, as with startups. What happens when you are tasked with upgrading and maintaining a long and chaotic list? How to keep my app neat, clean, and easy to manage, easy to edit and upgrade when needed? That is when we need a centralized management model, and packaging, inheritance that the Hyron provides.​Processing gif 76vx32tig5j21...A technology will be hard to succeed, if it becomes difficult to reach people. And that is why I am constantly looking for ways to make it more and more simple, more friendly, to be easy to learn and use. even for a beginner, there is only a little basic knowledge of javascript that can be easily accessed, and create a professional application!​There are many things, being a lazy person, I hope that one day, our programming, and our work can become much faster, and simpler, with just a few taps Drop, a few knuckles are we can build a professional application of term 🤣🤣🤣​However, in order to reach that future, it is necessary to help your friends, those who are like-minded, hope to work together and work with you :)A project is also very difficult to succeed, since it has no funds to maintain. With a small amount of support from you, a cup of coffee can make a difference.- Click watch to watch and star to help the project more popular to the community on Github : https://github.com/hyron-group/hyron- Follow fanpage to get the latest news from Hyron: https://fb.com/hyron.group- Donate to help Hyron develop products faster and better: https://liberapay.com/thangdjw/donate- Introduce Hyron to friends to help hyron more popular- Join co-developers with hyron, to develop useful products

Submitted February 27, 2019 at 06:01PM by thangdjw

Modern Token Authentication in Node with Express

https://developer.okta.com/blog/2019/02/14/modern-token-authentication-in-node-with-express

Submitted February 27, 2019 at 05:25PM by rdegges

HyronJS, the next powerful framework for server app

Hi everyone, I would like to introduce the framework I have just developed: HyronJs![](https://lh3.googleusercontent.com/-6c6is7d26tA/WvGYmUA907I/AAAAAAAA5B4/yuiwlyvsNNQKItgKcTMLO92tGVRHcPgPgCJoC/w530-h577-n-rw/codemkey.jpg) After a period of work, I realized that the problem of code reuse is still a rather complex issue, most of them only stop at the library level. The packaging and use require that you still have to intervene deeply. It would be hard if you want to plug a module into your product, especially someone else's, or another project. We or every company, every project, and around the world often meet the same problems, and we are in general reinventing the wheels of other brothers. A significant waste of resources. What if we could build a community, and people could share their code, services, add-ons, or plugins that could be easily reused so that it could be plugged into the app. like my jigsaw puzzle? Hyron makes packing and reusing quickly much easier, it can help the product development process become much faster!![](https://miro.medium.com/max/778/1*EumSBn3ItYDgQgNt8mbbWA.jpeg)Besides, managing the modules I see is also a problem to note. With small projects is not a problem, but with large project size, up to a hundred, thousands of services, why, when products, often have to change and maintain, as with startups. What happens when you are tasked with upgrading and maintaining a long and chaotic list? How to keep my app neat, clean, and easy to manage, easy to edit and upgrade when needed? That is when we need a centralized management model, and packaging, inheritance that the hyron provides.![](https://cdn-images-1.medium.com/max/1600/1*mu3FBO59a6w_eufvch3XUg.gif)Technology will be hard to succeed if it becomes difficult to reach people. And that is why I am constantly looking for ways to make it more and more simple, more friendly, to be easy to learn and use. even for a beginner, there is only a little basic knowledge of javascript that can be easily accessed, and create a professional application!There are many things, being a lazy person, I hope that one day, our programming, and our work can become much faster, and simpler, with just a few taps Drop, a few knuckles are we can build a professional application of the term 🤣🤣🤣However, in order to reach that future, it is necessary to help your friends, those who are like-minded, hope to work together and work with you :)A project is also very difficult to succeed since it has no funds to maintain. With a small amount of support from you, a cup of caffeine can make a difference.Click watch to watch and star to help the project more popular to the community on GithubFollow fan page to get the latest news from Hyron: https://fb.com/hyron.groupDonnateto help Hyron develop products faster and betterIntroduce Hyron to friends to help hyron more popularJoin co-developers with hyron, to develop useful products

Submitted February 27, 2019 at 05:41PM by thangdjw

Update in ES spec will make async functions way more performant

https://github.com/tc39/ecma262/pull/1250

Submitted February 27, 2019 at 01:56PM by ecares

Exploring Tokens with Stellar

https://medium.com/@todkap/291172208639

Submitted February 27, 2019 at 01:57PM by kiarash-irandoust

I released a report: ReDoS vulnerabilities in npm spikes by 143% and XSS continues to grow

https://snyk.io/blog/redos-vulnerabilities-in-npm-spikes-by-143-and-xss-continues-to-grow/

Submitted February 27, 2019 at 02:47PM by lirantal

ElectronCGI - Cross Platform .Net Core GUIs with Electron

https://www.blinkingcaret.com/2019/02/27/electron-cgi/

Submitted February 27, 2019 at 12:41PM by ruidfigueiredo

The state of open source security (includes npm)

https://res.cloudinary.com/snyk/image/upload/v1551172581/The-State-Of-Open-Source-Security-Report-2019-Snyk.pdf

Submitted February 27, 2019 at 10:50AM by ecares

Processing an array of million of elements using node js.

Can we process an array of million elements using node js? (assume if there are inner loops also)My findings areIt may block the eventloop and freezes the server.Memmory must be explicitly increased for the V8's heap.Is that good practice ? Is my findings are valid ?

Submitted February 27, 2019 at 11:55AM by sujesht

If you have multiple servers in different countries, how will the database connection be set up?

No text found

Submitted February 27, 2019 at 09:52AM by livinglibary

HyronJS, next powerful framework to build backend application faster and easier

Please introduce to the development framework framework: https://docs.hyron.orgAfter a period of work, I realized that the problem of code reuse is still a rather complex issue, most of them only stop at the library level. The packaging and use requires that you still have to intervene deeply. It would be hard if you want to plug a module into your product, especially someone else's, or another project. We, or every company, every project, and around the world often meet the same problems, and we are in general reinventing the wheels of other brothers. A significant waste of resources. What if we could build a community, and people could share their code, services, addons, or plugins that could be easily reused so that it could be plugged into the app. like my jigsaw puzzle? Hyron makes packing and reusing quickly much easier, it can help the product development process become much faster!Besides, managing the modules I see is also a problem to note. With small projects is not a problem, but with a large project size, up to a hundred, thousands of services, why, when products, often have to change and maintain, as with startups. What happens when you are tasked with upgrading and maintaining a long and chaotic list? How to keep my app neat, clean, and easy to manage, easy to edit and upgrade when needed? That is when we need a centralized management model, and packaging, inheritance that the hyron provides.A technology will be hard to succeed, if it becomes difficult to reach people. And that is why I am constantly looking for ways to make it more and more simple, more friendly, to be easy to learn and use. even for a beginner, there is only a little basic knowledge of javascript that can be easily accessed, and create a professional application!However, in order to reach that future, it is necessary to help your friends, those who are like-minded, hope to work together and work with you :) A project is also very difficult to succeed since it has no funds to maintain. With a small amount of support from you, a cup of coffee can make a difference. If you find it helpful, support yourself by - Click watch to watch and star to help the project more popular to the community - Follow fanpage to get the latest news from Hyron: https://fb.com/hyron.group - Donate to help Hyron develop products faster and better: https://liberapay.com/thangdjw/donate - Introduce Hyron to friends to help hyron more popular - Join co-developers with hyron, to develop useful products

Submitted February 27, 2019 at 08:55AM by thangdjw

Sanely debugging puppeteer and fixes to common issues

https://docs.browserless.io/blog/2019/02/26/puppeteer-debugging.html

Submitted February 27, 2019 at 06:33AM by mrskitch

I want to spawn processes in a for loop, but I want the for loop to wait until the previous process finished to start the next one.

I am currently trying to understand child_process.spawn, I have an array of urls to download with aria2c, so my current code looks like this:for (i in fileLinks) { let arguments = '-x 15 -s 15 "' + fileLinks[i] + '" --file-allocation trunc --max-tries 100 --retry-wait 10'; let child = spawn("aria2c", arguments.split(" ")); child.stdout.on('data', (data) => { console.log(`stdout: ${data}`); }); child.stderr.on('data', (data) => { console.log(`stderr: ${data}`); }); child.on('close', (code) => { if (code != 0) { fs.writeFile("error.log", "url=" + fileLinks[i]\n"); } }); //I can't figure out how to block for loop without blocking stdout showing on the terminal } I want to have only 1 aria2c process running at one time, I know there is spawnSync in Node.js, but I won't be able to show stdout in real time if I use that.I also know aria2c can read url list from text file, but I can't figure out how to make Node.js understand which file is fully downloaded or not.

Submitted February 27, 2019 at 06:38AM by axzxc1236

Go for Node?

Now that Golang is increasing popularity, is it still worth to pick up Node?

Submitted February 27, 2019 at 08:16AM by Knox316

"Node.js multithreading: What are Worker Threads and why do they matter?" by Alberto Gimeno

https://blog.logrocket.com/node-js-multithreading-what-are-worker-threads-and-why-do-they-matter-48ab102f8b10

Submitted February 27, 2019 at 08:19AM by dobkin-1970

Deploy AWS Lambda Using Command-Line Tools (x-post /r/aws)

https://www.reddit.com/r/aws/comments/avb5rm/deploy_aws_lambda_using_commandline_tools/

Submitted February 27, 2019 at 08:30AM by nshapira

Tuesday 26 February 2019

How Node Is Helping To Propel Angular

http://go.geeklearn.net/5732eac9f4

Submitted February 27, 2019 at 05:13AM by GlennMulligan

Node, Express, Angular 7, GraphQL and MongoDB CRUD Web App

https://www.djamware.com/post/5c75d68880aca754f7a9d1ed/node-express-angular-7-graphql-and-mongodb-crud-web-app#.XHXfeBpALhA.reddit

Submitted February 27, 2019 at 12:53AM by didinj

Is there a smart way to do module management?

I feel like layering module after module to resolve dependancies is not a good way of doing things.Anyone got any tips or reading on how to structure approach of sprawling modules in projects?

Submitted February 26, 2019 at 11:26PM by Tactineck

"The Road to Workers" by Anna Henningsen

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

Submitted February 26, 2019 at 09:04PM by r-wabbit

How, in general, does Node.js handle 10,000 concurrent requests?

https://stackoverflow.com/questions/34855352/how-in-general-does-node-js-handle-10-000-concurrent-requests

Submitted February 26, 2019 at 08:04PM by major_x9

Need some help with nodejs

Hello guys!I start learning node js. It’s amazing language and i like it. But i need some help. Somebody who can direct me about project structure & code style and best practices. If you could help me i’ll be grateful.Here (https://github.com/kurakste/NodeRestfull) is my study project.Any feedbacks or recommendation are welcome

Submitted February 26, 2019 at 07:32PM by kurakste

Node.js task runners: Are they right for you?

https://blog.logrocket.com/node-js-task-runners-are-they-right-for-you-bb29ea30b7fa

Submitted February 26, 2019 at 06:21PM by nucleocide

Node.js task runners: Are they right for you?

https://blog.logrocket.com/node-js-task-runners-are-they-right-for-you-bb29ea30b7fa

Submitted February 26, 2019 at 06:55PM by efofex55

How find() Works in Mongoose

http://thecodebarbarian.com/how-find-works-in-mongoose.html

Submitted February 26, 2019 at 06:27PM by code_barbarian

Introducing Package Diff: A service for diffing npm packages

https://medium.com/intrinsic/introducing-package-diff-for-npm-e6487cc9b434

Submitted February 26, 2019 at 05:20PM by nucleocide

Unknowing devs might be sending data from their MEAN app to an unknown Google Analytics account. It looks like linnovate's MEAN stack source code includes someone's Google Analytics gtag as of Nov.28.

The commit in question

Submitted February 26, 2019 at 05:26PM by zs_-

Use Docker to Create a Node Development Environment

https://auth0.com/blog/use-docker-to-create-a-node-development-environment/?utm_source=reddit&utm_medium=sc&utm_campaign=docker_devenv

Submitted February 26, 2019 at 04:53PM by Ramirond

JSON response when passing from one file to another - asynchronous issue

Need some help with Typeorm. I want to add a new entity to a database already in use. Do I need to define a migration for this?

So as the title states, do I need to define a new migration for adding a new entity to the db. If yes, is there any way of generating this from the entity definition?

Submitted February 26, 2019 at 02:49PM by sioa

Just Created my first npm package express-user-model . Would love any suggestions.

https://www.npmjs.com/package/express-user-model

Submitted February 26, 2019 at 12:43PM by iAmritghimire

An overview of the JavaScript Ecosystem, from Frameworks to Tools for front and back-end development. - JavaScript Works

https://javascript.works-hub.com/learn/javascript-ecosystem-38-tools-for-front-and-back-end-development-37c7a?utm_source=reddit&utm_medium=blog&utm_campaign=b.sheridan

Submitted February 26, 2019 at 11:21AM by BenSE-JS

How Custom Node.Js Web Application can benefit?

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

Submitted February 26, 2019 at 09:53AM by nishant_12

10 Node.js Frameworks Worth Checking Out: Express, Loopback, Hapi, and Beyond

https://medium.freecodecamp.org/10-node-js-frameworks-worth-checking-out-express-loopback-hapi-and-beyond-7b537b590f89

Submitted February 26, 2019 at 10:11AM by MichaelOconnor1

Famous laws of Software Development

https://www.timsommer.be/famous-laws-of-software-development/

Submitted February 26, 2019 at 10:22AM by jason_dev

Guild Case Study: Using React Native and Node.js to Share Over 80% of Code Between iOS, Android, and The Web

https://www.monterail.com/blog/guild-case-study-react-native-development?utm_medium=social&utm_source=reddit&utm_campaign=mobile%20development

Submitted February 26, 2019 at 10:33AM by estatarde

Making a WEBSITE - DISCORD COMMUNITY SERVER - Day 23 - #100DaysOfCode

https://www.youtube.com/attribution_link?a=fn0K8hYLkbI&u=%2Fwatch%3Fv%3Dgw8lQmJppVk%26feature%3Dshare

Submitted February 26, 2019 at 09:00AM by Tyler_Potts_

Monday 25 February 2019

Angular7 CRUD with nodejs and mysql example

http://go.learn4startup.com/575409cd6a

Submitted February 26, 2019 at 04:53AM by GlennMulligan

Is using a module like concurrently to run processes in production a bad practice?

I am deploying a number of worker processes that will be doing backend processing work but not doing any sort of web serving or scaling. They are all super lightweight so I don't want to deploy each worker to its own instance and unfortunately I'm not super well versed with docker. The path forward to me looks like I could simply use something like concurrently to launch each worker process and then call it a day, but I'm not sure if that module is just meant to be used for local development. Thanks!

Submitted February 26, 2019 at 03:31AM by bch8

Authentication flow using custom authentication

TL;DR - Noob trying to learn about authentication without using a third party because I want to learn it first and not just jump into something I know nothing about and slap it in the application. What's the flow of authentication using JWTs and Refresh Tokens for log in, sign up, logout, without having to sign in every time like Discord.authenticate.js gistI'm really sorry for the long post... I know you're probably thinking "why are you trying to do your own authentication when you have third parties like Auth0?" Well I want to learn more about authentication and how it works before using a third party service. If I can do it on my own first, I will understand a lot more when I want to implement an authentication service for a real application.So I'm working on an authentication server for a chat application in Node that has the basics: log in, sign up, send verification code, confirm verification code, and logout. I got pretty much all of it working using JWTs, but then I thought that it would be nice to not make the user have to login every time a lot like Discord. So I looked into refresh tokens and wanted to implement that in my auth server. I think I have the flow down but like I said I'm learning this from very little knowledge. Everything has come from blogs, articles, and asking smarter people than I am such as you fine fellows.Anyway, I just wanted to get an idea on the flow of authentication. I got deep in the code last night and got so lost I'm pretty much starting over from the refresh token perspective. I want to do it right this time and make sure I have all the "gotchas" accounted for. So here is the flow that I think it should be:Login -> create JWT (expires in 15 mins) and Refresh Token (expires in 2 weeks) to send to the client both in the cookies (so it's sent with every request automagically) -> save the refresh token in the database -> go to secure route - let's say /profile - where a middleware called authenticate will be run to make sure the user has a valid, non-expired token -> if the token is expired but the user has a valid refresh token then create a new JWT, clear the cookies, add the new JWT and Refresh Token to cookies and send back to the client.Logout -> clear the cookies and remove the refresh token from the databaseWhat am I missing? I know I didn't go into great detail on the process I have but that's because this post is long enough, but the code is linked above if you want to check it out. I know it's ugly, but you understand now why I'm starting over.Thank you for reading if you made it this far, and I really appreciate your help.

Submitted February 26, 2019 at 03:07AM by Clink50

node binaries take 500ms just to load?

I just spent a couple weeks scratching my head over a problem with a program totally unrelated to Node, which was caused by node which. Basically, node which was installed globally, so it was overriding /usr/bin/which. GNU which runs v. fast (3ms) compared to node which (500ms+).At first, I thought the problem was with node which itself, so I filed an issue on GitHub. Then, when debugging the issue, I realized that it takes over 500ms before the first line of the script is even evaluated:```javascript!/usr/bin/env nodeconsole.log((new Date().getTime()) - Number(process.env.START)) var which = require("../") ... ```sh $ START=$(($(date '+%s%N')/1000000)) which which 570 /usr/local/share/.config/yarn/global/node_modules/.bin/whichI'm on a 4th-gen Core i5 desktop Linux box and seeing the same behavior on a similarly specced laptop (ThinkPad T460). Is this just how node is, or is there some way to improve the initial load time?

Submitted February 26, 2019 at 03:12AM by ryanlue

Should my app have 1 DB file, or have queries spread throughout

Is it good practice to have 1 db file that contains all the queries that will be needed in my app, or have them spread out. Currently, I have 1 db file that creates the db connection with my MySQL database, and is called in every single one of my controller files. Each controller file then has a bunch of functions/queries needed for that controller. Which is better practice?

Submitted February 25, 2019 at 09:53PM by ortz3

Will Node.js forever be the sluggish Golang? - Presenting new Node.js addons which drastically scramble the conditions

https://levelup.gitconnected.com/will-node-js-forever-be-the-sluggish-golang-f632130e5c7a

Submitted February 25, 2019 at 09:23PM by Ewers

Just visualized Github graphQL schema m graph and mock backend available here!

https://www.linkedin.com/feed/update/activity:6501918552876941313/

Submitted February 25, 2019 at 08:12PM by rob_mat

10 npm Security Best Practices

https://snyk.io/blog/ten-npm-security-best-practices/

Submitted February 25, 2019 at 07:09PM by r-wabbit

Private InfoSec Community

MentorSec is a private community dedicated to individuals who are both experienced in information security and those who are getting into the industry. The purpose of this server is to help individuals network and share industry knowledge. For entry members must first fill out a short application that gets manually approved by the moderators.Key Features:* Option to get paired up with experienced industry veteran* Live cyber security news and published exploits* Section dedicated to development in languages such as python, php, rust, c/c++* Community events and conferences* Job listings* Section dedicated to standards such as NIST, cyber essentials, GDPR* Channels to discuss certifications such as CISM, CISSP, GSEC, etc* Channel to connect with fellow members via linkedin* CTF channelsInvite Link: https://discord.me/mentorsec​

Submitted February 25, 2019 at 07:35PM by mentorsec

Node.js clean code

Looking for node.js/Javascript/Typescript coding guidelines, clean code, writing for testing or other code quality guides linksTia! Yaron

Submitted February 25, 2019 at 06:35PM by yaronpd

100% Code coverage: too much and not enough

https://chris.dev/2019/02/20/100-coverage-too-much-and-not-enough.html

Submitted February 25, 2019 at 06:46PM by notkraftman

Parse JSON bodies in Express without body-parser

https://codewithhugo.com/parse-express-json-body/

Submitted February 25, 2019 at 06:49PM by hugo__df

Beginner question regarding node and lambda, trying to connect to MSSQL

Hi, I'm currently new to node and I'm just trying to connect to an MSSQL database and putting the function on Lambda. However I'm very confused about this one particular concept. My current code is: sql.connect(config, function(err) { if (err) console.log(err); console.log("connected"); var request = new sql.Request(); request.query("SELECT * FROM COACHES;", function(err, recordset) { if (err) console.log(err); console.log(recordset); sql.close(); }); }); const response = { statusCode: 200, body: JSON.stringify({ message: "hello world" }) }; callback(null, response); I'm really confused on why this works, because I figured the callback would get called before the database retrieves the info, however it works. The following code that makes more sense to me, but does not work sql.connect(config, function(err) { if (err) console.log(err); console.log("connected"); var request = new sql.Request(); request.query("SELECT * FROM COACHES;", function(err, recordset) { if (err) console.log(err); console.log(recordset); sql.close(); const response = { statusCode: 200, body: JSON.stringify({ message: "hello world" }) }; callback(null, response); }); }); This makes more sense to me because the response gets sent back after the database has executed the query, however this gives me an internal server error and it does not connect to the database when I execute it in Lambda, any thoughts

Submitted February 25, 2019 at 05:59PM by jsherman10

issue with axios, how can i have multiple async await

iam requesting data from website json object,i have some data stored in mongodb, and based on the extracted data i do multiple request to the website json using axios,but the problem is if i request 40 times, the website blocks my request, saying 403, so i want to have timedelay inside the loopfunction timedelay(){return new Promise((resolve,reject)=>{setTimeout(()=>{console.log('time delay')resolve('time delay')},5000)})}function littletimedelay(){return new Promise((resolve,reject)=>{setTimeout(()=>{console.log('time delay')resolve('time delay')},200)})}async function callall(){console.log('called firststep')await firststep()await timedelay()await secondstep()await timedelay()/* await thirdstep()await timedelay()await fourthstep()await timedelay()await fifthstep()*//*secondstep()await dosometimepass()await deletetimepassrecords()await thirdstep()await dosometimepass()await fourthstep()//await fifthstep()//await sixthstep()*/}​then in the second step there is a loop, i want to stop a loop for some 10 seconds, so that the external website dont block me, just delay a little bit for the next request using axiosproblem is when i do it speedily, it blocks​in getdatafrometherscan, i am passing some parameters, in that i want to have some little time delay for next ether addressproblem here is multiple async and await , can it be worked out ?async function firststep(){console.log('firststep')return new Promise((resolve,reject)=>{exchangesethaddresslist.find({}).exec((err,docs)=>{console.log(docs)let ttl=docs.lengthlet i=0let totaleth=0docs.forEach(kk=>{i=i+1console.log(kk.ethaddress)getdataforetherscan(kk.ethaddress,kk.exchange)//here i want to time delayif(i===ttl){resolve('done')}})})})}

Submitted February 25, 2019 at 05:05PM by aminnagpure

Running Node.js on Kubernetes

https://banzaicloud.com/blog/running-nodejs-on-kubernetes/

Submitted February 25, 2019 at 03:30PM by b9Fb2H

19 Best practices for Automation testing with Node.js

https://www.lambdatest.com/blog/19-best-practices-for-automation-testing-with-node-js/?utm_source=Reddit&utm_medium=blog&utm_campaign=SS-25022019-4&utm_term=OrganicPosting

Submitted February 25, 2019 at 01:43PM by saif_sadiq

[Question] How to fetch emails with their markup with Oauth2 (Gmail and Outlook)

Currently coding an app with Electron + React: The aim is to allow the user to fetch his latest emails from whatever service (in this case either Gmail or Outlook). These mails need to be fetched with their HTML markup and attachments. The user then decides if he wants to "archive" them, after which another unrelated process takes place​So far I'm having a lot of trouble wrapping my head around Oauth2: What I've gathered so far is that using node-imap requires me to set the account to use "less secure apps" but from what I've read that is less than ideal. Not to mention it'd require the user to fiddle in their settings instead of just clicking "allow".Is there any "simple" way to set up Oauth2 in an Electron + React stack to fetch emails through node-imap? Tutorials I've found so far go to great tangents and always lose me somewhere along the way.​As for fetching the emails themselves, node-imap allows to fetch plain text but not the HTML markup. After a thorough search through their issues the owner mentions and even shows an example, that sadly doesn't work.​tl;drWhat is the simplest way to set up Oauth2 (on Gmail and Outlook) to be able to fetch emails and their attachmentsFollow-up question: In the case of Google, am I required to add credit card information per the recent changes in their API? I'm asking because this might pose legal problems in this specific case in my countryUsing node-imap (or a similar lib) how can I fetch emails as HTML markup, with their styles? (to be able to display them as they appear in the Inbox)​PS: I also fiddled around with Mailkit, and I've managed to get emails with their HTML and styling. If I can't make node-imap work for me I'm considering using it thanks to Edge.jsBut that still leaves the Oauth2 issue.​PSS: The HTML markup is not a hard constraint in this case, but would be greatly valued.​Any and all thoughts are welcome.Thank you

Submitted February 25, 2019 at 02:40PM by Unforgiven-wanda

GraphQL Resources: tools, tutorials, blogs

https://dev.to/tomekponiat/graphql-resources-top-tools-extensions--resources-for-beginners-2f13

Submitted February 25, 2019 at 01:36PM by oczekkk

Should I use Mongo for looking up permissions on every API call?

Hey everyone,My Node app has a security model that involves different users having different permissions. The users identify themselves by using JWT. On every call to a protected endpoint, my app:Checks the authentication token (using express-jwt)Checks the permissions they have (by extracting a user ID from the authentication token), to make sure they're authorized to access the specific piece of data they request. (This is what I'm working on, it's not implemented yet).Right now, the permissions are stored in Mongo. Is it efficient to call Mongo every time a user makes an API call? (The call would be made to a collection with a unique index).The other option I have in mind is to use something like Redis to cache the permissions, and to propagate every change to the data in Mongo to Redis as well.What do you think? Have any experience with something like this? The app currently runs on a 4GB machine with a Xeon CPU, but can be upgraded at will.At what load do you expect Mongo will feel the pain? Thanks.

Submitted February 25, 2019 at 12:07PM by tehnologie

How to Install Node.js and Create a Local Development Environment on macOS

http://dev.edupioneer.net/4d652bd803

Submitted February 25, 2019 at 11:14AM by Jacob9x0

Nodejs-Developer-Roadmap

https://github.com/aliyr/Nodejs-Developer-Roadmap

Submitted February 25, 2019 at 11:43AM by Ali-yousefi

Why koa is wrong?

Koa has been created for years but it will never be the next generation of express.Why?Mostly it is because of the wrongly designed middleware.Middleware we can know by name that it is a bridge between two entities.But koa's middleware is not. It is a container that wraps every so-called middlewares added later into the first one.so make the first so-called middleware most significant.The first middleware can modify every changes made by the middlewares inside it.That makes the middlewares inside the first one almost meaning less.​It makes koa very vulnerable to middleware attacks and will destroy security models you build for your web sites.​And also koa wastes a lot of efforts in rewriting express middlewares.​In effect, to achieve promises and async/await syntax with express is very simple, even no need to write almost all middlewares for express.​You can easily check it with vig:​import { VHandler } from "vig";let app = require('express')();const handler = new VHandler();​handler.set({prefix: '/demo',urls: ['/', '/hello'],routers: {get: async (req, res, scope) => {res.send('Hello world!');}}});​handler.attach(app);​app.listen(10000, function () {console.log('server running on http://localhost:10000');});​

Submitted February 25, 2019 at 09:50AM by calidion

Creating a REST API with Express.js and PostgreSQL

https://www.robinwieruch.de/postgresql-express-node-rest-api/

Submitted February 25, 2019 at 10:26AM by rwieruch

Help with Google-Cloud Speech API and Heroku events.js error

I'm trying to get a simple Google Cloud/Speech app running to convert my Mic audio to text. My index.js.belowvar app = require('express')(); var http = require('http').Server(app); var io = require('socket.io')(http); const record = require('node-record-lpcm16'); // Imports the Google Cloud client library const speech = require('@google-cloud/speech'); // Creates a client const client = new speech.SpeechClient(); /** * TODO(developer): Uncomment the following lines before running the sample. */ const encoding = 'LINEAR16'; const sampleRateHertz = 16000; const languageCode = 'en-US'; const request = { config: { encoding: encoding, sampleRateHertz: sampleRateHertz, languageCode: languageCode, }, interimResults: false, // If you want interim results, set this to true }; // Create a recognize stream const recognizeStream = client .streamingRecognize(request) .on('error', console.error) .on('data', data => process.stdout.write( data.results[0] && data.results[0].alternatives[0] ? `Transcription: ${data.results[0].alternatives[0].transcript}\n` : `\n\nReached transcription time limit, press Ctrl+C\n` ) ); // Start recording and send the microphone input to the Speech API record .start({ sampleRateHertz: sampleRateHertz, threshold: 0, // Other options, see https://www.npmjs.com/package/node-record-lpcm16#options verbose: false, recordProgram: 'rec', // Try also "arecord" or "sox" silence: '10.0', }) .on('error', console.error) .pipe(recognizeStream); console.log('Listening, press Ctrl+C to stop.'); app.get('/', function(req, res){ res.sendFile(__dirname + '/index.html'); }); io.on('connection', function(socket){ console.log('a user connected'); }); http.listen(3000, function(){ console.log('listening on *:3000'); }); If I run the above code locally, it works perfectly. If I remove all the Google Speech code, the server runs fine. But when using the above (Same as the Docs) Heroku spins up then throws an error.2019-02-25T09:07:38.000000+00:00 app[api]: Build succeeded 2019-02-25T09:07:39.926417+00:00 app[web.1]: 2019-02-25T09:07:39.926435+00:00 app[web.1]: > socket-chat-example@0.0.1 start /app 2019-02-25T09:07:39.926437+00:00 app[web.1]: > node index.js 2019-02-25T09:07:39.926439+00:00 app[web.1]: 2019-02-25T09:07:40.617413+00:00 app[web.1]: Listening, press Ctrl+C to stop. 2019-02-25T09:07:40.626395+00:00 app[web.1]: events.js:174 2019-02-25T09:07:40.626399+00:00 app[web.1]: throw er; // Unhandled 'error' event 2019-02-25T09:07:40.626401+00:00 app[web.1]: ^ 2019-02-25T09:07:40.626403+00:00 app[web.1]: 2019-02-25T09:07:40.626405+00:00 app[web.1]: Error: spawn rec ENOENT 2019-02-25T09:07:40.626407+00:00 app[web.1]: at Process.ChildProcess._handle.onexit (internal/child_process.js:240:19) 2019-02-25T09:07:40.626410+00:00 app[web.1]: at onErrorNT (internal/child_process.js:415:16) 2019-02-25T09:07:40.626412+00:00 app[web.1]: at process._tickCallback (internal/process/next_tick.js:63:19) 2019-02-25T09:07:40.626414+00:00 app[web.1]: at Function.Module.runMain (internal/modules/cjs/loader.js:745:11) 2019-02-25T09:07:40.626416+00:00 app[web.1]: at startup (internal/bootstrap/node.js:283:19) 2019-02-25T09:07:40.626417+00:00 app[web.1]: at bootstrapNodeJSCore (internal/bootstrap/node.js:743:3) 2019-02-25T09:07:40.626419+00:00 app[web.1]: Emitted 'error' event at: 2019-02-25T09:07:40.626421+00:00 app[web.1]: at Process.ChildProcess._handle.onexit (internal/child_process.js:246:12) 2019-02-25T09:07:40.626423+00:00 app[web.1]: at onErrorNT (internal/child_process.js:415:16) 2019-02-25T09:07:40.626425+00:00 app[web.1]: [... lines matching original stack trace ...] 2019-02-25T09:07:40.626427+00:00 app[web.1]: at bootstrapNodeJSCore (internal/bootstrap/node.js:743:3) 2019-02-25T09:07:40.636937+00:00 app[web.1]: npm ERR! code ELIFECYCLE I have all the Google Cloud credentials set up as environment variables in Heroku and they seem to be working fine.Any help is much appreciated.Cheers

Submitted February 25, 2019 at 09:49AM by CyrisXD

Using local storage to save JWT with React Redux?

Hello guys, actually i ended up a very basic authentication system using JWT, i'm saving it on my localStorage ( I'm using React & Redux ).Once a sign in the api returns me an object that contains User object and JWT i save these informations on my local storage even the user object, so every time the user open the website i check his JWT if it's available on the local storage or not, if yes i make him as logged in ( authenticated ) this works even offline, but i don't really like this one!​I'm really confused about what i should do , i have to use the JWT because i'm working with the Strapi CMS!I really want to make this works like many websites, i mean when you close the web browser the user disconnect, but i'm not sure if this is good or not, even Facebook website is not working like that, because if you close your browser you still authenticated!Thank you guys! any suggestion will be appreciated.

Submitted February 25, 2019 at 09:29AM by ayech0x2

How To Build a Node.js Application with Docker

http://dev.edupioneer.net/136fc1315d

Submitted February 25, 2019 at 06:40AM by Jewell980

Storing socket on database

I am try to create a private message web app by using socket.io all I done,it's working but I want to save it in a separate database for each users but I don't knowhow to do it And I try to store socket in database but it is circular json I am not able to store and retrieve the socket someone help me

Submitted February 25, 2019 at 08:05AM by mohamedimy

Why am I getting the error that tasks is not defined when I clearly already defined it?

https://www.reddit.com/r/learnprogramming/comments/auhn6u/why_am_i_getting_the_error_that_tasks_is_not/

Submitted February 25, 2019 at 05:46AM by LawlessWalrus1

Sunday 24 February 2019

I'm trying to understand how communication between server/client works using express and react. Looking for some help with a simple demo app I'm building.

https://www.reddit.com/r/learnprogramming/comments/auct6o/im_trying_to_understand_how_communication_between/

Submitted February 25, 2019 at 04:19AM by skytbest

nexus-di - A simple and powerful IoC container for JavaScript.

Hi guys,this is my new dependency injection/IoC container framework :https://github.com/danillosl/nexus-di.​and here are some projects demonstrating how to use it in react and node:nexus-di-basic-react-example on how to use nexus-di with react and redux.nexus-di-basic-node-example on how to use nexus-di with node.​I need help with any feedback you can give me, and a star would be much appreciated.

Submitted February 25, 2019 at 01:25AM by danillosl

PIRPLE - Stay Clear

So, apparently the owner Leslie Lewis doesn't know how to run a business. Normally, when users ask questions, they'll get answers, so long as they're within reason of course. However, that's not the case for Leslie. See attached photo from reddit user bishoymelek. In my own personal experience dealing with them, I witnessed their own support staff make statements that they had a hard time converting site visitors to customers. I then emailed them through their contact form stating I had some suggestions on how they could change some things to make their product more appealing to potential customers. Ignored for almost a week, I was tweeting to them on their Twitter channel about something else and made a statement that I was still awaiting a response for an email I had sent them about suggestions I had. I was told "You will continue to wait *insert 5 laughing emojis*". I replied that if they didn't want to listen to suggestions that customers had about how to improve their business, then it is their loss. Then they replied with something stupid about it being my loss or something like that, then more laughing emojis. I was then instantly banned from their platform.​It's clear that they don't care about anything but bringing in money, and it's clear that they don't know how to run a business. Thinkific is the third platform (that I know of) that they are hosting their content on. Deep searches through Facebook, LinkedIn, Instagram, Google, and reverse image searches can't even find a Leslie Lewis that matches the profile found @ SkillShare. Clearly, for whatever reason, if Leslie is even his actual name, he wants to hide. Don't give them your money. Plus, their courses are outdated anyway, but they try to push the content off as brand new.https://www.skillshare.com/profile/Leslie-Lewis/7653916

Submitted February 25, 2019 at 01:05AM by engineertdog

npm install | what you need to know

https://www.stackchief.com/tutorials/npm%20install%20%7C%20how%20it%20works

Submitted February 25, 2019 at 12:09AM by stackchief

What's the best practices on how to keep reference of images uploaded to S3?

I'm currently saving images to S3 but I'm just wondering how go about this:Say I have a product and there's 15 images I'd like to send off to S3. Currently I'm using multer and it's being sent over to S3 fine.My question is what are the best practices on what to save to my db and also id like to save the image reference in the order it was sent so when I go and retrieve the image's there in order that the user uploaded them.How should I go about this?

Submitted February 24, 2019 at 10:45PM by prgrmmr7

Finding Serverless’ Hidden Costs (x-post /r/serverless)

https://www.reddit.com/r/serverless/comments/aubs4a/finding_serverless_hidden_costs/

Submitted February 24, 2019 at 08:00PM by nshapira

Hey community!

Been learning node.js for the last few days, and digging how simple it is to get a server up and running. Im creating a few APIs first and then a few websites.Im coming from a ios swift and python automation background and I know I could have gone for Python for all of these, but node just seems like the obvious choice right now, based on the popularity etc.Ill soon be getting into some actual coding, the syntax has been pretty hard to swallow as I dont have any JS experience, but im definitively getting there.Just came to check out the reddit community! As I might be spending alot of time here these days (Hopefully not, as it usually would mean im having a extremely difficult problem lol!)

Submitted February 24, 2019 at 07:50PM by livinglibary

Docker images wth Node.js nightly builds (updated daily)

https://hub.docker.com/r/vdeturckheim/node_nightly

Submitted February 24, 2019 at 06:39PM by ecares

Introduction to Node.js by flaviocopes

https://nodejs.dev/

Submitted February 24, 2019 at 05:58PM by harlampi

Good tutorials for caching in node?

I saw a bunch of them using redis but they require calls to redis before every mongo hit, I get that that's how it's supposed to be because one would first want to find if it's available in cache on GET and update cache on POST but still feel that a better way would be available.Memcache or redis, comment up a tutorial that helped you apply it to your project as someone who's never used any caching before.

Submitted February 24, 2019 at 06:19PM by sum__sleples

The Right Abstraction for Lambdas

https://hackeryarn.com/post/the-right-abstraction-for-lambdas/

Submitted February 24, 2019 at 03:35PM by hackeryarn

Is it possible to run a script directly in command line ?

like$: node console.log("hey I'm here") Currently it returns:bash: syntax error near unexpected token `('​Any hint would be great,thanks

Submitted February 24, 2019 at 11:50AM by JoonDoe

In a set of chained promises with catch, how to know which promise failed?

// simple promise var asyncAdd = (a,b) => { return new Promise((resolve, reject) => { setTimeout(() => { if(typeof a === 'number' && typeof b === 'number'){ resolve(a+b); } else { reject('Argument msut be number'); } }, 1500); }); }; // promise usage asyncAdd(3,5).then((res) => { //first promise console.log(res); return asyncAdd(res, 33); }).then((res) => { // second promise console.log(res); }).catch((err) => { console.log(err); // catch }); how to find out which promise fails? Reasons: I may return different error msgs depending upon what failed.What's the common way to do it?

Submitted February 24, 2019 at 12:55PM by sum__sleples

Node.js question

Hi guys,​This is my first time using Node.js, and I am having a bit of a problem, I tried googling but couldn't find anything related to my question. Basically, I want to get a get request's value, let's just say i have a button on my EJS page that redirects to /car, and I don't /car defined yet on my server file, I want it so it creates the /car automatically. i'm not sure how to explain it, but i hope it explains well.

Submitted February 24, 2019 at 07:30AM by Houssam12

Is exist a way to put NodeJS in sleep mode?

I'm building a chat app that sync with my remote database every 180 seconds, I'm wondering how would you put the function in sleep mode when the server is free of any request anymore, hence free of need to sync with the remote database?​I have thought to the following solution-mockup inspired from this discussion on stackoverflow :function sleep(ms) { return new Promise(resolve => setTimeout(resolve, ms)); } async function demo(time) { console.log('Taking a break...'); await sleep(time); console.log('Two seconds later'); } My thread { ... } demo(); // restart the sleepMode's timeout How would you release a such function in your code?Any hint would be great,thanks

Submitted February 24, 2019 at 09:04AM by JoonDoe

node.js puppeteer evaluate page and get id an index of element

Hi, i need help why this code it doesn't work i can get the currentID var currentID; const calendarArr = await page.evaluate(() => { const tds = Array.from(document.querySelectorAll('.table tbody td')) tds.forEach(function(el,index){ if (el.classList.contains('c') ){ console.log(el.id); console.log(index); currentID = index; } }); return tds.map(td => td.textContent ); }); console.log(calendarArr); // this works gives arr ['','1','2'.....] console.log(currentID); // this doesn't work undefined why the console.logs doesn't log? in tds.forEach and currentID isn't savedalso when i tried to use variable for selectors it doens't work never resulted and was stuck in waiting if i have likevar selector = '.table tbody td'; const calendarArr = await page.evaluate(() => { const tds = Array.from(document.querySelectorAll(selector)).... like i know how to get it work i split it into two separet page.evaluate() i just need to know why, what i'm missing. for any pointing out or directing to some resource would be appreciated

Submitted February 24, 2019 at 09:05AM by morflsd

Saturday 23 February 2019

Client side rendering of a chart using dc.js

I'm confused about how to render an interactive chart/graph on a client side.​The current set up involves running express on a raspberry pie where the user would be able to see some sort of data when connected to the pie's connection. For the chart package, I have been leaning towards dc.js since it has all I need.​But for actually rendering the content on the website, I need some guidance. I have looked at Jsdom, but I'm apprehensive of using it at this time. If there is an easier way, I would appreciate the input.​Thanks in advance!

Submitted February 24, 2019 at 04:04AM by krodiv

What should happen to my application if the connection to my hosted database fails to connect?

Currently I have the server throwing database connection errors to the console for development sakes, but what should happen to the application if there was a 'no connection' situation to the hosted database? For instance, right now my Express server will just throw an error in the console(to notify me), and then keep on moving if Mongoose happens to fail connecting to MLab.I figured this is alright because the routes that are requested by the client that read/write to the database already have error handling logic inside of them that would return any database errors back to the client to handle.Anyways, just something I couldn't really put into the right words for Google. Thanks for reading!​

Submitted February 24, 2019 at 03:56AM by skidmark_zuckerberg

How should I handle a form with file input and a dynamic table?

So I have a form and inside the form I have a few input fields but I also have a empty table that a user can add rows to.Also have a file input of image(s).​How should I get this data to my backend as I'm having trouble with the table data. I have the data stored as a js variable but not sure how I can get that to my backend.Any help would be appreciated.

Submitted February 24, 2019 at 04:04AM by prgrmmr7

JavaScript Tips and Tidbits

https://github.com/nas5w/javascript-tips-and-tidbits

Submitted February 24, 2019 at 02:44AM by bursttanalytics

npm rebrands (wombat begone)

https://www.npmjs.com

Submitted February 23, 2019 at 05:34PM by DrCorporate

Using Node 11.7 Worker Threads with RxJS Observable

http://on.edupioneer.net/a959911e80

Submitted February 23, 2019 at 05:11PM by JJohnson0x

UI Component of Docker

Hello, here is a somewhat naive question. I am curious to know what the technology behind the Docker Desktop UI component is. By that I mean the whale icon and the drop down you get when clicking it. I know docker itself is written in Go and Kitematic looks like is written in Electron. I am working on a project that is written in Go and has a cli that comes with it, but it would be nice to provide some small UI feature similar to that of Docker.

Submitted February 23, 2019 at 05:18PM by CoffeeBay77

Weird socket.io bug

User Authentication (Passport?? + MySQL) in Node

I have been scouring the internet for guides on how to implement user authentication and I am still very confused. If any kind soul could please explain to me how to implement such a thing or point me to a guide that is beneficial I would be forever grateful.​I have a MySQL database that already stores usernames and bcrypt passwords. I already have a login page and registration page. I need to be able to only allow users to access their data on the web application. I have separate files for post/get requests. Which I couldn't find any information on how using user authentication across multiple files worked. (Maybe you just add in that authentication check thing to every js file?)​Thank you.

Submitted February 23, 2019 at 04:17PM by kevinisathought

socket.io alternatives?

Hi, im looking for socket.io alternative which can be integrated with express.js server.I saw simillar thread which is by the time im writing this archived so i had to ask this since i couldn't find anything which could work with express, tried websocket but i couldn't make an integration with express server, even the docs of it doesn't have any resource which could solve my problem.

Submitted February 23, 2019 at 02:57PM by pakeey

Adding a single socket endpoint in a RESTful API server

I have an API server but there's a case where I need to display/post real time information in a web app​A good example would be:/:room-id/messages - returns all messages (REST api endpoint)/:room-id/latest-message - returns the latest message only (updated in real time whenever someone posts there) (socket endpoint)​Is this possible using a single server? If so, where can I learn more about such a case?

Submitted February 23, 2019 at 03:53PM by dutryz

Making a website - About section & colour changing navbar - Day 21 - #10...

https://www.youtube.com/attribution_link?a=4hRLaV1Axrk&u=%2Fwatch%3Fv%3DGURsa_VoadE%26feature%3Dshare

Submitted February 23, 2019 at 10:57AM by Tyler_Potts_

How do I read only the first value inside a Stream in order to execute a function once?

I have a Readable Stream from which I get ids 1,2,3,4 etc and for each id, I get numbers like 10,11,12 etc. Numbers or values could be anything. A sample workflow would be as follows​IDValue11001872154210913862478As seen above, when I start streaming, the first value of ID 1 is 100 and first value of ID 2 is 154, I want to call a function ONCE with these values but how do I capture them. Some direction would be appreciated

Submitted February 23, 2019 at 10:20AM by mypirateapp

To Create An Evolvable API, Stop Thinking About URLs

https://medium.com/@fagnerbrack/to-create-an-evolvable-api-stop-thinking-about-urls-2ad8b4cc208e

Submitted February 23, 2019 at 10:47AM by fagnerbrack

Friday 22 February 2019

Correct way to end code execution after res.send()

After a res.send() is used I want to end code execution, so to do this I've used a return statement like below:app.post('/someEndPoint', (res, res) => { if (someCondition) { return res.send('success'); } /*Some other code that will not execute because a return statement was used above*/ }); After doing some searches on Stackoverflow, some posters recommend this as a way of ending code execution, while others state that doing this is "semantically incorrect".Is what I did fine, or should I not be doing this?

Submitted February 23, 2019 at 03:54AM by MonkeyOnARock1

This Week on npm v20190222: eslint@5.14.0, next@8.0.0

https://js.report/blog/this-week-on-npm-20190222

Submitted February 23, 2019 at 01:14AM by code_barbarian

How do you guys usually save/retrieve S3 images?

Am new to S3, was wondering what are the best practices around saving and retrieving S3 images.From what I read online, I should save the `key` and then call on `getSignedURL` to then display the image on the client side?

Submitted February 23, 2019 at 01:56AM by prgrmmr7

Packages for building dynamic reports? Carbone, etc?

I'm currently using carbone for generating large reports but was wondering if anyone knew of any other open source report generation packages? I want to try alternatives before I settle on carbone, and if you guys have recommendations I'd love to hear them.

Submitted February 22, 2019 at 11:31PM by redis_help

Can someone walk me through moving a react project to github and hosting it on github pages?

I've been googling and asking and simply cannot accomplish what I want to do. I'll give you guys a starting point of where I'm at.I make a folder on my computer and call it "reactproject".I right click on it and open with VS Code.In the terminal in VS code I type npx create-react-app . and all of the react stuff gets downloaded.I create my react application and it works just fine when I a do "npm start"After that is where everything becomes shit. This is my first react app and I've been uploading my previous projects (which are just vanilla js, html, and css projects) to github using the github desktop app. I initially tried this but it did not work with this react application. I then googled how I upload react projects to github pages and have come across several ways to do it. I've tried them and they're not working. Can someone just hold my hand through this and clearly delineate my next steps like I did with the above 4? I've been stuck on this all day.

Submitted February 22, 2019 at 09:10PM by 01123581321AhFuckIt

AWS Elastic Beanstalk deploy question

I'm hoping someone can help out before I've torn all of my hair out.​I built a really basic set of endpoints in Node JS using Express. All is running perfectly from my local dev environment. Deployed to AWS on Elastic Beanstalk, and the service posts successful responses from Postman, and the GET endpoints return data just fine if I just put the URL in the browser. The problem is, AJAX requests from simple front-end code on a Shopify site not only time out, but the Node console logs I have set on the endpoints don't even register that the AJAX request arrived. Tested the front-end code with endpoints on a non-AWS service that I know works and they return correctly. My console logs register correctly when I hit the endpoints with Postman. Doublechecked URLs, etc.​For CORS stuff I have:app.use(function(req, res, next) {res.header("Access-Control-Allow-Origin", "site");res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");next();});Is there some AWS setup thing I might be missing, maybe around inbound traffic, to have client-side AJAX requests be accepted as inbound traffic and respond successfully that I just don't know about?​My inbound rules currently are port 80: 0.0.0.0/0And 443 same thing, but this install doesn't have an SSL certificate, so I'm not sure that matters. Outbound is wide open.​AJAX request is just this in case I missed something AWS-centric that needs to be here?$.ajax({url: url,type: 'POST',async: true,crossDomain: true,contentType: 'application/json',data: JSON.stringify(data),success: function(res){console.log('response-received');console.log(res);},error: function(res){console.log('error');console.log(res);}});​It's a Friday, so am I just missing something really simple here? I've been at this for tooo many hours. Any help greatly appreciated. Thanks!

Submitted February 22, 2019 at 08:15PM by bohr314

How to Read graphql body from Request?

I may be going about this all wrong, but I'd like a middleware piece that can read the graphql request. If it is for login mutation only, I can let it through without a valid session, else require a valid session. I could keep a whitelist of queries and mutations that are allowed through.I can't figure out where in Request the graphql is actually being stored.I'm using express. Any advice?I'll update this as I figure out more.const config = require('../config/config.js') const fs = require('fs') const path = require('path') const express = require('express') const expressGraphql = require('express-graphql') const expressJwt = require('express-jwt') const {schema} = require('./schema') const {root} = require('./root') const app = express() // JWT, applies a user to the req if the jwt is valid, req.user app.use('/graphql', expressJwt({ secret: config.sessions.jwtsecret, credentialsRequired: false }), function(err, req, res, next) { console.log('123') if (err.name === 'UnauthorizedError') { res.status(401).send('invalid token') } // currently, authorization happens at the resolver level. // Resolvers check that the session is still in the session store // This allows functions like login to run without a token // But will automatically reject bad tokens } ) // Test Middleware var logger = function (req, res, next) { console.log('\n\n\nLOGGED') console.log(req.user) console.log(req) next() } app.use(logger) // ================== This is the part I'm trying to figure out =================== // I want to make a peice of middleware that inspects the graphql request. // if it is for login only, pass it through // anything else, get the jwt, req.user, verify that the session is active // If they have an active session pass it through // Apply graphql to the App app.use('/graphql', expressGraphql({ schema: schema, rootValue: root // graphiql: true //pretty much limited to login because you can't modify header to include jwt })) // Start the server const server = require('https').createServer({ key: fs.readFileSync(path.join(__dirname, '../cert/key.pem')), cert: fs.readFileSync(path.join(__dirname, '../cert/certificate.pem')) }, app) const port = process.env.port || config.app.port server.listen(port, function () { console.log('Server started. Listening on port %d in %s mode', port, config.mode) }) ​

Submitted February 22, 2019 at 08:19PM by sleepyj222

I built this tool to solve my biggest frustration with the command line

Hey all, I have spent a few months coding an open source tool that has helped me tremendously with my day-to-day development and devops tasks involving the command line. My tool is called nama and can be found at https://github.com/alecdibble/nama. It allows you to store, organize, and easily run aliases . It incorporates tab autocomplete to make searching and running aliases really easy and fast. Right now, it only supports bash. nama is written mostly in node, with some bash scripting to provide part of the console-based functionality.I have a lot of freelance clients and need to remember many commands day-to-day, including SSH servers, dev environment scripts, database tunnels, handy backup scripts, and more. nama has helped me switch contexts and not have to stress about looking up common commands constantly. I have also built out a cloud service, called AliaSync, that is powered by the https://github.com/alecdibble/nama-sync package. I wanted a way to have my commands available on remote servers and keep them in sync on all of my computers, so I created AliaSync to provide that. It doesn't yet have a website or any web present besides the nama-sync github & npm pages.I am posting to get general feedback about the idea and am hoping that someone is willing to try it out and report bugs or give more detailed feedback. Thank you!

Submitted February 22, 2019 at 07:30PM by alecdibble

[HELP] Can anyone share me a good resource to learn about building Microservices with Node.js?

Or a sample repo from Github will do.

Submitted February 22, 2019 at 05:07PM by xzenuu

What's the best practice to build an app with Firebase and vue.js?

What's the best practice to build app with Firebase and vue.js?

Submitted February 22, 2019 at 02:42PM by orlando007007

What are the best solutions to protect website against XSS in node?

I currently am designing a wiki, and eligible members will be able to post data. I want to make sure that the data sent won't have script tags(or any other abuses - junior dev here) before being written to DB so that it will not have a major security opening. Any libraries or functions that I can use?

Submitted February 22, 2019 at 03:49PM by Yittoo

Enforcing Code Quality for Node.js

https://hackernoon.com/enforcing-code-quality-for-node-js-c3b837d7ae17

Submitted February 22, 2019 at 11:57AM by ginger-julia

AWS S3 Access Denied

So I'm pretty new to AWS and I feel as if I'm doing everything correct but when I programmatically try to upload an image to my S3 Bucket. I get an error of Access Denied.​I've created a IAM UserThen put that user into a IAM group with permission of AmazonS3FullAccessI then use the User's Access Key ID and Secret Key to programmatically save an image via aws-sdk in node.js but i get an error of Access Denied.​Something I'm doing wrong?​EDIT:​Found out it's because `Block new public ACLs and uploading public objects (Recommended)` was true. Once I made this false it worked.What's the solution for this as I'd like to keep that true.

Submitted February 22, 2019 at 11:19AM by prgrmmr7

Testing OAuth2-protected API endpoints, it is even possible?

It seems that a lot of people worship test-driven development and I think it super helpful if you develop API endpoints. But I am just wondering how to deal with OAuth2-protected endpoints (e.g. protected with LinkedIn-OAuth2).Mocking the OAuth2 provider would need to mock/rewrite the entire server app, isolated unit tests without login state don't seem to be really helpful. Setting up browser tests with puppeteer simulating all the clicks through the site just to test some protected API endpoints feels like taking a sledgehammer to crack a nut (paired with the problem that's is not so easy to create test accounts on LinkedIn without getting flagged).So, do I miss something? How do people deal with this? Is this entire thing about TDD/BDD just empty talk and only basic stuff is being tested (like the server responds status 200)?FYI, to get the auth code from the OAuth2 provider (e.g. LinkedIn) the user needs to go through the login flow. So, I don't see any way how to just provide a given code while skipping the login.​

Submitted February 22, 2019 at 06:45AM by desmap

10 npm Security Best Practices | Snyk

https://snyk.io/blog/ten-npm-security-best-practices/

Submitted February 22, 2019 at 08:03AM by hfeeri

Dynamic content from database on page load?

Hello, I am currently trying to move my website from PHP to NodeJS. One feature of PHP is the ability to have PHP code and html code load within the same file. This would allow pages to load dynamic content from the sql database before the page rendered. For example, showing a profile page with user information.Is there any way to do this in NodeJS? I’ve heard of ejs but I’m not sure if it is exactly what I need. And I’m not sure how to implement it if it is what I need.

Submitted February 22, 2019 at 08:15AM by Official_CDcruz

How to Perform Web-Scraping using Node.js

http://on.morioh.net/ee0bdf91d6

Submitted February 22, 2019 at 08:47AM by HazelMadsen

Thursday 21 February 2019

Please mention a book to learn Node.js for beginner.

A best best book for node.js

Submitted February 22, 2019 at 05:51AM by Chawki_

Check your internet connection speed from the command-line

https://github.com/sindresorhus/fast-cli

Submitted February 22, 2019 at 05:23AM by sindresorhus

How can I execute different multiple queries in using mongoose?

Currently I'm building a blog and on single post page I also need to show recent posts. To get single post by id I usedblogPost.findById(id).then((doc) => {Now I also want to executeblogPost.find().then((doc)=>{in order to get 5 recent posts. Can someone tell how how can I execute more than 1 queries in single client request?

Submitted February 22, 2019 at 03:57AM by pverma8172

Node-based Open Source CLI Tool

Hey all, I have spent a few months coding an open source tool that has helped me tremendously with my day-to-day development and devops tasks involving the command line. My tool is called nama and can be found at https://github.com/alecdibble/nama. It allows you to store, organize, and easily run aliases . It incorporates tab autocomplete to make searching and running aliases really easy and fast. Right now, it only supports bash. nama is written mostly in node, with some bash scripting to provide part of the console-based functionality.​I have a lot of freelance clients and need to remember many commands day-to-day, including SSH servers, dev environment scripts, database tunnels, handy backup scripts, and more. nama has helped me switch contexts and not have to stress about looking up common commands constantly. I have also built out a cloud service, called AliaSync, that is powered by the https://github.com/alecdibble/nama-sync package. I wanted a way to have my commands available on remote servers and keep them in sync on all of my computers, so I created AliaSync to provide that. It doesn't yet have a website or any web present besides the nama-sync github & npm pages.​I am posting to get general feedback about the idea and am hoping that someone is willing to try it out and report bugs or give more detailed feedback. Thank you!

Submitted February 22, 2019 at 04:41AM by alecdibble

Building MongoDB Dashboard using Node.js

http://go.morioh.net/7d0a8beb7a

Submitted February 22, 2019 at 04:57AM by DavisTL

How to retrieve selected value on a dropdown menu in handlebars (hbs files)?

My goal is to retrieve the selected value from a list of values on a dropdown menu and then the app.js will be able to access to it. I uploaded this question on stackoverflow, but it has gotten no replies yet. Would appreciate for your help! Thank you!https://stackoverflow.com/questions/54816621/how-to-retrieve-the-selected-value-on-a-dropdown-menu-in-handlebars-hbs-files

Submitted February 21, 2019 at 11:58PM by survivorsheep

danibram/scrapy-slack-bot

https://github.com/danibram/scrapy-slack-bot

Submitted February 22, 2019 at 01:32AM by danibram

Is it possible to interact with a CLI application using node.js?

I'm trying to build a game server discord bridge application using node js and I can't find how to(if possible) read and write from a console window.Btw,app will be running on a Linux serverEDIT: nvm,I found what I was looking for here: https://nodejs.org/api/child_process.html

Submitted February 22, 2019 at 02:00AM by alexkar598

Why am I not getting back one of the strings I imported when I use db.collection.find()?

https://i.redd.it/q547okzc51i21.jpg

Submitted February 22, 2019 at 02:21AM by LawlessWalrus1

NodeJS Job Opportunity - Greater DC Area - 5 Openings

A leading Government Systems Integrator is in need of 5 backend Node.js Developers for initial 12 month contract onsite in Windsor Mill, MD. The Node.js Developers will be members of an Agile Team working with other Agile teams, System Architects, Test Architects, Database Engineers, DevOps, Implementation team, Global Validation team, IT Infrastructure & Operations Team and External System Owners to develop a government application using open source technologies and products.​Senior level full-stack software development experience with Node.js (2 or more years) with detailed understanding of user interface frameworks, back-end software architecture interactions and node module capabilities.Two or more years' experience with JavaScript frameworks/technologies such as React.js, Express.js, MobX, Redux or Flux.js.Strong development experience with developing RESTful Web Services using Node.js.If this is something you'd be open to or interested in, please private message me!

Submitted February 21, 2019 at 11:24PM by sarah_ITRecruiter

How to call python program with std input in Node?

Mongoose Data collection

is it possible to run a function on a mongdb collection without having to pull everything into ram first? I'm trying to get certain data from a db, and later I'm using that data to work some math on it. If the output meets a condition, then I'll keep the data; else, I'll get rid just ignore the whole object in the collection. So, Do I have to load everything onto memory first by pulling the data from the db, or is there a better way? (btw, I'm using mongoose)

Submitted February 21, 2019 at 09:50PM by r_gui

February 2019 Security Releases

https://nodejs.org/en/blog/vulnerability/february-2019-security-releases/

Submitted February 21, 2019 at 10:56PM by dwaxe

What means "NodeJS.Timeout"? I haven't found it in doc

here the link of the sample, line.10: https://codesandbox.io/s/lpn3261j99

Submitted February 21, 2019 at 07:41PM by JoonDoe

[ Express JS] Maintaining middlewares with side-effects

Hey! I've been working with express.js for the past two years now, and one thing that I found to be quite difficult is how to properly document and enforce the state of the req object when multiple middlewares are mutating it. For example, I might have a validation middleware that updates the req.body object so that it only contains valid inputs. Another middleware might fetch an account from the database based on the id in req.body.id, and place it inside of req.body.account.When chaining these middlewares together, there is nothing that is preventing me from improperly chaining the middlewares together, with the exception of diligent coding.Has this been an issue for you all? If so, how do you manage this?A toy example is here: https://gist.github.com/pierreTklein/feca0766e4433ebb880a4558ac2a0706

Submitted February 21, 2019 at 08:12PM by ptklein

Need help with simple code

First off, I'm totally new to nodejs, and javascript in general. Basically I want to access the x variable outside the request method. Now x is just "{}" outside the reqeust method, but what I want it to be inside the request method. I think the problem has something to do with async, but not quite sure.I'm using the "request" package, and the code below is simplified.​function func() { let x = {}; request(url, function (error, response, body) { x = JSON.parse(body); }); return x; }Thank you​

Submitted February 21, 2019 at 07:19PM by bjabot

Free hosting for Node and MySQL

Hello, first post on this sub.I am doing some personal work on a couple projects and was wondering if anybody knew of the best service to deploy a node web app on. I'm currently using Heroku, but the ClearDB free option only allows for 5MB which is practically nothing. I am a student so I'm hoping maybe somewhere will have a fee plan for students? If you know of anything please give me some suggestions, even if it's super cheap. I am definitely going to need more than 5MB....

Submitted February 21, 2019 at 07:22PM by theStringArray

Use find-my-way in Koa

Hi everyone,I decided to release two packages that I have using myself. The first one is koa-my-way, which integrates the well-known find-my-way router into the koa ecosystem.The second one is route-imperator. It's a small utility to write express-like routes, but using a trie/radix/prefix router like find-my-way. It organizes declarative routes in an imperative way and allows nesting.Let me know what you think.

Submitted February 21, 2019 at 05:04PM by javitury

Building a Serverless Mixpanel Alternative with Node.js

https://statsbot.co/blog/building-an-open-source-mixpanel-alternative-1

Submitted February 21, 2019 at 03:21PM by brownkidd

A to Z of Node.js Packages(unconventional)…

https://blog.bitsrc.io/a-to-z-of-node-js-packages-unconventional-41178b2fbf30

Submitted February 21, 2019 at 02:38PM by JSislife

Callback Hell - A guide to writing asynchronous JavaScript programs

http://callbackhell.com/

Submitted February 21, 2019 at 02:03PM by wadie31

How to use RabbitMQ and Node.js to build a scalable, fault-tolerant web application

https://www.manifold.co/blog/asynchronous-microservices-with-rabbitmq-and-node-js

Submitted February 21, 2019 at 01:25PM by rab_eye

Need help uploading to AWS S3 using multer.

https://stackoverflow.com/questions/54765881/multererror-unexpected-field-when-trying-to-send-formdata

Submitted February 21, 2019 at 01:13PM by AlexOtero32

Server vs Client for image upload.

Hey guys, wondering what's better for uploading images to S3, should I do it from my server? Or straight from the browser client side?What's the best approach for this in the industry?My use case is uploading many images at once ~15 for a e-commerce platform.Also side question, do you usually fetch the image by the url that's saved in the database? Or are there more efficient ways.Thanks!

Submitted February 21, 2019 at 12:30PM by cutegamerchick

Wednesday 20 February 2019

OvernightJS: The best way to use ExpressJS with TypeScript

https://levelup.gitconnected.com/overnightjs-the-best-way-to-use-expressjs-with-typescript-35d71941aade

Submitted February 21, 2019 at 06:13AM by theTypeScripter

Node.js - Express Persistent Session Store with PostgreSQL + Sequelize

http://dev.edupioneer.net/056f73b874

Submitted February 21, 2019 at 06:32AM by KateParryz

Why Hybrid Approach is a Good Choice for Mobile App Development?

User are concerned with better experience. Hybrid mobile application making it more user-friendly. And also hybrid app is very cost-saving in comparison to developing a native mobile app. Read more reason to choose hybrid application.

Submitted February 21, 2019 at 06:44AM by Cingant

How to send data bidirectionally between an infinite running Python process and express/Nodejs

I have an node.js express app that is handling requests on the frontend dashboard for users. I need to do some computations on Python and run some tasks using Celery. After some research I found the following methods. I am feeling overwhelmed with the number of possibilities here. Would appreciate some direction...Child Process (spawns and dies when the task is over I guess)Python shell (same as above)ZeroMQ or any other similar queuing systemI could have Python store the computed values to redis and access them from express route handlerI could have Python use a tornado web server to directly serve the computed content on a different route (express has lusca not sure what Tornado offers here for CSRF, also not sure if Tornado can play nicely with Celery, the TCELERY library seems seriously outdated)I could have Flask run a separate webserver with Threads to do IO and processes to do computations and serve results directly. (Lusca XRSF no idea, though it seems Celery is good to go with this approach)I could setup a pubsub channel on redis between normal python script that runs infinitely in DAEMON mode and the express serverPhew! so many choices, I am feeling paralyzedWhat would be a decent way to do this. Can anyone share their experience on this, thanks in advance

Submitted February 21, 2019 at 05:46AM by mypirateapp

How to link css stylesheets to .hbs file?

I have been looking for suggestions on stackoverflow and all over the internet e.g. https://stackoverflow.com/questions/47371954/cannot-access-stylesheet-with-handlebarshttps://stackoverflow.com/questions/46116175/how-to-add-stylescss-and-js-to-handlebar-files Yet, I am still having problems on linking the css file to all hbs files.Look forward to your suggestions, thank you!My directory looks like this:public-views --main.hbs -stylesheets --style.css -app.js in app.js, I haveapp.use(express.static(path.join(__dirname, '/public')));in main.hbs, I have in the head tag.

Submitted February 21, 2019 at 03:00AM by survivorsheep

Keep Calm, and Keep Coding with Cosmos and Node.js

http://go.morioh.net/73d755a13d

Submitted February 21, 2019 at 04:04AM by DavisTL

For vs forEach() vs for/in vs for/of in JavaScript

http://thecodebarbarian.com/for-vs-for-each-vs-for-in-vs-for-of-in-javascript.html

Submitted February 21, 2019 at 12:54AM by code_barbarian

Where to store JWT?

I've been doing a lot of research on this and I can't really find a good solution to this. I think it really depends on what you want for your application, but that doesn't really help me. I'm making a small chat application using Electron and Node.js and I'm working on the authenication flow right now. I'm implementing passport.js (if you have a better suggestion please let me know, I'm open to anything) and from the research I've done you can store it in a lot of places but it seems that people say never store it in localStorage due to XSS attacks. Storing the JWT in cookies is good because you have the option to add the secure and httpOnly option to it which prevents such attacks. I thought that storing in the Authorization header was best because isn't that what it's there for??Anyway, can someone lead me in the right direction? If you need more detail here is the current implementation on Github: https://github.com/clink73/KibChat-ServerThank you for the help!

Submitted February 21, 2019 at 01:00AM by Clink50

Join a Node project

Hello!I'm Rodrigo, and i'm currently looking for a project to join, so I can gain experience and start a developer carreer.I just finished my B.Tech degree on Software Development and have never joined any project.​I'm not looking for paid projects. (but i wont refuse).​I have little experience with node, express, RoR, Java, and have solid Linux knowledge.​Any response is greatly appreciated!​Thanks!​​

Submitted February 20, 2019 at 10:19PM by rt3norio

Learning about dev habits

Hey guys,Sorry to post a bit off-topic, and apologies in advance if you've seen my thread in another reddit. I'm just trying to get the best answers I can.I'm starting a new job at a tech company, which revolves around Developer Marketing. Although I've loved tech and programming since I was a kid, I never really had the technical ability to do it myself. Personally, I call it fascinatingly boring. I'm always so excited to try and learn a new language, but usually, within a couple of lessons I start feeling overwhelmed and with the "uneventfulness" of web tutorials, I hit a wall (and fall asleep). All this to say although I respect developers, I'm unable to feel your pain first hand.But enough about me. The reason I'm writing all this is because I wanted to do some homework and be prepared as much as I can. I was hoping some of you may be so kind as to spend some time answering all or some questions I have for you (they're only "10"), in hopes of doing a good job. I thank you all in advance for getting this far and for your help from here on out.Onto the questions:What are your main destinations for coding related themes? (Websites, Blogs, Q&A sites, etc.)What are the communities you rely upon to communicate with others? (reddits, BBS, etc.)Are there any personalities you follow or look to for info, advice or tips? 3a. What did they do to catch your attention? 3b. What do they keep doing for you to keep going back?Do you use any social media accounts for personal use? 4a. If so, which ones? 4b. How do you use them? Only for consumption or do you actively participate?Do you allow yourself to be tracked online? (Advertising IDs)5a. If so, only on work computers, or also on your personal ones?Regarding the major cloud service providers (Google Cloud, MS Azure, AWS):When looking for a service to use, what are your priorities when doing research? (Pricing, Features, Granularity, Security etc.)Is there any particular service you prefer using often? Is it a nobrainer? 7a. What does that service offer to make you choose them over the others?Is there anything missing in all these services that you would like added?Regarding Marketing, developers are notoriously a very hard audience, because you guys do so much research and are so logical and impartial, usual approaches don't work with you guys. So here is my final question(s):If you were working in Marketing, how would you target yourself?What do you think would be the most effective way to communicate a message to you?

Submitted February 20, 2019 at 10:40PM by SmoothMarx

First published article about Node.

I have just written my first ever article about programming, and it has been published by Smashing Magazine.It it about ES6+ JS, Node, APIs, HTTP, JSON, and more. It is the first part in a series which will eventually cover building an API with Express and performing server side templating.If you have time, I'd be interested to hear what your thoughts are for improvement.Link:https://www.smashingmagazine.com/2019/02/node-api-http-es6-javascript/Thank you.

Submitted February 20, 2019 at 10:11PM by JamieCorkhill

What is the best Web Hosting site that I can use the MEAN stack that can handle say 500 concurrent requests a second?

No text found

Submitted February 20, 2019 at 09:34PM by allenyoung101979

HEDON header file

hey everyone,i created a simple( ,but messy (for now) ) header file.the whole idea was to create a tool that can bind functionality one-to-one, function to javascript function, array to javascript array,with the bare minimum integration code as possible when you bind a c or a cpp code with js code .i am wondering if anybody can find it useful, and if i need to it alive.unlike "nan" (which i like), i really don't want anybody to learn any macros or complex engine stuff.i know it's far from perfect and i would really like some feedback bad and worse.there isn't much,but the end to end test are in the bin test files and the test files.the git repo is : https://github.com/butterfly0x0/HEDONthe npm page: https://www.npmjs.com/package/hedonhthanks!

Submitted February 20, 2019 at 08:14PM by butterfly0x0

Question about interpreter location in shebang

Currently building a CLI and I have a question about the shebang line at the top -​what does env node mean in /usr/bin/env node and how is it any different from /usr/local/bin/node?​I know the point of the shebang is to point the file (once made into an executable) to the interpreter to be used.​When I use the which node command on terminal, I get /usr/local/bin/node so shouldn't I be using THAT path in my shebang? Also what does env really mean - the space between env and node in /usr/bin/env node made me think env is a directory which is clearly isn't. Any help would be much appreciated - nothing in my code is broken (for now) but I'm just curious as to how this works under the hood.

Submitted February 20, 2019 at 08:21PM by ksatia

Forwarding Request

I would like to create a service that allows only a list of IPs to connect to my server and they will send requests to a site that I will forward through a list of proxies and they can use a certain amount of traffic like 2GB, etc. The proxies they get will also have to be unique to them and rotates from the list every few minutes. How would I go about making this?

Submitted February 20, 2019 at 05:47PM by CanuckianGamer

Object.assign vs Object Spread in Node.js

http://thecodebarbarian.com/object-assign-vs-object-spread.html

Submitted February 20, 2019 at 06:05PM by dobkin-1970

Made a wallpaper of my projects nodejs code, hope you like it

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

Submitted February 20, 2019 at 06:34PM by arivan_amin

Why Node.js > Spring in 2019

https://www.stackchief.com/blog/Why%20Node.js%3F

Submitted February 20, 2019 at 02:50PM by stackchief

GitHub - saratonite/file-downloadr

https://github.com/saratonite/file-downloadr

Submitted February 20, 2019 at 12:18PM by saratonite

jscasts.tv ep7 - Running Node.js and Mongo with docker and docker-compose

https://youtu.be/Zg98pj5imho

Submitted February 20, 2019 at 09:36AM by lysywojtek

NodeJS : Best practices for production

https://medium.com/@monothorn/nodejs-best-practices-for-production-5b173983d14b

Submitted February 20, 2019 at 09:48AM by deker1991

A method to access express session variables in the front end

I have been using express session variables for a small project, however, I have only been able to get express session variables into the page using templating. I would like javascript on the frontend to be able to access this data and serve the user dynamically. I have looked through document.cookie, sessionStorage and localStorage thinking I would find something(which I didn't) since I am new to handling sessions and cookies.One of the ways I thought of a way around this, is to have a route which would provide the user with the session details, let us say /api/getsession or something among those lines with fairly simple backend route code:Installed and used packages:ExpressExpress SessionBody-parser...A few others not required for this thread​app.get("/api/getsession",(req,res)=>{ res.json(req.session) }) However, since this would require the page on the front end to perform an http request, it might add onto the loading time of the page. Thus, if there is a way to access the session variables on the page itself, IMO it would be more efficient.​Therefore if there is something wrong in the technique I am using or a better technique/package I could use, kindly point this out as I am new to node. Appreciate the help :)​

Submitted February 20, 2019 at 08:01AM by xZakurax

Tuesday 19 February 2019

How to Create a Public File Sharing Service with Vue.js and Node.js

http://on.morioh.net/29040dad35

Submitted February 20, 2019 at 07:06AM by Rogers911z

How to Build a URL Shortener With Node.js and MongoDB

http://go.morioh.net/ca376ea901

Submitted February 20, 2019 at 07:17AM by OliviaMn

How to Check Whether a Listening Port Accepts HTTP request?

I have a process running on port 5000 on a Linux server. How can I determine whether the process/ port accepts HTTP request? I tried using curl on a remote machine to check if the server accepts HTTP, but it doesn't return any response. If it doesn't accept HTTP request, is there a way to know what other protocol the process/ port will accept? Thanks a lot!

Submitted February 20, 2019 at 03:15AM by VickNicks

Deploying NestJS API to Azure

Build your own radio streaming app with Howler.js

https://medium.com/crowdbotics/build-your-own-radio-streaming-app-with-howler-js-637f929decc0

Submitted February 19, 2019 at 11:52PM by CurrentEditor

Why are node binaries not 0s and 1s?

I was sort of expecting my files inside node_modules/.bin to be composed of 0s and 1s. I guess I assumed that all "binary" files were this way, but I guess that's not the case? Is ".bin" somewhat of a misnomer then?

Submitted February 20, 2019 at 12:18AM by stoned_phillips

Data-transfer Real time

Hi. I have data that create every 50 ms. It is necessary to transfer from one server to another (save to DB) and send to the client with real-time display. What the best way to do what?

Submitted February 19, 2019 at 09:43PM by eultra

Registration and authentication for Node using FusionAuth - Feedback on the tutorial?

https://fusionauth.io/blog/2019/02/19/easy-integration-fusionauth-nodejs

Submitted February 19, 2019 at 07:46PM by BryanBugfrog

A CLI tool for visualizing git history

https://github.com/pomber/git-history/tree/master/cli

Submitted February 19, 2019 at 07:09PM by pomber

Divide and conquer: Scale your Node.js app using distributed queues

https://blog.logrocket.com/divide-and-conquer-scale-your-node-js-app-using-distributed-queues-8231a9486d3a

Submitted February 19, 2019 at 07:20PM by celestialvagabond1

The Human Relationship Package - Learning from event-stream

https://www.arei.net/archives/293

Submitted February 19, 2019 at 07:28PM by areinet

Open sourcing our visual coding node framework!

everyone, I thought here would be the best forum to share an open source bot framework that we developed for the last 3 years, hope you like it :) It runs on NodeJS, and comes with a visual behavior tree editor that allows super cool visual programming. It is built for chat/voice bots but can serve very well any automation task out there. It includes automated testing, sub processes, a debugger and much more. It's easily extendible -- extend one of 4 base classes, implement 1or 2 methods and you are done. If all this raise your curiousity then you are in for a treat: check out https://github.com/servo-ai/servo-platform

Submitted February 19, 2019 at 06:55PM by liormessinger

Looking for package: given a user agent string and a browser feature, return true if that browser supports that feature

Hi /r/node,Not sure if this is the best place to ask, but I'm looking for a package that basically does this:const supports = require('the-package-i-need'); const userAgent = 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:65.0) Gecko/20100101 Firefox/65.0'; supports('fetch', userAgent); // Returns true Where fetch is an ID used at caniuse.com.Anyone know of such a package? (Or a better place to ask.)

Submitted February 19, 2019 at 02:29PM by vinnl

Linkedin Scraper / Crawler working 2019 for Node.js!

Since LinkedIn changed his website to a SPA-ish in 2018 (?) almost all scrapers stopped working, but seems that no one cared about it! I suppose due to Linkedin API. I also tried to use the API however it has a lot of limitations, the API only give us basic information, unle$$ you are a partner, so I built one for myself, and it seems that is the 1st which works on Node.js: https://github.com/linkedtales/scrapedinIt took over 2 months, more than 10k profiles tested, it reads full data and I'm very happy if it also helps other people 😊. The "trick" what made it possible was using "puppeteer" a chromium headless browser. It is really not very performant if you scrap only one profile at once (~1 profile per second) , but it works amazingly in parallel (~5 profiles 1.5 seconds), I also built a crawler using scrapedin in parallel: https://github.com/linkedtales/scrapedin-linkedin-crawler

Submitted February 19, 2019 at 11:50AM by tumeni

I need contributors for my project

Hi guys, i need some people to contribute my open source Unsplash client written in node.Maybe you're using maybe not, however since I've found a job I can't continue the development of this project alone.​The project is Splash CLI, it has almost 10k downloads and got the 4th position as product of the day on product hunt.(the link of ProductHunt in the website is wrong)​​Thank you in advance, every type of commit is appreciated, from a typo in the readme to a critical fix.​— Federico

Submitted February 19, 2019 at 10:53AM by rawnly

Async/Await Best practices.

Hello gus whats the difference between usingvar response = await axios.get("/api"); // OR axios .get("/api") .then(res => { response = res; }) .catch(e => { response = null; }); When using the first one when the request fails what happen with the response variable? i just need to make an if statement like that:if(response){ //do something } // OR if (response.data){ // do something } // To know if an error happened what i should do? if(response){ }else{ // there's an error here?? } Thank you guys.

Submitted February 19, 2019 at 10:01AM by ayech0x2

Build A Group-Chat App in 30 Lines Using Node.js

https://medium.com/@dkhd/15bfe7a2417b

Submitted February 19, 2019 at 08:51AM by jsloverr

How to create an IMAGE MANAGER with VueJS & NodeJS - Day 18 - #100DaysOf...

https://www.youtube.com/attribution_link?a=cMSK77csy4Y&u=%2Fwatch%3Fv%3DnXUWsPhQcWQ%26feature%3Dshare

Submitted February 19, 2019 at 09:06AM by Tyler_Potts_

Monday 18 February 2019

Hi, Can anyone tell me what happens to the pending promise in node architecture?

The single thread will be used by other process but what happen to the previous one? Where will it go?

Submitted February 19, 2019 at 06:33AM by Knightash

Using fs.watchFile(), how can I get which data was changed?

I hope the title is self explanatory. If I have 'x' in the file, and write 'y' to the file, how can I return that 'y' was added? I'm not sure sure how else to word it. Thanks in advance

Submitted February 19, 2019 at 05:19AM by Vezqi

Deno v0.3.0 released

https://github.com/denoland/deno/blob/master/Releases.md

Submitted February 19, 2019 at 05:08AM by kevinkassimo

After using passport.authenticate(), my express server routes all stop responding

I'm creating a small demo app to learn user authentication with passport.js, sequelize & express. When I hit my /register endpoint, it creates a user account just fine. Same with if I hit my /logIn endpoint, it'll return the proper user if I give it the correct credentials.The issue I've run into is that after starting the server up and hitting either the /register or /logIns endpoint the server will stop responding to all GET and POST requests until I restart the server.Here is my index.js code:var express = require('express') var bodyParser = require('body-parser') var Sequelize = require('sequelize') var session = require('express-session') var passport = require('passport') var bCrypt = require('bcrypt') var LocalStrategy = require('passport-local').Strategy var flash = require('connect-flash') var morgan = require('morgan') var app = express() app.use(express.static('public')) app.use(bodyParser.json()) app.use(session({ secret: 'keyboard cat' })) app.use(passport.initialize()) app.use(passport.session()) app.use(flash()) // Sequelize & Sequelize models var sequelize = new Sequelize('auth_demo', 'auth_demo', 'auth_demo', { host: 'localhost', dialect: 'mysql' }) var User = sequelize.define('user', { id: { type: Sequelize.INTEGER, autoIncrement: true, primaryKey: true }, username: { type: Sequelize.STRING }, password: { type: Sequelize.STRING } }) // Server initialization stuff require('./config/passport.js')(passport, User) sequelize .sync() .then(() => { console.log('Connection successfully established') }) .catch(err => { console.log('Unabled to connect:', err) }) app.listen(3000, () => { console.log('App is running on port 3000') }) // Routes. app.post('/register', passport.authenticate('local-signup'), function(req, res) { res.send(req.user) }) app.post('/logIn', function(req, res, next) { passport.authenticate('local-signin', function(err, user, info) { if (err) { console.log("found err") return next(err) } if (!user) { console.log("didnt find user") return res.redirect('/') } req.logIn(user, function(err) { console.log("executing login") if (err) { return next(err) } console.log(req) return res.send(user) }) })(req, res, next) }) app.get('/loggedInUser', function(req, res) { console.log(req.user) res.send(req.user) }) app.get('/test', (req, res) => { console.log(req) res.send('Hello') }) Also, here is the passport.js file to show the strategies:const LocalStrategy = require('passport-local').Strategy const bCrypt = require('bcrypt') module.exports = function(passport, User) { // Passport stuff passport.serializeUser(function(user, done) { done(null, user.id) }) passport.deserializeUser(function(user, done) { User.findById(user.id, function(err,user) { done(err, user) }) }) // Configure passport strategy passport.use('local-signup', new LocalStrategy({ usernameField: 'username', passwordField: 'password' }, function (username, password, done) { var generateHash = function(password) { return bCrypt.hashSync(password, bCrypt.genSaltSync(8), null) } User.findOne({ where: { username: username } }).then(function(user) { if (user) { return done(null, false, { message: 'That user already exists' }) } else { console.log("Creating user") var userPassword = generateHash(password) User.create({ username: username, password: userPassword }) .then(function(newUser) { if (!newUser) { return done(null, false) } if (newUser) { return done(null, newUser) } }) } }) } )) passport.use('local-signin', new LocalStrategy({ usernameField: 'username', passwordField: 'password', passReqToCallback: true }, function (req, username, password, done) { var isValidPassword = function(userpass, password) { return bCrypt.compareSync(password, userpass) } User.findOne({ where: { username: username } }).then(function(user) { if (!user) { console.log("didnt find user") return done(null, false, { message: 'User does not exist' }) } if (!isValidPassword(user.password, password)) { console.log("bad password") return done(null, false, { message: 'Incorrect password' }) } return done(null, user) }) .catch(function(err) { console.log("Error:", err) return done(null, false, { message: 'Something went wrong with your signin' }) }) } )) } If I hit that /test endpoint before I try to hit a /logIn endpoint or /register endpoint, it works fine and prints "hello" as expected. However, if I hit the /logIn or /register endpoint right after starting the server up and then try to hit /test the request will hang and not go anywhere at all.Here is what the express debugger prints in the terminal when it hangs: express:router dispatching GET /test +4s express:router query : /test +1ms express:router expressInit : /test +0ms express:router serveStatic : /test +0ms express:router jsonParser : /test +2ms express:router session : /test +0ms express:router initialize : /test +0ms express:router authenticate : /test +0ms It stops at express:router authenticate, so I'm inclined to believe it's passport.Any help is appreciated, thank you.

Submitted February 19, 2019 at 01:16AM by macswaggerrrr