Saturday 31 August 2019

File Upload In Node.js Using Multer

https://codesquery.com/file-upload-in-node-js/

Submitted September 01, 2019 at 07:12AM by hisachincq

XML to JavaScript object converter in Node using node-xml2js

https://codingshiksha.com/javascript/xml-to-javascript-object-converter-in-node-using-node-xml2js/

Submitted September 01, 2019 at 07:14AM by coderchrome123456

Is there a npm package to control another script?

Hi. I have a python scripts that asks for multiple parameters in execution time (depending on variable facts, so they cannot be passed as simple command line arguments). I have found a Python3 module that handles this, however my application is entirely made using Node and the only part using Python is the script in that file (because there is a library that I need which is exclusive to Python).In case you're aware of a package to achieve this, let me know. Thanks.

Submitted September 01, 2019 at 07:25AM by iwanttobemayor

How do I connect to mysqlDb using Axios and node

How do I connect to mysqlDb using Axios and node

Submitted September 01, 2019 at 02:24AM by Drexx_B

Critique my work. In house database migration handler for node-postgres ('pg').

I love NodeJS but don't like using an ORM. I like working with raw sql and the 'pg' module works just fine for me. The one thing stopping me from ditching an ORM was database migrations. I tried out TypeORM and noticed it tracked migrations using a migrations table and stored the name of the last migration that was run. Generating files with a timestamp and creating a migrations table didn't seem like a lot of work so I did it myself. Now I get the benefit of using migrations and not having to learn how to use an ORM.https://github.com/seanpmaxwell/InHouseDbMigrationHandler​P.S. the reason I didn't like using an ORM was cause I didn't like having to double check the SQL in my migrations and having to google how to do queries with the ORM when I already know SQL. I was like, what's the point of an ORM if I have to double check my sql anyways?

Submitted September 01, 2019 at 04:46AM by TheWebDever

Routing

Should routing be done in React or in nodeJS, I see that you can make routes as a part of back-end, by I can also install an npm extension are do it in React? Question is do I do server or client side routing

Submitted September 01, 2019 at 01:53AM by Drexx_B

User Login / Registration System without database?

I came up with the idea to make a User Login / Registration System with node.js by simply storing the users' information in a JavaScript file. When a user registers, node.js would edit that file to add their information with arrays - for example, it creates an array named with the person's username and that array holds the username (again), the password and the e-mail. And when a user logins, node.js would scan through that file for matches. As far as I know, JavaScript files can be hidden from the user but I still want some advice, is it safe? Are there more clever ways to do this (excluding databases)?

Submitted August 31, 2019 at 09:39PM by Plam3n04

[Help] searching for a mentor

hello their i am new to node and to the async system in general i come from a PHP background ( im a junior backend dev ) and im in sarch for a mentor to help me understand node express ( or any framework ) and asynch dev in general

Submitted August 31, 2019 at 07:40PM by rcm005

Securing auth tokens, which one is better: send auth token to front and let them save it in a localstorage, or just store it yourself in cookie/cache with sessions?

Just asking, wanna find out which one is more secure.

Submitted August 31, 2019 at 06:46PM by warchild4l

[Help] Why am I still getting a 500 error when I'm doing a POST postman request, everything looks fine?

When I try to make a post request I get no response, and I saw that I was actually getting a 500 error, so it's something on my end, but I have no clue what it could be. What's wrong with this code? By the way, I'm following this tutorial.File Structure:​https://i.redd.it/hrfban3r4tj31.pngApp.js:const express = require('express'); const app = express(); const mongoose = require('mongoose'); const morgan = require('morgan'); const bodyParser = require('body-parser'); const cookieParser = require('cookie-parser'); require('dotenv').config(); //import routes const userRoutes = require('./routes/user') const port = process.env.PORT || 8000; const database = process.env.DATABASE; //MIDDLEWARE app.use(morgan('dev')); app.use(bodyParser.json()); app.use(cookieParser()); //routes app.use('/api', userRoutes); //db mongoose.connect(database, { useNewUrlParser:true, useCreateIndex:true }).then(()=>{ console.log('Connected to database!') }) //run server app.listen(port, ()=>{ console.log(`listening on port ${port}`) }) /routes/user.js:const express = require("express"); const router = express.Router(); const { signup } = require("../controllers/user"); router.post("/signup", signup); module.exports = router; /controllers/user.js:const User = require('../models/user'); exports.signup = (req,res)=>{ console.log('req.body', req.body) const user = new User(req.body); user.save((err,user)=>{ if (err) { return res.status(400).json({ error }); } res.json({ user }); }) } Model:const mongoose = require('mongoose'); const crypto = require('crypto'); const uuidv1 = require('uuid/v1'); const userSchema = new mongoose.Schema({ name: { type:String, trim:true, required: true, maxlength: 32 }, email: { type:String, trim:true, required: true, unique: 32 }, hashed_password: { type:String, required: true }, about:{ type:String, trim:true }, salt:String, role: { type: Number, default: 0 }, history:{ type: Array, default: [] } }, {timestamps:true}); //virtual field userSchema.virtual('password') .set(function(password){ this._password = password; this.salt= uuidv1(); this.hashed_password = this.encryptPassword(password); }) .get(function(){ return( this._password ) }) userSchema.methods = { encryptPassword: function(password){ if(!password){ return '' } try{ return crypto.createHmac('sha1', this.salt) .update(password) .digest('hex') } catch(err){ return ''; } } } module.exports = mongoose.model('User', userSchema); Thanks so much! If you need to see anything else let me know!

Submitted August 31, 2019 at 05:04PM by LawlessWalrus1

Different approaches for building a website that aggregates news from multiple sources, how to go about this?

I am trying to build a website that aggregates news from multiple sources (Node.js)After doing lots of research, it seems that there are multiple approaches to do this sort of thingSimplest Way:Subscribe to something like Google News rss for the interested categories of news and simply relayThe simplest way mentioned above is ILLEGAL if you are doing this for commercial purposes which is exactly my planModerately Complex Way:Get a bunch of RSS urls from each websiteScan them every minute or twoCheck if there are any changesProceed to emit changed itemsAfter hours of searching on GitHb I found THISThis library was updated 4 years ago thoughIs something wrong with this method?Does it not work for 2019Extremely Complex Way:Have AI load each pageExtract contentFilter tags and other anomaliesProcess and storeQuestionsHow do I go about this, I dont plan to involve AI on day 1Is RSS the way to go in 2019?Is anyone aware of any techniques apart from the 3 I listed to build such a website?Thanks

Submitted August 31, 2019 at 05:23PM by amazeguy

How do I connect React native , node (express) ??

I am a beginner and trying to make an app using react native but while connecting to the server. I stuck there . Any tutorials link or suggestions would be appreciated.

Submitted August 31, 2019 at 04:18PM by crusarappy

Authenticate your users in Node with Passport.js

https://codingshiksha.com/javascript/authenticate-your-users-in-node-with-passport-js/

Submitted August 31, 2019 at 12:39PM by coderchrome123456

I built a selfhosted open source privacy-friendly analytics using Typescript, React, Express, PipelineDB (Postgres)

https://github.com/sheshbabu/freshlytics

Submitted August 31, 2019 at 10:30AM by sheshbabu

How do i use dynamic query in mongoose

​I have created an employee attendance application where attendances are logged and stored in a database. I have been able to obtain a count of the particular date-field with the value of "Present"the code is written like so :Employee.collection.countDocuments({"attendances.2019-08-26":"Present"},(err,data)=> { if(err){ res.status(500) res.send(err) }else{ res.status(200) res.json(data) } }) // mongoDb database records { "_id": "5d6565236574b1162c349d8f", "name": "Benjamin Hall", "department": "IT", "origin": "Texas", "employDate": "2019-08-27", "__v": 0, "attendances": { "2019-08-28": "Sick" } }, { "_id": "5d6367ee5b78d30c74be90e6", "name": "Joshua Jaccob", "department": "Marketing", "origin": "new york", "employDate": "2019-08-26", "__v": 0, "attendances": { "2019-08-26": "Present", "2019-08-27": "Sick" } }, // output is 1 //schema const Schema = mongoose.Schema; const employeeSchema = new Schema({ name: String, department: String, origin: String, employDate: String, attendances: Object }); module.exports= Employee = mongoose.model('Employee', employeeSchema); How can I create a dynamic query, for instance, how do I get all document with "present" in the last 7 days? really wish someone will help out!

Submitted August 31, 2019 at 09:36AM by 2virtual

NAPI throws it's own error message instead of own error message

Let's say I have 1 million promises in my node program that will never return, how does nodejs tell the kernel to handle these asynchronous functions?

I understand that the main event loop is a single thread and that the functions can execute asynchronously. I also heard that the async functions aren't multithreaded but instead scheduled by the Kernel..somehow that i can't really grasp.So I was thinking, if I have a promise that just does an infinite loop before returning a promise (so it never returns the promise and keeps on running), and I have 1 millions of those, how does the kernel and nodejs handle those functions? Will it still execute asyncronously? Will the functions, which are each processes have to share each core?

Submitted August 31, 2019 at 07:36AM by sterling729

Very Peculiar Mongo Behaviour !

