Thursday 31 January 2019

Why DevOps Engineers Love AWS Lambda (x-post /r/aws)

https://www.reddit.com/r/aws/comments/altlv9/why_devops_engineers_love_aws_lambda/

Submitted February 01, 2019 at 06:52AM by nshapira

Is "use strict" still a common and good practice?

I haven't used it in a long while and haven't encountered any issues.

Submitted February 01, 2019 at 07:16AM by TaskForce_Kerim

Node.js Tutorials for beginners in hindi | Nodemon Installation | Part-9

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

Submitted February 01, 2019 at 05:33AM by phptutorialswebsite

What package makes it into every project you start, and why?

My go to packages are:dateFns: because it makes manipulating dates fairly simple, is of a modular design, so i only package what I use.clg-color: because it’s a super light weight way to add color to my terminal during development.What about you guys? What do you think new developers (and old) could benefit from including in their projects?

Submitted February 01, 2019 at 03:12AM by WebDevLikeNoOther

Need help writing a Jira web hook

Need help writing a JIRA web-hook. I am trying to write a google calendar API that creates a google calendar entry when a jira deployment issue type is created.I have code that works on my local system but does not work on as a jira web hook. Any hell would be appreciated

Submitted February 01, 2019 at 01:53AM by Limeman36

Looking for node coding tutorial suggestions.

No text found

Submitted February 01, 2019 at 12:56AM by citrinemachine

Looking For A Vanilla Node.js Book

I am currently learning Node.js with Express. Afterwards, I'd like to learn vanilla Node.js, but it's very difficult to find a book that doesn't utilize Express. There's a Udemy course on this topic, but it's $199 and never goes on sale. Even if it were to go on sale, books have more information. Do you guys and gals have any suggestions?

Submitted January 31, 2019 at 09:29PM by SecretAgentZeroNine

How to setup a powerful API with GraphQL, Koa, and MongoDB -- scalability and testing

https://www.strilliant.com/2019/01/31/how-to-setup-a-powerful-api-with-graphql-koa-and-mongodb-iii/

Submitted January 31, 2019 at 09:08PM by thickoat

Node and websocket

I have a node server that accepts http requests. I am working on extending the functionality of server so it allows public clients to send continuous stream of data to my server. Websockets seems to be the obvious answer.Questions: 1. what's the best way to achieve my usecase (allow third parties to send high frequency, high load data streams to my server)? 2. i looked into socket.io.. will that force my third party clients to use socket.io on their end?Thanks

Submitted January 31, 2019 at 08:40PM by nitinsh99

multiple express servers for subdomains or not?

Hi everyone,​So I want to run a website on a server which will have a few subdomains too - all in node. With apache I would just setup some express servers to certain ports and have domains redirect to them - but with an apache-less setup, how would I do this?I could do it all under one express server, with `vhost` and `express-subdomain` packages maybe - but then if a dev updates one subdomain's backend code, I'd need to restart the entire node app to get it to update (I use pm2 for managing node.js stuff, is there a feature for hot reload without performance drop?) and so this isn't ideal.However, if I use a different express server for each subdomain I'd need to someone link them all with one master express server - and will running multiple express servers not affect performance?​Thanks in advance for any help

Submitted January 31, 2019 at 07:59PM by SebyWeby19

GoogleNews Api - A rest api which will give news of different categories from any location and also related news

https://github.com/singhbhavneet/GoogleNewsApi

Submitted January 31, 2019 at 07:17PM by bhavisingh

[new npm package] http-header – Utilities for working with HTTP headers.

https://github.com/gajus/http-header

Submitted January 31, 2019 at 07:21PM by gajus0

Is there any coexistence between worker threads and the I/O thread pool threads?

Now with the latest node update we've got worker threads running in the same process as that of the main thread unlike clusters and child processes, so is that multithreaded/multiprogrammed or asynchronous?, if they are asynchronous how do they coexist with the existing thread pool used for I/O?, this might be a very naive question sorry for my ignorance,also, if they are asynchronous does this mean for cpu intensive jobs more cores should be made available to worker threads by decreasing the number of async I/O threads?

Submitted January 31, 2019 at 07:45PM by Prateeeek

Issues after cleaning cache!

I have Node running on an AS400 IBM System i. I recently had some issues installing some packages so I ran the following:npm cache clean -f Perhaps I misunderstood what I was doing, but since then, I am getting the npm command is not found. I also noticed when running my applications that run on the AS400, node_modules are missing. For example, "moment" is no longer found.Any ideas what the issue is or how I can solve it?Thanks ahead of time.

Submitted January 31, 2019 at 07:02PM by fvrthebrave

Protecting your JavaScript APIs

https://medium.com/intrinsic/protecting-your-javascript-apis-9ce5b8a0e3b5

Submitted January 31, 2019 at 05:29PM by nucleocide

Shrink node_modules with refining

https://indexandmain.com/post/shrink-node-modules-with-refining/

Submitted January 31, 2019 at 03:52PM by ByFaraz

🚀Full GraphQL Day Toronto schedule and talks are up!

https://www.graphqlday.org/

Submitted January 31, 2019 at 04:03PM by ukrainiankolbasa

Overlaying 2 audio files in Node JS

I am trying to make a tool in Node.JS that allows the user to give an audio file and that will overlay another short audio file on top multiple times.The idea is kinda like "AudioJungle" where you can hear the sound in the background.I have been searching for a solution online but I was unable to find anything that could do the job.Does anyone have an idea how I can achieve this?Thanks in advance!

Submitted January 31, 2019 at 02:50PM by MartinVino

Adding an Analytics Dashboard to an E-Commerce React App with Cube.js: The Saleor Example

https://statsbot.co/blog/adding-analytics-dashboard-to-ecommerce-web-app-with-cube.js-saleor-example

Submitted January 31, 2019 at 03:09PM by 4ananas

Switching between different node version for running multiple node projects

NVM stands for node version manager, which will help to switch the your node versions for specific use. It also allows the user to work with multiple npm and node versions. Installation and usage of NVM : https://www.tutespace.com/2018/11/nvm-installation-on-windows.html

Submitted January 31, 2019 at 01:36PM by shrinivas28

New Tab page with node

I made an application with node to be used as homepage or newtab in your browser, the app screenshot is below
the link of the GitHub page is https://github.com/arivan-amin/AtomNewTabthe circles are spining​the design is inspired by Atom Websiteany advice or suggestion appreciatedNew tab page

Submitted January 31, 2019 at 12:28PM by arivan_amin

Generating code with Yeoman js

https://medium.com/@matthewdbill/f13e0da87374

Submitted January 31, 2019 at 10:15AM by kiarash-irandoust

Wednesday 30 January 2019

Question about undefined variable

Hey guys, I'm trying to build a webserver. I've never used Node before so I'm completely new to this.I have this block of code with an async function.router.post('/new', async (req, res) => { console.log('Received Post Request: '); console.log(req.body.name); console.log(req.body.description); console.log(req.body.abv); try{ const client = await db.getClient(); console.log('Client Checked Out'); const { rows } = await db.query('INSERT INTO testbeer(name, description, abv) VALUES($1, $2, $3)', [req.body.name, req.body.description, req.body.abv]); await db.query('COMMIT'); console.log('Added entry'); } catch(e) { await db.query('ROLLBACK'); throw e; } finally { db.releaseClient( client ); console.log('Client Released'); } res.render('new', { title: 'Add New Entry' }); }) When I post a request from my browser, I get the following error at "db.releaseClient(client)"(node:14880) UnhandledPromiseRejectionWarning: ReferenceError: client is not defined However, when I add a second variable (i.e. "client2 = client", noted by **), it works fine.router.post('/new', async (req, res) => { console.log('Received Post Request: '); console.log(req.body.name); console.log(req.body.description); console.log(req.body.abv); try{ const client = await db.getClient(); **client2 = client;** console.log('Client Checked Out'); const { rows } = await db.query('INSERT INTO testbeer(name, description, abv) VALUES($1, $2, $3)', [req.body.name, req.body.description, req.body.abv]); await db.query('COMMIT'); console.log('Added entry'); } catch(e) { await db.query('ROLLBACK'); throw e; } finally { db.releaseClient( client2 ); console.log('Client Released'); } res.render('new', { title: 'Add New Entry' }); }) Does anyone know why this is?

Submitted January 31, 2019 at 05:06AM by Integral_10-13_2xdx

Why do so many people use MongoDB with NodeJS ?

From what I've read almost everyone seems to use mongodb with NodeJS. Why not MySQL or PostgreSQL ?

Submitted January 31, 2019 at 02:54AM by JackTheTradesman

MongoDB for Javascript developers: How to begin

https://contextneutral.com/story/mongodb-and-nodejs-how-to-begin

Submitted January 30, 2019 at 11:44PM by nulless

Node v11.9.0 (Current)

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

Submitted January 30, 2019 at 10:42PM by dwaxe

How to setup a powerful API with GraphQL, Koa and MongoDB -- CRUD actions

https://www.strilliant.com/2019/01/30/how-to-setup-a-powerful-api-with-graphql-koa-and-mongodb-mutatations-fields-resolvers/

Submitted January 30, 2019 at 09:56PM by thickoat

restgoose - decorator-driven REST API

Hey guys,I just finished writing the "Getting started" article of my library, restgoose.Basically, it makes the creation of simple REST APIs very easy and with little boilerplate code : no routes, controllers... Just the model definitions and some decorators.I'm really looking for some peer review. If someone is interested and willing to give me feedback about the concept and the API, that would be great !The project can be found here: https://xurei.github.io/restgoose/The "getting started" article is there: https://xurei.github.io/restgoose/getting-started.htmlThank you very much !

Submitted January 30, 2019 at 10:41PM by xurei

HTTP Partial Requests // THEY GAVE ME INTERVIEW HOMEWORK...

https://www.youtube.com/watch?v=o2m-W1iyAzQ

Submitted January 30, 2019 at 10:18PM by _arnm

Import modules from URL instead of local node_modules

https://github.com/egoist/import-http

Submitted January 30, 2019 at 09:04PM by lowonkarmaz

29 Useful Open Source Libraries for NodeJS

https://medium.com/crowdbotics/29-useful-open-source-libraries-for-nodejs-4cefe08f7205

Submitted January 30, 2019 at 07:02PM by crowdbotics

Swiss Army knife for Unix permissions

https://github.com/ehmicky/unix-permissions

Submitted January 30, 2019 at 06:26PM by ehmicky

Notable - The markdown-based note-taking app that doesn't suck

https://github.com/fabiospampinato/notable#readme

Submitted January 30, 2019 at 05:56PM by fabiospampinato

How can one node instance tell all other node instances to do something?

I'm looking to implement a "Refresh Config" function where from my admin screen I can trigger my other node instances (on multiple servers) to re-load their config from the database. What's the best way to do this? I was thinking I'd store a flag in redis like reloadConfig = true/false. Then just have a middleware function check this flag and if true, reload the config from database.Anybody do anything similar to this?

Submitted January 30, 2019 at 05:57PM by 64bitHustler

Diving Deeper in JavaScripts Objects

https://blog.bitsrc.io/diving-deeper-in-javascripts-objects-318b1e13dc12

Submitted January 30, 2019 at 04:33PM by JSislife

Node js iis help trying to deploy node api and connect to react app

I am running a react app on iis, and i want to connect my nodejs api to the react app. How do I go about doing that. I have tried deploying the node app to iis, but still confused.

Submitted January 30, 2019 at 03:52PM by codinginsomnia

Deleting ALL node_modules folders from windows

Hi reddit/r/node, i decided to try asking there after a good hour looking on google. I found many scripts good for doing this for mac but none working simply on windows.As i have been transitioning and need to import my old project folders from windows to mac i'd like to uninstall all node_modules before doing it since it's going to take some USB key management to do that without this step.I took a look here too and i found a couple scripts, but for mac. Any chance one of you guys know how to do this on windows?​I'm looking for what i guess is a loopy one-liner, i know how to do that folder by folder, but it's simply going to take a... while.​Thanks in advance for any relevant input on the matter!

Submitted January 30, 2019 at 02:14PM by Nikrom89

Building a N-Tier Express App using Dependency Injection

https://medium.com/@benlugavere/building-a-n-tier-express-app-using-dependency-injection-9dffb2a0f8d2?source=friends_link&sk=1619e1e35581c02aa7ea16b88f838429

Submitted January 30, 2019 at 03:01PM by dearkitect

Tutorial - Enforcing Code Quality for Node.js

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

Submitted January 30, 2019 at 03:20PM by patrickleet

Next.js CMS?

Hi everyone, I'm pretty new to using CMSs and I was wondering how they worked with react. If I was using Next.js to make a static site for a business, how could I let the business edit the content/information on the static site without having to change the react source files? I had a quick look at Strapi and I could use axios to make http requests to the API, and I could see how this would work for something like a blog that has blog posts, but I don't understand how it would work with just editing the content/information on a static site. Could anyone point me in the right direction? Thanks

Submitted January 30, 2019 at 11:28AM by JakeGore

ES6 modules: All possible ways to import and export ES6 modules

https://youtu.be/ananPWEdfDA

Submitted January 30, 2019 at 09:26AM by arboshiki

Controlling gadgets with Google Home, IFTTT and Node-RED

https://medium.com/@karolis.rusenas/controlling-gadgets-with-google-home-ifttt-and-node-red-d165a680bb2c

Submitted January 30, 2019 at 08:10AM by jsloverr

Tuesday 29 January 2019

Handling Time Zone in JavaScript

https://medium.com/@toastui/handling-time-zone-in-javascript-547e67aa842d

Submitted January 30, 2019 at 07:55AM by fagnerbrack

Did the basics, now what?

I've made an API for android/ios that will soon hit beta testing stage. It's pretty stable, no obvious crashes. Has about 50 subroutes in 6 different controllers.CRUD, uploading files, streaming files, connected schemas, the basics.How do I get myself to the next level, how do I prepare for whats to come? What do I read, as obviously tutorials are not enough now, I need more. I have a few months ahead of me to work as the usage of my API goes up. This is the only tutorial that seems to have something above the basics - https://www.udemy.com/advanced-node-for-developers/ . I'm fine with books, blogs, anything that will push me further.Help me.

Submitted January 30, 2019 at 07:36AM by moneymakingmiguel

Previously selected data not reflecting in dropdown list

Hi Guys,I am new to web development and encountered, I am sure, a common rookie mistake.​I have a HTML form that includes 2x dropdown lists. The data is then stored to MongoDB.When looking up the stored data using the same form, all the fields are correctly populated with the data from the DB with the exception of the dropdown lists. These lists display the default value instead of the DB value.​Server Environment: NodeJSHTML written using PUG / JADE​Below is an extract of the form code block. (I have also attached a video depicting the behaviour)mixin ontForm(ont = {}) form(action=`/addOnt/${ont._id || ''}` method="POST") h6.heading-small.text-muted.mb-4 Resident information .pl-lg-4 .row .col-lg-6 .form-group label.form-control-label(for='input-name') Name input#input-name.form-control.form-control-alternative(type='text', placeholder='John', name="resident_name" value=ont.resident_name, required) .col-lg-6 .form-group label.form-control-label(for='input-surname') Surname input#input-name.form-control.form-control-alternative(type='text', placeholder='Appleseed', name="resident_surname" value=ont.resident_surname, required) .col-lg-6 .form-group label.form-control-label(for='input-email') Email address input#input-email.form-control.form-control-alternative(type='email', placeholder='john@example.com' name="resident_email" value=ont.resident_email, required) .col-lg-6 .form-group label.form-control-label(for='input-cell') Cellphone Number input#input-name.form-control.form-control-alternative(type='text', placeholder='0821238888' name="resident_cell" value=ont.resident_cell) hr.my-4 // Address h6.heading-small.text-muted.mb-4 Address Information .pl-lg-4 .row .col-md-4 .form-group label.form-control-label(for='input-address') Complex Name input#input-address.form-control.form-control-alternative(placeholder='Complex Name', type='text', name="complex" value=ont.complex) .col-md-4 .form-group label.form-control-label(for='input-address') Block Name input#input-address.form-control.form-control-alternative(placeholder='Block Name', type='text', name="block_name" value=ont.block_name) .col-md-4 .form-group label.form-control-label(for='input-address') Unit No input#input-address.form-control.form-control-alternative(placeholder='Unit number', type='text', name="unit_no" value=ont.unit_no) .row .col-md-6 .form-group label.form-control-label(for='input-address') Suburb input#input-address.form-control.form-control-alternative(placeholder='Suburb', type='text', name="suburb" value=ont.suburb) .col-lg-6 .form-group label.form-control-label(for='input-city') City input#input-city.form-control.form-control-alternative(type='text', placeholder='City', name="city" value=ont.city) hr.my-4 // Description h6.heading-small.text-muted.mb-4 ONT Information .pl-lg-4 .row .col-lg-6 .form-group label.form-control-label(for='input-manufacturer') ONT Make input#input-complex_name.form-control.form-control-alternative(type='text', placeholder='Zyxel', name="manufacturer" value=ont.manufacturer) .col-lg-6 .form-group label.form-control-label(for='input-model') ONT Model input#input-email.form-control.form-control-alternative(type='text', placeholder='PMG1005-T20A', name="model" value=ont.model) .row .col-lg-6 .form-group label.form-control-label(for='input-ontsn') ONT GPON SN input#input-first-name.form-control.form-control-alternative(type='text', placeholder='5AF69411223344', name="serial_number", value=ont.serial_number required) .col-lg-6 .form-group label.form-control-label(for='input-bwprof') Bandwidth Profile Required? select#input-address.form-control.form-control-alternative(name="package", placeholder="Bandwidth Profile" value=ont.package) option 20Mbps Down | 10Mbps Up option 50Mbps Down | 25Mbps Up option 100Mbps Down | 50Mbps Up option 200Mbps Down | 50Mbps Up option 400Mbps Down | 100Mbps Up option 1000Mbps Down | 100Mbps Up if user.isp_vlan_int === 4080 .row .col-lg-12 .form-group label.form-control-label(for='input-vlan') VLAN select#input-address.form-control.form-control-alternative(name="vlan", placeholder="vlan" value=ont.vlan) option 3 - VI Local LAN option 100 option 200 option 300 option 4080 else .row .col-lg-12 .form-group label.form-control-label(for='input-vlan') input#input-address.form-control.form-control-alternative(type='hidden' name="vlan", placeholder="vlan" value=user.isp_vlan_int) .text-center if ont.serial_number button.btn.btn-primary.mt-4(type='submit') Update ONT else button.btn.btn-primary.mt-4(type='submit') Add ONT ​Any help is appreciated.https://reddit.com/link/al9r57/video/umqy4i3e4id21/player

Submitted January 30, 2019 at 06:05AM by asdutoit

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

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

Submitted January 30, 2019 at 02:57AM by Barbara9119

How to compress a large string with gzip to a file?

Hello, I was wondering what is the proper way to write data from in-memory to file and have it compressed along the way? The best I got is this. I get "Error: write after end" most of the time (not always).const stream = require('stream'); const zlib = require('zlib'); const gzip = zlib.createGzip({level: 9}); let Duplex = stream.Duplex; const stream = new Duplex(); stream.push(JSON.stringify(data)); stream.push(null); const inp = stream; const out = fs.createWriteStream('./foo.json.gz'); inp.pipe(gzip).pipe(out); I tried with a stream.passThrough as the input (it wants a readable) and got the same result.Thank you :)

Submitted January 30, 2019 at 03:11AM by charlesdarkwind

circular dependencies in a react/react-native app

I'm planning on creating an app for web and native mobile using react and react-native. I've looked into how to go about code sharing between these two environments and have not found much useful info. I did come across react-native-web which tries to let you use your native code on the web too, but I'm not really interested in that, I want to write the native stuff using the react-native code and use standard web technologies for the web and I suspect trying to patch the react-native code onto the web would be a nightmare. So instead, I figure I should create 3 modules, one for strictly react-native, one for strictly react, and one for shared code. My only problem is I'm not sure how to deal with the dependencies. I figure the non-shared code should depend on the shared code since the non-shared code would be the entry point. However, I would like to also have component code in the shared code, but at a higher level. For example, if I created some low-level component in the non-shared code which implemented say a basic form (just as an example). Then I want to be able to refer to the correct lower level code at runtime so that on mobile it imports the native form and on the web it imports the web form. So basically I would like the non-shared code to provide dependencies for the shared code when it is imported. Is this possible to do? I haven't done a lot with nodejs modules before, so I'm not sure how to go about doing something like this and what technologies I might need. Thanks for any help.

Submitted January 30, 2019 at 02:45AM by rosebeats1

Sequelize+Expressjs question

Long time Rails dev looking to expand my backend portfolio and am building a small side project that's supposed to be a meal planner. Basically, its an app to spit out 5 random recipes per week with grocery lists.I'm working on the recipe endpoint as I'll allow a user to create a recipe to save that they will later cook when it comes up. In post, a user should create a brand new Recipe { name and instructions } and hasMany ingredients. An Ingredient has { quantity } and belongsTo an IngredientType which has { name, unit }.A user should be able to submit a recipe with ingredients(always created) and can either create a corresponding ingredient type or find one with the exact same combo of name/unit.My goal is to make this into 1 transaction so that if any validations fail, the whole transaction fails. Here is my current code:router.post("/", (req: Request, res: Response) => { const { name, instructions } = req.body.recipe; db.Recipe.create({ name, instructions }) .then(async recipe => { const ingredients: IngredientInstance[] = await req.body.recipe.ingredients.map((ingredient: any) => { const { quantity, ingredient_type } = ingredient; const { id, name, unit } = ingredient_type; db.Ingredient.create({ quantity }) .then(async ingredient => { const [ingredientType, ] = await db.IngredientType .findOrCreate({ where: { id, name: name.toLowerCase(), unit }}) await ingredient.setIngredientType(ingredientType.id); await ingredient.setRecipe(recipe.id); return ingredient }) }); return recipe; }) .then(recipe => res.status(201).json({ recipe })) }); This is obviously several transactions. The recipe is created, then every ingredient is created. I'm not sure how to make this one transaction though.

Submitted January 30, 2019 at 02:33AM by boboguitar

Getting started with Node.js modules: require, exports, imports and beyond

https://adrianmejia.com/blog/2016/08/12/Getting-started-with-Node-js-modules-require-exports-imports-npm-and-beyond/#.XE-gh-1PFJw.reddit

Submitted January 29, 2019 at 08:30PM by NathalieMejia2018

Debug flow through express Node.js application?

I've been looking for a way to better trace the code flow through an express application built on top of Node.js.I've tried the DEBUG environment variable but it's not quite what I am looking for.I am thinking more along the lines of which files were hit as part of the middleware flow, which routers were hit, which files were rendered including filenames/line numbers/function names.This would be very, very useful.Does anything like this exist?

Submitted January 29, 2019 at 09:22PM by adamthompson22

Node v10.15.1 (LTS)

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

Submitted January 29, 2019 at 08:42PM by dwaxe

What if I dont want to use loopback.js? What are my other options?

I am testing loopback and strapi.js to get some help while building api. Issue with loopback is , there are not tutorials on it. Couple of youtube videos and they are dead boring.​Strapi is still in alpha.​So, Is there any other option which can create api really fast. Like, in loopback, I can use cli to create some model,controllers.​Should i do it in old way where i need to create end points and create all controllers manually?​Thanks

Submitted January 29, 2019 at 07:25PM by fanaticCoder

Loopback v4 resources?

Does anyone know of a good place to get help with Loopback v4?I'm looking at it for a project and I've done all the tutorials, etc. But I can't find anywhere to get my more advanced questions answered. Many frameworks have a lot of activity on Stack Exchange, etc, but this one doesn't seem to.

Submitted January 29, 2019 at 06:07PM by SpongHits

Finished my bachelor degree in information systems and now I'm stuck.

So I want to learn node.js to improve my curriculum. Do you guys have any directions to give me about where can I go to find what I'll need to learn this?