I'm using Passport, Passport-local-mongoose for User Registration and Management.When i create a token hash. It just get saved with "user.resetPasswordToken". This particular field is not existing in the User Schema Model until now when I have saved it.The peculiar part is if I change the name to anything else for example "emailverificationToken" then the token does not get saved in the database nor is the field created.Infact other than "resetPasswordToken" field I cannot add any other field to the user doc.Not really getting why.P.S. "resetPasswordToken" as already something I use for forget password system. Hence want to change the name to "emailverificationToken". But it's just not happeningBelow is part of my code for User Email Verification: -User.register(newUser, req.body.password, function (err, user) {if (err) {console.log(err);req.flash("error", err.message);return res.redirect("/register");}passport.authenticate("local")(req, res, async function () {try {var user = await User.findOne({ _id: req.user._id });console.log(user);var userEmail = user.email;var host = req.headers.host;var token = await crypto.randomBytes(20).toString('hex');user.resetPasswordToken = token;user.emailverificationToken = token;await user.save();await sendEmailVerificationMail(userEmail, user.username, host, token);req.flash("success", \An e-mail has been sent to verify ${userEmail}.`);res.redirect("/");} catch (err) {console.log(err);req.flash("error", err.message);return res.redirect("/");}});});});`​Result{emailVerified: false,_id: "78839da18de156252410edf6b8",username: "abc",firstName: "abc",lastName: "abc",email: "abc@gmail.com",mobile: "2625351153",accountCreated: "2019-08-31T06:51:10.848Z",__v: 0,resetPasswordToken: "ads5fsdfg5df4gsd5fhsdfhsdhsdd"}Issue :- No filed created for "user.emailverificationToken = token;"Thanks in advance!

Submitted August 31, 2019 at 08:07AM by ujshah

Scraping Reddit's API in NodeJS with Snoowrap

https://browntreelabs.com/scraping-reddits-api-with-snoowrap/

Submitted August 31, 2019 at 08:10AM by pmz

Friday 30 August 2019

ressources for guided Node Rest APIs

I want some resources that can help me get used to building advanced APIs

Submitted August 31, 2019 at 02:49AM by AhmedBenAmmar

The only introduction to Redux (and React-Redux) you’ll ever need. In case you're using the MERN stack, check it out!

https://medium.com/@h.stevanoski/the-only-introduction-to-redux-and-react-redux-youll-ever-need-8ce5da9e53c6

Submitted August 31, 2019 at 12:14AM by yodaanakin0

res.json vs res.end

I know res.json returns a JSON object. But does it end the request ?Or must I do res.json(some_json_obj).end()Thanks for answering

Submitted August 30, 2019 at 10:28PM by minot0r

Enable CORS in node.js app

https://codesquery.com/enable-cors-nodejs-express-app/

Submitted August 30, 2019 at 09:46PM by hisachincq

How to store a password in the database

https://learnworthy.net/how-to-store-a-password-in-database

Submitted August 30, 2019 at 08:26PM by susanvilleula1

Build a Simple Password Generator in Node.js

https://codingshiksha.com/javascript/build-a-simple-password-generator-in-node-js-coding-shiksha/

Submitted August 30, 2019 at 06:16PM by coderchrome123456

D3 object projection can't set to center

Hi, so i'v been wanting to create a choropleth map of the philippine map using D3 im using topoJSON for my geodata. so i have a bit of a problem to center the object or adjust it's position. i have using the center function with .geoMercator() but still no changes here's what happen.​It's pushing to the far right.Here's my code.

Philippines

and the link for the topoJSON file: https://raw.githubusercontent.com/deldersveld/topojson/master/countries/philippines/philippines-provinces.json

Submitted August 30, 2019 at 04:12PM by Magic-Sarap

I made an open-source, Pokemon-inspired Auto Chess game with TypeScript, React and Node

https://github.com/Jameskmonger/creature-chess

Submitted August 30, 2019 at 03:39PM by jkmonger

Is it possible to create a rest api using jwt token for a website that needs to track if the is logged in/out?

Hi, I have a website in node.js using express, all the current pages are ejs template files, that are rendered accordingly to parameters.If the user is logged in, he can see's more options in the navbar, an can access some options, like editing or deleting posts, which are not possible if the user is not logged.Using the session approuch with express I can know if the user is logged in or not while rendering the page. I set some information in the cookies using express-session, and I can verify this information to render the content in the page or not.Recently I learned how to create a rest api using jwt token, and I was wondering if I could change my current website to an rest api, which would serve the webposts information through requests, and also perform update/deletes if the jwt token is valid and autenticated.My problem is that I don't know how I would render the pages. For example, if the user is logged I need to render the page differently, with additional buttons and actions.Using jwt token I can know if the user is authenticated in the rest-api server, but my front-end server (the one that sends the webpages) wouldn't know this information and would be unable to render it correctly.How can I have the information if the user is logged, to render my views?

Submitted August 30, 2019 at 03:41PM by eliseu_videira

Using a second passport strategy using the same User model?

Hello, I started a node project some time ago using Node, Express, MongoDB and Passport using passport-local-mongoose for user auth using sessions, and my user model looks like this:const mongoose = require("mongoose"); const passportLocalMongoose = require("passport-local-mongoose"); var UserSchema = new mongoose.Schema({ username: String, email: String, password: String, //etc }); UserSchema.plugin(passportLocalMongoose); module.exports = mongoose.model("User", UserSchema); Now i want to create a react native app for the same webapp, so I want to use the same DB of users.My questions is: can I use something like passport-jwt alongside the current user model and auth strategy that I have on the website? Or do you guys recommend me to re-create the complete project using jsonwebtokens for auth only and then trying to import the current users DB?Thanks!

Submitted August 30, 2019 at 02:43PM by alejandrojsx

Not able to fetch any product data from json

https://repl.it/@nikki158/test

Submitted August 30, 2019 at 03:17PM by nikki_9279

Working with Asynchronous Javascript in Node.js Using Async.js

https://codingshiksha.com/javascript/working-with-asynchronous-javascript-in-node-js-using-async-js-coding-shiksha/

Submitted August 30, 2019 at 01:55PM by coderchrome123456

AWS Cognito example using React UI and Node.js REST APIs — part 3 (JWT secured REST APIs)

https://medium.com/@arron.harden/aws-cognito-example-using-react-ui-and-node-js-rest-apis-part-3-jwt-secured-rest-apis-e56d336ce306?source=friends_link&sk=5ca63d780da194341cdca5ebacede988

Submitted August 30, 2019 at 02:15PM by Fewthp

How do i deal with dates and times from my mobile client?

How do I deal with dates and time inputs from my iOS/Android application?Lets say a user starts a event at 2.30, my app sends the information about the event and the time it was started.Now umm? What then? Because if I save that to the DB like that, the event wont be visible to sime others in different time zones, even if it should be! Should i also send a code of which time zone it is with the share?But then again, we are relying on client input for this kind of thing, WHICH IS TERRIFYING, AND SO WRONG. So obviously the solution would be to stamp the event time on the server while saving it to the db! But the problem is still the same lol, then its the servers time, and people in different time zones will see the event timing wrong.What would be the best way to deal with this?I know this is question really simple, and ill probably figure it out on google in the next hour.So why did I make this post then?Because theres something else...What about when i have to delay the time of the request to the server? If im sending large amounts of small data, thats usually what you have to do, postpone a upload to the servers to a more convenient time.BUT, the times on the stamps still need to be EXACTLY when the data was gathered.My application and this specific feature requires 30 second percision.What do I do then?And what if the user changes the time on their phone to a fake time, how do I verify that its correct?

Submitted August 30, 2019 at 02:33PM by livinglibary

Save Money by caching paid APIs with Amazon CloudFront

https://www.codelime.blog/save-money-by-caching-paid-apis-with-cloudfront/

Submitted August 30, 2019 at 01:01PM by r-randy

Dynamically generating SQL queries using Node.js

https://medium.com/@gajus/dynamically-generating-sql-queries-using-node-js-e89d69930fcb?sk=5350f17e74e6c5c9edc5e1531a022c26

Submitted August 30, 2019 at 12:23PM by gajus0

A simple key-value database with multi adapter support

https://github.com/enhancd/endb

Submitted August 30, 2019 at 10:27AM by Whirl_

HLS Video stream capturing

Hello r/node,I was wondering about possibilities to record a video stream in a performant way. The streams I want to record are HLS. My current setup is a small NodeJS application which uses FFMPEG to record a HLS stream, but the final application needs to handle a lot of recording requests in parallel.My questions:Does anyone have experience with recording HLS streams?When presenting a recorded stream to an end-user, in what format should I present? Convert the recording to MP4 (this requires quite some processing power)?Would love to hear your thoughts

Submitted August 30, 2019 at 10:34AM by Saltroad_Patrol

Thursday 29 August 2019

Why Go for Java for Ethereum Blockchain Development

https://medium.com/@anubhavsingh2709/why-go-for-java-for-ethereum-blockchain-development-92bbaf827419

Submitted August 30, 2019 at 06:24AM by blockchainoodles13

updating user in mongo db using express

Hello, I have following user in my mongodb:email: String, username: String, password: String, acceptedTerms: Boolean, registrationDate: Date, gender: String, birthday: Date, firstName: String, lastName: String, city: String, state: String, zip: String, favoriteDestination: String, description: String now I want to send a new user to the server and all attributes that are different should be changed:for example I have//in db: ... username: "test", gender: "male", lastName: "" ... //new user: ... username: "testtest", gender: "male", lastName: "test" ... //after the update the user in the db should lokk like this: ... username: "testtest", gender: "male", lastName: "testtest" ... How would I write an request on my express server for this?This would be my code to register a user:router.post('/register', (req, res) => { let userData = req.body; let user = new User(userData); user.save((error, registeredUser) => { if(error) console.log(error); else { res.status(200).send(registeredUser) } }) });

Submitted August 30, 2019 at 07:10AM by UnknownInnocent

Discord bot + Express + Node.js in 5 Minutes

https://medium.com/@skryshtafovych/discord-express-node-js-f4acd68a6b75

Submitted August 29, 2019 at 10:43PM by skryshtafovychReal

Help with Mongoose Schema with existing Collection

A friend of mine wants a simple site to view some statistics that he has gathered. He has saved the data using mongodb and now I'm trying to create a simple api so that I can create a front end with the information (This is a sample of what each document looks like https://pastebin.com/KmxGSkPy)​Here is my issue, I tried creating a mongoose Schema which currently looks like this:const mongoose = require('mongoose');const profileSchema = mongoose.Schema({_id: mongoose.Schema.Types.ObjectId,uuid: String,name: String,essentials: { nick: String },options: {showScoreboard: Boolean, allowSpectators: Boolean, receiveDuelRequests: Boolean}});module.exports = mongoose.model('Profile', profileSchema);If you looked at the sample data I provided you can see that this is missing kitStatistics and loadouts, but this still works and gives back all of the information from my api running this code:app.get('/api', (req, res) => {Profile.find({name: "Irantwomiles"}, function(err, profile) {if(err) {res.send("error");}res.json(profile);})})Note, that the current name of the file is profile.js. Now if I were to rename this file to anything else, the api just returns and empty array [] . So my question is why does this work when its named profile, but then it doens't work when its named anything else? Does a schema need to match exactly to what I have in my collection?

Submitted August 29, 2019 at 09:38PM by Irantwomiles

As an aspiring Nodejs dev, are there certain parts of the JS language that I need to learn for the backend that I wouldn’t need to learn for the frontend? And vice versa?

While learning the basics of JavaScript for backend development, are there any parts of JavaScript that would be applicable to backend development but not frontend? Or perhaps certain data structures I should pay more attention to? Thanks!

Submitted August 29, 2019 at 08:14PM by Ty_David

How to think like a programmer

https://learnworthy.net/how-to-think-like-a-programmer/

Submitted August 29, 2019 at 08:40PM by PeteyCruiser123

Image Processing in Node.js Using Jimp Library - Coding Shiksha - Coding Shiksha

https://codingshiksha.com/javascript/image-processing-in-node-js-using-jimp-library-coding-shiksha/

Submitted August 29, 2019 at 04:17PM by coderchrome123456

Express Middleware - Mastering JS

https://masteringjs.io/tutorials/express/middleware

Submitted August 29, 2019 at 03:28PM by code_barbarian

How to Remove a Directory's Files & Sub-Directories in NodeJS

https://coderrocketfuel.com/article/remove-directory-files-and-sub-directories-in-node-js

Submitted August 29, 2019 at 03:38PM by jkkill

Build a JS Interpreter in JavaScript Using Acorn as a Parser

https://blog.bitsrc.io/build-a-js-interpreter-in-javascript-using-acorn-as-a-parser-5487bb53390c

Submitted August 29, 2019 at 03:09PM by JSislife

What is the Difference Between Node and Nodemon - Coding Shiksha

https://codingshiksha.com/blogs/javascript/what-is-the-difference-between-node-and-nodemon

Submitted August 29, 2019 at 01:38PM by coderchrome123456

Kubernetes Deployments 101

Folks,A Deployment resource uses a ReplicaSet to manage the pods. However, it handles updating them in a controlled way. Let’s dig deeper into Deployment Controllers and patterns.Here's this week article Kubernetes Deployment 101What's inside:Why use a Kubernetes Deployment?The Deployment definition.Performing Updates with Zero Downtime.Kubernetes Deployments Strategies Overview.Updating a Deployment while another is in progress.Scaling and Autoscaling Deployments.https://www.magalix.com/blog/kubernetes-deployments-101

Submitted August 29, 2019 at 01:39PM by AhmedAttef

How to make a Simple Keylogger in Javascript - Coding Shiksha - Coding Shiksha

https://codingshiksha.com/javascript/how-to-make-a-simple-keylogger-in-javascript-coding-shiksha/

Submitted August 29, 2019 at 12:16PM by coderchrome123456

Sequelize always needs a primary key on join where there is no primary key '_indcies.id' is not found'

Hi all,Been in a full goolge circle for me. Maybe this is a limitation in sequelize but I'm asking hoping my assumption is wrong.When I learned databases in college it was my understanding you can use an index table where a pair of keys can become the primary key. So this is great when you need a 3 way association (this example uses 2 but assume 3)The modelsconst Access = sequelize.define('access', {id: {type: Sequelize.INTEGER.UNSIGNED,autoIncrement: true,primaryKey: true},label: {type: Sequelize.STRING},weight: {type: Sequelize.INTEGER}});​const UserAccessIndex = sequelize.define('user_access_index', {access_id: {type: Sequelize.INTEGER.UNSIGNED,index: true},user_id: {type: Sequelize.INTEGER.UNSIGNED,index: true}});​const User = sequelize.define('user', {id: {type: Sequelize.INTEGER.UNSIGNED,autoIncrement: true,primaryKey: true},account_status_id: {type: Sequelize.INTEGER.UNSIGNED,index: true},access_id: {type: Sequelize.INTEGER.UNSIGNED,index: true},date_created: {type: Sequelize.DATE,defaultValue: Sequelize.literal('NOW()'),allowNull: false},date_modified: {type: Sequelize.DATE,defaultValue: Sequelize.literal('NOW()'),allowNull: false},date_subscription_expiration: {type: Sequelize.DATE,defaultValue: null,allowNull: true},date_last_login: {type: Sequelize.DATE,defaultValue: Sequelize.NOW,allowNull: true}});Access.hasMany(UserAccessIndex, { foreignKey: 'access_id' });UserAccessIndex.belongsTo(Access);User.hasMany(UserAccessIndex, { foreignKey: 'user_id' });UserAccessIndex.belongsTo(User);​When you join & use that modelawait User.findOne({attributes: ['id', 'account_status_id'],where: {id: userId,account_status_id: CONSTANTS.VALID_ACCOUNT_ID},include: [{attributes: ['access_id', 'user_id'],model: UserAccessIndex}]});​I get something like 'user_access_indcies.id' is not found. Sequelize injects the need for the primary key. When I debug there is 'originalAttributes' (which are correct) but then the 'attributes' .Am I missing something here or is sequelize just this opinionated?

Submitted August 29, 2019 at 12:45PM by bigorangemachine

Build KeyLogger using Node.js & WebSockets to exploit XSS vulnerabilities in a Site - Coding Shiksha

https://codingshiksha.com/javascript/build-keylogger-using-node-js-websockets-to-exploit-xss-vulnerabilities-in-a-site/

Submitted August 29, 2019 at 10:27AM by coderchrome123456

Need some help! What is that problem and how to resolve it?(I googled it, but I need to understanding). thanks in advance.

https://i.redd.it/34z1vlmw8cj31.jpg

Submitted August 29, 2019 at 08:14AM by haiahem

Problem with Mongo

Newbie with node here!I'm trying to make a connection with a database in my cluster but when I execute the script it returns "MongoError: MongoClient must be connected before calling MongoClient.prototype.db". I've already checked my code but without any avail. Does anyone know why this might be happening? Thanks beforehand

Submitted August 29, 2019 at 08:22AM by U_L_Uus

Feathers v4 with Typescript support released

https://blog.feathersjs.com/introducing-feathers-4-a-framework-for-real-time-apps-and-rest-apis-afff3819055b

Submitted August 29, 2019 at 08:27AM by ilja903

Wednesday 28 August 2019

How to customize CSV to XLS columns?

Total CSV Converter convert CSV and TSV files to PDF, XLS, XLSX, DBF, XML, JSON, HTML, TXT, DOC and a variety of OpenOffice formats. The program was designed to be convenient and user-friendly. Loaded with helpful customization options, the Total CSV COnverter doesn't just convert your files to a different format, it lets you make improvements along the way.When you export CSV to XLS you can use the options of making the header bold and column autofit.

Submitted August 29, 2019 at 05:52AM by miantanzeel

Node package with it’s own cli

Hi, everyone! I’m new to writing node packages and just wanted help with how to go about a project I’m working on.My question is how would you build a node package with its own cli built in? The package gets required in someone else’s code like normal but you have the option of using helpful commands to make any needed files, etc.I kind of understand how these work separately but I get confused in putting them together.Any help is appreciated. Thanks!

Submitted August 29, 2019 at 03:45AM by nnnicka

Pausing between API calls—sync or async?

Hey all, I'm currently working on a web app that involves lots of sequential calls to an external API. This particular API provides a list of data but it has a limit on the number of items that are given per request. For this reason, I have to loop through all the pages of the data to get everything I need. I wish to space out these requests by a second or so to minimize the traffic of the API.​So far with node.js, all the external API calls that I've made have been asynchronous (using promises) because it didn't matter how long it takes to move onto the next step, but I don't think that would be the best approach for this situation. Based on this assumption, how can I accomplish this in a synchronous manner? If it makes a difference, these requests are being handled by a third-party NPM package that uses callback functions. I know that it's not a good idea to force pauses into what would be asynchronous code, but I'm not sure how to translate it to the functionality I need.​Thank you so much for your input!

Submitted August 29, 2019 at 03:56AM by MindBodyLightSound

Help deploying a Node app built on IIS elsewhere

Hi, I would really appreciate some tips or guidance here. I’ve been asked to deploy a Node app to production that was built on IIS (I think they used an app service template on Azure). I seem to have got most of it working but I can’t work out how to re-write the web.config file from IIS to work as .htaccess.The web.config file is below. It looks like it has come from a template on Azure, as mentioned, and it needs the static content connecting to the public root and the dynamic content connecting to the Node app. Eg an image file should resolve as an actual file, whereas an endpoint created by the app should be routed to the app.I’m really not used to IIS and I’ve hit a bit of a mental block on how to do this! Thanks in advance.EDIT: sorry, I can’t get the code to post as a block, on mobile, am trying,,,Code moved to pastebin – https://pastebin.com/iGQtgfvp

Submitted August 28, 2019 at 11:15PM by Mr--Chainsaw

Can't SSH into digital ocean droplet

I'm new to this and just exploring but I'm having trouble. Here were my steps:​ssh -i ~/.ssh/my_key root@$SERVER_IP apt-get update adduser $USERNAME usermod -aG sudo $USERNAME su $USERNAME $ exit $ exit from my ssh directory ssh USERNAME@$SERVER_IP response isroot@SERVER_IP: Permission denied (publickey) I'm using a mac on Mojave and my server is using ubuntu 16.4. I've seen online that I should have a config file in my ~/.ssh/ directory but I do not.

Submitted August 28, 2019 at 11:51PM by dj1041

Express: Can the * be exploited?

So I’m making an app where the file you access is based off of your url using:app.get(‘/users/*’, (req, res) => { res.send(fs.readFileSync(__dirname + “/users/person/anotherfile/“ + req.url); });Obviously it’s not my real code, but the idea is the part after users will be the path to a file. If I put a ‘..’ in can you do anything with it, besides read data?My plan was to send a 403 if it contained a ‘..’ would this work? What other ways can the * be exploited?

Submitted August 28, 2019 at 08:54PM by Creeperofhope

What is your go-to way for authenticating graphql applications in node?

Something what would be useful for production app, also secure and managable. Currently using passport-instagram with graphql-ypga but having a route for auth seems not best practice at all.

Submitted August 28, 2019 at 07:34PM by warchild4l

I'm a JS/TypeScript developer with more than 8 years experience, where can I find some freelance projects or long term remote project?

Github https://github.com/tigranbsMedium https://medium.com/@tigranbs

Submitted August 28, 2019 at 06:20PM by tigranbs

A Practical Guide to Symbols in JavaScript

http://thecodebarbarian.com/a-practical-guide-to-symbols-in-javascript.html

Submitted August 28, 2019 at 05:11PM by code_barbarian

Sharing code between projects. How do you handle this?

How do you guys manage shared code between your projects. There's various bits of code from our mobile app, website, API, and tooling that are more or less the same. It would be nice to have a symbolic link of sorts between these projects to share this code and keep things DRY. If it was just something on my computer, a symbolic link would be easy enough. But, of course, this is something that's managed with git and npm and such.Creating a dedicated repo and referencing it in package.json seems like the best solution I've found but if you're working on something that requires, e.g., augmenting that shared code, the dev cycle gets incredibly tedious as you now have to push to github, update your package.json, and then install it.Are there tools or features of npm/yarn or git that I'm overlooking that would make this more manageable?

Submitted August 28, 2019 at 05:30PM by HasFiveVowels

Unhandled Rejection (TypeError): Cannot read property 'data' of undefined

I'm using express-fileupload to upload files but I have a problem that says the property data is undefined this is a property that comes with express-fileupload dependency so I don't know why am I getting this error, the files you should look in the repo are only 2 one is in the routes folder and it's name is movies.js there is all the implementation for uploading files and the other one is in the client folder under src/components and is the uploadImages.jsx component with an error on line 35const { filename, filepath } = res.data;here is the repo with the backend and the frontend, the frontend being the client folder.https://github.com/Ceci007/vidlyplease help and thanks beforehand.

Submitted August 28, 2019 at 01:31PM by CeciPeque

Upload images in node.js using express and multer

https://youtu.be/-Hvmj8yXfyU

Submitted August 28, 2019 at 02:02PM by subrat_msr

Regenerator Runtime not defined, I've tried every fix I can find

I'm new to node and React, and rather than using create-react-app I wanted to make my own webpack config and learn how that worked. But I've been having this regeneratorRuntime not defined issue for a day now, and I've tried every fix from the deprecated babel-polyfill to the direct import of core-js and regenerator-runtime, and I'm clearly doing something wrong.Here is my .babelrc{ "presets": [ [ "@babel/preset-env", { "useBuiltIns": "usage", "corejs": 3 } ], "@babel/preset-react" ], "plugins": ["@babel/plugin-proposal-class-properties"] } And here is the entry point to launch my serverrequire("ignore-styles"); require("core-js/stable"); require("regenerator-runtime/runtime"); require("@babel/register")({ ignore: [/(node_modules)/], presets: ["@babel/preset-env", "@babel/preset-react"], plugins: ["@babel/plugin-proposal-class-properties"] }); require("./server"); Any help would be greatly appreciated

Submitted August 28, 2019 at 01:06PM by XingXManGuy

Knex Objection

I'm new to this ORM and can't actually understand the initialization steps. Can someone help me out?

Submitted August 28, 2019 at 01:17PM by gaurav219

Questions for Mid / Senior Node.js Interview

Hey folks!I would like to create a website which helps developers prepare to Mid / Senior Node.js Interview. And on this website developer will find :roadmapmatrix of competencetechnologiesand common and unusual questions about it.Does anyone knows cool resources where I can thous materials?

Submitted August 28, 2019 at 11:49AM by delph09

Top GraphQL tutorials reviewed 2019

https://blog.graphqleditor.com/top-graphql-tutorials-reviewed-2019/

Submitted August 28, 2019 at 11:18AM by geekfreakdev

Moving to nodejs

Hello everyone.I've been on software&web development for some years and actually I'm studying Node for building the back-end of my apps. Using an express+mongoose+ejs stack. I like it, there's nothing bad I can say about it, but now I'm wondering if it is really useful. I mean, are there companies out there working with noSql databases and relying on Node for building their back-ends or Python, for example, sounds more solid and reliable?

Submitted August 28, 2019 at 10:46AM by 0023sm

Mastering Node.js version management and npm registry sources like a pro

https://snyk.io/blog/mastering-node-js-version-management-and-npm-registry-sources-like-a-pro/

Submitted August 28, 2019 at 09:10AM by lirantal

Need some help with encoding

I’m doing a project where I need to basically add a specific token into a request, but when the request is sent it encodes that token which makes it invalid. Is there a way to prevent that specific string from being encoded?

Submitted August 28, 2019 at 08:50AM by anton5009

Forward GitHub Pull Requests to your Phone with Standard Library and Node.js

https://medium.com/@notoriaga/forward-github-pull-requests-to-your-phone-in-5-minutes-with-standard-library-and-node-js-d18ea846305

Submitted August 28, 2019 at 07:59AM by notoriaga

Tuesday 27 August 2019

Scraping sites with Node, Axios, and Cheerio

https://browntreelabs.com/scraping-sites-with-node/

Submitted August 28, 2019 at 07:46AM by pmz

JavaScript, then what?

So other than a solid fundamental knowledge of JavaScript itself, as a junior node dev what are some CS concepts or other skills that I should have? Databases, a framework (Express, Adonis), what CS concepts will apply more so than others? Compilers, Networking, Architecture. Please don’t roast me, I’m sincerely wanting to learn. But I need to know what to learn first.

Submitted August 28, 2019 at 06:34AM by Ty_David

I have a question, and I want your guys suggestion.

If I had 100 million users (an exaggeration I know) in my database and I need to retrieve all of them. How would you do it such that it doesn’t sit there for a long time?I like to learn new things from experienced people.

Submitted August 28, 2019 at 04:21AM by GirthyWood

I have a Google cloud VM instance running. Is it possible to build a node app that runs commands on that VM terminal and get the output?

For more context, as a learning experiment I'm running a blockchain node through a Google cloud VM and want to build a node app that can query the blockchain network (which the VM is connected to) to do something like retrieve the balance of an address.Thanks a lot.

Submitted August 28, 2019 at 03:35AM by vegascrypto

Understanding and protecting against malicious npm package lifecycle scripts

https://medium.com/@kyle_martin/understanding-and-protecting-against-malicious-npm-package-lifecycle-scripts-8b6129619d7c

Submitted August 28, 2019 at 01:53AM by js-kyle

Run a node app as a child process and start/stop from an API?

I have a node app (known as Alfred) that runs some services on our network at work. It's pretty hacky...and occasionally gets into a bad state and needs to be restarted. I'm not always around to do this, the company won't give me a laptop to remote in, and it causes problems if it's in this state for too long say, over a weekend). So here's my proposed solution:I want to run a simple Express server with an API that can start or stop my Alfred service. There would be a button on Alfred's front end that would hit this API, which would stop the main Alfred process, then start it again. Alfred would initially get started when I run this API server.Is this feasible, and if so, how might I accomplish it? The only I know for sure is that I would have to host this API on a different port than what Alfred is listening on...I think...and I feel like the child_process package might be involved?

Submitted August 28, 2019 at 12:48AM by PM_ME_A_WEBSITE_IDEA

How to rewrite tutorial code using Async?

How do I write the it section of NetNinja's tutorial to use Async?Here is Netninja'svideo. Here is Netninja'sgithub.Here is Netninja's original code:githubHere is my attempt:it('Updates the name of a record', async function(){ await MarioChar.findOneAndUpdate({name: 'Mario'}, {name: 'Luigi'}); await function () { MarioChar.findOne({_id: char._id}); }.function(result){ console.log(`Result is ${result}`) }; }); Result: My console.logs don't show and I get an error at function(result).

Submitted August 28, 2019 at 12:39AM by normandantzig

auth, local electron with webApp

I have a working MERN app with authentication hosted on heroku, now I want users that register with this site to also be able to have a login/protected routes in the electron app, this app has nothing to do with the webApp and have differenz code, so I only want to authenticate users that signed up on web inside Electron app. Where do I start, do I need local 8n electron again a express server!

Submitted August 27, 2019 at 09:32PM by texxxo

I've never felt the need to use anything other than express...

Can someone explain to me some use cases that made you switch from express to something else? Is there something I'm missing (entirely possible)? Building a REST API with express is so trivial at this point.

Submitted August 27, 2019 at 09:44PM by ClassicPurist

All you need to know about Synchronous Iterators

It seems there are some problems with devto, so I had to find a workaround.

Submitted August 27, 2019 at 06:20PM by jfet97

Separate servers for web socket connections and REST API?

Good afternoon all!Apologies if this is a simple question - hoping someone with experience can save me some potential headache down the road. I've got a React front-end and a REST API back-end on separate servers. When looking at web sockets, it seems pretty easy to integrate into an Express server. My question is whether there are issues with handling web socket connections on the same REST API server or if I should separate the web socket requests into a separate server.Thank you all for any guidance you can offer on this!

Submitted August 27, 2019 at 06:09PM by SquishyDough

Get text content and link of HTML page with NodeJS/Cheerio

Going beyond NPM: meet Yarn & pnpm

https://blog.nicco.io/2019/08/27/going-beyond-npm-meet-yarn-pnpm/

Submitted August 27, 2019 at 04:37PM by CupCakeArmy

Has anyone saved base64 in mongoose with dridfs?

Hello everyone,​I'm trying to save base64 that come through a POST in gridfs with mongoose but I can't find anything that works for me,​My nodejs is with hapijs.​I have tried several libraries like https://github.com/aheckmann/gridfs-stream or https://www.npmjs.com/package/mongoose-gridfs​But I do not get the step of transforming the payload of the request to binary for storage in mongoose through the gridfs,​the truth is that I am somewhat desperate ...

Submitted August 27, 2019 at 05:03PM by adrikai

Strapi js

What are your thoughts on using Strapi to build a social network or any other kid of app outside of a blog?

Submitted August 27, 2019 at 04:13PM by ineedhelpcoding

Production mentor

I am currently in the tech spec phase of a personal startup I decided to go forth with. I know 99% of the time these things fail, but you miss 100% of the shots you don't take. I am more skilled in client-side development but have had trouble finding anyone to help lead the tech effort with me so I am deciding to just jump in.With that said I have never built a node server/api for production, only side projects. I want to make sure I do things right from the start, although I am aware of it being a learning process and mistakes will be made. So I was hoping to get a helping hand from someone more experienced in the domain that can sort of play a mentor role that I can ask questions about architecture, db backups, etc. to.If you would be willing to advise a lad, or interested in collaborating with a lad, please shoot me a dm!If this goes against the subs rules please do remove the post!

Submitted August 27, 2019 at 04:27PM by col0rcutclarity

Using `await` without try/catch blocks

https://github.com/craigmichaelmartin/fawait

Submitted August 27, 2019 at 04:30PM by jrtrah

DevOps/Deployment a little overwhelming for a beginner?

Hey all,I'm sure this question has been asked an answered hundreds of times, but I'd like to be a bit more specific for my use case.A little background, I am a Front End developer (circa 5 years, with 4 years of College), recently been building React projects. I have little to no backend or DevOps Experience (Other than seeing some jargon/services and briefly looking at a synopsis of what they are).I've recently been building a MERN stack application and have done a few tutorials on Udemy/FrontEndMasters to get to grips of backend development with Node (Which I am really enjoying and feel like I am learning a lot).However when it comes to the DevOps/Deploying side of things, I feel completely out of my depth with most of it, like, it seems so much more complicated/contrasting than just writing some code, also seems like there a lot of branching paths that can lead you down a rabbit hole.Any of the courses I have followed on Node development have detailed a reasonably basic deploy to Heroku without really delving into what I feel would be the real industry standards on deploying a Node.js application.Which leaves me in a scenario where I feel like there is a huge mountain of knowledge that I am missing out on and not sure where to look. Such as CI/CD, Docker, Kubernetes, Deploying to the likes of Digital Ocean/AWS/Azure etc.I get that DevOps isn't just one specific thing, but would like to know where to even start learning about DevOps in the Node.js world, any time I've tried to delve into research on this topic I get overwhelmed. Perhaps, it just isn't for me? 😂I guess my question comes in 2 parts.Are there any really good courses out there on more advanced deployment/DevOps so I can get my toes in the water? I prefer watching a video of someone talking through a topic rather then reading an article, but if there are some fantastic articles out there, would love to have a read through them too.What does your current DevOps/Deployment Strategy consist of with your Node.js projects? (Just so I can get a list of topics/services etc. to look into at a later date).Any help would be greatly appreciated!

Submitted August 27, 2019 at 03:53PM by Bongster7

Closures in JavaScript: Why Do We Need Them?

https://blog.bitsrc.io/closures-in-javascript-why-do-we-need-them-2097f5317daf

Submitted August 27, 2019 at 03:05PM by JSislife

What AWS Lambda’s Performance Stats Reveal

https://epsagon.com/blog/what-aws-lambdas-performance-stats-reveal/

Submitted August 27, 2019 at 03:18PM by nshapira

Building a "use status indicator" app, want to make it real-time. Is sockets.io my best option?

Hey all. I'm making a ridiculously simple app to show the "in use" status of an account I share with a friend. Right now I have it built using express and a mongodb database that stores a single object that represents the current user of the account. The interface for updating this value is basically just three boxes on a page that contain text indicating the user, and some DOM event listeners that update the color of whichever box gets selected. This in turn updates the value in the database so that the "use state" is persistent. I have it so that on page load, the app queries the DB and the current user is indicated in the aforementioned manner. However, if the user value is updated, the browser must be refreshed to guarantee that the new user will be indicated accurately.I was looking into sockets.io to make the background color of the boxes update in real time - so if my friend were to log on and indicate that he's using the account, I'd be able to see the change in real time. This is my ultimate goal - to be able to see any change to the use status (as indicated by my app) in real time. Right now everything works as expected - page load accurately reflects the current use state of the account, and I can update the use state and view its status - I just have to refresh the browser to check for any changes to the status made by the other user.I know that the scope of this project is really simple and kinda silly, but I'm using it as an opportunity to play with some back-end stuff in a low-stakes way. I'm willing to share some code if anyone is curious or particulars are necessary for getting a better idea of what I'm talking about.Thanks in advance for your help!

Submitted August 27, 2019 at 02:43PM by TiredOfMakingThese

Using Parser Combinators to Expressively Parser Binary Data

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

Submitted August 27, 2019 at 11:40AM by FrancisStokes

Refactor a functional component with useReducer. (What is useReducer and how to use it)

https://medium.com/@avivbiton01/refactor-a-functional-component-with-usereducer-what-is-usereducer-and-how-to-use-it-c996eb99c481

Submitted August 27, 2019 at 11:12AM by Sh0keR

Monday 26 August 2019

Delete a property from the array of objects

Suppose I have an object with three properties:object = { "A" :"a", "B":"b", "C":1};Now I have an array arr which have many such objects, I want to delete property C from each object in arr and get the final array. Is there any efficient method possibly using lodash?

Submitted August 27, 2019 at 06:24AM by GhostFoxGod

The Wisdom of TAP Numbering in a JavaScript World

http://www.wumpus-cave.net/2019/08/26/the-wisdom-of-tap-numbering-in-a-javascript-world/

Submitted August 27, 2019 at 12:09AM by frezik

How does socket.io scale?

Has anyone used socket.io extensively in a project? I'm looking to use it to stream audio data from the browser to a node server and then asynchronously run some processing on it, but I'm trying to determine what I can expect in terms of how many connections an instance can handle.If I ran the socket.io server on AWS EC2 autoscaling micro instances, how many concurrent connections would I expect to be able to handle per instance? Should i be more concerned with my memory usage instead of how many simultaneous connections I can support?Thanks in advance for any information! I'm just worried I'll deploy and the app will work for and that's it.

Submitted August 27, 2019 at 01:34AM by idmontie

Remove white flashes in Electron when redirecting to another page.

I'm making an app using Electron and I have a simple page with my name, showing that I am the one who made the app. I used JavaScript to make it redirect to another page which is basically the application after 7 exact seconds. However, there is a tiny white flash before that other page appears. How do I make it disappear and give the page enough time to load so it can appear instantly, without flashes or waiting for elements to load when it's opened. Is that possible? I'm using windows.location.href as well as the 'ready-to-show' function in main.js.Thank you!

Submitted August 26, 2019 at 11:24PM by Plam3n04

Nobody did this before?

While searching for libraries that handle payment I could not find any package that do all of the payment solutions. For example there is the package Passport that has all authentication methods bundled into one library why there is not something like Passport but only for payments? PayPal, Stripe etc... does somebody know a package like that or has really nobody done this before?

Submitted August 26, 2019 at 10:28PM by texxxo

Node v12.9.1 (Current)

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

Submitted August 26, 2019 at 08:53PM by dwaxe

Node v12.9.1 (Current)

https://github.com/nodejs/node/blob/master/doc/changelogs/CHANGELOG_V12.md#12.9.1https://nodejs.org/dist/v12.9.1/

Submitted August 26, 2019 at 08:27PM by ThinkNotice

Express.js webserver vs something like Caddy?

https://www.reddit.com/r/learnjavascript/comments/cvr8tk/expressjs_webserver_vs_something_like_caddy/

Submitted August 26, 2019 at 06:46PM by blockchain_dev

Top 5 JavaScript Machine Learning Libraries

https://blog.bitsrc.io/top-5-javascript-machine-learning-libraries-604e52acb548

Submitted August 26, 2019 at 05:57PM by JSislife

After installing / uninstalling some global packages, most of my tests in a specific project no longer run

I have a project with 1000+ tests that were working fine until yesterday when I installed / uninstalled some things globally and also locally in a completely different and unrelated project folder. Now, only 3 of the tests run.The test framework used in this local project is Mocha, which I don't use anywhere else on this computer except this project folder. I did change the ESLint package globally, and ESLint is used in the script to lint these tests. I tried removing the portion of the script that uses ESLint, but still only 3 tests run.Is there another way I can troubleshoot this, or maybe something I've missed? Thanks!*edit* is it possible I somehow have switched my default test runner for this project?

Submitted August 26, 2019 at 05:31PM by professor-coffee

Why my Google Chrome is being opened through selenium webdriver in my puppeteer app?

Hi all , i am trying to do automation through puppeteer lib, i am trying to automate logging in into a website in chrome browser and doing some stuff there. So my problem is that i am putting google chrome's path in my code ( it is a right path ) but when i am running the code it works through selenium webdriver i guess. ( NOTE: I have other projects where i am doing scraping and that's why i am using selenium ). So do you know any way that i can use to make my code work though my actual browsers and not with selenium ? I have searched every forum in SO and everywhere but can't find even sufficient problem .Here is my code.const puppeteer = require('puppeteer-core'); //const email = document.querySelector('#email'); //const pass = document.querySelector('#pass'); async function login() { const browser = await puppeteer.launch({headless: false, executablePath: '/opt/google/chrome/google-chrome' }); // const context = await browser.createIncognitoBrowserContext(); const page = await browser.newPage(); // Focus input await page.goto('https://www.facebook.com'); await page.click('#email'); await page.keyboard.type('SOMELOGIN'); // Focus password await page.click('#pass'); await page.keyboard.type('SOMEPASS'); // Get login button and submit it const loginButton = await page.$('#loginbutton input'); await loginButton.click(); await loginButton.click(); await page.goto('https://www.facebook.com'); await page.click('#js_w > div._i-o._2j7c > div > div._7r84 > div.clearfix._ikh > div._4bl9 > div > div > div > div'); await page.keyboard.type('https://www.kickstarter.com/projects/boazinstruments/boaz-one-one-modular-guitar-50-combinations?ref=section-homepage-projectcollection-2-staff-picks-popular'); const postbutton = await page.$('#js_w > div._1j2v > div._2dck._1pek._4-u3 > div._45wg._69yt > button'); await postbutton.click(); // Wait if we get redirected to login await page.waitForNavigation() browser.close(); } login(); And yes, using puppeteer-core is mandatory , due to my project i can't use just puppeteer.

Submitted August 26, 2019 at 03:48PM by Grigor_1

What is the best way to setup repository in GitHub for a college project so that all the members can show it in LinkedIn and their Github account?

Hi everyone! I am in my last year of CS course. We are required to do four projects to finish the course. In the previous semester, I created the repository for our project and did all the push and pull as my teammates were not that habituated with Github.I don't know much about how teams work with git and Github but I later added them as contributors and made them do simple push and pull requests. Now that we will add that project in our LinkedIn account, I noticed that the repository comes under my Github account only. They don't mind it as their names come up in the contributors but I kinda feel bad.So my question is, is there any better way to do projects in Github so that every one of my team can have the repository in their account. I was going through some options called Organization and team in Github but did not understand much.tl;drWhat is the best way for a team to work together on a project in GitHub and show it in their accounts?

Submitted August 26, 2019 at 02:57PM by Katsuga50

How to test performance on API as if 10's of thousands of requests are being sent

Basically, my site only has maybe 50-100 per day. But I want to structure the code, threads, and infrastructure that if 1000s were to come in a second, my site can handle it and not lag.Can anyone recommend libraries where I can test this and perhaps view the performances?

Submitted August 26, 2019 at 03:01PM by sterling729

Kubernetes StatefulSets 101 - State of the Pods

Folks,A Statefulset is a Kubernetes controller that is used to manage and maintain one or more Pods. So what does Kubernetes use StatefulSets for?Here's this week article Kubernetes StatefulSets 101 - State of the Pods.What's inside:The difference between a Statefulset and a Deployment.How To Deploy a Stateful Application Using Kubernetes Statefulset?Persistent Volumes and Persistent Volume Claims.Creating the StatefulSet/Creating a Headless Service for our StatefulSet.Connecting one pod to another through the Headless Service.https://www.magalix.com/blog/kubernetes-statefulsets-101-state-of-the-pods

Submitted August 26, 2019 at 01:33PM by AhmedAttef

How to handle admin controlled product list access?

I'm making a MERN app and have an "admin panel" of sorts with direct control over the products available in the DB. I'm wondering what would be the best way to actually implement this sort of thing alongside the public product list. Would an /admin route with authentication be the typical approach? Or would it be possible to have the admin panel output the actual HTML file that would be used for public, to prevent the need for users to query the DB at all?Sorry if this isn't the place for these kinds of questions, or if I'm asking this in the wrong way. I'm fairly new to this kind of thing, and am not sure what the next steps should be. I'm just not sure the right approach to keeping the admin stuff easily accessible but hidden/separate from the user experience.

Submitted August 26, 2019 at 12:09PM by whatisaname2

Automate Node Server Restart with Nodemon

https://www.ceos3c.com/programming/automate-node-server-restart-with-nodemon/

Submitted August 26, 2019 at 08:43AM by Ceofreak

List and delete old and heavy node_modules with style. free up space!

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

Submitted August 26, 2019 at 11:27AM by juaniman99

Hey!, i made a module in nodejs that can give you photos from mars taken by some rovers!

https://github.com/R4yGM/r4nasa-api

Submitted August 26, 2019 at 10:51AM by r4yyz

Introduction to Node.js / A beginners guide to Node.js and NPM

https://medium.com/@thatisuday/introduction-to-node-js-a-beginners-guide-to-node-js-and-npm-eca9c408f9fe?source=friends_link&sk=9610cba1e9eed095b66bda5c894851ce

Submitted August 26, 2019 at 08:28AM by EvoNext

Sunday 25 August 2019

[SHOW] A 12 line library for writing readable code with `await`

https://github.com/craigmichaelmartin/fawait

Submitted August 26, 2019 at 01:38AM by sammrtn

express-generator-typescript now has an option to include user-authentication and client-side session storage

https://www.npmjs.com/package/express-generator-typescript

Submitted August 25, 2019 at 11:25PM by TheWebDever

I created a website in NodeJS + MongoDB similar to fmylife

https://mwd.itunix.eu/

Submitted August 25, 2019 at 06:19PM by skorotkiewicz

How to upload image using put request ?

I am making put request using method-override and uploading image through multer. Everything except image is being updated ( like Name, description) in the database. Image is not even being uploaded on file system. All the information and image is being passed through same form

Submitted August 25, 2019 at 05:50PM by wrongtake

JavaScript Best Practices and Coding Conventions

Just wanted to share a video about best practices and coding conventions of JavaScript, hope some of you find it useful! :)All feedback and critique is welcome!Here is the link: https://youtu.be/RMN_bkZ1KM0.

Submitted August 25, 2019 at 05:51PM by HolidayInternet

Memento, a devtool for caching APIs responses while developing

https://github.com/antoinechalifour/memento

Submitted August 25, 2019 at 06:02PM by tvvann

README source code import helper

https://www.npmjs.com/package/markdown-source-import

Submitted August 25, 2019 at 03:07PM by iamssen

Passport in MERN App

What is exactly the difference between the strategies local-authentication and passport-jwt. I know the last one is using jsonwebtoken but what does the local strategy? What are the advantages of local because I see it is more popular based on the downloads?

Submitted August 25, 2019 at 02:20PM by texxxo

Memory leak

My function is following:function delete(file, logger){ fs.unlink(file, (error)=>{ if (error) logger.info({error}) }) } Does this function create memory leak, but shouldn't fs library handle this? I suspect it, but how should I do it otherwise...with callback function?

Submitted August 25, 2019 at 02:32PM by spartan12321

Serving a Restify static site on nginx

I'm having some issues with this, wondering if anyone had any insights.I have a public controllerimport restify from ‘restify’; const { serveStatic } = restify.plugins; const directory = __dirname + ‘/../../../public’; const serveSite = () => serveStatic({ directory, default: ‘index.html’ }); const serveFile = file => serveStatic({ directory, file }); export default server => { server.get(‘/*’, serveSite()); server.get(‘/about’, serveFile(‘about.html’)); }; My static site (which is built using nextjs) is built and stored in /public on the server, remotely. My NGINX location directive looks like thislocation / { try_files $uri $uri/ =404; } Going to / and reloading serves the site correctly. Navigating to /about via the nav works fine, but if I refresh this route, I get a 404 page from NGINX. If I go to /about.html it works. Locally, just testing restify without NGINX involved, everything works fine so I feel it must be something to do with the server config.

Submitted August 25, 2019 at 11:00AM by moving808s

How can I find freelance node.js jobs?

I recently started learning node.js and I've really started to love Javascript as a language.Learning node is fun, but finding a node.js job isn't.Any tips on how to find remote node.js jobs?

Submitted August 25, 2019 at 10:34AM by rohan_bhatia

JavaScript Singleton?

So I've been working on a small project recently. I'm fairly new to node.So, what I'm looking for is:client sends object to back endback end express server adds it to 'master' listat the end of the day, somebody can generate a report, wiping the days liststarts over the next dayI was thinking that I could use some kind of database, but I don't really like the idea of wiping the database every time somebody wants to make a report. Also , I thought that I might be able to do some simple csv file io, but I think that might be a little strange. Preferably, I'd like some sort of 'singleton' that will take any new objects and add them to the list. I'm not especially concerned about the performance issues this might have, but I'd love to hear ideas on that.Edit: Maybe I could just add them to the database (I want to use mongoose/mongodb) and when I want to generate a report, query the specific day? This might work, but I dont really like the idea of persisting essentially a bunch of useless data.

Submitted August 25, 2019 at 07:13AM by gungunthegun

how would i create a simplified version of facebook's activity/news feed?

i want to create something similar to facebook's news/activity feed.i have an application where users can perform CRUD actions on their books list and whenever a user modifies their list i want to send their action to the activity feed. i want to display something along the lines ofcherrypicker55 added Harry Potter to their listcherrypicker55 liked BumbleBerry's listi'm using ws with node and the built in browser websockets for the client. i'm also using node-postgres for the db.my plan was to just simply emit an event on the server whenever a database query has been completed and send back data to the client. So whenever cherrypicker55 adds a new book to their list, after the db query has been successfully executed i will emit an event to the client.does this make sense? it seems too simple.thanks

Submitted August 25, 2019 at 07:40AM by crazyboy867

Saturday 24 August 2019

Building a Node API with stateless authentication

https://blogg.itverket.no/stateless-authentication-in-node/

Submitted August 25, 2019 at 06:25AM by Southern_Maintenance

Instant messaging

First post on here but I’m running out of search terms. I was wondering if there is a node/socket package that provides instant messaging between users. This isn’t like a chat room as much as one one one or up to 3-4 user group chat. Like Facebook messenger.I’m trying to find a more in-house solution otherwise I’m stuck with something like cometchat pro or sendbird

Submitted August 25, 2019 at 02:42AM by bossryan32

Simple package.json style IOC container for Node

I created an IOC container designed with simplicity and familiarity to package.json in mind. This was created to be the simplest possible way of mapping modules to their respective dependencies. Feedback on what people think of the dependency declaration-style as well as design decisions (such as auto-instantiation instead of the common factory-pattern), as well possible contenders that do the same (thus rendering it redundant) would be much appreciated. If anybody would like to comment on the technical implementation that would also be great (such as the subscriber-based dependency resolution). I think the performance could probably be increased by the use of certain log-n tree structures (instead of iterating as much as is currently done), or possibly priority queue for faster leaf-finding.

Submitted August 24, 2019 at 11:57PM by booleantoggle

OSS developers start putting advertisements into npm packages what do you guys think?? This guy made 2K for a library which nobody needs(its just eslint config file with 2 line)

https://github.com/standard/standard/issues/1381

Submitted August 24, 2019 at 10:09PM by RandomHackerGenius

Create Nom App - A zero-config build tool for creating, testing, and building Node modules

https://github.com/MaximDevoir/create-nom-app

Submitted August 24, 2019 at 05:56PM by MaximDevoir

Path too long? You kidding me???

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

Submitted August 24, 2019 at 03:27PM by GoofAckYoorsElf

User Login System in Electron App (Using database)

I posted this in the electronjs subreddit but since there aren't many active users there and I found out people are posting here too about their Electron Apps, I decided why not? I'm absolutely sorry if there is already an answer somewhere for this, I couldn't fine one, so I decided to post a thread myself.​It has been probably a month since I found Electron. I'm really familiar with stuff like HTML, CSS and JavaScript and always wanted to make desktop applications with those programming languages. It's basically a dream come true for me. I have made pretty simple apps so far and I want to go further. I was never good with server-side languages and databases. That 'never good' becomes even worse with Electron. I want to create a form where users can log into their accounts and explore the app like any other website. I am more familiar with mySQL but I still have no clue how to do this inside my Electron App. Is there any guide somewhere?Normally, on a regular website, the package.json file would include this:"start":"node ./server"But on Electron App, it has to be like this (from what I have learnt):"start": "electron ."So... how do I do this? Do I have to include "start": "node ./server" in my app or I'm fine with "start": "electron ."?I'd be extremely grateful for any kind of answer, as long as it expands my knowledge on this.Thank you!

Submitted August 24, 2019 at 02:36PM by Plam3n04

How to stop someone scrapping my database using my api?

Hello, I come from a MVC .net background using Entity Framework where in my newbie opinion the backend feels much more hidden.I have a MEVN stack which is a public portal to search through a database of around 1000 contact records. The portal contacts my node API and returns paged results once 3 characters have been entered in the search-box. The site requires no authentication. If anyone where to investigate the network traffic in dev tools they can clearly see the how the API works. Appreciate its a public database, but I don't really want people scrapping my entire database.Is there any way I can prevent someone using my own API to scrap my entire database? Maybe Ip address throttling? Maybe encrypting the data being send to my API?

Submitted August 24, 2019 at 12:49PM by Starchand

I made just release v2 of my first npm package!!

https://www.npmjs.com/package/instagram-public-api

Submitted August 24, 2019 at 11:46AM by CouldThereBeMoreIce

How the Node.js Event Loop Polls

https://www.alexhwoods.com/event-loop-polling

Submitted August 24, 2019 at 12:12PM by pmz

Love thy fellow programmer as thyself: Setup ESLint and Prettier in VSCode

My 2nd blog postLove thy fellow programmer as thyself: Setup ESLint and Prettier in VSCodehttps://manisuec.blog/2018/08/23/eslint-prettier-vscode-setup.html

Submitted August 24, 2019 at 12:21PM by manisuec

How to Rename a System File Using NodeJS

https://coderrocketfuel.com/article/how-to-rename-a-system-file-using-node-js

Submitted August 24, 2019 at 12:14PM by jkkill

esiJS 3.0.2 has dropped!

https://www.reddit.com/r/evetech/comments/cuqq98/esijs_302_has_dropped/

Submitted August 24, 2019 at 09:08AM by GingkathFox

How would I better model this relationship in mongodb using mongoose to query easily?

Relationship: User and communityuser can join different communities.communities can have multiple users just like reddit.Query:list the members of a communitylist the communities that a member belongs tolist all communities and list all membersCurrent Model:const userSchema = mongoose.Schema({ name: { type: String, required: true }, email: { type: String, required: true, unique: true }, password: { type: String, required: true }, isVerified: { type: Boolean, default: false } }); const communitySchema = mongoose.Schema({ name: { type: String, required: true, unique: true }, members: [ { type: mongoose.Schema.Types.ObjectId, ref: User } ] }); With this model,I can list all members and community and also list members of a particular community but not able to list all the community that a member belong to..If that query is possible with this model, orIf it has to modelled differently also, please let me know.Ps: Yes, thought about having another ref in the user model that points to the community but wouldn't that have a duplicate write when users joins a community?I have push userid into the particular community and community id into user model. So I thought there would be a better way.

Submitted August 24, 2019 at 11:09AM by sum__sleples

Boat - Borderless floating browser

Hi! I suppose this problem was already iterated upon in the past but I haven't had experience with an app that's minimalistic enough to suit my needs. Closest thing I've found was pennywise but it had its problems because pages were rendered in a webview (youtube.com/tv was not working at all for example).So I took the the matter in my own hands and just whipped up a simple electron wrapper that provides you with a way of having an optionally frameless browser window to play desired content while you work/study or whatever else you're doing.Boat has options to be frameless, always-on-top, preload urls and many more. Check out the repository here for more information.Contributions to make it work on Mac are desired as i don't have access to a Mac machine.PR's and feature requests are welcome!

Submitted August 24, 2019 at 11:28AM by Acrilion

Friday 23 August 2019

Eclipse IDE for Web and JavaScript Developers vs. Visual Studio Code

Looking for a IDE with minimal customization out-of-the-box. Especially for Node.js debugging, JavaScript Intellisense.Do I have to add plugins or extensions, editing of configuration files after installation before I can be productive?

Submitted August 24, 2019 at 04:56AM by 2048b

Does anyone use a different file extension for your nodejs files to distinguish them from browser scripts?

Sometimes I write code to run in only NodeJs, and sometimes I write code to run in both NodeJs and browsers. If the former, I'm thinking about using an extension "nodejs". Does anyone do anything like this?

Submitted August 24, 2019 at 03:21AM by breck

The new way of writing microservices

https://blog.spaceuptech.com/posts/function-mesh-new-way-to-write-microservices/

Submitted August 24, 2019 at 04:00AM by YourTechBud

Firestorm: An ORM for Firestore

https://medium.com/better-programming/firestorm-an-orm-for-firestore-82ffa8a646c8?source=friends_link&sk=f73ef6f658de565e9c369bbac310be8e

Submitted August 24, 2019 at 01:11AM by lmcq_dev

How to run a telnet command through node ?

I am trying to use telnet-client library to shutdown a projector in node. Here is my command so far.const Telnet = require("telnet-client"); let tel = new Telnet(); let params = { host: '192.168.20.201', port: 4352, shellPrompt: '', timeout: 2500 } try { await tel.connect(params) await tel.exec('%1POWR 1 '); } catch (error) { console.log("telnet error") console.log(error) } What exactly am I doing wrong here?

Submitted August 23, 2019 at 07:56PM by samratluitel

Downloading videos/GIFs with pupeteer

I am trying to download some videos or GIFs to a predetermined file structure from this site. I already have the navigation aspect working fine, but I can not figure out how to download a video or a GIF once I get to here.I want to put them into a structure like so:```Nades ├── Dust2 ├── Mirage ├── Cache │ ├── A │ │ ├── Smokes │ │ ├── Flashes │ ├── B ```

Submitted August 23, 2019 at 07:48PM by DeepSpaceGalileo

Is it a good idea to build a website ping/monitoring tool with Node.js?

I'm building a general-purpose website pinging tool, and need to make some kind of `setInterval` for pinging website with a given URL and check content on response.It seems obvious that I can just use `setInterval` to perform this, but it gets complicated if you consider having few hundred websites and each of them should be checked within a specific time interval. I had done a similar thing with Go by spinning separate coroutine for each individual timeout.With Node, I imagine that it is possible to do a similar thing using promises, but wanted to get some ideas if possible, is it a good idea to stick with Node for that kind of use-cases?Thanks!

Submitted August 23, 2019 at 05:33PM by tigranbs

Any production company using JAMStack?

Hi all, I see strapi is in beta & may not be suitable for production. How about the others? Do you know any jampstack ready to build for production?

Submitted August 23, 2019 at 04:19PM by trumhemcut

🐕 Announcing NodeGUI and React NodeGUI - Build native desktop apps with Javascript and CSS 🎉

https://blog.atulr.com/nodegui-intro/

Submitted August 23, 2019 at 04:42PM by mominriyadh

Tests are breaking on travis

Hello DevelopersI have an issue with travis CI. I have written tests and they are passing locally on my machine, but after synchronizing my repository with travis, the build finished and the tests were failing. I have tried to work around to see that they pass but failed. Could anyone look through my configurations and figure out what I might be doing wrong? Thanks

Submitted August 23, 2019 at 02:23PM by SendiStephen

Code examples demonstrating good practices for a REST API

As the title says are there any repos or posted examples of clean code for developing REST APIs with Node. Thanks in advance!

Submitted August 23, 2019 at 01:27PM by CallumA_

Moongose validation good practices

Hello, I am currently learning MEAN stack to build some basic applications and was wondering if there are any good practices regarding validating data while using mongoose.In my example I have registration endpoint and want only valid e-mails to pass through, and I don't know whether should I validate the data in the schema or in some middleware using for example express-validator module, perhaps it doesn't matter?

Submitted August 23, 2019 at 11:12AM by Szpinux

Rename JavaScript again?

JavaScript has a few name changes behind it it started out as Mocha then LiveScript and last was to JavaScript it uses the word 'Java' because in that time Java was the most popular language. I think we are on a point where JavaScript needs a rebranding (New Name). JavaScript is now more popular than Java and do not neet this word anymore to be recognized, I would like the whole language to be renamed to 'Node' so nodejs and js come together under name Node as language. What do you think about this and will we see a rebranding again?

Submitted August 23, 2019 at 11:23AM by texxxo

node.js + Express + DynamoDB app error on lambda

https://www.reddit.com/r/aws/comments/cuas85/nodejs_express_dynamodb_app_error_on_lambda/

Submitted August 23, 2019 at 09:17AM by politerate

What do you guys think of this stack for the upcoming hackathon season?

https://link.medium.com/TjTHk7EMnZ

Submitted August 23, 2019 at 09:40AM by pringon

Promises API in Node.js core: where we are and where we’ll get to by Joe Sepi | JSConf EU 2019

https://www.youtube.com/watch?v=-4p_qLYjUDc

Submitted August 23, 2019 at 10:14AM by our_best_friend

Anybody here using Node for IMAP access?

I want to get and process some emails via IMAP, so I thought that there might be some libraries out there and of course there is. But it's not been updated in almost three years. Do you know of any good IMAP solution for node? If not, what do you use?I was thinking about jumping over to Python for this one, their IMAPClient seems to be actively maintained.

Submitted August 23, 2019 at 10:20AM by real_kerim

JavaScript Type Coercion Taken To An Extreme

https://youtu.be/sRWE5tnaxlI

Submitted August 23, 2019 at 08:42AM by FrancisStokes

Open to contribute to projects

I am open to contribute to open source projects largely based on Nodejs and react.I have 5+ years of experience on nodejs.

Submitted August 23, 2019 at 08:20AM by manisuec

Looking to create an algorithm that shows 20 images on a certain event call, with 50% of images being based on a user’s interests, and the other 50% being random

Hey r/node!I’m currently making a simple website that allows users to set their desktop background from a fullscreen image on my site (through the magic of Wallpaper Engine). All images have keyword tags that are related to what the image displays. When a user signs up, they give us 2 interests they have. I’m interested in how I would go about creating an algorithm that, on every page load, they are served 20 images. 50% of which are based on the interests they have, that match an image’s keyword(s), and the other 50% being completely random.Any help is appreciated. Thanks guys!

Submitted August 23, 2019 at 07:29AM by hazeust

The nuances of testing in pair cucumber.js + puppeteer

https://blog.maddevs.io/the-nuances-of-testing-in-pair-cucumber-js-puppeteer-49c3ff2da44c

Submitted August 23, 2019 at 07:42AM by darikanur

Thursday 22 August 2019

Global variables for testing in node?

I was hoping someone had a solution for what I am trying to do. I would like to set a global variable (right now I have a config.js file I use) for testing purposes to turn and and shut off access to things like SQL throughout the test in order to test different things like errors. Maybe even to setup a different connection to a test database.Is that possible? How would you do it?

Submitted August 23, 2019 at 06:11AM by gemurdock

Best library for writing raw sql for Node?

Ive been writing SQL in an sql file and then converting them to Knex queries in Nodejs. This is taking much more time than I thought it would and have been using knex.raw a lot since it doesnt support lot of PostgreSQL features like ON CONFLICT, GENERATED BY, ::CASTING, etc and decided it might be better to just go with writing raw queries.I do love the knex migrations/seed feature and if anyone knows of an good library for migrations for node that would be helpful too.Ive been looking at these libraries for writing raw sql:node-postgress aka pgmassivejspg-promiseslonikFor migrations:postgres-migrationsAlso might just use knex for migrations only if there isnt anything better.Do you guys have any experience with any of these? I saw that pg was the most popular by far.https://www.npmtrends.com/pg-vs-pg-promise-vs-knex-vs-slonik

Submitted August 23, 2019 at 04:46AM by natpagles

Explain me Serving static files in Express in an actual example

Hey guys, just recently started learning node and I stumbled upon Middleware functions. Now the problem is I dont fully understand built-in Middleware function express.static. How could I use it in an actual project, for example how could I use this to serve static files such as an image or a CSS file in an actual real life project. I guess don't get serving part of this sentence.

Submitted August 23, 2019 at 02:44AM by Drexx_B

Promise in series.

With an API I need to make an "authentication" request to get a token then I need to make the "data" request that will return what I actually need, then I need to make a "logout" request. All completely obnoxious I know. I am trying to convert it all to asynchronous programming through the use of promises. Obviously those 3 requests need to be made in order. The solution I first came up with is nesting promises so login.then(token => { getData().then(data => {}) }) and so on. This feels really dirty like I shouldn't be doing it. Is there a better solution or am I on the right track?

Submitted August 23, 2019 at 03:42AM by Stripestar

Need some direction

So I've played around with NodeJS and expressJS but other than that I haven't done too much with the back-end. I love how open ended everything is but there seems to be a lack of resources describing what you can do with it all. So I guess I'm just looking for some direction or some resources of where to begin & what I can build or do with all this awesomeness! Any help would be appreciated my dudes.

Submitted August 23, 2019 at 01:33AM by sierra61

Opinion on Loopback 4 & Strapi

I'm creating a social app and wanting to decide if I should use Loopback 4 or Strapi. The application will be API based and use React + Redux on the frontend. Wondering if any people have used these applications in production and what's your experience using.

Submitted August 23, 2019 at 01:32AM by tlew408

How to Compress PNG Image Sizes by Up to 75% With Node.js

https://coderrocketfuel.com/article/compress-a-png-image-size-by-up-to-75-percent-with-node-js

Submitted August 22, 2019 at 10:09PM by jkkill

All versions of bb-builder found to have malicious code

https://www.npmjs.com/advisories/1119

Submitted August 22, 2019 at 09:35PM by dreddriver

Announcing NodeGUI and React NodeGUI - Build native desktop apps with Javascript and CSS

https://blog.atulr.com/nodegui-intro/

Submitted August 22, 2019 at 08:59PM by moustachedelait

Image to base64 tool convert

Image to base64 tool convert. Base64 encoded images can be embedded using img tags or CSS, speeding up load times for smaller images by preventing additional HTTP requests.#base64encodehttps://imagetobase64.io/https://i.redd.it/iat4jqyf31i31.png

Submitted August 22, 2019 at 05:46PM by jasonbuiduc

Any guides to starting a NodeJS API?

Hello! I've been looking into creating an API for my other programs as to provide data from mongodb and other sources, etc yet I'm not fully sure where to start. Are there any good guides or sample API's that could get me started with Post/Request and API tokening systems? Thanks!

Submitted August 22, 2019 at 06:51PM by thatboy-evn

Build a Command-Line Real-Time Chat App using SocketIO

https://blog.bitsrc.io/build-a-command-line-real-time-chat-app-using-socketio-f2e3553d6228

Submitted August 22, 2019 at 03:31PM by JSislife

[Help] Reverse engineering Aliexpress mobile app

I am trying to understand how the Aliexpress application adds stuff to the cart and then implement this functionality in NodeJS.I captured some HTTP Pockets that are sent when you add something to your cart using mobile app:Headers:POST /v2.0/api/experiment/2/allocate HTTP/1.1 Charset: UTF-8 Content-Type: application/x-www-form-urlencoded Connection: Keep-Alive ab-sign: 98a17f73c6f348d06ad66ebf72b9641e ab-client-version: 1.0.4 app-key: 21371601 app-version: 7.9.2 Content-Length: 272 User-Agent: Dalvik/2.1.0 (Linux; U; Android 9; MI 6 MIUI/9.8.15) Host: abtest.alibaba.com Accept-Encoding: gzip Body:requestBody=WmZzzD7gsE7nB%2FH2vMoSHq6ArdE%2FIPSPJNAPmWa%2Ftr%2FNag2JVsAFnHFIzvFK2aC9usrJ1HC4hmzWbBJqBPPFh14JRYrom7txR7W%2BBGMuZwSD47ExCRZM75wQ0SRWl7uOnb4eFT5RniyoMNd2zUh0Oo8XN3bJLakqkTYrRZSk%2BQpQRe4XXOWBeLNL%2FEcY%2FZXLV9syjxTmQvyv297%2BMZCzlwDtxWt0uRs8r3v%2Bz9FTZg%3D%3D Body looks strange. It looks like typical Base64:WmZzzD7gsE7nB/H2vMoSHq6ArdE/IPSPJNAPmWa/tr/Nag2JVsAFnHFIzvFK2aC9usrJ1HC4hmzWbBJqBPPFh14JRYrom7txR7W+BGMuZwSD47ExCRZM75wQ0SRWl7uOnb4eFT5RniyoMNd2zUh0Oo8XN3bJLakqkTYrRZSk+QpQRe4XXOWBeLNL/EcY/ZXLV9syjxTmQvyv297+MZCzlwDtxWt0uRs8r3v+z9FTZg== But decoding this gave me some unreadable string. According to headers it should be x-www-form-urlencoded.Any idea how does it work?

Submitted August 22, 2019 at 02:46PM by kszyh_pl

Metaprogramming in JS: Write your first codemod!

https://medium.com/onfido-tech/metaprogramming-in-js-write-your-first-codemod-75eca71a97e2

Submitted August 22, 2019 at 12:07PM by ab-azure

What issues still exist in ES8+ JavaScript?

https://www.reddit.com/r/ProgrammingLanguages/comments/cmkxly/what_issues_still_exist_in_es8_javascript/

Submitted August 22, 2019 at 12:38PM by brianjenkins94

Hello! I need opinions about my rest api boilerplate.

I created a simple boilerplate because I keep rewriting this everytime I make a new project so I decided to create simple boilerplate with everything I need. Now I need some opinions or reviews on the structure and its cleanliness.​Here is the repo: rest-api-boilerplate

Submitted August 22, 2019 at 10:51AM by asp143

What are some articles on advanced Nodejs (or backend) development that you recommend?

I keep seeing beginner friendly content. What are some articles that cover advanced Nodejs concepts that you think are important to understand to be a better Nodejs developer?

Submitted August 22, 2019 at 09:49AM by AdoM1

[Help] Winston logging

I'm not sure if questions like this are allowed in this sub, but I couldn't find a better place to ask.I want to log different levels to different files as you can see in the code. The problem is Winston logs all of info, debug, warn and error in the `INFO_LOG_PATH` file. I understand that there's a hierarchy in log levels and that all logs that are below the current level are logged in that file.Is there a way I can make strict log levels so that each file only receive logs for one particular predefined level ?const logger = winston.createLogger({ level: 'verbose', format: winston.format.simple(), defaultMeta: { service: 'user-service' }, transports: [ new winston.transports.File({ filename: INFO_LOG_PATH, level: 'info' }), new winston.transports.File({ filename: DEBUG_LOG_PATH, level: 'debug' }), new winston.transports.File({ filename: WARN_LOG_PATH, level: 'warn' }), new winston.transports.File({ filename: ERROR_LOG_PATH, level: 'error' }), ], });

Submitted August 22, 2019 at 07:37AM by Ncell50

Wednesday 21 August 2019

Need help understanding a build pipeline

I'm new to DevOps and currently working with Azure DevOps. I setup this build pipeline from an auto-suggested template. It's for a simple web app that'll serve static files. I wanna know what the hell is going on; in particular, what are each of the build tasks doing?Here are my assumptions:npm install: downloads and install project dependencies according to what's in the package.json. Right?Archive files: apparently it zips up all the project stuff into a single zip file. Not sure why though, lol.Publish artifact: drop: takes the zip file from above and makes it available for release. Right?

Submitted August 22, 2019 at 06:20AM by ncubez

[Help] Express can't get POST data

I have used express before to do this, getting data posted to a URL, but it does not seem to be working. I keep getting undefined. Using postman I am able to get to the function just fine and do anything I need to except get that data. What am I doing wrong? I can't seem to figure out the dumb mistake I am making.-- Server.js --const express = require('express');const app = express();//app.use(express.json());app.use(express.urlencoded());const todo = require('./routes/api/todo');app.use('/api/todo', todo);const port = process.env.PORT || 5000;app.listen(port, () => console.log(\Server started on port ${port}`));`​-- TODO.js --const express = require('express');const SQL = require('../../sql/sql.js');const router = express.Router();// Add todorouter.post('/', (req, res) => {console.log(req.body);res.send(req.body);});module.exports = router;

Submitted August 22, 2019 at 06:02AM by gemurdock

Domain to ip address

I have an node webserver running off Ubuntu that I can access from outside the LAN(I've had friends test it and it works.) I also own a domain(through domain.com) that I want to point to that ip address. The goal here is to do all the hosting and web development myself, does anyone have good resources on how to accomplish this?

Submitted August 22, 2019 at 02:29AM by hhhhhhhhgreg

Backend framework that supports plug and play modules

Hi developers,For a side project I'm building my 100th implementation of a JWT with API with express. I looked at some of the more mature node API frameworks like Adonis and NestJS, but found them too complex. I'm wondering why there is no framework that supports components/modules. For example a JWT module that automatically providers some endpoints for authentication. A framework where developers can create there own backend modules and share them with others. Just like React / Angular or Vue, but for the backend.Is there a framework that provides this for the backend, and if not are the developers that want to explore this idea with me?

Submitted August 21, 2019 at 05:41PM by savioverdi

Adding a self-destruct with a reset timer to a Node.js program

Over the last couple of years, we've experienced multiple partial outages due to various bugs in the Node.js ecosystem that resulted in our program hanging, e.g. database socket hanging without a timeout, Redis hanging, proxy agent hanging, etc. Usually this goes unnoticed for a long time (1-2 hours) because it only affects a subset of workers and there are no errors in the logs – the program is just hanging waiting for some event.Long story short, we ran into another partial outage today when we noticed that even though we have 1k+ active agents in Kubernetes, there were only 400 active jobs. Bug details are not important, but it made me think of what safety mechanism we could add to prevent this happening in the future. I am currently thinking of adding a sort of self-destruct mechanism that requires program to check-in every X minutes or otherwise it terminates the process, e.g.``` // @flowconst createTimeout = (interval: number) => { return setTimeout(() => { console.error('liveness monitor was not reset in time; terminating program');process.nextTick(() => { // eslint-disable-next-line no-process-exit process.exit(1); }); }, interval); };/** * This exists because of numerous bugs that were encountered * relating to hanging database connection sockets, http agent, * Redis and other services that resulted in Node.js process hanging. * This is a sledgehammer solution to ensure that we detect instances * when program is unresponsive and terminate program with a loud error. * In practise, this timeout is never expected to be reached * unless there is a bug somewhere in the code. * * Liveness monitor must be created once and reset trigger injected * into whenever program makes observable progress. */ const createLivenessMonitor = (interval: number = 15 * 60 * 1000) => { let lastTimeout = createTimeout(interval);return () => { clearTimeout(lastTimeout);lastTimeout = createTimeout(interval); }; };export default createLivenessMonitor;```Program would call the liveness monitor whenever it does something that indicates progress (e.g. a new task picked up from the queue). If program fails to check-in for X minutes, then the process is terminated with an error and possibly additional debug details.What are your thoughts about this solution?

Submitted August 22, 2019 at 12:48AM by gajus0

Mustache.js: How to separate server-side rendering than client-side mustache templating?

I try to render second.html with server-side after validating a form in home.html, then keep mustache.js to template (update) parts from second.html as user validates new form in it (multiple times).problem: html renders the parameters from server-side but sees parameters from mustache as empty stringsI knew that mustache can work for both server and client side but I didn't use mustache in the server filesserver-side file node.js var serverSideParameter = 'server' res.render('chat.html', { serverSideParameter }) client-side file js var clientSideParameter = 'client' const html = Mustache.render(Template, { clientSideParameter }) document.querySelector('#Container').innerHTML = html; html file ```html
```output:```html

server

```Desired output:```html

client

server

```

Submitted August 21, 2019 at 09:33PM by Traveler_12

Connecting Node.js backend with Angular

I made a simple Node.js app containig simple login-logout system(passport.js) and simple CRUD operations with database (MongoDB). Website currently uses ejs (Embedded JavaScript) to plug variable in my html pages, there is no css.Then there is a Angular frontend designed by someone else independently for the above app using TS.Problem is I don't know any Angular as of now. I need to connect the Node backend with Angular. I need a high level overview, someone to point me right direction on how to go about doing this. Should I build Angular front end over my Node app.js file or other way around ?

Submitted August 21, 2019 at 08:42PM by wrongtake

Processing webhooks with Node.js and Pipedream

https://medium.com/@dylan.sather/processing-webhooks-with-node-js-and-pipedream-63fe205cb0f8

Submitted August 21, 2019 at 07:50PM by dylburger-pipedream

Same JSON response for all requests in express, how would you do it?

So one of my requirements is that ALL responses must be of the following structure.{ success: true/false data: {}/[] } This even has to be done with any errors I send. No problem, expect...I have around 50 endpoints I need to make, so my res.json will be littered withres.json({success: true, data: someDatabaseResponse}); So I will end up adding this to every single route I have...mmhmm okay so I make a class instead.class ServerResponse { constructor(data, success = true) { this.data = data; this.success = success; } } module.exports = ServerResponse; This works expect...well same thing, every res.json will have a new ServerResponse class insteadres.json(new ServerResponse(dataResponse, true)); Maybe using middlewares? Well, then I will have to pass the success and true to the next method.next(dataResponse, true?) Either way I don't really want to be using next() anyways. So I ask you, is there a way in express to make sure all JSON responses have the same properties I want without defining it in every res.json method?

Submitted August 21, 2019 at 07:10PM by HappyZombies

Should Every Back-end developer learn DevOps?

Okay so hear me out, I am still a beginner so treat me as one. I've been learning nodejs and its server side stack(mongodb, express, etc.) and I already started a simple job as a junior dev, writing my first ever application when im hired, and i am getting close to deploy it. but lastly, i have been getting across a lot of posts on this subreddit about devops, and all i have been reading was stuff i really dont understand, like Kubernetes, pm2, Iaas, etc. and i have no idea if i need them, or should i learn them, so could anyone explain all of those stuff like you are explaining it to a child?

Submitted August 21, 2019 at 06:29PM by warchild4l

Node.js vs. ASP.NET for Enterprise Application Development Services

https://www.linkedin.com/pulse/nodejs-vs-aspnet-enterprise-application-development-services-limbani/

Submitted August 21, 2019 at 06:49PM by OddComfort

Go-inspired context library

Found existing context frameworks a bit cumbersome; here's a more lightweight one.https://www.npmjs.com/package/nullary

Submitted August 21, 2019 at 06:55PM by mcandre

Would it be better to create multiple child processes for cpu intensive work or create separate node instances?

I have 3 tasks that are all time consuming. 1 is a web crawler, the second is analyzer that tries to match an image against other images, and the 3rd is a color analyzer of an image. Each is going to block for enough time that I don't want them all running on the same process.If I understand clustering correctly it won't really solve my problem because I want each task to have equal availability and if the crawler or the analyzer eats up all the room on the cluster than the color analyzer just waits.What I was thinking about doing was creating a child process for the 3 tasks so they can each run separately and just pass info back and forth. However, the same could be accomplished by just creating 3 different node instances and communicating via an api.In cases like this what would be seen as best practice or is there a 3rd option I'm not thinking of?

Submitted August 21, 2019 at 06:13PM by blindly_running

Proxying With Puppeteer - JavaScript Web Scraping Guy

https://javascriptwebscrapingguy.com/jordan-does-proxying-with-puppeteer/

Submitted August 21, 2019 at 05:34PM by Aarmora

Kubernetes 101 - Concepts and Why It Matters

Folks,If you are into the DevOps or the IT field in general, you surely heard the term Kubernetes. In this article, we explore Kubernetes from a 10,000 ft. We’ll also shed light on some of its most important use cases and best practices.What's inside:Docker Containers.Containers And Microservices.Why Is Kubernetes So Popular?Kubernetes Architecture And Its Environment?Kubernetes Core Features.The DevOps and Infrastructure Environment.https://www.magalix.com/blog/kubernetes-101-concepts-and-why-it-matters

Submitted August 21, 2019 at 04:54PM by AhmedAttef

Functional Programming in JavaScript: How and Why

https://blog.bitsrc.io/functional-programming-in-javascript-how-and-why-94e7a97343b

Submitted August 21, 2019 at 03:43PM by JSislife

Dependency Resolution in NodeJS

https://medium.com/@kaustubh_khati/dependency-resolution-in-nodejs-with-js-map-c5051ed66020

Submitted August 21, 2019 at 01:47PM by kk_red

Should I use `nvm use lts/dubnium` or `nvm use 10` and why?

`nvm use lts/dubnium` and `nvm use 10` resolve to the same version and it seems to me like they always will? as I can't imagine why LTS would stop but a new version then is released after?So is there any reason for installing `lts/dubnium` via during each build instead of `nvm use 10` ?

Submitted August 21, 2019 at 11:27AM by theclarkofben

Scaling In Nodejs for enterprise level apps

So I have been reading a lot about nodejs and it's ability to scale when used for enterprise grade applications considering its single-threaded nature but it is still not so clear to me... Actually am considering building a school management system using Nodejs backend you there is going to be alot of requests at a time to a particular api considering how much students and pupils can be.... Can nodejs effectively handle a system like this? Is it a right choice?

Submitted August 21, 2019 at 10:20AM by joeycrack1

Build a Twilio SMS Hub with Standard Library and Node.js

https://medium.com/@notoriaga/build-an-sms-hub-in-under-7-minutes-with-twilio-standard-library-and-node-js-b22c45f331b

Submitted August 21, 2019 at 07:59AM by notoriaga

Tuesday 20 August 2019

Question using multiple computers

Hello all -Full disclosure - my career to date has been in technology but never have I been a developer.I'm teaching myself Node.js for an upcoming position at work, but finding a tutorial on JUST node.js is pretty limited. I found a tutorial on the MERN stack and thought the skills would translate well since I have never done full stack dev.That I am using multiple computers to work through the tutorial and coding but I am having trouble keep the environments consistent. I am using git but until this tutorial have really only used it via copy paste and never had multiple directories... so I'm learning a couple things with this expedience.I'm certain I am not the only person who uses multiple computers. What is your process for keeping web servers and environments consistent across computers and projects?Not looking to have anyone solve my problem per-se as I'm very positive my issues are just related to my inexperience.Any help is appreciated!

Submitted August 21, 2019 at 01:59AM by soullesseal

Synchronous variable setting in nodejs

Sorry if this is too nooby for the sub. I'm messing around in nodejs and wanted to create variables that are set from db queries and then used later, once the connection is closed.However, as the db call takes nontrivial time, the variable initialization isn't happening until after the final line gets printed.Is there any way to ensure the calls are made synchronously, and the next line waits on the query to finish, without nesting each query?Note that the commented lines work as desired.Snippet:con.connect(function(err) { if (err) throw err; console.log("Connection successful!"); var totalRes; var distinctRes; con.query('select userid,name,address from MYTEST.people;', function (err, result) { if (err) throw err; console.log("Result: " + JSON.stringify(result)); }); con.query('select count(userid) as totalresults from MYTEST.people;', function(error,result) { if(err) throw err; //console.log("There are " + result[0]['totalresults'] + " results, with "); totalRes = result[0]['totalresults']; }); con.query('select count(distinct name, address) as distinctresults from MYTEST.people;', function(error,result) { if(err) throw err; //console.log(result[0]['distinctresults'] + " distinct entries."); distinctRes = result[0]['distinctresults']; }); con.end(); console.log("There are " + totalRes + " results with " + distinctRes + " distinct entries."); }); Output:Connection successful! There are undefined results with undefined unique entries. Result: [*entries*]

Submitted August 21, 2019 at 01:04AM by BallsyPalsy

Node v12.9.0 (Current)

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

Submitted August 20, 2019 at 09:02PM by dwaxe

Phone call listener app -speech to text

-2I have to build a phone-call listener app - that performs operations such as you do - "Pay you bill over the phone". You give specific answers to specific questions, and you bill is paid. The exception is There will be another live person on the other end. You will not be talking to an automated system. This app will not be a credit card billing system, I am only using it as an example.I have looked into node.js api's for both google-speech-to-text and twilio. Still researching. AWS speech-to-text APIs are also welcome. But I have not looked into those.The phone number does not need to belong to a specific carrier. I can have any vendor. Domestic calls only.The system needs to work at least from the outgoing calls from my number. The user at the other end will be prompted to agree for recording.I need to be able to give cues to the system, as to what is being recorded: such as credit card number, expiration date, CVC.My preferred stack is Mongo-express-react-node.

Submitted August 20, 2019 at 08:44PM by mozpider

Job Posts?

I've seen other subreddits that will post a weekly/monthly thread for people to post that they are either looking for work or looking to hire developers in the given language/technology. Does /r/node do that by chance? I've been subscribed to this subreddit for a while and hadn't seen one. Thanks.

Submitted August 20, 2019 at 08:11PM by razaan

Does await block code execution for every user trying to get a response from server?

Example: there are two users, asking for a response from the same endpoint at the same time. Lets assume one of them hit await statement a bit early(talking about miliseconds), will server wait for that statements execution before it continues code execution for second user? Or how does it work? Or does node do this without async await too? Im confused.. still kinda newbie..

Submitted August 20, 2019 at 07:47PM by warchild4l

Does installing a package from a repository install the release version?

If I install a node package that has a release version that includes optimizations like prebuilt binaries from a repository like this: npm install github_username/repo_name does that installation include all the goodies like a proper release when I use the command npm install package_name instead?

Submitted August 20, 2019 at 05:34PM by rraallvv

Inspect system information on a remote server from an express server

Hello,I'm currently building an express webserver to monitor activity on a list of server and I was wondering if a package exists to get cpu/memory usage on a remote server.I had a look at the `systeminformation` npm package which seems to do the job but only on the server on which Node is running.The other solution I have in mind is to try to find a package which could launch Powershell scripts/commands because this could provide a workaround.Any advice/suggestion ?Thanks,Bob

Submitted August 20, 2019 at 04:41PM by BobMilli

Node.js & React Native hackathon app

https://medium.com/@eliezer/how-to-win-a-hackathon-c50413500741

Submitted August 20, 2019 at 02:47PM by elie2222

need a "captivating" nodejs course

Hi everyone,This is probably a noob question - apologies in advance if it annoys anyone...I'd really like to learn to code (something decent) - but most of the courses I've tried usually have me bored outta my skull a fifth of the way through -- the most fun I have (genuinely) is debugging when something I've coded doesn't work as expected.Short of heading to a physical school, can anyone recommend a genuinely captivating online coding course (does not need to be node - I'll consider other languages too) where you build something even mildly interesting besides a shopping cart.To give you an idea of where I'm at, I've recently enjoyed building a basic Discord bot using discord.js and some old youtube videos (that used deprecated commands) which was kinda interesting as I only started using Discord a month ago (and no, I'm not a gamer). I've done some basic Python courses in the past too - but nothing decent. I regard myself as a coding newbie, but very teachable.Cheers and please be gentle with your responses :-P -- If you do end up recommend something, I'd appreciate it if you substantiated your response.

Submitted August 20, 2019 at 02:55PM by Ihatejam