Submitted January 29, 2019 at 05:35PM by waynegomes

Setting up a Full-Stack TypeScript Application: featuring Express and React

https://levelup.gitconnected.com/setting-up-a-full-stack-typescript-application-featuring-express-and-react-ccfe07f2ea47

Submitted January 29, 2019 at 05:47PM by theTypeScripter

Send UDP-Packet to given IP (no response)

Hey there, I am new to the world of servers and have a pretty basic question:I want to make a basic lobby-server for a videogame. I figured out how to send http and udp requests and responses back to the client; but I dont know how to send udp packets to the hosts IP address I have saved in my json file in response of a http or udp request of a client. Thanks for help :)

Submitted January 29, 2019 at 04:31PM by SmittyWerbenXD

Node express server integration with Cognito user pool

I'm working on a node / express web app.I want to use Cognito user pools to manage users, and its provided login pages to authenticate users that may be federated - .e.g facebook/google/cognito managed accounts.What is the best practice / easiest way to achieve this in node?I've seen the amplify library but that is geared towards client-only/SPA/mobile apps.Roll my own oauth integration code to get an oauth token and parse it via using cognito endpointsI've seen a couple of Passport + Oauth libraries but they seem to not be regularly maintained / popular and others suggest that it is a bit of overkill to use Passport as well as Cognito.AWS SDK for node?What do most people do for this? I'm heading towards #2 - roll my own - but want to know if I'm missing something easier / more robust.

Submitted January 29, 2019 at 05:07PM by random523

A simple debugging module for AWS Lambda (λ) timeout

Hi Everyone,https://github.com/rpgeeganage/iftoI developed a small and simple module which can be used to debug AWS lambda timeouts.It is not advanced as X-Ray.I'm planning to add more features in the future like showing the stack trace.I already posted this in AWS, DevOps and Typescript subreddits.I thought this group also find this package useful.Thank you.

Submitted January 29, 2019 at 05:19PM by geeganage

Object.assign vs Object Spread in Node.js

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

Submitted January 29, 2019 at 03:10PM by code_barbarian

Stripe Payments Integration 101 for JavaScript Developers | @RisingStack

https://blog.risingstack.com/stripe-payments-integration-tutorial-javascript/

Submitted January 29, 2019 at 03:03PM by fwalkwithm

Node Health Checks

https://medium.com/@deadlysyn/b25a6c62d990

Submitted January 29, 2019 at 08:47AM by jsloverr

Can't print that someone joined the server on the console!

So in my server.js I've included this:var io = require('socket.io').listen(server);io.sockets.on('connection', function (socket) {var address = socket.handshake.address;console.log('New connection from ' + address.address + ':' + address.port);});​Do I have to write code in the client.js to print in the console that someone joined, and if "yes" - what code do I have to write.

Submitted January 29, 2019 at 09:01AM by Martixell

Monday 28 January 2019

How to Build a Meetup Slack App with Standard Library and Node.js

https://medium.com/@janeth_10755/how-to-build-a-meetup-slack-app-with-standard-library-52f96b27d95a

Submitted January 29, 2019 at 07:42AM by JanethL

[HELP] How to build subscription management / free trial period in web app?

Noob's here. TBH I can't even google this right. I've tried "how to build subscription management with node js", "how to build free trial period with node js", both came out building user authentication posts as results.​What I want to do is, giving 14-days trial to users since they signed up and then after trial period, temporarily suspend the account until they re-activate with a subscription.​If this is not big for you, could you please enlighten me with a brief walk-through or some learning resources, or just the right way to google it.​Speaking of authentication, currently I'm using passport-local and express-session. But since I'm using AWS, would it be better if I use AWS's Cognito than using Passport.js?​(Stack in case you needed: Express, TypeScript, Postgres, AWS, EJS)

Submitted January 29, 2019 at 05:59AM by xzenuu

Website to check whether a package name is available on npm

https://npm-name.com/

Submitted January 29, 2019 at 05:26AM by bjornkrols

How to get npm audit log when npm audit gives 400 bad request?

Hello so I am trying to upgrade to Node 11 with my project and when I run install it keeps saying I have security vulnerabilities and to run `npm audit fix` to fix them. Unfortunately that always comes back with E400 bad request.So when I googled I found a bunch of explanations related to github repos or no versions and I tried removing anything like that from my package.json but nothing I do seems to make `npm audit` work for me.Anyone know a way I can just get a list of the packages that `npm audit` doesn't like? Thank you.

Submitted January 29, 2019 at 12:57AM by runvnc

Be careful of the JWT hype train

https://www.darraghoriordan.com/2019/01/23/be-careful-of-the-jwt-hype-train/

Submitted January 28, 2019 at 11:16PM by philnash

Node Collaborator

I am a full-stack dev lookin for another 1 or 2 collaborators to build a project management tool with. The stack is Node, Vue, Postgres. This is a great opportunity for anyone looking to build up their portfolio or simply have fun collaborating on cool projects. Shoot me a message or reply here.Hope to have some interest!

Submitted January 28, 2019 at 11:20PM by col0rcutclarity

View package install history?

Looking for a way to view the local install history for a package. My google-fu has failed me.Context: I need to determine which version of a package I had installed previously so I can roll back to it.

Submitted January 28, 2019 at 09:13PM by guesswhochickenpoo

misspelled "install" but npm installed anyway.

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

Submitted January 28, 2019 at 09:22PM by pamblam0

Is node suitable for offline software?

I was wondering if an node based (probably electron) app would be a suitable framework to create business software (POS, booking e.c.t.).I was thinking of starting to offer companies software and wondered if this would be appropriate?​Thanks, Ed.

Submitted January 28, 2019 at 06:00PM by thelynched

What are your best resources for learning to build database structures.

I’m relatively new to coding and have only made your normal MongoDB based tutorial projects (yelpCamp and the likes).I want to sink my teeth into a rather daunting project of making a personal CRM/automating some of my day job. I know it’ll be a lot to take on but in my opinion being thrown in the deep end is the fastest way to learn. I also want to make it using an SQL based database system rather than Mongo as relational has more appeal to the types of data I want to work with.I can already visualize the potential for larger and larger amounts of data to be collected. I eventually want want tables for users, companies, employees, projects, financial history of different companies, status updates for different employees in individual projects, and also a logging system to see what user updated what record and when. I feel I can get the logic down relatively easily, but the most daunting task I see now is setting up the databases to be efficient and have minimal repeated entries.As I don’t have much experience in building out these larger applications, and to the best of my knowledge SQL databases aren’t the easiest to just alter and adjust on the fly, where is the best place to learn correct database structuring for my application?Happy to take any other advice on the project also.

Submitted January 28, 2019 at 04:59PM by Xzas22

ExpressJS: Router.get() throws Error: Route.get() requires a callback function but got a [object String]

Need Some Help With MEVN Stack Authentication

Good morning everyone,I've done a lot of work on this on my own. I've followed a tutorial on MEVN stack but it was coming up to be a failure. It may be because it's using Vue2? Not sure about that. Then I went back to my original, because I didn't think to check it before the tutorial. And it... works.What it is doing at the current moment is authenticating the user and then redirecting them to the express version of '/' and not back to the vue home. Is there a way with my current authentication will work with this. The files can be found at:The login route is found here:https://github.com/Randygbiv/portfolio/blob/api_and_frontend/routes/userRoutes.js​The User model is found here:https://github.com/Randygbiv/portfolio/blob/api_and_frontend/models/user.js​What I'm asking is if the code I have here can work in any way to authenticate a MEVN app or will I have to completely re-write this. I really don't want to because it may change the way that the password is stored in the database and I've already got the working version in production.

Submitted January 28, 2019 at 03:28PM by randygbiv

why webstorm need access to my photos?

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

Submitted January 28, 2019 at 11:56AM by sourabhgoyal

Why I've stopped exporting defaults from my JavaScript modules

https://humanwhocodes.com/blog/2019/01/stop-using-default-exports-javascript-module/

Submitted January 28, 2019 at 10:59AM by fagnerbrack

Threads in Node 10.5.0: a practical intro

http://dev.edupioneer.net/6a36149d89​https://i.redd.it/4tfgcrlnd5d21.png

Submitted January 28, 2019 at 11:14AM by MaryDBlackwell

Delegating Work Using NodeJS and AMQP

https://medium.com/@davesag/4d3cc1f62824

Submitted January 28, 2019 at 08:50AM by kiarash-irandoust

fnm: 🚀 Fast and simple Node.js version manager, built in ReasonML

https://github.com/Schniz/fnm

Submitted January 28, 2019 at 08:41AM by galstarx

Sunday 27 January 2019

Node.js Tutorials for beginners in hindi | node.js http module | Part-8

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

Submitted January 28, 2019 at 05:29AM by phptutorialswebsite

What does your node.js production setup look like? How do you do deployment?

Do you use a box that you have setup yourself - eg. similar to:https://www.digitalocean.com/community/tutorials/how-to-set-up-a-node-js-application-for-production-on-ubuntu-18-04If so how is its basic architecture? (Node, PM2, Nginx, database) How do you deploy to it?​Or a PaaS like Heroku:https://developer.mozilla.org/en-US/docs/Learn/Server-side/Express_Nodejs/deploymentIf so how do you deploy to it? What other features of the PaaS do you use? (Monitoring, logging ...)​

Submitted January 28, 2019 at 03:58AM by chief_monkey

Bungie.net Library for Node.js

I just finished a Bungie.net API library for node.js. It's 0 dependency and fully asynchronous. I could use some help testing it out before I push Version 1.0.0 to NPM.​Anyone out there willing to give me a hand?GithubDocumentation

Submitted January 28, 2019 at 01:26AM by TyMeador

REST API Best Practices

https://jonathas.com/rest-api-best-practices/

Submitted January 27, 2019 at 10:23PM by jonathasrr

Chaining spawned processes in Next.js

How to setup a powerful API with GraphQL, Koa and MongoDB

https://www.strilliant.com/2019/01/27/how-to-setup-a-powerful-api-with-graphql-koa-and-mongodb/

Submitted January 27, 2019 at 09:14PM by thickoat

Looking for some help with do's and don's on separating the api and frontend

HiI'm more of a c# dev and decided to join a friend for a project. I have never worked with node before (except for some crawlers). So we are trying new things out and decided to use node for the api and react for the frontend. When i work with c# everything comes pretty much out of the box like user registration, roles etc...And i have never really worked before on project with a api only. Until now e everything we did was return views, fill forms etc...So what would be the major points i should consider before starting?

Submitted January 27, 2019 at 07:39PM by ekclone

typescript + nest + swagger + mongo

Recently found Nest as a framework for backend development - gave it a whirl - see what you thinkhttps://github.com/bRRRITSCOLD/typescript-nest-swagger-mongo-todos

Submitted January 27, 2019 at 06:17PM by sad_c10wn

Yarn V2 and beyond

https://github.com/yarnpkg/yarn/issues/6953

Submitted January 27, 2019 at 05:11PM by erka_apostrophe

How to setup Project Folder structure and and other resources for a complex node js Project

I know basics of node js , but want to know what to do when working in a complex project which requires many resources like videos, images etc. and uses complex database queries.

Submitted January 27, 2019 at 04:04PM by shanks44

NODE_ENV: So easy to miss your step

https://kostasbariotis.com/node-env-so-easy-to-miss-your-step/

Submitted January 27, 2019 at 02:52PM by kostarelo

fs.readFile wont let to end the connection

router.get('/', (req, res) => {`fs.readFile('/index.html', (err, data) => {` `if (err) throw err;` `var $ = cheerio.load(data);` `$('a#archive').attr('href', baseURL+'/archive');` `res.status(200).end($.html());` `});` });​"fs.readFile()" makes the browser wait although the data was sent (the browser writes "Waiting for localhost..."),when i look at the "Network" tab in "Inspect Elements" i see the packet with the file's data i've sent from the server side but it wont show it because the browser is waiting for the server to end the connection.

Submitted January 27, 2019 at 01:55PM by Bar771

How do you share default config files?

Familiar with that annoying scenario: you pull a git repo but it doesn't work because you don't have the .env/.config file and need to ask by Slack... Security-wise, how would you share default env config between developers? I'm not referring to structure only rather to values as well. For example, keys/tokens for dev services like 3rd party tools, URL of AWS test env, etc

Submitted January 27, 2019 at 10:36AM by yonatannn

I'm building a web app and I need some feedback on the way I decided to handle the backend structure.

I posted this question before in r/webdev and I didn't got a good answer so I'll post it again here.So I'm using reactjs and nextjs on the frontend and nodejs, mongodb on the backend. Now the thing is that I have two servers running for this application. The first one is the nextjs(well it's a nodejs server but you get the idea) which I only want to use to pass the request params on the front end, basically for just rendering the correct pages based on url and then use these params to call another server which handles everything else. To differentiate the servers I use /api/ for the second one.The second server interacts with the database but the database is on mongodb atlas(I do plan to move it to a separate server tho). Also I plan to use nginx load balancers so if one server goes down the app is still up and running. And just to make it clear I don't have separate machines as severs, the servers both run on the same machine with different ports.Also here is a scenario where, at least in my mind, makes sense to have a separate server for the ui. So the users loads a page and the first server sends the ui elements which needs to rendered. Now a request to the second server is made in order to get the data for the page. Let's say that the page has many comments and I just show 30 of them, if the user wants to see more he only needs to make a request to the /api/ server and leaves the ui server free for other users. So if I see the that the /api/ is under load very often and the ui one isn't I can just add another /api/ server to scale the app. Again I'm new to all of this so if this doesn't make sense please let me know.

Submitted January 27, 2019 at 10:56AM by 0xde908cb

Saturday 26 January 2019

Footing: A foundation for developing REST APIs using Express with Node.Js.

https://github.com/arviteri/Footing

Submitted January 27, 2019 at 06:41AM by apptryer

To database and not to database?

Today I woke up with my friend ranting about MongoDB ( he is big on SQL ) and its poor performance. I tried to explain to him that he was feeling for SQL and should die. This got me thinkings about leveldb ( a lightweight in-memory database ). I wanted to create my version of leveldb a database that will store data in json format in the local storage. But the problem is I can't understand a line of C++ ( native to leveldb ). Is there a native js key-value store DB that I can take apart and do some stuff on it?Have any of you did this? And how insane does this sound?

Submitted January 27, 2019 at 05:01AM by sayanmallick

Accessing An Object Across Multiple Modules

Hi guys. I’m sorry if this question has been answered already. Feel free to lay into me if it has.I working on my first big node app and I just feel like I’m doing this wrong. It’s an electron app for managing a football team, and one render process is designed to run during the game. While the game is being played, I have objects that represent each player, each coach, each referee, the stadium, the plays, the stats, etc. Then I have one object that represents the game itself. Sometimes, I need to access one object from another - for example, when I enter a play, it needs to reference player objects to update their stats, then access the game object to change the down and distance, etc.The way I have done it this: each Class is defined and exported in its own module. The exception is the game.js module - it defines the class, but the exports an instance of this class. Within that instance, there are objects that contain all of the other objects (players, coach’s, teams, etc) that I may need.When I launch the program, the game.js module is required and a new Game object is initialized. Then, within each of the other modules where I may need to access the game instance, I require the game.js module and assign a reference of the game object to a global (to the module) variable named ‘game’. Then, when one object needs to access another - say a Play object needs to access a Player object - i just use game.players[{plrId}] and it works the way I want it to.Is the best way to do this. I mean, it works, so why not? It just doesn’t feel right.Two things that make me question it. One, I use the modular-global ‘game’ variable within each instance of the other objects, which just feels odd. I could assign it to this.game, but that would create a circular structure, which I want to avoid.The second, bigger issue, is that I included the var {game}=require(‘./game’) one at the top of every module before the class definition, but I was finding that that didn’t always work. So I had to add a line in the constructor function that checked if game was undefined and if it was, then I would require the file again.TLDRHow do I make an object that can be accessed by multiple modules in a node project? Essentially a global object, though I don’t want to use that word.

Submitted January 27, 2019 at 03:18AM by rudypepper

Request not passing req.body through to other service

I have a Node.js API gateway that passes requests to my different services. It seems to pass the URL correctly (expected) but it is not passing `req.body` to my other services, in this case my auth service.​Here is my route​router.post('/signup', (req, res) => {request.post(req.path, options, (error, response, body) => {if (error) throw error;res.send(body);});});​Here is my route in my auth service​router.post('/signup', (req, res) => {console.log(req.body);res.send(req.body)});​I am getting back `{}` as my response to the API gateway so it seems like my `req.body` is not being passed through to my auth service. I'm not sure the correct way to have it pass through the whole `req` object to the auth service while using the request package.​I think that I need to include `form: {key:'value'}},` somewhere in the request where I include `req.body` as part of the form data. Not sure how this would work since I already have the options included to set my base URL which is dynamic based off a setInterval elsewhere in my code.​options = {baseUrl : serviceURL}​​

Submitted January 27, 2019 at 02:10AM by jsdfkljdsafdsu980p

Node.js vs PHP?

In an interview a few days ago, I asked about their decision to use PHP for the backend rather than Node. I was caught off guard by his response of something along the lines of there being more packages/libraries available for PHP. However, I was under the impression that Node passed PHP in basically everything a long time ago. What are your thoughts on this?

Submitted January 26, 2019 at 10:39PM by Revircs

Await & "alert", "confirm" and "prompt" functions

Why do the "alert", "confirm" and "prompt" functions work asynchronously natively?It is not necessary to prefix the reserved word "await" as the Promises work.

Submitted January 26, 2019 at 09:06PM by anlijudavid

Compile node on powerpc (WD MyBookLive NAS)

I own a WD MyBookLive NAS. I replaced the stock firmware with a vanilla Debian Jessie in order to get a more recent OS on it. I also wanted to use Node.js on it, but since there is no package for powerpc i tried to compile it myself.Make ran ~4h and excited with an error:​/root/node-v10.15.0/out/Release/torque: 1: /root/node-v10.15.0/out/Release/torque: Syntax error: ")" unexpecteddeps/v8/gypfiles/v8_torque.host.mk:16: recipe for target '35252d6966aea87a064e77b58e5c626fdea5910e.intermediate' failedmake[1]: *** [35252d6966aea87a064e77b58e5c626fdea5910e.intermediate] Error 2rm 35252d6966aea87a064e77b58e5c626fdea5910e.intermediateMakefile:99: recipe for target 'node' failedmake: *** [node] Error 2​The full output is here: https://pastebin.com/0LEPDHW7​I tried to run make several times and also downloaded the source tarball again. Compilation failed every-time. What am I doing wrong/missing? Any hints?

Submitted January 26, 2019 at 09:27PM by GawkyGibbon

How to Create PDFs With Node JS and React

https://youtu.be/bt1tOhUYxvM

Submitted January 26, 2019 at 08:41PM by HolidayInternet

What Javascript MVC web framework should I choose : AdonisJs, SailsJs or something else?

I need a MVC web framework to build my web application and I've run into these 2, (also Keystone but I removed it from the list since it doesn't have ACLs) . I've read some opinions on reddit about these 2 frameworks, but it's still not enough.So my question is what should I choose between AdonisJs and SailsJs (from the perfomance/documentation/maturity/etc point of view) ? Or is there anything better I haven't found yet?

Submitted January 26, 2019 at 09:22PM by Roo_ooky

This Week on npm v20190125: onetime@3.0.0

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

Submitted January 26, 2019 at 08:10PM by code_barbarian

Dates on Nodejs on Windows 10 seems a bit off.

This might be the the wrong forum for this, but someone knowledgeable in this might be able to answer this quick and clean. Either it's my system (or rather two of my systems). If this is the wrong place to ask this query, then I'll apologize and head over to stackoverflow.It's regarding Date .Example: new Date(2019,1,1) 2019-01-31T23:00:00.000Z This does not seem right. Trying around with moment I'll get the following. ``` let date = moment().subtract(1, 'month');console.log(date.startOf('month').toString()); console.log(date.startOf('month').toISOString());Sat Dec 01 2018 00:00:00 GMT+0100 2018-11-30T23:00:00.000Z ``` Is this some mad quirk in JavaScript v8, since I have yet to see another language behave this way.

Submitted January 26, 2019 at 04:07PM by Kylozor

Is it possible to decompile a nodejs app that was converted to exe?

I have an exe file, which through looking at memory strings and viewing it with Notepad++ I realize it was made with NodeJS.I want to reverse-engineer/view the code of the program, is it possible to decompile the exe? (in other words, reverse the js2exe process).

Submitted January 26, 2019 at 01:27PM by ZeroByter

Node.js 11.8 is here: news for the worker threads

https://helpdev.eu/node-js-11-8-is-here-news-for-the-worker-threads/

Submitted January 26, 2019 at 12:10PM by helpdeveu

How easy it is for a client-side JS Developer to gain depth knowledge in nodejs?

Hi folks,I am a full-time JS Developer with 3+ years of experience. I think I have a fair amount of knowledge on client-side JavaScript and tools. I'd like to make my transition and gain advanced knowledge of nodejs. How easy is the path? What is different? I have basic knowledge of server-side coding+DB.

Submitted January 26, 2019 at 10:39AM by git_world

Decoupling and/or code splitting inspiration needed

https://www.reddit.com/r/CodingHelp/comments/ajuavw/decoupling_andor_code_splitting_inspiration_needed/

Submitted January 26, 2019 at 09:33AM by inabahare

JavaScript V8 Engine Explained

https://hackernoon.com/javascript-v8-engine-explained-3f940148d4ef

Submitted January 26, 2019 at 07:51AM by kadishay

GitHub - seanpmaxwell/mail-promise: Simplifies interface for nodemailer and returns a promise. Also includes TypeScript definition.

https://github.com/seanpmaxwell/mail-promise

Submitted January 26, 2019 at 07:22AM by theTypeScripter

Friday 25 January 2019

Question about the number of requests a simple node server can handle

Hi allI have two simple node apps (express) behind a load balancer. Between them they can handle about 400 requests per second. (Response time roughly 400 ms, and no lost data).I have a few questions on this please:How exactly can a single threaded app handle so many simultaneous connections? Is it simply a case of when a connection comes in, it quickly adds the request to the event queue, so actually it seems like it is concurrently handling all the requests but really it's just queuing them and processing them when it can?What would be the most effective way to improve the 400 requests per second/400 ms response time without scaling horizontally? For example, would doubling the RAM make a difference? Or adding a second processor? Or even removing express and using core node.js modules for the req/res processing? Or something else?Thank you for your responses.

Submitted January 26, 2019 at 05:50AM by TuckerMcInnes

Design Patterns - Singleton Pattern

Please give me some feedback on the video. What would you like, what you disliked. Really am trying to give you guys good content on design patterns, but everyone has opinions about them.​https://www.youtube.com/watch?v=5SWIQL5Zepw

Submitted January 25, 2019 at 11:57PM by WebDevJourneyWDJ

How to lie to program about `process.platform`?

There is a CLI that runs on Node and can be executed via command on the command line. In its code, some functionality is deactivated for Windows users by if (process.platform === 'win32') { process.exit(1); }. Now I want to disable this check, and allow Windows users to use the "hidden" functionality (usually the the required software is not installed on Windows, but I have a special setup where it is).Is there some way, to lie to this CLI and simulate that it is running on e.g. Linux or macOS?Of course I could fork the CLI, remove the check and work with my own version - but this would require repeating this process for each release. As this functionality should also be available to other users, I would have to publish the forked and modified CLI which could be a frequent source of confusion for its users (What about version numbers? Do I use the same command?) - 99.9% of the code will stay untouched.Could I maybe write my own CLI, that does something to "fake" the environment, then executes the installed, original CLI, and cleans up afterwards?I created an example package that works identical to the CLI, but only does exactly that part that I am investigating:https://github.com/janpio/nodejs-cli-nowinhttps://www.npmjs.com/package/nodejs-cli-nowinInstall via npm i -g nodejs-cli-nowin.

Submitted January 26, 2019 at 12:04AM by Sujan

Is something like Strapi worth using to speed things up?

I've been reading it's documentation, seems to be pretty fitting to use for CRUD development. Also has abilities to handle connection between models, handles data depending on that connection, etc. Anything further from that I'd be using my own functions, but that's where the tricky part starts. I'm not exactly sure if it's really smart to do in the long run. But the idea of having that CRUD functioallity alongside authentication, swagger documentation and basic subroutes seems very appealing.Are there any better options? Is using something like Strapi even a smart idea?

Submitted January 25, 2019 at 09:02PM by moneymakingmiguel

Socket.io-RateLimiter: A node module that helps you with rate-limiting socket.io events

https://github.com/fabosch/socket.io-ratelimiterhttps://www.npmjs.com/package/socket.io-ratelimiter​If you have nothing to do, feel free to try it out. I created this project because I think that there is a gap in this area, atleast I couldn't find a good node module that would help me with rate-limiting and was fitting my requirements when I started with this as part of a bigger project.

Submitted January 25, 2019 at 07:55PM by fabosch

GitMessenger

Hey developers i have created a chat app with help nodejs, socket.io, passport, firebase and express-session where github users can chat with each other and share codes,images and much more.Here is link https://gitmessenger.herokuapp.com/Github link-https://github.com/singhbhavneet/GitMessenger/​https://i.redd.it/4nu4uhijmmc21.pnghttps://i.redd.it/6rmewa5gmmc21.png

Submitted January 25, 2019 at 08:11PM by bhavisingh

Error: Can't set headers after they are sent.

im trying to create a POST route to my Device management/Device Configurations end point​I've tried different methods, also followed the documentation on microsoft.com Used the graph explorer, which handles everything for you.​// in my graph.js file, this is the functions that is being used to post to the endpoint.​postIntuneForm: async function(accessToken) {const client = getAuthenticatedClient(accessToken);const intuneForm = await client.api('/deviceManagement/deviceConfigurations').version('beta').post({}, (err, res) => {console.log("=================");});return intuneForm;} };​// file: /routes/intune.js​router.post('/',async function(req, res) {if (!req.isAuthenticated()) {// Redirect unauthenticated requests to home pageres.redirect('/')} else {let params = {active: { Intune: true }};​// Get the access tokenvar accessToken;try {accessToken = await tokens.getAccessToken(req);} catch (err) {res.json(err);}​if (accessToken && accessToken.length > 0) {try {// Get the eventsvar postToIntune = await graph.postIntuneForm(accessToken);​res.json(events.value);} catch (err) {res.json(err);}}}});​module.exports = router;I expected the form results to be posted into the end point as json.​I am getting an error: "Can't set headers after they are sent."

Submitted January 25, 2019 at 07:11PM by JRTHEGR8

Want to build a command line application that centralizes a bunch of scripts.

Problem: I'm having to write a bunch of scripts lately. Things like generate a report, send this file, aggregate this data, trigger this function in this api, etc. I would like to have one tool that can do all that.​I found https://oclif.io/, but I'm not entirely sure if this is what I want. I do PHP + JS, so my reference point is Artisan/Symfony Console.​I would like to be able to something like `manage-app reports:email:billing --send`. Also, code completion, and help would be ideal. What would I use for this?

Submitted January 25, 2019 at 05:33PM by nobrandheroes

Do You think Design patterns would be a good series to make?

https://youtu.be/pv-RdXrG23g

Submitted January 25, 2019 at 02:51PM by WebDevJourneyWDJ

What is your most useful package.json script?

No text found

Submitted January 25, 2019 at 02:03PM by WebDevLikeNoOther

JScasts - episode 4 - mocking and stubbing with sinon.js

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

Submitted January 25, 2019 at 02:26PM by hotcto

Authentication in Strapi (node.js headless CMS)

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

Submitted January 25, 2019 at 01:15PM by shahinrostami

How to install typescript

https://www.reddit.com/r/angularjs/comments/ajn2et/how_to_install_typescript_typescript_hello_world/

Submitted January 25, 2019 at 08:53AM by naikgad21007

IISNode and shared drives

Hi everyone! I'm relatively new to Node.js but I have been loving it.I am currently hosting a website with IISNode and using Express. My directory is my C: drive and it is running just fine. I have a shared drive (I'll called it E:) and I want to have my website have access to the contents in that drive. I have had no success with being able to load content from that drive into my website. I tried creating a virtual directory but had no results. I might just being doing things wrong.I was wondering if someone could point me in the right direction. Thanks!

Submitted January 25, 2019 at 07:36AM by MayKnott

Advice for a front end dev wanting to learn node.js

I'm currently working for 3 years as a javascript front end developer. I'm comfortable with the technology and also some of the frameworks (react, angular).The issue is I have no experience with backend technologies, best practices, common tools etc.So my question is: What would you recommend me to do in order to transition from FE dev to full stack js dev. Any book, paid tutorials that helped you guys and you could recommend, or even just some advice on how to make my transition smoother will be highly appreciated.

Submitted January 25, 2019 at 09:09AM by xennon1993

Electron questions for new node developer

I want to develop an application for work that will make workloads for everyone at the company a lot lot easier. I've decided that given my background in web development the best way to do this is with node and electron. I've done all my research and am confident this is the way to go and am well underway in learning all the ins and outs of node. I have a couple questions about electron though.Can I make my application with web pages now and then port it over to electron when done? Or will I severely regret not coding it with electron in mind from the beginning. Reason for this is I might make it a web app instead of a desktop app. Heavily leaning towards desktop app though given some company politics.The application I'm making makes heavy use of subversion (svn) commands. For windows users is it possible to include svn binaries (like sliksvn) with the electron package? Or is there no way around the need to instruct users to install something like sliksvn separately?

Submitted January 25, 2019 at 09:17AM by Aishateeler

how do I update Node.js?

Been browsing the internet and not find a method that works.. I am running v6.10 and I want to update to 10.15.0 LTS.

Submitted January 25, 2019 at 09:30AM by THE-TRAP-GOD

Module export default ES5

Hi, I am working on an npm package. I export my function like this module.exports = myFn;. In a javascript project, I can import it like import myFn from 'mylib'; or const myFn = require('mylib'); but then I import it in a typescript project I can use only import * as myFn from 'mylib'; or import myFn = require('mylib');. I what to use it as import myFn from 'mylib'; and I am getting error TS1192: Module '"mylib"' has no default export.. How can I add default export to my package?

Submitted January 25, 2019 at 09:38AM by dr4605

Thursday 24 January 2019

I created a Discord channel meant for developers to come together/think of an idea/work on a project together.

The channel is very small since I just made it, but several developers have made it clear to me that they're interested in something like this. If you're interested in joining, please respond in the comment section below and I'll send you a link to the Discord channel in your private messages.

Submitted January 25, 2019 at 06:17AM by IKATAKIMAS

How do I dynamically push items in a res.render to a jade file

I need to be able to change the amount of students I access when doing res.render. Otherwise the program crashes. Sometimes I want to get three students, sometimes five, ect. How do I create a loop of variables to render and pass to my jade file? Any help is much appreciated.For Example one time I want to grab one student:router.get('/', function(req, res){var studentlist = "SELECT * FROM student, advises WHERE student.PID = advises.PID AND advisorid = '1'";getConnection().query(studentlist, (err, c) => {if (err) throw err;console.log(c);res.render('houme', {student_PID1: c[0].PID,student_fname1: c[0].fname,student_lname1: c[0].lname});});});Another time I want to grab two:router.get('/', function(req, res){var studentlist = "SELECT * FROM student, advises WHERE student.PID = advises.PID AND advisorid = '1'";getConnection().query(studentlist, (err, c) => {if (err) throw err;console.log(c);res.render('houme', {student_PID1: c[0].PID,student_fname1: c[0].fname,student_lname1: c[0].lname,student_PID2: c[1].PID,student_fname2: c[1].fname,student_lname2: c[1].lname});});});​

Submitted January 25, 2019 at 03:57AM by kevinisathought

Node v11.8.0 (Current)

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

Submitted January 25, 2019 at 02:33AM by dwaxe

Upcoming youtube programming and web dev tutorials

Constant Coder will offer a variety coding tutorials, tips, tricks, and anything else that can help you on your journey to be a better programmer. If you want to learn coding, or just like tech in general, give the channel a subscribe. You will not regret it!

Submitted January 25, 2019 at 01:22AM by theconstantcoder

Looking for a new package idea for the weekend

Hi everyone, I’m looking for a new package idea to do on weekend. To spend sometime in development. Any ideas and thoughts will be highly appreciated. Thanks

Submitted January 24, 2019 at 11:58PM by geeganage

Creating a private local library of components dependant on react and styled-components

Hi folks,So I have a project the following folders at the project root: -- common- private-- package.json- public-- package.json​private and public both represent self-contained applications. Both of the apps import standard js (ES6) functions and constants from the common directory via yarn workspaces in their respective package.json files: -"workspaces": ["../common"],As you can see, this goes up one level from the app root so are not under the npm packages in the package.json files and therefore are not compiled by webpack (don't need to be as they are standard ES6).This was fulfilling my needs until recently, when I realised my project would work better (DRY coding) if I were to move some react and styled-components dependant components common to both applications to the common directory. But, as mentioned above, they are not subject to compiling by webpack to I get an error when I tried to import them (doesn't recognise import styled from styled-components).What is the best way around this? Am I looking at having to compile that directory separately via their own webpack compiler config then import them from there or is there a simpler way to do it? Thanks.

Submitted January 24, 2019 at 10:33PM by U4-EA

does anyone actually use bitwise operators ????

https://www.stackchief.com/tutorials/JavaScript%20ES6%20Bitwise%20Operators

Submitted January 24, 2019 at 11:12PM by stackchief

Sending Emails with Gmail API

I'm currently working on hooking into the Gmail API using NodeJS. I have a working connection and can access my messages and such, but I'm having difficulty actually sending email with the API. Here is what I have below:/** * Send Message. * * @param {String} userId User's email address. The special value 'me' * can be used to indicate the authenticated user. * @param {String} email RFC 5322 formatted String. * @param {Function} callback Function to call when the request is complete. */ function sendMessage(userId, email, callback, auth) { // Using the js-base64 library for encoding: // https://www.npmjs.com/package/js-base64 //var base64EncodedEmail = Base64.encodeURI(email); var base64EncodedEmail = Buffer.from(email).toString('base64'); var request = gapi.client.gmail.users.messages.send({ 'userId': userId, 'resource': { 'raw': base64EncodedEmail } }); request.execute(callback); } This is from the official documentation (here), for the most part. I'm calling the function as such:authorize(JSON.parse(content), sendMessage('me', btoa('This is a test'))); The error I'm getting is this:var request = gapi.client.gmail.users.messages.send({ ^ReferenceError: gapi is not defined at sendMessage (D:\Documents\Web Programming\React\neis-guy-painting\src\Server\Node\gmail.js:148:17) at fs.readFile (D:\Documents\Web Programming\React\neis-guy-painting\src\Server\Node\gmail.js:23:34) at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:511:3)I realize that this is because I don't have gapi defined, but I can't seem to figure out what that actually should be.What am I missing here?

Submitted January 24, 2019 at 08:17PM by Onikouzou

Redis LFU for NodeJS

Hello Everyone,How can I use the LFU features which are available in latest redis release. The npm module seems to be old. Any tip for work around would be a lot helpful.

Submitted January 24, 2019 at 06:53PM by stopcharla

Is there a way to pass off a socket connection to another Node listener on a totally different server?

I'm trying to wrap my head around how I can possibly architect my app with scalability in mind with Node. I'm at the point where my idea is to have a client connect to an initial Node server (Express / web-based in this case) and that server will load balance connections, sending connected clients off to other slave instances based on load.Anyone feedback on reading material or if there's an existing method I just haven't discovered, I'm all ears. Thanks!

Submitted January 24, 2019 at 06:29PM by Grandpa_Willy

Looking for 1-2 Front-End/Note.js Developers for Project

https://www.reddit.com/r/webdev/comments/ajf0ss/looking_for_12_frontendnotejs_developers_for/

Submitted January 24, 2019 at 06:10PM by WDImagineering

How do I create dynamic variables in Node.js?

Is there any framework like WordPress to build site on node.js?

Is there any framework like WordPress to build site on node.js?

Submitted January 24, 2019 at 05:03PM by sam_dak

Automatically Aligning two Subtitle Files (.srt)?

Beginner here. I have two subtitle files (.srt) in different languages; I would like to align them so that I in the end get a single (say) json with both languages. However, I'm not entirely sure how I would go about this in a clever way (I'm a beginner)? How do I make sure that I pair the right lines?It's possible for example, that one file contains this:Min 01-09: He stood up. And he went away.While the other file, (in a different language), contains this:Min 01: He stood upMin 05: And he went awayHere I can't do a simple 1:1 mapping, because that would be wrong & ruin everything that comes after. Also times might be slightly different. Sorry if this is a simple questions for the more advanced here, I'm just wondering what a good approach might look like (roughly)​

Submitted January 24, 2019 at 04:20PM by rmtedv

Using ExpressJS and TypeScript with OvernightJS (v3).

https://levelup.gitconnected.com/using-expressjs-and-typescript-with-overnightjs-v3-c76c2f189fa9

Submitted January 24, 2019 at 04:37PM by theTypeScripter

How do i uninstall all the unused modules of MDBreact ?

How do i uninstall all the unused modules of MDBreact as it it making my project very heavy.Any help will be appreciatedThank You!

Submitted January 24, 2019 at 03:34PM by inFamousJkr

Create a blog API with Nestjs CQRS and EventSourcing - Part I

https://blog.lendro.it/#/articles/3

Submitted January 24, 2019 at 12:55PM by Srammmy

Need your advice on node.js + express metrics monitoring

Hello everyone,I’m the CEO of a team of developers, we mostly develop web-based applications using ES + node.js + express + React. For every application we implement for our customers we have to be confident about maintaining our SLA-related metrics (we’ll simply lose customers if we aren’t able to meet our SLA terms) - which requires a proper metrics monitoring such as response time, error rates, etc.We had to invent a new small infrastructure each time we implement a new project, most often it was ES + Grafana/Kibana + modifications inside the app to collect metrics and ship them into the ES instance.So we got tired of doing the same thing over and over and created a cloud-hosted tool for our internal usage, which monitors all our node.js + express applications, we called it SLAO. It monitors all the methods calls with response codes, durations, headers, and other metrics, and we made its integration as simple as it could be - by adding a single row of code: app.use(slao()).Now we only use SLAO internally, but we’re considering publishing it as a cloud service because we think that we’re not the only team that had such node.js + express app monitoring issues.What do you think about this whole idea, should we go for it? P.S. If anyone wants to test it - just text me and I’ll give you a test access.

Submitted January 24, 2019 at 11:55AM by fpd4444

My Top 20 Docker commands use cases for developers

https://dev.to/alex_barashkov/20-docker-commands-use-cases-for-developers-2d9g

Submitted January 24, 2019 at 10:40AM by AlexBV1

Production ready Node.js REST API Setup using TypeScript, PostgreSQL, and Redis. [Part 2]

https://medium.com/@alex.permyakov/production-ready-node-js-rest-api-setup-using-typescript-postgresql-and-redis-part-2-3921dd8c875f

Submitted January 24, 2019 at 10:51AM by coldyx

Nuxt + Firebase Cloud Functions - Unexpected import token "vue"

heyho,I have a problem to deploy my Nuxt-Cloud Functions app on Firebase because Vue itself seems to be an unexpected import token. More details in my stackoverflow question:​https://stackoverflow.com/questions/54246010/nuxt-firebase-cloud-functions-unexpected-token-import​​

Submitted January 24, 2019 at 08:28AM by abbrechen93

Wednesday 23 January 2019

How to vssh into vagrant, run commands, and read the stdout?

I've been messing around with the 'child-process' module and trying to read the stdout. I've messed around with spawn and exec, but when I attempt to ssh into vagrant the output from vagrant doesn't return and it doesn't seem possible to execute additional commands within the context of vagrant. Not sure if this is making any sense at all... anyone familiar with running shell scripts from inside node with the intent to process whatever comes back via stdout?

Submitted January 24, 2019 at 06:31AM by SentFromBelow

Send mail with NodeMailer

https://youtu.be/p4bnK0qy89w

Submitted January 24, 2019 at 03:44AM by subrat_msr

do you realistically use Generator functions with NodeJS?

https://www.stackchief.com/tutorials/JavaScript%20ES6%20Generators

Submitted January 23, 2019 at 10:48PM by stackchief

Type of projects I should be working on to impress employers

Hey everyone. I recently began job hunting after being out of the game for the past four years. It's just time to move on. So NodeJS is much more prevalent than it was four years ago. I've begun playing around with some side projects to acclimate myself with it, but I don't think a chat application or a hacker news clone will cut it for an employer. I know I would catch on pretty quickly if I was in Node 9-5, but unfortunately I can only really devote 5-10 hours a week to learning it.What types of applications or skills should I be able to demonstrate to employers? I know thats vague, but again, this little chat application on my github probably won't cut it. So I want to think bigger.

Submitted January 23, 2019 at 11:01PM by systematical

I made a reminder bot for Slack because the default one can't use @here or @channel

https://github.com/a0viedo/reminder-bot

Submitted January 23, 2019 at 05:56PM by a0viedo

Silly question, but regarding database connections...

Many examples seem to leave the password blank in the connection string, ie:module.exports = { 'connection':{ 'host':'localhost', 'user':'root', 'password':'' }, 'database':'bort', 'user_table':'users' } and when I've tried a few of these, I get connection errors. So... I'm guessing that the password for the DB connection is passed to that module when the server is running, however, I'm not sure how said password would be sent.what could I be missing?

Submitted January 23, 2019 at 05:09PM by 1foryes

How to Perform Web-Scraping using Node.js- Part 2

https://blog.bitsrc.io/how-to-perform-web-scraping-using-node-js-part-2-7a365aeedb43

Submitted January 23, 2019 at 03:59PM by JSislife

My first NPM package. A tool for simple communication between a DJI tello drone.

https://www.npmjs.com/package/tello-drone​My first package on NPM and im pretty happy with the structure and usage.My package connects to a tello drone when you are on its wifi and has a few events and supports both async and sync communication between Node and the drone.Not sure how good the readme/documentation is but learned that its quite difficult to write a short but comprehensive guide of your API to others. Missing a few things that i need to add, but overall quite satisfied.I linked a short youtube clip where i demo the sample code in the readme on npmjs.

Submitted January 23, 2019 at 04:21PM by TappT

Good day. Please I need a npm server side package that compress the image before uploading it to the cloud. Please any suggestion?

No text found

Submitted January 23, 2019 at 03:14PM by dudewith3faces

GraphQL vs REST - Handling errors

https://blog.graphqleditor.com/graphql-vs-rest-errors/

Submitted January 23, 2019 at 03:05PM by oczekkk

Common API mistakes and how to avoid them

https://blog.logrocket.com/common-api-mistakes-and-how-to-avoid-them-804fbcb9cc4b

Submitted January 23, 2019 at 01:42PM by r-wabbit

You can use Typescript using JSDoc

https://itnext.io/be-type-strict-without-typescript-296565483bfd

Submitted January 23, 2019 at 01:37PM by fagnerbrack

Use node to write a variable from js to mongodb

So for a class project I'm creating a browser game in js. At the end of the game I would want to upload the scores to a mongodb database. (and later display it on another page). I've found that you can't write to mongodb with pure js so I'd have to use node.I haven't ever used node.js and tried just adding a function to my existing js file and running it with a json string from another function. However when I do that I get 'require is not defined'.So it seems I can't just add a 'require' function to my other js code and have it ran from inside that js file.To summarize what I'd like to do is take a json string that I have created in my js file upload it to mongodb atlas but out of my depth hereAny help would be awesome

Submitted January 23, 2019 at 01:16PM by CucumberMilkshake

How to flush an endpoint?

So I have an endpoint that returns an array of objects for my react application to use. The application basically shows the objects as entries in a list. When I click sign out, which is just an And view the data again, it's now doubled in size. I've tried emptying out state on the front end, but it's a node issue. I was wondering how I flush an endpoint in node, and haven't found much in the way of help online.​

Submitted January 23, 2019 at 11:33AM by HUMBLEFART

Node Express Passport Facebook Twitter Google GitHub Login

https://www.djamware.com/post/59a6257180aca768e4d2b132/node-express-passport-facebook-twitter-google-github-login#.XEhLAH9Y1xw.reddit

Submitted January 23, 2019 at 11:08AM by bhavisingh

How Do You Send to Slack When Deploying Using PM2?

I'm lost and slowly giving up. I deploy using PM2 but I couldn't find a way to send to slack after a successful deployment in PM2.I checked their docs and couldn't find anything related to that.I'm an Android dev and slowly learning nodeJS and the JS community. Been scratching my head a lot of times. If you guys could help me, I would greatly appreciate it. Thank you!

Submitted January 23, 2019 at 07:15AM by arthlimchiu

Github projects that showcacase good principles?

I'm 2 months into making a backend for an android/ios app and things are slowly getting out of hand.I didn't have much luck with the github search so I'd like if any of you guys coud point me to some projects on a larger scale that showcase how they've handled things.

Submitted January 23, 2019 at 07:51AM by moneymakingmiguel

NPM ideas and help

Hi there, hope all is well!​So I want to start developing some open source npm modules, in part to help for when I need to start applying for jobs I can show off and in part because I like the community.​I don't really know where to start though.​So really what I'm asking is what is needed and how can I publish it to npm?​Thanks, Ed.

Submitted January 23, 2019 at 07:53AM by thelynched

Tuesday 22 January 2019

Use node-oracledb 3.1's connection tagging to efficiently set session state

Node-oracledb 3.1 is now available on https://www.npmjs.com/package/oracledbMain improvements:Connection taggingNew-connection callbackExplicit session dropMulti-binary installDeferred Oracle Client library initializationRelease Announcement: https://blogs.oracle.com/opal/use-node-oracledb-31-connection-tagging-to-efficiently-set-session-stateChange Log: https://github.com/oracle/node-oracledb/blob/master/CHANGELOG.mdInstall: https://www.npmjs.com/package/oracledbQuick Start Installation instructions: https://oracle.github.io/node-oracledb/INSTALL.html#quickstartUser Guide: https://oracle.github.io/node-oracledb/doc/api.html​​

Submitted January 23, 2019 at 01:49AM by cjbj

First npm package, zero dependency console text box

https://www.npmjs.com/package/console-text-boxHey, this is a pretty simple lib, 0 dependencies.Started out as a fun project then realised im filling a bit of a gap in the npm sphere.Let me know what you think.​​

Submitted January 23, 2019 at 01:38AM by LVCXD

moving 700 images from old storage and database to aws S# and new database

I was tasked with rebuiliding a website built with laravel 5.1 which has around 700 images.Now I'm more of a frontend guy with some backend experience (both php and node), but i have very little experience with migrating existing data to new infrastructures.The only idea I've had so far was to create special migration endpoints to retrieve and process data into new infrastructure.I've tried it but i have issue with images, where either a very few error out (timeout or getaddrinfo ENOTFOUND) and always endup with more images than i should which i find baffling.​What are tried and tested workflows for what i'm trying to achieve?​EDIT:Little bit more about structure​{ "id": 850, "model_type": "App\\Models\\School", "model_id": 27, "collection_name": "gallery", "name": "Study Anywhere_Entrepreneur Education Gold Coast 2", "file_name": "Study Anywhere_Entrepreneur Education Gold Coast 2.jpg", "size": 143744, "manipulations": [], "temp": false, "order_column": null, "created_at": "2017-07-13 07:49:50", "updated_at": "2017-07-13 07:49:50" }, ​This is a sample entry from media table The id column specifies the name of directory where the file is stored. From what i've seen all are in .jpg

Submitted January 22, 2019 at 11:28PM by Leezorq

For the love of Pipes - Not node per se but we can appreciate this

https://blog.jessfraz.com/post/for-the-love-of-pipes/

Submitted January 22, 2019 at 08:21PM by zoon_politikon

[Help!] API endpoint through Express works on localhost but gives 500 error on web server

I'm running a node app with express and I've built an endpoint for a filtering functionality.It works totally fine when I am running locally but when I deploy onto the web server, it gives me a 500 error when trying to post to the api endpoint.Everything else works, the logic/functionality, etc, its just the XMLHttpRequest status failsThe web server is on https, while my local is just running http. Could this have something to do with what is going on and why the endpoint is failing? It started happening fairly recently, although I am certain it was running earlier on https totally fine so i am really stumped here.Thanks in advance

Submitted January 22, 2019 at 07:21PM by searchingforroots

Convert a String to a Number in JavaScript

http://thecodebarbarian.com/convert-a-string-to-a-number-in-javascript.html

Submitted January 22, 2019 at 07:20PM by code_barbarian

Code structure and call flow

I want to create a service which returns the github users who has repos in a specified programming language and a username. The response should contain the user info i.e. name, followers etc.​This is the url on localhost once this is receivedI obtain list of users with this urlThen for each user his info is available in the json returned above in the url field (like this)I have written the first draft of the functionality and code is available here​My main concern is what functionality should userController do and what should the userService do. Should I write separate file to make the rest calls (as both url calls are get and was thinking to reusing the code).​Any help to make the code modular following the SOLID patterns would be appreciated and I am thinking to cache the response for certain period of time in redis (for pagination). Is this the right way to go?​

Submitted January 22, 2019 at 03:24PM by stopcharla

How to install a MongoDB for GraphQL

https://blog.graphqleditor.com/installing-graphql-to-mongo/

Submitted January 22, 2019 at 02:09PM by oczekkk

Unable to install module

I am trying to install the following module:​https://www.npmjs.com/package/posix-fork​The actual code seems only 1 page: https://github.com/Fabel/posix-fork/blob/master/src/posix.cc​But I am getting errors, maybe because it's for a very old version of Node.​Can somebody please take a look and tell me how to get it work?

Submitted January 22, 2019 at 12:43PM by PlayerInfinityX

Question: NodeJS secure file saving into file system. Preventing path traversal

Hello,I'm writing simple desktop app using electronJS(Please don't judge me using electron. I need fast solution for all 3 platforms)(electronjs runs on Nodejs engine), which let's user to upload files to cloud, list files, download files.When user clicks Download file, app downloads file to users selected destination in his computer. I want to prevent path traversal vulnerability, which would allow overwrite users local files when they download others people uploaded files.Use case: user selects download location "/home/userName/Downloads". Uploaded file have name "../.ssh/id_rsa". So complete save location would be "/home/userName/.ssh/id_rsa" and your privatekey would be destroyed.​Possible solutions?:Filter file name and extension using blacklist and slice out characters like .. / \\ nullBytesIn web development blacklists normally never work, but in this case I need to allow all characters except malicious ones.var path = require('path');path.join('/home/userName/Downloads/', '../picture.jpg'); orpath.join('/home/userName/Downloads', '../picture.jpg');returns "/home/userName/picture.jpg", so path.join() doesn't help​Thanks.

Submitted January 22, 2019 at 01:21PM by AshamedRange

Just RPC...

I've already posted this in my account but wanted to share here also.​📫 RpiecyI'm looking for feedback so any is apreciated! Even the bad stuff ;)​Hi there,I just wanted to share one of my latests libs with you guys, also another sideproject whom was born from a project at work and we decided to separate it.​It's a RPC Request/Response checker/generator wich tries to follow JSON-RPC 2.0 specification.It helps you with creating RPC Requests, Responses, Errors and Notifications with ease. It also checks they are valid.Also it has included a "cli comunicator", it sends and receives requests from stdin, but can be really easily changed!​You can find it here: https://github.com/nombrekeff/json-rpiecyHere is an example:const rpiecy = require('rpiecy'); const request1 = rpiecy.createRequest('method', { /* params */ }, 'id'); const request2 = rpiecy.createRequest({ method: 'method', params: {}, id: 'id' }); request1.print(); request2.output(); const response1 = rpiecy.createResponse('id', { /* result */ }); const response2 = rpiecy.createResponse({ result: { }, id: 'id' }); response1.print(); response2.output(); // Parse will return a Request, a Response or a Notification depending on what was parsed! const parsed = rpiecy.parse('{"method": "method", "id": "id", "jsonrpc": "2.0"}'); request1.sendAndAwait() .then(response => { console.log(`Response for ${request.id}: `, response); }) rpiecy.listen((request) => { console.log(`Received request ${request.id}: `, request); request.response({ data: SOME_DATA }).output(); });

Submitted January 22, 2019 at 12:28PM by nombrekeff

Super simple example of a button for NODE please?

Can someone please give me a super simple example of some html code that has a single button on it, when clicked it sends a message back to the server side javascript which can then act on it.I just need a super simple example as every example I have looked for includes things like Express or MongoDB etc.e.g index.html, client.js and server.jsI just need to get my head around the basics and how they work.Thanks in advance,Mike.

Submitted January 22, 2019 at 11:15AM by TheArduinoGuy

Express SSR and API architecture

Hello all. I'm building my react SSR with express and my REST API. My question is, should I use the same express server for SSR and API or instead separate my API in another server and port??? I don't know if having everything in the same server would be not secure from client calls. Thanks in advance

Submitted January 22, 2019 at 09:17AM by chekuda

Monday 21 January 2019

Need help creating a dynamic file name path.

https://i.imgur.com/abppLLL.jpg

Submitted January 22, 2019 at 02:20AM by airwreck98

NodeJS to Executable

So I made a dumb virtual pet program using nodejs with 2 js files. How would I make it a file that can be executed? Can it be made into an ELF file? Or something similar that can be run/distributed on Linux?

Submitted January 22, 2019 at 03:23AM by ddmac__

How should a Nodejs newbie tackle user/login authentication?

Hi all,I just read a tutorial on how to implment based authentication using many frameworks like Passport, express-jwt, jsonwebtoken with bunch of other packages that is so confusing.So what should I dive in first to implement a local user authentication on Nodejs with Mongodb as a beginner?Should I only use Passport or only jsonwebtoken or any other packages or frameworks?

Submitted January 22, 2019 at 12:43AM by I3adAss

The future of TypeScript on ESLint

https://eslint.org/blog/2019/01/future-typescript-eslint

Submitted January 22, 2019 at 12:06AM by EntroperZero

I made an API Rest generator with Yeoman.

About why made this generatorI'm pretty new at NodeJS, I started using it about one month or so, therefore, I'm creating a lot of disposable-projects.I made this generator because I'm pretty lazy, and every time I needed to create an Entity I thought to myself: It would be very helpful if NodeJS had something like JHipster's entity generator (I'm used to Java).So instead of searching for a NodeJS generator, I started studying how JHipster was made. A friend of my told me about Yeoman so I started studying about it, and the result is this two generators: lazy-backend and lazy-backend-entity.Main packagesI'm using Express, mongoose, and joi.LinksMain GeneratorThe main generator is the lazy-backend, is responsible for creating the project.Npm GitHub​Entity GeneratorThe entity generator is responsible for creating the Entity (Entity = Routes, Controller, Model, and a Validator)Npm GitHub ​Plans for the futureAdd documentation/commentary for the generators and the generated project (If you guys could recommend a good and easy to document an API Rest I would be grateful. I've been searching about Swagger and APIDocs but I don't know which one to use)Add Front-end generator. (I've been studying React lately, so when I feel like I can do something reliability good I'll update the generator)If you find something that can be improved please tell me.If you want to contribute just send me a message.

Submitted January 21, 2019 at 08:56PM by UnDer_SeVen

Setting Up Swagger In a JavaScript Application

https://medium.com/@paigen11/d3c4d7aa56d4

Submitted January 21, 2019 at 08:22PM by kiarash-irandoust

Node.js multithreading: What are Worker Threads and why do they matter?

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

Submitted January 21, 2019 at 06:23PM by celestialvagabond1

A Better Way to Develop Node.js with Docker, And Keep Your Hot Code Reloading - Hacker Noon

https://hackernoon.com/a-better-way-to-develop-node-js-with-docker-cd29d3a0093

Submitted January 21, 2019 at 04:03PM by patrickleet

Zipping and unzipping files with NodeJS

https://mentorcruise.com/learn/zipping-and-unzipping-files-nodejs/

Submitted January 21, 2019 at 04:05PM by Sig_Luna

Portable Node.js guide

https://github.com/ehmicky/portable-node-guide

Submitted January 21, 2019 at 01:35PM by ehmicky

Come read my tutorial on how to build a simple chat app with node.js and socket.io

https://medium.com/@noufel.gouirhate/build-a-simple-chat-app-with-node-js-and-socket-io-ea716c093088​I wrote an easy to follow article on how to build a chat app with node.js and socket.io. I have taken time of explaining how sockets are working, how to setup a node server and also the front implementation.

Submitted January 21, 2019 at 01:19PM by djangster75

Managing images with GraphQL

https://fullstack-developer.academy/image-management-via-graphql/

Submitted January 21, 2019 at 01:20PM by tpiros

[HELP] Facebook Chatbot Learning Resources

Hi, I've been searching for tutorials how to create Facebook messenger chatbots with Node.js (with Postgres/Mongo) that can take restaurant orders, tickets and etc, but I still can't find good ones. Although other people do those like easy. Could you please throw me some resources to learn and read on. Thanks!

Submitted January 21, 2019 at 01:24PM by xzenuu

react-wasm - Declarative WebAssembly instantiation for React

https://github.com/mbasso/react-wasm

Submitted January 21, 2019 at 12:54PM by Teo_Basso

How to log response sent using middleware in express ?

Hey everyone.I'm trying to save the response for api in a file using custom middleware.Can anyone please help me with this ?How can we access the response body like res.statusCode.

Submitted January 21, 2019 at 12:34PM by MYTHiN07

[x-post from /r/javascript] mhy.js.org - an out-of-the box development environment

Greetings fellow developers,​I'd like to share my creation with you. After having enough of the repetative task to set up my environment for every project, after having enough of having the same npm packages on my machine multiple times over and over again (and syncing them to the cloud...), I decided to create a tool which I can use globally on any project from a single install. This `mhy` which supposed to `my` environment :) It's still in early stages but since the beta a few teams at my workplace already started to use in production and I think the results are kinda satisfying.Support for server side stuff is incoming also, but the main focus was client side until now.​https://mhy.js.org

Submitted January 21, 2019 at 11:13AM by wintercounter2

Cloud service for logging and visualization express requests and responses

Hi, redditors!I’m Indie hacker and earn money by developing web apis for enterprises.  My stack is node.js/express/elasticsearch/mongodb. I need to constantly watch how performs my APIs (avg. response time, response codes, etc) to complete the SLA. Does anyone knows good cloud services to do it?

Submitted January 21, 2019 at 11:15AM by sochix

HELP ! Fetching data on search & filter logic

Hello node redditers,My mobile app has implemented a search and filter method, it should filter products based on client criteria for exemple, brand, price etc..Suppose we have 1 million products, Is it better :- client fetchs all products from server then datas are filtered on client sideor- client sends http request for criterias (one or multiple) , then datas are filtered server side before sending back to client.​I believe they all have pros and cons.First method :Pros : datas are feched once / Cons : Datas are too big and can take times.​Second method :Pros : Only needed datas are fetch / Cons : A lot of request. Server does too much work in my opinion.Can anybody give me an insight ? What's the best way to deal with this without loosing on performance ?Thanks in advance for your help :)

Submitted January 21, 2019 at 09:42AM by Surikaate

How to create a REST API with Express.js in Node.js

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

Submitted January 21, 2019 at 09:43AM by rwieruch

Using worker_threads in Node.js

https://medium.com/@Trott/using-worker-threads-in-node-js-80494136dbb6

Submitted January 21, 2019 at 08:39AM by harlampi

Sunday 20 January 2019

JavaScript iterator patterns

https://loige.co/javascript-iterator-patterns

Submitted January 21, 2019 at 03:52AM by loigiani

What is the best way to write front end Javascript?

I really enjoy laravel's "laravel-mix" feature, because it allows me to write multiple javascript files, then compile them into one javascript file which I then import using the

Limit maximum connections to HTTP proxy under Puppeteer

Hello,is it possible to limit the number of concurrent connections to an HTTP proxy under Puppeteer?I seem to understand that I have to set up a policy file, but don't find additional details on how this is done under a local Puppeteer installation.

Submitted January 20, 2019 at 10:25PM by DavideBaldini

Need help with express/HTML routing, completely stuck

I've been at this for hours, and cannot for the life of me figure out what I'm missing. No doubt it's a simple thing, but I cant seem to see it. I open my html page, and... nothing happens when i click the submit button. Again, it's a dumb question, but I'm stumped.I've checked as many stackexchange solutions as I can find, as well as several other sites. Nothing works, or so it seems.HTML (cant get simpler than this)
JSvar express = require("express"); var bodyParser = require("body-parser"); var app = express(); app.use(bodyParser.urlencoded({extended: true})); app.post('/', function(req, res){ res.send("you sent " + req.body.name); console.log(req.body.name); }); app.listen(3000);

Submitted January 20, 2019 at 09:02PM by 1foryes

hexeye - Inspect binary data using a colorful CLI, in Node

https://github.com/ethanent/hexeye

Submitted January 20, 2019 at 09:09PM by Etha_n

I gathered challenging yet cool app ideas to build

https://www.strilliant.com/tags/coding-challenges/

Submitted January 20, 2019 at 09:32PM by thickoat

Best way to handle user registration?

I want to make a simple registration form for an app, and then let users add items to favorites, like, etc. What stack would be best for accomplishing this, so far ive only made some small rest apis using express with mongodb.

Submitted January 20, 2019 at 08:42PM by Jigsayan

Do multiple cores matter in Node?

I've started reading up on how Node works and I just learned that it only runs on a single thread. So does that mean that a dual core CPU and a quad core CPU with otherwise identical specs perform identically?

Submitted January 20, 2019 at 08:45PM by Intellectual-Madman

How to debug Node.js in a Docker container

https://dev.to/alex_barashkov/how-to-debug-nodejs-in-a-docker-container-bhi

Submitted January 20, 2019 at 08:27PM by r-wabbit

Connecting NodeJS Request Promise API to React.JS

Hey everyone,I apologize if this isn't the right subreddit but I thought this would be a good place to ask.Anyway, I'm currently trying to build an app using the coinmarketcap api. I have the basic skeleton up thus far, but I'm a little confused on how to fetch a NodeJS request-promise from the client side. I'm able to console.log the API, but I don't know how to pull this in with React.Attached below is a gist link to my server.js file along with my main App file.https://gist.github.com/camus-code/84c53662d29bf973e8ba2f167122727cThanks in advance!

Submitted January 20, 2019 at 07:25PM by kevbr

Could use a hand with a bit of code, POST method from form

I swear this was working last week, but now it aint. Any help appreciated. And I know it's a seemingly dumb question, but I know I'm missing something obvious. Must be the hangover.HTML:
JS.var express = require('express'); var bodyParser = require('body-parser'); var app = express(); app.use(bodyParser.urlencoded({ extended: true })); app.post('/', function(req, res) { var pName = req.body.name; res.send('You sent the name "' + pName + '".'); console.log(pName); }); app.listen(3000, function() { console.log('Server running at 3000'); });

Submitted January 20, 2019 at 05:53PM by 1foryes

Getting all listening ports with the net module?

Hello all,​I've been looking through the net module in node, but the answer wasn't self evident to me. Is there a way to simply get all listening ports on a server?​Kind regards

Submitted January 20, 2019 at 04:28PM by sma92878

Asyngular; a SocketCluster fork optimized for async/await

https://medium.com/@jonathangrosdubois/introducing-asyngular-a-socketcluster-fork-optimized-for-async-await-16de2877d5b3

Submitted January 20, 2019 at 04:54PM by jonpress

Random Key NodeJs

Hello! I made some research and couldn’t find what I need, basically I would like to generate a random key that having the following format XXX-XXX-XXXX

Submitted January 20, 2019 at 03:35PM by RamoSterious

Could someone explain how DEBUGGING "attach by process ID" and "launch" works?

Hi all,I am debugging nodejs with vscode and see the options to debug "attach by process ID" and "launch". When I have a simple nodejs script, setting the breakpoint on vscode prior to starting the script seems to work but in a sophisticated nodejs project with npm script - I have to debug by "attach by process ID". I don't understand what happens under the hood. Could someone please explain this in layman's terms?Side note: I have a Linux background and understand how processes work at a high-level.debug: https://www.youtube.com/watch?v=2oFKNL7vYV8​

Submitted January 20, 2019 at 11:56AM by git_world

Free API to speed up forms creation and validation.

We have developed an API that includes multiple services:Gender API: determine the gender of a first name.ZIP Code API: get zip code state and city, and list zip codes in city.Validation API: validate data using object data notation.Check the working example at: form-api.comYour feedback is welcome :)

Submitted January 20, 2019 at 08:28AM by FormAPICOM

Saturday 19 January 2019

Confused on the order these are fired

I have an API that updates a user's profile and then gets the user's information again, send it back to the client.In my API, I haveawait client.query(`UPDATE user_profiles SET user_business_name = $1, user_address = $2, user_phone = $3, user_city_code = $4, user_country = $6, user_region = $7, user_city = $8 WHERE user_profile_id = $5`, [req.body.businessName, req.body.address, req.body.phone, req.body.code, req.session.user.user_id, req.body.country, req.body.region, req.body.city]); let user = await controller.session.retrieve(req.session.user.user_id); But it seems the controller is still getting the old user data before the above the query. This is my controller.jsconst db = require('../db'); module.exports = { session: { retrieve: async(id) => { let user = await db.query(`SELECT users.username, users.user_email, users.account_type, users.user_status, users.is_subscribed, users.plan_id, users.user_last_login, users.user_level, users.subscription_end_date, user_profiles.*, user_settings.*, user_listings.listing_status FROM users LEFT JOIN user_profiles ON user_profiles.user_profile_id = users.user_id LEFT JOIN user_settings ON user_settings.user_setting_id = users.user_id LEFT JOIN user_listings ON users.username = user_listings.listing_user WHERE users.user_id = $1`, [id]); if (user && user.rows.length === 1) { return user.rows[0]; } else { return false; } } } } When I change user's business name from BC #1 to BC's #1 and log it on my client side, I still see BC #1. Shouldn't the UPDATE fire first and then the controller selects the new updated data in controller?

Submitted January 20, 2019 at 05:10AM by eggtart_prince

How to list files

I am trying to display all all files in a folder using NodeJS. The folder structure is data > subdata_folder > file I expect the second time I run fs.readdir to display the files I am only Code const path = require('path'); const fs = require('fs'); let p = path.resolve(__dirname, '..', 'data'); fs.readdir(p, (err, folders) => { for (var i = 0; i < items.length; i++) { let folder= p + '\\' + folders[i]; pathland = String.prototype.toString(folder); console.log(folder); fs.readdir(pathland, (err, file) => { console.log(file) }); } }); ​

Submitted January 20, 2019 at 01:24AM by citrinemachine

why write C/C++ addons for nodejs?

Hi all,what are the use cases in a pragmatic world to write C add-ons for nodejs? I read that it can extend nodejs capabilities but please describe a scenario.

Submitted January 19, 2019 at 11:55PM by git_world

jq-alternative for processing data with pipelines composed of functions

https://github.com/raine/ramda-cli

Submitted January 19, 2019 at 08:50PM by rair41

hey: A human-readable interface for terminal commands

https://github.com/chrisdothtml/hey

Submitted January 19, 2019 at 09:13PM by here-for-karma

I wrote about how to Dockerize Node.js

http://concisecoder.io/2019/01/19/how-to-dockerize-node-js/After recently Dockerizing a React side project, I decided to create a blog post to compile some of the best practices and common pitfalls I found into a tutorial with explanations. Any feedback is welcome and appreciated, including anything I may have missed.

Submitted January 19, 2019 at 07:58PM by concisecoder

Beautiful theme/template for jsdoc generated documentation

https://github.com/SoftwareBrothers/better-docs

Submitted January 19, 2019 at 07:20PM by lysywojtek

Can't connect to service when using consul for service discovery | Node.js

https://www.reddit.com/r/learnprogramming/comments/ahodb9/cant_connect_to_service_when_using_consul_for/

Submitted January 19, 2019 at 06:04PM by jsdfkljdsafdsu980p

Complex Question, Cant Really Summarize

Hey everyone, me again.This question is complicated not because of the code but rather the way I have to write the words. I'm almost positive that the code will be incredibly easy, but I cant find it.When I wrote my portfolio I stored my username and password on a database upon creation. Then I created a middleware folder with an index.js file. This file checks to see if I'm logged in. If I'm not logged in, it redirects to the login page or home page. This stack was (effectively) MEEN.My question is, is there a way to use that same middleware within vue by passing the session data back to vue?

Submitted January 19, 2019 at 04:42PM by randygbiv

Yet Another Simple NodeJS App, Push To Github Repo (YASNA, P2G)

https://numoonchld.github.io/2019/01/18/generate-an-express-app.html

Submitted January 19, 2019 at 02:35PM by rsaralaya

Async Stack Traces in Node.js 12

http://thecodebarbarian.com/async-stack-traces-in-node-js-12.html

Submitted January 19, 2019 at 09:09AM by dobkin-1970

Friday 18 January 2019

Simple application using Nodejs Express (backend) and React JS (frontend)

I created a simple User Management application using nodejs and reactjs and mongodb.Here is the github link: githubHere is the live URL for the application: userManagement.Please provide your suggestions.

Submitted January 19, 2019 at 05:18AM by ag0965

NodeJS Books or resources Recommendations?

I know intermediate Python.

Submitted January 19, 2019 at 06:30AM by normandantzig

polydev - Faster, route-centric development for Node.js apps with built-in Hot Module Replacement.

https://v.redd.it/g3amxw5aabb21

Submitted January 19, 2019 at 04:59AM by ericclemmons

I would like feed back on this demo API I build

I built this to replicate a business solution I implemented. While this one doesn't really do much, I'm interested in thoughts on code structure and improvements you think I could make.https://github.com/scottminter/express_mysql_restful_api

Submitted January 19, 2019 at 04:08AM by the_amazing_spork

Small ES6 Proxy utility to mock Date without monkey patching the globals

https://github.com/capaj/proxy-date

Submitted January 19, 2019 at 01:20AM by Capaj

Refactoring Controllers (Route Handlers)

Hi all,In the context of nodejs backend API applications, is it accurate to say that controllers(route handlers) have the following responsibilities (and nothing more):Extract the parameters (query or body) from the requestCall external functions to perform backend operationsReturn an HTTP response (with status code and serialized data)In the past, I have (admittedly with lack of foresight), done something of the following nature:function createUserController(req, res, next) { const userName = req.body.name // perform CRUD operations with an ORM User.create(userName) .then(function() { res.status(200).end(); }) .catch(function() { res.status(400).end(); }) } Aside from a bloated controller, I end up having express related objects passed down to data layers (as stipulated here: https://github.com/i0natan/nodebestpractices#-12-layer-your-components-keep-express-within-its-boundaries), which also makes it more difficult to unit test.To remedy this issue, what do you think of the following implementation:// Controller function createUserController(req, res, next) { const userName = req.body.name // perform CRUD operations with an ORM userDataOperations = new UserDataOperations(); userDataOperations .on('SUCCESS', function() { res.status(200).end() }) .on('ERROR', function() { res.status(400).end() }) userDataOperations.saveUser(userName); } // CRUD operations class UserDataOperations extends EventEmitter { saveUser(userName) { User.create(userName) .then(function() { this.emit('SUCCESS') }) .catch(function() { this.emit('ERROR') }) } } Have you guys experienced any issues with an EventEmitter implementation? How would you generally approach this?

Submitted January 18, 2019 at 10:06PM by raccoonranger73