Monday 31 December 2018

Is storing passwords and username in a .env file a good idea ?

I am contributing to this project puppeteer-salvator which takes as input the username and password of the user, stores it inside a .env file. Then the main script is run which loads the .env file using dotenv npm package, and logs into the facebook account of the user by opening up facebook in the headless browser provided by puppeteer. I wanted to know if storing the username and password inside a .env file is a good coding practice. Will it be safe to store there? Should i encrypt my .env file?

Submitted January 01, 2019 at 05:31AM by kryptokinght

Javascript Closures in Depth | Tutorial for Beginners | Easy Explanation with Examples

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

Submitted January 01, 2019 at 05:19AM by promisecoder

Electron and the Decline of Native Apps

http://bit.ly/2EGdTQ5

Submitted January 01, 2019 at 02:25AM by fagnerbrack

Uninstalling packages - dependencies being updated but some node modules not being removed?

So I am starting with a blank package.json and no other files or modules in the directory. I install a package with a dev_dependency reference using:npm install myPackage -DTrying to uninstall a package and remove the dev_dependency reference in package.json using:npm uninstall myPackage -DThis works successfully although I noticed that some of installed node modules still remain, including a blank folder from the package I installed. Is this to be expected? Also how do I completely remove any folders left over from the previously installed package? Thanks.

Submitted January 01, 2019 at 02:42AM by Guest911911

Crypto Noobs /Junior Devs/Amateurs Working together to build a D.A.O.

Kaleidoscope is a Decentralized autonomous organization being built & developed by crypto noobs /junior devs who are trying to take our ish seriously & grow our skills. We are doing our best to make the most out of this bear market . Here is our website if interested in learning more. We also teach skills if you dont have any.https://kld.life/Mahalo.

Submitted December 31, 2018 at 11:31PM by McNattyDread

should i be updating model files following a db migration - sequelize cli

hello all, I am getting started with sequelize and sequelize-cli​after creating a model using the sequelize-cli sequelize model:generate function, should I then be going back into the model file and updating the model columns to match exactly what I just put in the migration?​For example if I have some validations in my db table, should i add these validations (ex. allowNull: false) in the model? Should I add foreign keys as well? My gut tells me yes, but I wanted to hear some insight from others who may be more experienced than I.​I will add that without making any changes to these models, my db will return all columns, which leads me to wonder what the point of having these models are in the first place?

Submitted December 31, 2018 at 09:47PM by Dasnowman1183

crack-json 🥊 – Extracts all JSON objects from an arbitrary text document.

http://bit.ly/2QY6LWt

Submitted December 31, 2018 at 08:47PM by gajus0

Building a HTTP monitor | Help figuring out how to handle multiple monitors from database

I am looking to build an application that will take some values from a database and will run a certain 'script' using the values as parameters. The application is a website monitoring one. I am looking for advice on how best to handle pulling the data (url, timeout limit, ssl check boolean, how often to check in ,1, 5, 15, or 60 minutes) from a DB (mongo) then would run the check against the site. Currently I have a basic application that handles checks of an array of sites but it currently does not pull from Mongo nor does it look at how often it should be checking the site.​The script will output and save certain data to Mongo which I then handle with my front end application.​How best should I create a node service to handle the checks? I was thinking of a redis queue but that seems to not be the best option.​I'm really lost on this as I have never had to build something that required essentially cron jobs (my script/current service used `node-cron`)

Submitted December 31, 2018 at 08:51PM by jsdfkljdsafdsu980p

What CSS does your page actually use at load?

Like any good Dev, I spent part of my vacation playing with Puppeteer, the headless Chrome API.The result? whatcss.infoWhatCSS.info automatically generates a minified version of the bare minimum CSS a user needs to begin interacting with your site.Github: http://bit.ly/2EZaGfh

Submitted December 31, 2018 at 07:56PM by JohnnySuburbs

Build a Stock HD Photo Finder App in Javascript

http://bit.ly/2F2GLlN

Submitted December 31, 2018 at 06:06PM by codingworldhero

Reverse proxy your NodeJS apps on the Devilbox with custom domain names and valid HTTPS

Hi NodeJS community,I am usually browsing more r/PHP related subs, but as I've just finished the Reverse Proxy feature for Devilbox and explicitly wrote a tutorial for NodeJS I wanted to share it here.Most of you have probably never heard of the Devilbox, as it is more PHP related, but give it a look:Devilbox: Setup reverse proxy NodeJSThe above tutorial let's you run the application in an already available PHP container, there is however also the possibility to attach multiple custom NodeJS container (or only one with multiple projects) to the existing stack and therefore also make use of the underlying domain name and HTTPS feature.Any feedback, specifically on the use of pm2 is welcome, as I do not have a lot of experience yet with managing multiple NodeJS projects.Keep in mind that this is just my very first iteration on NodeJS support, so give me some input here about what is usually required to make a NodeJS developer's life easier.

Submitted December 31, 2018 at 04:40PM by cytopia

Unreported Error in "Testable Javascript"?

I'm working through the O'Reilly book "Testable Javascript" by Mark Ethan Trostler. I found something that doesn't make sense to me, but it is not called out in the errata for the book. What I'm looking at is on page 71, and other code from that page is noted in the errata, but the smaller snippet I'm concerned with is not. Here it is:var BD = function(dbHandle) { this.handle = dbHandle; } DB.prototype.addUser = function(user) { var result = dbHandle.addRow('user', user); return { success: result.success , message: result.message , user: user }; }; My question is, on the second line of the second block, wouldn't you have to use the instance specific database handler object such that the line should read: var result = this.handle.addRow('user', user); ??????

Submitted December 31, 2018 at 03:27PM by SoPoOneO

.remove not working on child document

Happy New Years Eve all,​I'm coming across some really strange behavior:​app.delete("/api-v1/tickets/:ticketID/notes/:noteID", auth, async (req, res) => {const ticketID = req.params.ticketID;const noteID = req.params.noteID;const ticket = {id : ticketID}const note = {id : noteID}const validTicketID = validateID(ticket);const validNoteID = validateID(note);if(!validTicketID.error){if(!validNoteID.error){try {let ticket = await Change.findById(ticketID)let note = await ticket.notes.id(noteID).remove()//let result = await ticket.notes.findByIdAndDelete(noteID)console.log(note)res.send(note);} catch (error) {res.status(404).send(error);}}else {res.status(500).send(validNoteID.error)}} else {res.status(500).send(validTicketID.error)}});};​My function is attempting to delete a sub-document, a note attached to my ticket. I am able to get the ticket, and get the note in my ticket. However the remove() method simply does nothing. I also tried findbyIDAndDelete with the noteID, but that also just does nothing.​I'm confused....​Kind regards

Submitted December 31, 2018 at 02:05PM by sma92878

How to run multiple versions of NodeJS with nvm for Windows

http://bit.ly/2EZwRkP

Submitted December 31, 2018 at 12:44PM by shrinivas28

Start the new year with a new Promise utility library

http://bit.ly/2EVlUkQ is the day before 2019, I thought of creating a library which waits till All the promises (fulfilled or rejected) finished. Since Promise.all() bails out on the first exception.I rarely use libraries like Q or BlueBird, since I use native promises for backend development. So, I thought writing this small library (with one job) which does not depend on any 3rd party libraries (except for TypeScript). I'm following the same output format as Q.allSettled.Thank you and Happy 2019...

Submitted December 31, 2018 at 12:55PM by geeganage

GraphQL or REST?

Hi guys,What's your policy on GraphQL vs REST discussion?http://bit.ly/2s14Wcg

Submitted December 31, 2018 at 11:30AM by oczekkk

What does this output mean when trying to initiate a torrent download via node-torrent?

Video Explainin the use of Async/Await on a Real World Example

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

Submitted December 31, 2018 at 10:57AM by HolidayInternet

Sunday 30 December 2018

How can I improve this SCSS parser of mine?

I am working on a little side/pet project of mine. All I am looking to accomplish (at this stage) is grabbing a .scss classes height attribute value, from all project .scss files.I'm using the npm package lineReader to read through the .scss files line by line, then checking to see if that line has the height attribute with indexOf('height') > -1; .This is where I am concerned I'm doing some hacky stuff.With the lines that have the height attributes, I'm grabbing the height value by parseFloat(line.split(':')[1]); which returns just the height value.But part of me has a sinking feeling that there is a better way to get this as a key-pair value, rather than having to do all of that nonsense to simply get the value from the height attribute. I want to be able to modify the height value, eventually. But for right now, I just want to physically get the value, and output it to the console (for testing purposes).​Any thoughts?

Submitted December 31, 2018 at 06:55AM by WebDevLikeNoOther

Javascript Promises in Depth | Tutorial for Beginners | Easy Explanation with Examples

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

Submitted December 31, 2018 at 07:30AM by promisecoder

How does ExpressJS(or any library used to write server side code) know the domain name of the server it’s running on?

No text found

Submitted December 31, 2018 at 05:12AM by SSuryansh

2D Multiplayer Space Sim Walkthrough - built with NodeJs/React/SocketIO

Hi guys,I have put up the first parts of a 2D multiplayer space sim walkthrough using NodeJS/React/MongoDB/SocketIO that some may find interesting.http://bit.ly/2Robz6J blog parts are so far are still in the early draft stages and have quite a few things that need fixing but it will be updated weekly. Right now it is in one huge long post but I will break it into separate sections shortly.It is currently up to part 15 and my intention is to build a full Multiplayer Space RPG game, with the blog containing the posts on how to build the entire thing. On the blog you will find a link to the test server (www.cmdship.net) which runs the latest version although at present it will probably crash or be down frequently - though hopefully will be more solid in a few weeks.I began building it and making it up as I went, then went back and rebuilt it again a few times in a more structured way. It isn't intended to yet be a guide on how best to do things (and in parts may be a guide on how not to do things), more just an idea of what you can do with just NodeJs, sockets and a client canvas. It may at times just read like endless walls of code but over time I will improve the parts to include more explanation.All the source code is linked to on the blog and free to use as you like, I've also linked the source code at each part at the end of a chapter. Project source: http://bit.ly/2GPrQxD free to contact me if you have ideas for improvements or find bugs and I will attempt to implement them where possible.​​​

Submitted December 31, 2018 at 03:57AM by dbdjsdev

Any graphing/plotting packages that run out of the console, similar to MatPlotLib for Python?

I'm looking for something that generates plots directly from the console (via NodeJS), without having to code-up a bunch of HTML and whatever.A good example of what I'm looking for is MatPlotLib for Python. The plots pop-up on the screen when they are created, and halt code from executing until they are closed. The plots are also interactive (zoom, save, etc), opposed to just creating a static image.I'm not looking for plots within the console, so something like asciichart is out.MatPlotNode provides MatPlotLib bindings for NodeJS, but requires Python 2.7, which is antiquated and not what I have (currently on Python 3.7).Thanks for any insight!

Submitted December 31, 2018 at 01:48AM by rockitman12

How to redirect my react app from nodejs properly?

I have a page that when user clicks a button the app will listen and creates a fetch call to my local server which will do a process and then redirect to an external url say google.com (I placed actually the url of my homepage just to see if it would work but nothing I get the same error (server and react app are on different ports))how do I avoid the current error that I'm facing "Access to fetch at 'http://localhost:3001/' (redirected from 'http://localhost:3000/servreq') from origin 'null' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled."Client:----------------------------------------------//..... testitem(){ fetch('http://localhost:3000/payreq', { method: 'post', headers: { 'Content-Type': 'application/json'}, body: JSON.stringify({ }) }) } //...... //...... Server:-----------------------------------------------const express= require('express'); const bodyParser= require('body-parser'); const cors=require('cors'); const app=express(); app.use(bodyParser.json()); app.use(cors({origin: 'http://localhost:3001'})); //im requesting from say localhost:3001/test/test app.post('/',(req,res)=>{ res.redirect('http://localhost:3001/'); }) I have tried to do the following with no result: (I understand that the origen is null but I dont know how to fix)-Add Headers-concatenation method-Wildcard method '*' (i dont think this is the appropriate plus does not work)One attempt did work but, its just not in my opinion what should be done.I simply generated a res.json(website to go to) in server side and on the client side just read that and use window.location=response to redirect but again I don't think it the way top go about it.If someone out there could help me I would trully appreciate it.

Submitted December 31, 2018 at 03:56AM by anarchy9511

Port number for Socket.io with Express on Heroku

I use the the following configurations for my node server and react client respectively;index.jsconst express = require('express') const io = require('socket.io')(8000) const app = express() const port = process.env.PORT || 5000 app.listen(port, () => console.log('Listening')) App.jsimport openSocket from 'socket.io-client' const socket = openSocket('http://localhost:8000') This works all good on the localhost. However, when I deploy to Heroku, it does not recognise the port number of 8000 and http://localhost:8000 as expected.Is there configuration to make it assign a port number automatically for the web socket, just like we do with the Express server by using const port = process.env.PORT || 5000 ?​EDIT:This article helped mehttps://devcenter.heroku.com/articles/node-websockets#option-2-socket-ioExample codeAlso don't skip this step:Apps using Socket.io should enable session affinity. If you plan to use node’s Cluster module or to scale your app to multiple dynos, you should also follow Socket.io’s multiple-nodes instructions.heroku features:enable http-session-affinity​

Submitted December 30, 2018 at 11:27PM by eligloys

Array.reduce is not a function?

Node 11.5I've got some very odd behavior cropping up when attempting to use an array of keys to create an object. This is something I've done many, many times before, and a minimum use case with the same code w/same data runs perfectly in Chrome..reduce is a function, but also not. What am I missing here?Error in Nodev11.5.0 [0] { id: 1, apple: 'pear', banana: 'orange' } [0] [ 'id', 'apple', 'banana' ] [0] function [0] function reduce() { [native code] } [0] true [0] Unhandled rejection TypeError: configKeys.reduce(...) is not a function Code That produced the errorlet defaultConfig = {id:1, apple:"pear", banana:"orange"} console.log(defaultConfig) const configKeys = Object.keys(defaultConfig) console.log(configKeys) console.log(typeof configKeys.reduce) console.log(configKeys.reduce.toString()) console.log(Array === configKeys.constructor) defaultConfig = configKeys.reduce(function(acc, key) { if(key !== 'id') { acc[key] = defaultConfig[key] } return acc }, {})

Submitted December 30, 2018 at 09:37PM by relativityboy

Hi all, I wrote a quick walk through to get started with Sequelize, let me know what you think!

I'm still a student so writing these tech blogs are still new to me. Please let me know what you think! Any criticisms or pointers are very welcome! If you like it, claps are welcome too :)http://bit.ly/2CFpJIy

Submitted December 30, 2018 at 09:08PM by Kinpaku

Compress or gzip an image for response

I'm writing an endpoint that fetches images off the file system and would like to compress the file but having trouble on the browser side.I'm using Node.js zlib module like thisresponse = fs.createReadStream(filePath).pipe(zlib.createDeflateRaw())this is deflating the file size correctly but on the client side the image element isn't rendering this response . Is this something that's even possible or am I doing it wrong? Thanks

Submitted December 30, 2018 at 05:48PM by crobinson42

Populating multiple layered models in MongoDB.

Hello,I'm having a problem with populating my MongoDB models.I already did one populating before this and it worked:.populate({ path: "comments", populate: { path: "commenter" } }) I tried doing this but it didn't work. How do I make this work?.populate({ path: "posts", populate: { path: "comments", populate: { path: "commenter" } }, populate: { path: "poster" } }) I basically have a User model that I find and I need to populate a field "posts" and "poster" in it, then I need to populate "comments" and "poster" in posts and then populate "commenter" in "comments"Does anyone know how to do this or a better way of populating models in MongoDB.

Submitted December 30, 2018 at 04:47PM by AmirSaran

epub help...

Hello,I am currently developing a online reader using react.js . I am thinking about securing the content (epub books ) from theft, but unlike PDF there is no such thing as password protection. Books will be stored in cloud and users can access them only if they login. Please help me by giving any suggestions how you will secure.Thank you.

Submitted December 30, 2018 at 01:27PM by ripviserion

Security procedures for nodejs

Good day. I am not new to nodejs but I am new to website development. Please what are the security issues to keep in mind when developing backend and how to fix them. For example, to block user account from being hacked and things like that. Thank you!

Submitted December 30, 2018 at 12:28PM by dudewith3faces

Saturday 29 December 2018

How do I loop through or enumerate a Javascript object?

http://bit.ly/2EZrr9x

Submitted December 30, 2018 at 07:13AM by facebookcoderbuddy

How do I remove a particular element from an array in JavaScript?

http://bit.ly/2QWXC0s

Submitted December 30, 2018 at 05:53AM by facebookcoderbuddy

A Guide to Deno Core (Design & for Contributors)

(Not necessarily related to Node.js... Hope it would be fine to post here...)A Guide to Deno Core​Background: Deno is a secure TypeScript server-side runtime on V8, by the creator of Node.js, Ryan Dahl, and debuted on JSConf EU.​Created this guide to discuss some current designs of Deno.It aims to make the current codebase and design more accessible and possibly encourage new contributions.Might contain errors or unclear descriptions, and the document itself is also pretty much WIP. PLEASE help point them out and submit issues on Github!

Submitted December 30, 2018 at 01:36AM by kevinkassimo

Made a Node.js boilerplate that implements hot reloading for (Post)css, ejs and js files, it takes away some painpoints and thought I'd share, feedback and suggestions are welcome!

http://bit.ly/2BMd0lW

Submitted December 30, 2018 at 03:27AM by pm_me_your_breast_s

ESLint Config Zoe

http://bit.ly/2LJaTny

Submitted December 29, 2018 at 10:43PM by ScottOreily

New to typeorm: having a hard time setting up a relation

I'm new at using typeorm and I can't define the relation that I want.Some help would be appreciated.Context: I have a user and a conversation table.A user has many conversation, and a conversation has one sender (user) and one recipient (user).Here's my User entity: http://bit.ly/2VkNqNB entity: http://bit.ly/2QakZ1g problem is that I want to access a user conversations with user.conversations, but right now it only gets the conversations where the user is the sender, whereas I want conversations where the user is either the sender or the recipient. Hopefully it makes sense.

Submitted December 29, 2018 at 08:10PM by Oalei

Cool! I made a modding tool for a video game with node :)

IF anyone has played X4 Foundations, (its a space sim with lots of modding support) - I got carried away with creating a "ware generator" - and dealing with X4's XML stuff. So I got to learn a LOT about xfering JSON to XML and back, used xml2js quite a bit for that, and to wire everything up to their xml system it took me about 10 days. Most of it was me creating classes with Typescript, as it honestly just helped me learn their xml schemas better (since they dont release a full schema of their objects anyway)​Some things I learned along the way:​You can use a library to convert a JSON object to a Typescript type, so if you convert an XML object to a JSON object you can get some of that IDE auto completion goodness when working with deeply nested and hard to remember objects.the PKG library lets you convert your CLI to a windows .exe file (and mac/linux binary FWIW) - which is great for making a CLI tool that is focused on a windows platform game.omg facebooks metro-memory-fs is THE absolute best at mocking filesystems, I couldn't even get other mocking fs libs to work with windows!Node has come a very long way with windows support (I generally code on a mac) - even without using the windows subsystem for linuxTypescript's module alias mapping will create outputs of files that still map to aliases, so if youre not using something like webpack (which I'm not because this is a CLI tool) - then dont bother!aside: I did find a library that let you run some require overload but it didnt work with PKGnode's ZLIB implementation is painlessly easy to use (a few lines of code to ungz files)Event Streams are still not what I thought, and I still don't understand themI've been using promises for years, and I still get surprised by their behavior. Seems like they're very eager to evaluate, even before calling them. I guess that's on purpose.XML is evil.. (not really, but...)Well, that's stuff I learned which I feel like I've learned the promise thing before but forgot it again haha.​Feel free to browse my most recent labor of love (ok that sounds cheesy but lets keep it) here: http://bit.ly/2SmUHul

Submitted December 29, 2018 at 08:01PM by tonechild

Code first DB using express and sequelize

hello all, I'm hoping someone more experienced can give me some insight on this.​I am developing on a windows machine. My production server is a linux box.​I originally set up my models and table structure using sequelize-auto, which allowed me to create my project with the db-first approach.​I back up my local db, and send it up to my linux box to restore the db with the updated db structure. Unfortunately, and something I did not consider before, there were certain windows specific characters that did now allow me to build the tables in linux.​Now i am at a cross roads. I'm wondering if I should use a code-first approach for this db, and if so, what are my options with sequelize ? Is this something that someone has experience with? My other option would be to rent a VPS and develop my db there on another linux server.​Thanks everyone​

Submitted December 29, 2018 at 07:29PM by Dasnowman1183

The MERN Stack Tutorial – Building A React CRUD Application From Start To Finish – Part 3 - CodingTheSmartWay.com

http://bit.ly/2EXOOAj

Submitted December 29, 2018 at 05:14PM by codingthesmartway

How do I pass command line arguments to a Node

http://bit.ly/2ET0lBH

Submitted December 29, 2018 at 05:47PM by coderchampion

Thoughts on embedding vs referencing documents for MongoDB

I'm going through a Node course, and I'm covering referencing and embedding documents. I can see for something like a ticketing system, you would want "notes" embedded in a document because they are specifically tied to that ticket. However something like a "user" that submitted the ticket could be referenced. That way is the person gets married and changes their name, the ticket reflects the change.​This is my very simple way of looking at it, do any of you folks with real world experience have any guidance on this?​Kind regards, and happy holidays.

Submitted December 29, 2018 at 05:48PM by sma92878

Storing HTML "pages" in MongoDB with Mongoose

Good day all,​I'm working on a simple Wordpress replacement, I've have authentication working, and I can read, write and update collections in Mongo. I'd like to take my learning and create a simple CMS, where I can add HTML into a collection.​Is there a "recommend" way to do this? I see there is a "code" data type, that is used to store JS code in the document. I was sort of expecting a UTF datatype to store static HTML documents. Will there be any issues with string escaping if I use a standard string data type? Has anyone done this and ran into issues?​Kind regards and happy new years.

Submitted December 29, 2018 at 03:46PM by sma92878

How to make external HTTP Requests with Node.js?

http://bit.ly/2Sqgce1

Submitted December 29, 2018 at 02:54PM by rivercodingworld

sqlogs - Quickly send a copy of your console.log messages to a SQLite database that you can easily query

http://bit.ly/2LEBKRx

Submitted December 29, 2018 at 02:53PM by nodeuser747

Multithreading (CyclicBarrier) in Node.js

Hi all,I have a question regarding multithreading (I know it's technically one thread) in Node.js. Let's say I have thread A, which at some point splits off into A and B. At some point in the future, A and B merge into one thread (A) again. But here is the issue: if subthread A finishes its work first, it can add a .on('event') to B's EventEmitter, and that's easy to work with. But what if B finishes its work before A? In this hypothetical scenario, by the time A registers the .on('event) listener, the event was already emitted, and thus A would have missed it, resulting in the program locking up. My current workaround is checking for a boolean being true first, and only after that registering the listen event, but 1) that is ugly; and 2) it is not 100% safe due to the lack of mutex in Node.js. Am I missing something here? Is someone willing to point me in the right direction?

Submitted December 29, 2018 at 02:06PM by NullProbability

How to resolve Bower dependency version conflicts?

http://bit.ly/2VhCJeX

Submitted December 29, 2018 at 10:40AM by codingwall

Problems with mongoose’s populate()

Calc schema:const { Schema, model } = require('mongoose');const calcSchema = Schema({_id: Schema.Types.ObjectId,preset: { type: String, required: true },datasets: [{ type: Schema.Types.ObjectId, ref: 'Dataset' }],model: String,});module.exports = model('Calc', calcSchema, 'calc'); ​Game schema:const { Schema, model } = require('mongoose');const gameSchema = Schema({_id: Schema.Types.ObjectId,name: { type: String, required: true },description: String,calc: [{ type: Schema.Types.ObjectId, ref: 'Calc' }]});module.exports = model('Game', gameSchema);GET games API routerouter.get('/', passport.authenticate('jwt', { session: false }), (req, res) => {Game.find().select('_id name calc').populate('calc').then(game => res.status(200).json(game)).catch(err => res.status(500).json({ error: err }));});Without populate calc property is an array full of calc IDs, however, as soon as I populate('calc'), calc property turns into an empty array. (["5c26b1a2a64a303358411a66", ... ] -> [])

Submitted December 29, 2018 at 08:58AM by Just42s

How do I update devDependencies in NPM?

http://bit.ly/2Q6NOvn

Submitted December 29, 2018 at 07:30AM by angularcodingbuddy

Changing index.html content through server response.

That should be fairly easy, but I couldn't figure it out. I have an index.html, a client.js file and a server.js file.

App

Hello Message

client.js is for making requests to server.jsdocument.querySelector('.button').addEventListener('click', function(e) { fetch('/fetchAll', {method: 'POST'}) }); In server.js I listen to these requests and run certain functions// serve the homepage app.get('/', (req, res) => { res.sendFile(__dirname + '/index.html') }) app.post('/fetchAll', (req, res) => { browserWindow() }) Let's say helloFunc() sets a variable; const helloMessage = "Hello there"I want to be able to change the content of the index.html in accordance with helloMessage variable.How can I do that?Also, sometimes helloFunc() might be async. In this case how can I listen to it's completion to send a data to html page?

Submitted December 29, 2018 at 07:00AM by eligloys

How to uninstall npm modules in node js?

http://bit.ly/2EU2FaH

Submitted December 29, 2018 at 08:52AM by coderdreamworld

Friday 28 December 2018

How do I update each dependency in package.json to the latest version?

http://bit.ly/2VhyUpP

Submitted December 29, 2018 at 04:56AM by billionairecoder

Node JS - Authentication - Testing With Mocha

In this video we are going to be talking about testing our /users and /users/me routes with mocha.https://youtu.be/WXKjHxOxtt0

Submitted December 29, 2018 at 03:58AM by WebDevJourneyWDJ

sync() method provided by sequelize required in production but not locally

hello all, I am new to the backend and to node. I'm using express and sequelize as my ORM.​Locally, I've created an API that connects to a postgresql db to handle my info. this works fine, and I had no issues reading and writing data. I also did not need to use sequelize.sync.​Move forward to my production server. during the deployment process, i received an error saying that a table from our db script did not exist. to fix this error, .sync() was used and now this works on the production server.​I'm wondering if anyone more experienced than me could help me debug:why the table was not created from a postgresql db backup,what the sync method is fixing in production, but not needed for locally.I should also add that I'm using sequelize-auto, running db first .

Submitted December 28, 2018 at 08:49PM by Dasnowman1183

Versioning Automation Management Tool

Does typecasting exist in JS?

I am writing to a NoSQl db (Nedb) and when I pull documents out, they are no longer defined by their type or constructor. What is the protocol? In Java, you can typecast upon deserialization to obtain access to the object's methods and properties. Not sure how to go about this in JS.

Submitted December 28, 2018 at 10:41PM by tdot456

JSReport: This Week on npm v20181228: eslint@5.11.0, Changelog Links

http://bit.ly/2EQGIJE

Submitted December 28, 2018 at 11:16PM by code_barbarian

Need a new year's resolution? Try 'The Ultimate Reading List for Developers' post I wrote

http://bit.ly/2em3jAa

Submitted December 28, 2018 at 08:18PM by YogX

Which node.js MVC framework is suitable for CRUD sites

http://bit.ly/2VftFHp

Submitted December 28, 2018 at 05:30PM by coderfriendbuddy

Node JS - Authentication - Hashing Passwords & Private Routes

In this video we are going to be talking about creating Private routes, since all of our routes are public meaning any user can delete any other users todos. And we are going to be hashing our passwords.https://youtu.be/HHf9SmXyuzo

Submitted December 28, 2018 at 02:39PM by WebDevJourneyWDJ

[Guide] Being fast and light: Using binary data to optimise libraries on the client and the server.

http://bit.ly/2EP2Gwy

Submitted December 28, 2018 at 11:02AM by dobkin-1970

Async-Ray v.3.1.0 new feature: chaining methods in an easy way

Async-Ray 3.1.0 introduces a new feature to chain Async methods, without looking weird.Chaining documentationhttps://github.com/rpgeeganage/async-ray#chainingSample 1http://bit.ly/2Qbytde 2http://bit.ly/2Vfn4wE

Submitted December 28, 2018 at 11:10AM by geeganage

A Pragmatic Overview of Async Hooks API in Node.js

http://bit.ly/2AilLEa

Submitted December 28, 2018 at 10:19AM by kiarash-irandoust

How to decide when to use Node?

http://bit.ly/2GJeUte

Submitted December 28, 2018 at 09:23AM by coderwallfriend

How to debug Node Remotely

http://bit.ly/2CBY8rH

Submitted December 28, 2018 at 06:50AM by coderswitch

Bare Node.js - no npm, no framework guide to node.js

http://bit.ly/2RoIGr6

Submitted December 28, 2018 at 08:32AM by devabhinav

Thursday 27 December 2018

Caching cloud data via a custom node server?

For an upcoming project I'm using a cloud database (Firebase Firestore). It works great, but my concern are potential high costs in case of high traffic to the site.​To keep the costs down, my idea is to avoid fetching data from Firebase directly in my frontend (React) app and instead:- create Node scripts that will pull data from Firebase and save it to local JSON files on my server every 15 minutes- create a basic Express.js API that will serve those local JSON data to my frontend apps​Is anyone doing something similar? My data doesn't update often, so making read requests to Firebase every 15 minutes is fine and would be a huge cost saver compared to making read requests for every single visitor.​My main question for the Node community, is it a good idea for my custom Express API to use "fs" to read json files and serve them? It seems redundant to use a local database as well, but I'd do it if it would be better for performance in case of high traffic.

Submitted December 28, 2018 at 06:09AM by reacttricks

How do I debug Node.js applications

http://bit.ly/2Ai7SWI

Submitted December 28, 2018 at 05:04AM by coderworldwide

Is it inadvisable to export request handlers as objects?

My first post here, thanks for the help in advance.So I am working on the backend of a product that uses node+express and was developed as part of a hackathon, much before I joined the team. The code was riddled with malpractices and pitfalls, which is why I was tasked with refactoring the code to meet enterprise standards (It is primarily a B2B app).One of the conscious decisions I took to make the code look cleaner and more modular is have the routers (like app.get('endpoint'), (req,res)=>{...}) in a different file and the actual request handler functions (like function createEntity(req, res)) in a different file, grouped based on what virtual data entity they operate on. I am doing request validation in the router and calling the request handlers only when request has been validated.The thing is, I am exporting the request handler functions as key-value pairs in a JSON object like so :module.exports = {createEntity: createEntity,getEntity: getEntity};I just had a round of code review by my seniors and one them, having about 7 months more experience than me in the team, raised the issue that what I am doing is unwittingly implementing a "Singleton" pattern, which I know node does by default, but according to this article should be done only knowingly. My manager says his point "makes complete sense".My question is, do we have to put an effort into not exporting objects in case of request handlers which are bound to a specific path in the API and won't sensibly be required (imported) in more than one place? If yes, what would exporting a constructor look like in this scenario.Edit: grammar

Submitted December 28, 2018 at 04:28AM by enkayjee

One-liner to delete node_modules recursively

I found myself with a ton of old abandoned projects, and their node_modules folders were eating up a significant amount of disk space.​To clear all node_modules folders from current folder recursively:find . -name "node_modules" -type d -prune -exec rm -vrf '{}' +​To ignore a specific subfolder:find . -name "node_modules" -type d -prune -not -path "./folder-to-ignore/node_modules" -exec rm -vrf '{}' +

Submitted December 28, 2018 at 12:40AM by FatherCarbon

Asyngular - Real time WebSocket server and client optimized for async/await

http://bit.ly/2GI1P3h

Submitted December 27, 2018 at 11:31PM by jonpress

Send message to a specific worker from master?

So I had an IRC client in python and it was using way to many resources, so I switched to node. I converted the code and was trying to figure out child processes then found my way to forks. I eventually found out about clusters and that seems like my best option, but I have a question.I have been trying to figure this out for a while and don't know if this is actually going to work.1.) Many people need to send a message from the worker -> master but I need to mainly send data form the Master -> worker. Most examples only display sending from the worker at the main source of sending, am I doing something wrong here?2.) I also need send these commands to specific worker (I just found out you cannot Or at least I think send data to a specific forked child processes hence the reasoning to look into clusters). I know that3.) These commands send to the worker are commands to disconnect from a certain IRC. Would that work?

Submitted December 27, 2018 at 08:39PM by Wonderful_Appeal

A Framework for the exploitation of NodeJS and Electron that allows to inject covert malware inside verified and signed applications

http://bit.ly/2VaYo8o

Submitted December 27, 2018 at 06:53PM by Alex0789

How to best Create a RESTful API in Node.js

http://bit.ly/2SuX8eo

Submitted December 27, 2018 at 05:12PM by reactivecoder

SRE: Resiliency: Bulkheads in Action — Using node.js

http://bit.ly/2EQWILx

Submitted December 27, 2018 at 05:01PM by dm03514

Sending data onto the client after authentication using express.

This may seem like a nooby question... But it's a scenario I've not yet encountered.Normally when I write my server code it's responsive, in that it simply replies to user requests. But this is different.I have a callback endpoint that will extract an access token. The problem I'm facing is that because the user never makes a get request, and that wouldn't really work even if they did, I don't know how to correctly send across and receive that token on the client side.So I can do a res.send() and that will send the token information to the user to be automatically rendered on the page. It's not what I want, however. I want the client to get the access token, but not display anything automatically. I suppose I could use res.sendFile() but this and res.json() both bring me to this problem:How do I listen for these? Since I'm not fetching and using a .then(responsedata), how do I get the response?​tl;dr: how can I send data to client without fetching it or displaying it with res.send().

Submitted December 27, 2018 at 03:54PM by HUMBLEFART

Suggested API gateway: Express Gateway or any other?

Hi all,Recently, a use case came up that requires a ton of Miroservices and I need an API gateway as expose those services externally. All (or at least most) of the Microservices will be written in Node itself.The actual question is about the Express Gateway. Is it good enough, I mean its performance and the support behind it. Are there any other open-source alternatives to that you guys might think is better. Any suggestion would really be helpful.

Submitted December 27, 2018 at 04:00PM by nulless

How to manually check hashed password stored with Passport.js in MongoDB database

So far I only have this way of verifying if the user entered the password correctly:// Login routes router.route("/login") .get((req, res) => { res.render("login"); }) .post(passport.authenticate("local", { successRedirect: "/", failureRedirect: "/login" })); I want to add a feature where the user can change the password and I have two inputs: old-password and new-password. I need a way to compare the hashed and salted password in the mongodb database and the one that is a string from the old-password input. If the passwords match update the password in the mongodb database with the new-password.Basically I need a function like bool password_verify ( string $password, string $hash) in PHP.I am using passport, passport-local and passport-local-mongoose for my user authentication, everything standard.

Submitted December 27, 2018 at 03:49PM by AmirSaran

How do I check if an element is hidden in jQuery?

http://bit.ly/2Styknr

Submitted December 27, 2018 at 03:27PM by coderdream

Node JS - Authentication - JSON Web Token (JWT)

In this video we are going to be talking about modifying our user schema so that way we can create custom methods and also creating tokens using JSON Web Tokens (JWT) to securely pass around user information.https://www.youtube.com/watch?v=xQakpJdhzLU

Submitted December 27, 2018 at 02:39PM by WebDevJourneyWDJ

Easy trick to get 95% discount on hosting services

- Hostinger.com is accepting BitDegree coins (cryptocurrency) as a payment method, with a fixed value of $0.07 per coin.- As with most minor cryptos in 2018, BDG is worthless now and sells for 0.004 on crypto exchanges.The trick: Buy BDG for $0.004 and spend them on hostinger for x20 the value. Enjoy your 95% discounts with 20 cents per month VPS or 7 cent shared hosting :DI'm not entirely sure how long will this be possible, I'm assuming until the end of this year.https://www.youtube.com/watch?v=H5IOc_3PeVk

Submitted December 27, 2018 at 02:50PM by Nisandzija

Standardised REST API responses?

Hi All,Im working on a reasonably large REST API and I would like to keep the responses (including error responses) consistent trough-out the entire application. The only specification that documents this is JSON:API however I am curious if there are any other specifications

Submitted December 27, 2018 at 01:00PM by runo9

How do I check if an array includes an object in JavaScript?

http://bit.ly/2GK1A7Q

Submitted December 27, 2018 at 11:58AM by bustycoder

robots-agent: robots.txt HTTP agent with in-built cache (new NPM package)

http://bit.ly/2LI2hxv

Submitted December 27, 2018 at 12:15PM by gajus0

The Myth Of 100% Code Coverage

http://bit.ly/2GDEm39

Submitted December 27, 2018 at 09:59AM by fagnerbrack

How to exit in Node?

http://bit.ly/2LC6in5

Submitted December 27, 2018 at 06:46AM by reactnativebuddy

What does “use strict” do in JavaScript, and what is the reasoning behind it?

http://bit.ly/2EOgCqu

Submitted December 27, 2018 at 08:48AM by coderfriend

ECMAScript modules in Node.js: the new plan

http://bit.ly/2rMt16E

Submitted December 27, 2018 at 07:41AM by ms-maria-ma

How to scale your Node.js server using clustering

http://bit.ly/2GzIgtJ

Submitted December 27, 2018 at 07:46AM by harlampi

Wednesday 26 December 2018

Firebase Cloud Messaging: Handling tokens and notifications with Node.js

http://bit.ly/2Vc6v4I

Submitted December 27, 2018 at 05:32AM by nulless

AdonisJS

It's a nice framework. I like it. If I mastered Adonis, could I call myself a "complete" Node.js developer? Would there be anything missing?

Submitted December 27, 2018 at 01:22AM by ncubez

The Hitchhiker's Guide to Serverless (x-post /r/serverless)

http://bit.ly/2ERanDd

Submitted December 26, 2018 at 08:55PM by nshapira

trying to install eslint and prettier but get symlink/space errors.

when i run npm i -D prettier eslint eslint-config-prettier eslint-plugin-prettier i get the following errors about acorn symlink and space:http://bit.ly/2PZ2DAd know there is enough space. im running KDE-Neon locally and my coding dir is on a mounted(cifs) zfs pool(mirrored drives) from a networked ubuntu-server box. on the ubuntu-server box node is also installed.

Submitted December 26, 2018 at 08:25PM by madMyco

[HELP] Scope issue?

Here is a quick excerpt of what I'm doingvar express = require('express'); var app = express(); var sql = require('mssql/msnodesqlv8'); var config = { connectionString: 'Driver=SQL Server;Server=SQLServer;Database=DEDB;Trusted_Connection=true;' }; app.get('/this/:id/thing', function(req, res){ var id = req.params.id; var data; var dataQry = "SELECT * FROM qTable WHERE ID = '" + id + "'" sql.connect(config, function (err) { if (err) console.log(err); var request = new sql.Request(); request.query(dataQry, function (err, recordset) { if (err){ console.log(err); } else { data = recordset; } sql.close(); }); }); console.log(data); //This is where I would like the data to be avalible so I can make one more call to a DB then //send both sets of data to my template }); The final console.log(data) returns as undefined. I am rather new to JS so I'm not sure what I'm missing. If I console.log(data); right under my attempt to assign recordset to the higher scope data, it works just fine. Outside of the callback data is still undefined. Any help or pointing in the correct direction is greatly appreciated!

Submitted December 26, 2018 at 06:08PM by TuxMux080

[HELP] TypeORM Vs. Objection on Knex for TypeScript API

I'm moving my Express with TypeScript API from Mongo to Postgres. I have tried a bit of both, TypeORM and Objection. And still can't decide, that's why I'm here. So please throw me some advice.

Submitted December 26, 2018 at 06:36PM by xzenuu

The route doesn't run when called after PayPal checkout

The success route is not been activated after PayPal checkout it redirects to the root component instead of the new root.PS: I'm using react at the view.​This is the code that is not been called:​app.get('/success', (req, res) => { const payerId = req.query.PayerID; const paymentId = req.query.paymentId; const execute_payment_json = { "payer_id": payerId, "transactions": [{ "amount": { "currency": "USD", "total": "25.00" } }] }; And that is the source code:​const express = require('express'); const ejs = require('ejs'); const paypal = require('paypal-rest-sdk'); const app = express(); app.set('views', __dirname + '/view/src/index.js'); app.set('view engine', 'jsx'); app.engine('jsx', require('express-react-views').createEngine()); app.get('/', (req, res) => res.render('index')); // config folder paypal.configure({ 'mode': 'sandbox', //sandbox or live 'client_id': 'AZ1yeX94XfiVko9t5mwMtOxl7xZDqph81t4-ZeUsIyCu6KwdU0WawBwifmRWJCkczJwjomV5BNdgSzmf', 'client_secret': 'EE2E_7kYXST4a8Fj8K8NJh447cBA_QT3xibEUKZgYKNGZWvXGGNsZ2t5zPEwHP961RVYm8KfMuu_6CSo' }); app.post('/pay', (req, res) => { const create_payment_json = { "intent": "sale", "payer": { "payment_method": "paypal" }, "redirect_urls": { "return_url": "http://localhost:3000/success", "cancel_url": "http://localhost:3000/cancel" }, "transactions": [{ "item_list": { "items": [{ "name": "Red Sox Hat", "sku": "001", "price": "25.00", "currency": "USD", "quantity": 1 }] }, "amount": { "currency": "USD", "total": "25.00" }, "description": "Hat for the best team ever" }] }; paypal.payment.create(create_payment_json, function (error, payment) { if (error) { throw error; } else { for(let i = 0;i < payment.links.length;i++){ if(payment.links[i].rel === 'approval_url'){ res.redirect(payment.links[i].href); } } } }); }); app.get('/success', (req, res) => { const payerId = req.query.PayerID; const paymentId = req.query.paymentId; const execute_payment_json = { "payer_id": payerId, "transactions": [{ "amount": { "currency": "USD", "total": "25.00" } }] }; paypal.payment.execute(paymentId, execute_payment_json, function (error, payment) { if (error) { console.log(error.response); throw error; } else { console.log(JSON.stringify(payment)); res.send('Success'); } }); }); app.get('/cancel', (req, res) => res.send('Cancelled')); app.listen(5000, () => console.log('Server Started')); ​

Submitted December 26, 2018 at 06:00PM by danilosilvadev

Node v8.15.0 (LTS)

http://bit.ly/2GFAi2l

Submitted December 26, 2018 at 04:44PM by dwaxe

What is the Difference Between Node and Nodemon ?

http://bit.ly/2Rl1J5G

Submitted December 26, 2018 at 05:38PM by angularbuddy

Node v10.15.0 (LTS)

http://bit.ly/2Vc8mpW

Submitted December 26, 2018 at 04:44PM by dwaxe

Node v6.16.0 (LTS)

http://bit.ly/2Q49Tuv

Submitted December 26, 2018 at 04:44PM by dwaxe

Node v11.6.0 (Current)

http://bit.ly/2Q226xu

Submitted December 26, 2018 at 04:44PM by dwaxe

New to node and am having issues connecting to remote site

Hi all,I am in the process of learning about node and it's packages. One of the simple things I want to do is transfer files from my local to my remote (shared) servers via FTP. To that affect, I have installed vinyl-ftp.I've set up my gulpfile.js file as per the example given but when I try to connect I get the DNS error:Error: getaddrinfo ENOTFOUND ftps.mysite.com ftps.mysite.com:21 at errnoException (dns.js:50:10) at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:92:26) I'm not sure how to fix this. Connecting to the same server with the same details via FileZilla works fine, I just cannot connect with node and vinyl-ftp.My gulpfile.js is as such:gulp.task('ftp-deploy', function() { var conn = ftp.create({ host: 'ftps.mysite.com', port: 21, user: 'user@mysite.com', password: 'password123', parallel: 10, log: gutil.log, }); var localFilesGlob = ['css-dist/**']; return gulp.src(localFilesGlob, { base: './css-dist/', buffer: false }) .pipe( conn.newer( '/css' ) ) .pipe( conn.dest( '/css' ) ) ; }); Would anyone know how I could approach solving this error?Many thanks in advance!

Submitted December 26, 2018 at 10:42AM by MeltingDog

Cross platform portable shell scripts in Node.js

http://bit.ly/2ELEBaJ

Submitted December 26, 2018 at 10:49AM by harshitsinha1102

[Noob Alert] How to move from console application to webpage?

Hello. I'm quite new in node.js and I have no clue about webpage part of this language.I'm looking for a way how to move my node.js console app to website.​​My current script is getting some data about image from database, process it and send it back.​Now I want make this script accesable for anyone.Someone call my script like http://bit.ly/1eauXFg , I'm processing image and returning url.I have no clue how I can that with node.js.​​​

Submitted December 26, 2018 at 11:33AM by BuyMeMomo

Should Node be installed with Homebrew or installer?

Should Node be installed with Homebrew or the installer provided on their website? I'd like to use Homebrew because it keeps all my package installations in one place, but I'm not sure if the installer on their website is going to be more reliable or safe.

Submitted December 26, 2018 at 08:25AM by rumboogy

JavaScript achievements of the Year 2018 and key Frontend’s trends

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

Submitted December 26, 2018 at 08:32AM by r-wabbit

Trying to run this webapp via node.js, and getting errors. Noob warning. Help

Hi.I am trying to run this package from github:http://bit.ly/2BIiP3y is what I did to try and make it work:I am running windows 10 64-bitI downloaded Node.js from the official site.I downloaded Git and followed directions to add to PATHI opened a terminal and went to package directoryI commanded npm install.I then followed dev instructions:commanded npm run build:dllAnd then npm run startI opened a chrome in incognito with no extension and went to localhost:3001App will seemingly start, but will not go through first stage.Here are the screenshots:http://bit.ly/2QRq5o7 advice for a noob would be so appreciated. Thanks.

Submitted December 26, 2018 at 06:36AM by ebwvibfhwbovchwdshjd

Generate-Resume: Node CLI to generate resume in HTML and PDF formats from data stored in an XML file

Hello all,​I've created a Node CLI called Generate-Resume to generate resume in HTML and PDF formats from data stored in XML format. Please try it out and let me know your feedback/comments.​Link: https://github.com/sumeetdas/Generate-Resume​Please leave a star if you like it. :-)​Thanks.

Submitted December 26, 2018 at 04:40AM by MeowBlogger

Tuesday 25 December 2018

Server-side TypeScript framework

Hi guys!I am currently working on the server-side TypeScript framework. My team already widely use this framework in various e-commerce and ERP projects. Structure and semantic were inspired by other popular frameworks like Spring and ASP.NET.Currently, there are a lot of possibilities:Describing routing using controllers and decoratorsPowerful, full-typed Dependency InjectionIncoming data validation (using AJV) with various set of decoratorsTypeORM integration (Repositories injection, Transactional support using CLS)Extendable JWT-based authenticationAll parts of the framework are fully typed and integrated with the whole infrastructure.For the best performance, under the hood, Fastify is used. The framework is declarative, but also avoids using decorators were it's possible. So, it's keep everything simple, clean and minimalistic.Example:@Controller('foo') export class FooController extends IController { @RoutePatch('{id}') bar(id: string, payload: FooDTO) { ...some updates.. return Ok(); } } So, as you see, there no need to provide any additional param decorators for injection data from the HTTP request. It's just a small controller overview, there are a lot of other possibilities.Features coming soon:AOPGRPC integrationGraphQLCLIand more...From the beginning, the framework was designed as opensource. I really need your feedback guys, it's very important for me!Here the few links:Github - ODIDocs - ODIAlso, we aim to support Deno in the future.Thanks for your time! :)

Submitted December 25, 2018 at 03:20PM by Wrapy

A NodeJS Boilerplate, for scalable applications

Hello guys, I'm new to Reddit, and I just completed a really nice NodeJS Boilerplate!Feel free to check it out and let me know what you think! :Dhttps://github.com/arbershabani97/nodejs-setup

Submitted December 25, 2018 at 01:26PM by arbershabani97

19 ways to become a better Node.JS developer in 2019

http://bit.ly/2LtRgj7

Submitted December 25, 2018 at 09:46AM by r-wabbit

Monday 24 December 2018

Node.js testing best practices - call for ideas

Hey, I'm the author of node-best-practices and currently working my next blog post "Node.js testing best practices". It's almost done. Before publishing I always enjoy gathering here few more ideas (and giving credit like I did here), would you kindly share some tips & good practices that you learned during your testing journey?Example of bullets that will appear in the blog post:Include 3 parts in each test nameLint your tests with test-dedicated ESLint pluginsTest only public methods, stick to black-box testingDon’t “Foo”, use real input dataAnd 20+ more

Submitted December 24, 2018 at 08:19PM by yonatannn

package.json and node_modules folder installed into my C:\Users\Me folder?!

I just noticed this and am not sure why they're there (I'm on Windows 7 and will downgrade to 10 when I have to). I did install node per instructions on Google's site for Windows, but it just seems like at least package.json should not be there... not sure if I did something wrong, nor why node_modules would ever be installed there. I'm not familiar with the Linux/Mac way it installs either, but I've only used npm (not yarn, which I think isn't even compatible with Windows yet).Please, if your answer is to get a Mac or Linux, I'll set up a GoFundMe link for you to contribute to.I also installed Git Bash from Git Extensions (awesome program), which I know has "global" config in my Users folder, so is package.json node's "global" file? It seems that could conflict with other programs' "global" package.json file if that's what's actually happening.

Submitted December 24, 2018 at 07:27PM by dyngi

Using ExpressJS and TypeScript with OvernightJS (v3).

http://bit.ly/2GFduzJ

Submitted December 24, 2018 at 05:25PM by theTypeScripter

A guide on how to install Node

Hi,​I created a guide to help anyone who might be trying to install Node on a Mac at http://bit.ly/2EKRNvv. It uses NVM so that you can manage different node versions. Hopefully this helps anyone who might need it. I created it using Nice Guides.

Submitted December 24, 2018 at 04:34PM by hidace

Creating a simple REST API with Node and Hapi in 10 min

http://bit.ly/2V8gGag

Submitted December 24, 2018 at 01:08PM by qpbp

Importing functions from files or creating files for each function.

Hello it's better to use :import {functionName} from 'filename' or i create file for each function and export it as default to import it like that:import functionName from 'filename' what's the best practice in this case?thank you.​

Submitted December 24, 2018 at 11:44AM by ayech0x2

How to POST and GET API in Loopback

How to develop a node.js application which has POST API for username, sex, age and GET for the same. How to implement it using loopback and mysql.

Submitted December 24, 2018 at 11:44AM by zuccyboy

How to upload multiple buffer objects to a same file in AWS S3 using node.js?

I am trying to upload multiple buffer objects to a single file in aws s3. I am unable to do so.For each of these buffers, I am able to upload them individually to a file in S3, but not combined.S3.upload(APP_BUCKET_NAME,"all.xlsx",data); "all.xlsx" => filename to be created and data=> array of buffers.

Submitted December 24, 2018 at 12:09PM by datavinci

Production ready Node.js REST APIs Setup using TypeScript , PostgreSQL and Redis

http://bit.ly/2T14YMN

Submitted December 24, 2018 at 09:36AM by kiarash-irandoust

A2 Hosting Experience

Hi,​I am just starting out learning Node and want a place to post a few of my projects in a working form and wanted to know if anybody has experience running Node on A2 Hosting. I am not doing anything commercial grade as yet and just starting out with personal projects I expect zero to little traffic on.​Thanks in advance.

Submitted December 24, 2018 at 07:44AM by mtttmpl

Node.js - Upload File to Google Cloud Storage

http://bit.ly/2EM2wps

Submitted December 24, 2018 at 08:39AM by dobkin-1970

Sunday 23 December 2018

Mongoose findOneAndUpdate can't take an object?

hello all,​I'm working on learning how to build API's and I'm having some trouble with my PUT. With my POST I can do something like:​const userToAdd = new User({firstName: req.body.firstName,lastName: req.body.lastName,password: hashed,email: req.body.email.toLowerCase(),address: req.body.address,city: req.body.city,state: req.body.state,zip: req.body.zip});let result = await userToAdd.save();​The above works just fine, however when I try and do a findOneAndUpdate, I have to break out each field instead of just creating a new User object.​const user = await User.findOneAndUpdate({_id: id},{firstName : \${firstName}`,`\lastName : `${lastName}`,`\password : `${hashed}`,`\email : \${email}`,`\address : \${address}`,`\city : \${city}`,`\state : \${state}`,`\zip : \${zip}`},`{ new: true })\`​I expected I would be able to do something likeconst userToUpdate = {firstName: req.body.firstName,lastName: req.body.lastName,password: hashed,email: req.body.email.toLowerCase(),address: req.body.address,city: req.body.city,state: req.body.state,zip: req.body.zip};const user = await User.findOneAndUpdate({_id: id}, userToUpdate, {new: true})​kind regards

Submitted December 24, 2018 at 02:55AM by sma92878

Question about while loops with async http.get

Newbie question. I'm requesting information from a url and running a while loop to put things on hold until it gets what's needed. I've found some hints online saying this doesn't work, but is someone able to explain it to me? Thanks!Note--taking shortcuts just to display my logiclet var1 let var2 let var3 get1 = http.get({ //update var1 in callback }) get2 = http.get({ //update var2 in callback }) get3 = http.get({ //update var3 in callback }) while (!(var1 && var2 && var3)){ // wait until we have them all } console.log("Got them all!")

Submitted December 24, 2018 at 12:48AM by IsotopicBear

NPM Blog: Details about the event-stream incident

http://bit.ly/2EzTYC2

Submitted December 23, 2018 at 11:23PM by fagnerbrack

Node express server does not work on Zeit Now

I am trying to deploy a node application to Zeit now server but even a simple express server does not work properly.When I deploy the application, I get hello message for / , but visiting /hello gives me 404 page.This guy does not even use a now.json file and it just works fine.Am I missing some fundamental steps?This is the index.jsconst express = require('express') const app = express() app.get('/', (req, res) => { res.send('hello') }) app.get('/hello', (req, res) => { res.send('hello2') }) app.listen(3000, () => console.log('listening')) This is now.json I don't know the difference between node and node-server, but using node does not even display the hello message at /{ "version": 2, "builds": [ { "src": "index.js", "use": "@now/node-server" } ] } And this is the package.json{ "name": "demo", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "now-start": "node index.js" }, "keywords": [], "author": "", "license": "ISC", "dependencies": { "express": "^4.16.4" } }

Submitted December 23, 2018 at 10:25PM by oneevening

Best blogs/mailing list for node.js (backend)?

Hi all,Like my previous post - http://bit.ly/2Cwggn6 looking for Node.js blog -again for advance backend development, does anyone have a good recommendation?Just to give a little context, an advanced developer (mainly python/java), already know node quite but I want to improve/ take it to the next level :)​Thx

Submitted December 23, 2018 at 09:25PM by etlsh

Node.js Fundamentals: Web Server Without Dependencies

http://bit.ly/2EGZvHi

Submitted December 23, 2018 at 08:16PM by bloomca

How to get data from another file?

So I have been searching over internet for more than an hour now but couldn't find a good answer and wanted to ask here as well. Please keep in mind I am fairly new with node.js.My problem is, I have one .js file that is a chatbot and actively listens user texts on the platform. And it checks "if message == some_pre_defined -> write pre_defined_response". Now I can do this and it works pretty well. However, I have the message / response list on the same .js file as well.What I want to achieve is, have two files, and keep commands/responses at one of them, and use the main one to call different functions. So, it would be like this,main.js -> functions/other stuffcommands.js ->const responseObject = { "ayy": "Ayy, lmao!", "wat": "Say what?", "lol": "roflmaotntpmp" }; Then I want to call that constant from my main file. Currently I have that command list in my main.js file, so I can call them & use them no problem. But, is there a way to call that variable from another file? I know that functions could be called with "require" but I haven't find a way to call that constant/variable from other file and use it actively.

Submitted December 23, 2018 at 04:03PM by nithronium

Proper way to release a Postgres Pool connection

I'm learning about PgSQL pooling. I wrote a script using the node-postgres package. Currently it successfully grabs a connection from a pool of 5, executes a query, gets results, and then I'm not sure how to properly release it. It's just a script and I'm running it using node index.js. But when I use pool.release() the script takes longer to exit than when I use pool.release(true). Which way is will release the connection back into the pool, and can you explain the difference between them. Here's a link to the documentation I'm referring to http://bit.ly/2EIf6WN.

Submitted December 23, 2018 at 01:26PM by the_amazing_spork

@gizt/selector - Fast and simple JSON selector

I just created JSON selector library. It supports many type of selectors e.g. property, wildcard, array, nested. I would like to here everyone's opinion https://github.com/gizt/selector​Here's playground http://bit.ly/2Ra3Mtr

Submitted December 23, 2018 at 11:39AM by rezigned

a problem with sending a response

Hi everyone,   I'm using Linux Ubuntu. I've downloaded node.js through this link by completing those steps and it's installed successfully. I get request data in my terminal when run the file. But when i try to send a response on localhost:3000 it just keeps loading and doesn't send the response. What could be the problem? Could you please help?Thanks in advance for your time​i'm using this code:​const http = require('http');const server = http.createServer((req, res) => {console.log(req.url, req.method, req.headers);res.setHeader('Content-Type', 'text/html');res.write('');res.write('');res.write('

Hello from my Node.js Server!

');res.write('');res.end();});server.listen(3000);​

Submitted December 23, 2018 at 10:04AM by heyoomark

The MERN Stack Tutorial - Building A React CRUD Application From Start To Finish - Part 2 - CodingTheSmartWay.com

http://bit.ly/2rNI1kI

Submitted December 23, 2018 at 08:56AM by codingthesmartway

Saturday 22 December 2018

thank u, next: an introduction to linked lists

http://bit.ly/2BzhHzf

Submitted December 23, 2018 at 04:57AM by fagnerbrack

Good programming practises for storing / displaying data?

Hey guys, I am a cs student and still learning so I apologize in advance if this comes off as a little simple. Also if this is the wrong sub, I apologize but I think Electron runs on top of Node.jsI have an electron app and am storing data in a NoSQL db, NeDB (something like a NoSQL version of SQLite) . This data is also being displayed on screen. Should IStore everything in memory, display the changes as they occur, and write to the database upon exiting the program?Read / write to the db, and pull data from the DB to show to the screen?Hold the data in memory (in some variable) so I can display it on screen, and also continuously add to the DB as it is updated?The first option seems a little unstable as obviously, if the program crashes, you could lose a good chunk of data if you've had an app running for some time.The second option - I'm worried whether or not this would be too slow / redundant to both write to DB and then pull it back to display to screen? I think NeDB stores the whole thing in memory anyways, so it's less about the efficiency and more about just plain code redundancy.The third option - I don't know why I thought it was any good when I was running through options but I think I had some logical reasoning behind it at the time.Any help would be appreciated!​

Submitted December 23, 2018 at 01:03AM by tdot456

antipathy: Sane Node.js filesystem operations for TypeScript 📁 (It's my first NPM package! Questions? Comments? Feedback?)

http://bit.ly/2QPnLOH

Submitted December 23, 2018 at 01:42AM by jwinnie8

How to save uploaded files on a disk

I wrote a very simple file uploader, which calculates hash of the file content, adds it to the file name (so that files with the same name do not get overwritten, but if the same file is re-uploaded it overwrites the previously uploaded file), and saves the file in the root of the specified directory.There are a couple of problems with my super-naive approach.First, all files end up in a single directory. Presumably, as the number of files grows, this can slow down the time to access files. I googled for a good solution, but found only this article on Medium discussing how to build a directory structure out of the hash of file name. Is this a standard approach? Do you know of any pre-existing packages that already do something like that?The other problem is that calculating the hash of file content takes a long time if the file is large, and this CPU-intensive operation blocks the main thread. What is a good way to offload this operation from the main thread? (Sorry for asking such a noob question.)

Submitted December 22, 2018 at 10:08PM by azangru

[Bounty] Cannot run tests without sudo on Mac OS X High Sierra

http://bit.ly/2PW2AVN

Submitted December 22, 2018 at 06:51PM by jonnygravity

Users complaints about a Node-driver method implementation for MongoDb

http://bit.ly/2V8pD3F

Submitted December 22, 2018 at 06:48PM by spartanz51

Connect to public MySQL Database from my PC

I'm attempting to connect to a MySQL Database in JavaScript, with Node.js specifically. I have a LAMP stack installedI've made a MySQL connection in Java and can add records to the database with no problem, no errors - full connectivity however I cant in Node :(I've set /etc/mysql/mysql.conf.d/mysqld.cnf file to have bind-address commented out and also set to 0.0.0.0 yet both haven't given me a solution.I've assured that the following IPTable / UFW rules have been applied to my Ubuntu Machine: (To prevent 'spam', i've uploaded it to pastebin.com)http://bit.ly/2EKIHju my code below, I've also tried:server.listen(port, "0.0.0.0") without the second argument,scrapping normalizePort, and just using 3000Without the socketPath: '/var/run/mysqld/mysqld.sock' parameterHere's my code: bin/www.jsfollowed by app.jsHere's my code: `bin/www.js\` followed by `app.js`http://bit.ly/2EDFq4w bin/www.jshttps://hastebin.com/etewenonur.js app.jsWhen "socketPath" is not included, I get this error:There was an error{ Error: connect ECONNREFUSED xx.xx.xxx.xx:3007at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1117:14)When it's not included, I getThere was an error { Error: connect ECONNREFUSED xx.xx.xxx.xx:3007 at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1117:14)If anyone can help me out, I will appreciate it a lot a lot alot since I've spent the past 7 or so hours on google, i've tried every link :(, Thanks everyone

Submitted December 22, 2018 at 05:55PM by VectroChicken

I love Back End, love JS, love node. But I totally hate Front End.

I mean, I know how to use HTML/CSS, I know well bootstrap. But I hate DOM manipulation, choosing colors, fonts, right layouts, react and friends, etc. UI design is not for me. I prefer deal with API's, data, system's architecture and that stuffs. So, I have less chances to be hired than a Full Stack developer? A Full Stack profile is better than a Back End engineer?

Submitted December 22, 2018 at 04:39PM by andersonjdev

What's the "proper" way to search using multiple options with a RESTful endpoint?

I'm teaching my self how to create RESTful endpoints using Express. My question is what's the "proper" to search for something using different criteria.​Example:In this first example, I want to search for a user by IDapp.get("/api-v1/users/:id", async (req, res) => {let id = req.params.id;res.send(await user.searchUserByID(id));});In this second example I want to search for a user by emailapp.get("/api-v1/users/:email", async (req, res) => {let email = req.params.email;res.status(await user.searchUserByEmail(email));});​The system doesn't know what I'm actually passing, it could be an id or an email.Should I create a more specific route?​/api-v1/users/id/:id"/api-v1/users/email/:email"​What is the "proper" convention for this? Does anyone have a link to industry best practices?Kind regards

Submitted December 22, 2018 at 05:09PM by sma92878

Rockin’ around the JavaScript tree: the Raspberry Pi, HomeKit connected Christmas tree

http://bit.ly/2SfZNbT

Submitted December 22, 2018 at 12:27PM by Htch

Introducing Visual GraphQL Editor [Alpha] - draw your graphql schema and deploy mock backend from it.

http://bit.ly/2SeX9Dt

Submitted December 22, 2018 at 12:33PM by ArturCzemiel

What is the most stable ORM for a Node project ?

I’m coming from Laravel which is using Eloquent ORM. I also worked with Spring (Java) that is using Hibernate ORM.I’m familiar with models, relationships, migrations and seeders... I’m not sure if libraries works the same in the Node world ? I saw sequelize and a few others but people seems to say it’s not very mature.My project is using the Express framework, it’s a REST api.

Submitted December 22, 2018 at 12:39PM by Oalei

Boilerplate for nodejs with Babel and Webpack

Do you know any minimal boilerplate to use Nodejs with the latest JS syntax and bundle the code with Webpack?

Submitted December 22, 2018 at 01:17PM by oneevening

I would like to wirite a program for my granddad on christmas

Hello, as i mentioned in title i would like to write a program for my granddad. He loves crosswords, he can solve it for hours but he has weak knowlage of new movies, music and generally show business so he use wikipedia for it. To make his work easier i would like to wite a program for solving crosswords. For example if he want to find w word and he has missing 2 letters like A*b*. Program should give him all words which can fit to this word. I have found wikipedia apihttps://en.wikipedia.org/w/api.php?action=opensearch&format=json&search=lasBut it works only with full word and if i want to use it for every letter of alphabet (polish has 32) it would be 32^(missing letters) so 1.048.576 request for 3 missing letters are too many...I have thought that it will be easier to download wikipedia in json file, but its large file (compressed is 42gb so raw file i think is about 100gb so idk how to divide it later..).Do you have any idea how can i do this kind of program?PS. Great feature would be also possibility to set category

Submitted December 22, 2018 at 11:50AM by Sebqu

Best podcast for node.js (backend)?

Hi all,​I'm looking for Node.js podcasts - mainly for advance backend development, does anyone have good recommendation?​Just for the reference (I come from python): Podcast._init_/talk python to me etc'​Thx​

Submitted December 22, 2018 at 09:47AM by etlsh

Good looking developer merch?

Might not be the place to ask this, but does anyone know of a good store/site where I can find good looking developer merch? I love the kinds of tshirts github does for hacktober. Im tired of just finding merch on redbubble etc. Where its literally just a node logo pasted on a hoodie for example!

Submitted December 22, 2018 at 09:13AM by reakan

Friday 21 December 2018

DB modules in routes or separate?

So maybe this is a silly question but hey, it is what it is. When using something like redis, is it best to create and connect in each route of your REST api or have a separate file that creates a single client, connects once, and import that into your route to use instead? Are there pros/cons to either one as far as performance, connection limits, etc?

Submitted December 22, 2018 at 07:00AM by sesharc

Functional Programming Principles in Javascript

http://bit.ly/2V5hpcy

Submitted December 22, 2018 at 05:10AM by fagnerbrack

Runkit like app that works in local environment - Anything like that?

Runkit is amazing to try out libraries, create and share code snippets. But I want to try things in my local environment. It will help me include local files and debugging easier. I know I can use node interactive shell. But that's not much pleasant editing environment.

Submitted December 22, 2018 at 05:12AM by chubby601

JSReport: This Week on npm v20181221: webpack@4.28.0, Fixing GitHub Security Warnings

http://bit.ly/2CrYH7A

Submitted December 21, 2018 at 11:35PM by code_barbarian

Passport.js session is working in postman but is no in browser.

Hello guys, i'm making a resftul api using express mongodb and passport js ( local strategy ).i created a /is_connected route to check if user is in the session or not! once i login then i make /is_connected request it gives me the user connected i'm calling req.isAuthenticated() passport method this is working fine on postman ! but when i try to do this in my browser i get empty sessioni'm using axiosthank you.

Submitted December 22, 2018 at 01:59AM by ayech0x2

Creating a RESTful API using Node JS and Mocha For testing

Created a playlist of videos that will show you how to create a RESTful API using Node JS, Express JS, MongoDB, Mongoose JS, and Mocha for testing our routes.https://www.youtube.com/playlist?list=PLrwNNiB6YOA1aRBhFsKznH2rtNqsgXKGK

Submitted December 22, 2018 at 12:16AM by WebDevJourneyWDJ

AdminBro just got an option to modify its dashboard

an example app with custom dashboard (login: [test@example.com](mailto:text@example.com) password: password): http://bit.ly/2T9SuTp bro repo: http://bit.ly/2CtoYCm

Submitted December 21, 2018 at 09:35PM by lysywojtek

Running node-cron for a changing DB | asynchronously running a function for each entry

I am building something that will run a certain function every so often (I will have it running either every 1, 5, 15 or 60 minutes depending on a DB value). My project is learning how to make an HTTP/SSL monitoring service (yes I know many exist, this is for learning), so I would in theory have users signing up every so often and that I would want to include their checks in the periodic checks.​I have the functions that will do the HTTP/SSL checks already I just am not sure how I would be best to have `node-cron` to get the updated values from the database while being able to run all of the check asynchronously so that when I would have say 10,000 checks that it would not make the cron job last too long and cause issues with the next running of it.​Suggestions on how I could do this? I'm kind of lost on the most performance optimized way to handle it.

Submitted December 21, 2018 at 09:08PM by jsdfkljdsafdsu980p

Newbie wants to build a Node a React, MongoDB, GraphQL app then deploy to cloud

Just need some resources and advice this has been long over due on the bucket list but aspiring to become a full stack developer who knows a little devops is the goal for the next 9 to 5 job.So I have some experience with javascript and node and i want to start building apps for my portfolio.I use usually use udemy / pluralsight but always run into issues , and find my self jumping around or as im learning the front end (javascript 2017,React) I'm forgetting the back end (node, GraphQl/rest, SQL Mongo, docker) .

Submitted December 21, 2018 at 08:57PM by KaizenLionNinja007

Question , how to get values from db and pass to router response

Hello everyone , I am trying to make a function that will return values from db and then i have to pass to router for now my working code is followingrouter.get('/add_item', isAuthenticated, function(req, res, next) { db.merchants.findAll({ where: { merchants_owner: req.session.userId, merchant_type: 'store', } }) .then((result) => { if (result) { result.forEach(result => { console.log(result.dataValues); }) res.render('merchants/add_item', { merchants: result, title: 'Add Item', }); } }); res.render('merchants/add_item', { merchants: result, title: 'Add Item', }); }); Now for code practice ,this merchant part i tried to move into function but i am unable​router.get('/add_item', isAuthenticated, function(req, res, next) { var result = userMerchantlist(req.session.userId); res.render('merchants/add_item', { merchants: result, title: 'Add Item', }); }); function userMerchantlist(uderid, callback){ db.merchants.findAll({ where: { merchants_owner: uderid, merchant_type: 'store', } }) .then((result) => { if (result) { callback(null,result); } }); }; please help me , thanks

Submitted December 21, 2018 at 06:29PM by franco_tuv

question about an API paradigm

I am building an API server.Most request will include data from a few different tables, and have some logic performed before sending the resulting JSON to the client. It seems that this does not really fit a REST interface. I have looked at graphQL and it does seem to better fit what I am doing, however, I was just wondering if some other standard might fit better.in my previous API server, I just made a bunch of functions that responded to certain urls. But there was no real standard to it..​any tips would be great, thanks !​

Submitted December 21, 2018 at 04:46PM by s-keL

Converting Promise to ASYNC / AWAIT

Hello all,I've been working on using ASYNC and AWAIT, and for some things it seems to be working just fine. However I'm running into a specific problem I don't understand. In the code below I'm saving user data into MongoDB via Mongoose.​This code block works fine:const addUser = async (firstName, lastName, email, password) => {return new Promise((resolve, reject) => {const user = new Users({firstName: firstName,lastName: lastName,email: email,password: password,isPublic: true});const result = user.save();if (result) {resolve(result);} else {reject(err);}});};​This code block does not:const addUser = async (firstName, lastName, email, password) => {return new Promise((resolve, reject) => {const user = new Users({firstName: firstName,lastName: lastName,email: email,password: password,isPublic: true});try {return await user.save()} catch (error) {return error}};​I am under the impression that when you 'await' the promise, it's handing the resolution for you. Is this not correct? I know the try / catch sequence is handled, but do you still need to resolve or reject the promise? It's looking like you still do. Also is there a "better way" than a simple if statement to check the promise's resolved condition?​Kind regards​

Submitted December 21, 2018 at 02:12PM by sma92878

Node project coding practices

I have been interviewing with companies based out in europe mainly Berlin. I got rejected for my coding task a lot of times. I would like to know the coding practices and structure to follow to clear the interview round and help me write better code.Here is a sample project: https://github.com/stopcharla/CurrencyExchanger​Any suggestions would be appreciated. Thanks a lot

Submitted December 21, 2018 at 12:27PM by stopcharla

It's normal to require a lot of modules in Node.Js?

I mean that didn't effect the speed of the website?

Submitted December 21, 2018 at 01:17PM by mounaim2dev

Node.js & Raspberry Pi Temperature & Humidity Monitor

http://bit.ly/2GLrbxp

Submitted December 21, 2018 at 01:27PM by deckard_cainabis

Express.js error handling and responses statuts

Hello guys, i'm making a restful API using Express.js and mongoDB here my code for the login post routeauthRoutes.post("/login", function(req, res, next) { passport.authenticate("local", (err, user, info) => { if (err) { return res.status(400).json(err.message); } if (!user) { res.status(400).json("Wrong email or password!"); } req.logIn(user, err => { if (err) { res.status(500).json(err.message); } res.status(201).json(user); }); })(req, res, next); }); What i want to know its better to use try and catch and put all the code within and return 400 code for example or checking every statement and return a response with an statuts code? like that? i'm really confused about this! can anyone suggest me to right way to deal with this? it's Restful api.Thank you.​​

Submitted December 21, 2018 at 11:15AM by ayech0x2

Introducing the API Documentation (Swagger) Plugin 🧭

http://bit.ly/2QKaWoR

Submitted December 21, 2018 at 10:59AM by soupette

Issues with login and authentication in PASSPORTJS

Hey guys :)I am having some issue with my application. I have two different logins in this application, and I am using passportjs and express-session to handle it. However, I am having some issues:One login refers to a model called "user". This login works perfectly.The other one, is a model called "employees". I made the "employees" routes a mirrored version of the "user" routes, since the "user" is working fine.The "employees" login works fine, but, after the login, req.isAuthenticated() is false (it means, login is not working that fine lol), then, req.user is undefined. I don't have this issue when I do the login for the "user".I have created two different strategies for each model, and two different instancies of passport to handle each of them; It still does not work properly.Here are some images from my code:App config related to passport and the models. I have two strategies for each one, as well as two instancies of passport.​Passport configuration​User model​Employee model​User register and login routes. This one works perfectly. No problems at all! (ignore the get route for /protected, that was made only for tests...)​This is the employee register and login routes. The registering is working fine, but not the login. After I do the login, it is like nothing happened at all...​Thank you guys for the attention! I have been struggling with it for some days, and not even stackoverflow could help me on this.. I think that it is something either with the passport configuration or in the post route at my employees login.​Any help is appreciated​I wish you the best​

Submitted December 21, 2018 at 10:29AM by SEXYBRUISER

Thursday 20 December 2018

Process manager with no vulnerabilities?

I've been using Snyk as part of my CI and am attempting to use a process manager with a few node apps. As you can see both nodemon and pm2 both have vulnerabilities (according to snyk). So I was wondering, what do you guys use for managing process uptime in production? am I being overly cautious?

Submitted December 20, 2018 at 11:44PM by whatisboom

SQL Server to MongoDB RESTful API suggestions

I am creating an API that is going to have to get information from our local SQL server that is being called by an outside development company using MongoDB to store the information for the app to use.Getting the information using mssql and express to app.get the SQL data with a query (soon to be a stored procedure) to JSON format is the easy part now I am looking at how to best get this secured and delivered to the developers. The only requirements they have given me are that the protocol be HTTPS and authorization is to be handled by a predetermined token via a HTTP authorization header for all API requests.​I have looked into a few options that may/may not be overkill such as passport.js, OAuth, Auth0, etc.​Looking for some suggestions as to what will be sufficient and secure.​Apologize for all the questions as I mostly deal with C#/C++ and am not as knowledgeable regarding this as I would like to be.

Submitted December 20, 2018 at 11:51PM by Hellshing

Node JS for Beginners - Restful API App - Getting a Specific Data From DB

Today we are going to be creating a GET route that will grab a specific todo and will be testing this new route that we are going to create with mocha.https://youtu.be/4_puTJMVWlA

Submitted December 21, 2018 at 12:53AM by WebDevJourneyWDJ

Question about Async/await

Hello guys,i'm wondering what is the difference between the famous Async package from NPM and the recent async/await introduced in ES8.Are they the same or is one faster/better than the other ?Or maybe they are the same ?? ...I need to know :)

Submitted December 21, 2018 at 02:02AM by nerwin45

Request package question

I posted my question on Stack Overflow if anyone could please answer... thankshttps://stackoverflow.com/questions/53878214/reading-google-response-json-files

Submitted December 21, 2018 at 02:07AM by KF3_F

My book Data Wrangling with JavaScript has been printed!

The world of data is big and it can be difficult to navigate on your own. With data all around us growing at an ever-increasing rate, it’s more important than ever before that we are able to deal with data effectively and efficiently to support our businesses and our customers, to be able to monitor and understand our processes and enable faster and better decision-making.When I started working with data in JavaScript there wasn’t much information or resources out there, I had to learn it for myself. I wrote Data Wrangling with JavaScript in the hope of making life a bit easier for those that come after me. I’ve already blazed these trails and in this book I share my years of hard won experience with you.Read more on The Data Wrangler: http://www.the-data-wrangler.com/data-wrangling-with-javascript-printed/​​https://i.redd.it/8b8yz5f0ii521.jpg

Submitted December 20, 2018 at 10:49PM by ashleydavis75

Are there any better alternatives to sequelize-auto?

So I was wondering if there was a way to convert my large amounts of database tables into sequelize models, s I stumbled upon sequelize-auto, a tool which catered almost all my needs, except one, it didn't sort the relationships among the tables out for me, so I was wondering if we had a better alternative to sequelize-auto.

Submitted December 20, 2018 at 09:31PM by Prateeeek

Beginner with problems working with the Harvest API and getting paged results

HiI am fairly new to JS and Node.JS so please bear with me while I try and explain.​I am working with the Harvest API (https://ift.tt/2I5xCa3) which returns 100 results per page with added pagination.​EG{"projects":[{"id":14308069,"name":"Online Store - Phase 1","code":"OS1","is_active":true,"bill_by":"Project","budget":200.0,"budget_by":"project","budget_is_monthly":false,"notify_when_over_budget":true,"over_budget_notification_percentage":80.0,"over_budget_notification_date":null,"show_budget_to_all":false,"created_at":"2017-06-26T21:52:18Z","updated_at":"2017-06-26T21:54:06Z","starts_on":"2017-06-01","ends_on":null,"is_billable":true,"is_fixed_fee":false,"notes":"","client":{"id":5735776,"name":"123 Industries","currency":"EUR"},"cost_budget":null,"cost_budget_include_expenses":false,"hourly_rate":100.0,"fee":null}],"per_page":100,"total_pages":1,"total_entries":2,"next_page":null,"previous_page":null,"page":1,"links":{"first":"https://api.harvestapp.com/v2/projects?page=1&per_page=100","next":null,"previous":null,"last":"https://api.harvestapp.com/v2/projects?page=1&per_page=100"}}​I am trying to create a function which paginates the results and appends each of the paged results into a single set. I believe that I need to use Async Iterators but I am not too sure and I don't have anything to show at the moment, sorry.​Some links which you may find useful:​Node codehttps://github.com/harvesthq/harvest_api_samples/blob/master/v2/harvest_api_sample.js​Pagination Infohttps://help.getharvest.com/api-v2/introduction/overview/pagination/​Project Objecthttps://help.getharvest.com/api-v2/projects-api/projects/projects/​Any pointers would be great.Thanks for your time.​Al

Submitted December 20, 2018 at 10:25PM by alan-alan-alan

Convert your database tables to equivalent orm templates

https://ift.tt/2Cs0LMN

Submitted December 20, 2018 at 09:08PM by Prateeeek

Limitrr: Better ExpressJS rate limiting

https://ift.tt/2SbGP6j

Submitted December 20, 2018 at 07:44PM by m1screant

Top NodeJS Libraries and Tools For Machine Learning

https://ift.tt/2rKzP4z

Submitted December 20, 2018 at 07:11PM by simplicius_

How to drop multiple databases at a time via MongoDB Compass

Totally a noob question, and I know this is typically not something you'd want to do, but I've been taking a MongoDB tutorial course which includes Jest testing and for some reason the test suites have been generating hundreds of DBs that are now showing up in my compass. I have about 502 DBs and I only care about 5 or 6 of them. Manually dropping each one sounds tedious and I feel like there's definitely got to be a better way but google hasn't helped me out very much. please help a brother out.

Submitted December 20, 2018 at 05:01PM by trblackwell1221

Number of server instances for small website?

I'm still pretty new to Node JS, I have a small website with a ton of images (~300 per page), should I use multiple Node JS instances? And if so, how many?

Submitted December 20, 2018 at 05:12PM by Wakeful_Cloud

point me in the right direction for some node technologies

Greetings all.I am coming from a rails platform with a simple API that I am moving to node.jsI have an app built in React-Native with Expo. So here is my issue.I use Mobix to handle state on the app. I like it a lot. Actually, the whole idea of state changes updating the view instead of page refreshes is just awesome to me. However, our company allows our clients to control industrial machines with our app. Right now, to get the change of state of the machine, I am making lots of calls to the API for updates from our server. For example, if a customer presses "start" on the app, it takes a minute or two before the machine is running and our database knows about it. I don't want the app repeatedly making calls to the server to check if its running or not. Push notifications seem to be an idea but also seem a bit overkill. I have looked at Socket.io, but am not sure if it was really meant for a task like this, to push information to the App. So this is one area I am looking for an answer to.The other thing is our data processing. When a machine reports to our system its state (running, off, idle, etc..) we do a lot of processing on it's sensors (pressure, current, etc) to properly know the status of the machine. We log it's history, running time, etc.. I am starting to write more of this process in node.js and would like to share some code between the webserver code and the engine code because a lot of it is similar. Would a framework be better suited to something like this? (currently using Objection.js as my data interface and Express as the api server) . I mean, a lot of things the app needs to know are the same things the machine processes need to know. But our machine process sending requests to our api server would (because of http) be quite overkill and i wonder if it would even be fast enough to keep up.I am reading lots of articles about data mappers and socket servers and was thinking perhaps an idea might be to have functions in the API that pull (via tcp) info from our machine processes code that make use of some of the same data mapping before sending that result via JSON to the client. Or is it a better discipline to keep these separate for the sake of maintainability?So, I guess my questions are about technologies I may not know exists, or best practice kind of questions. Sorry for the long post, any ideas would be very helpful and well considered.

Submitted December 20, 2018 at 05:19PM by s-keL

Building Serverless Google Analytics from Scratch

https://ift.tt/2QFBasq

Submitted December 20, 2018 at 04:16PM by shch1289

Using Firebase to Insert Budget Transactions to Google Sheets from Trello

https://ift.tt/2S7RjDH

Submitted December 20, 2018 at 03:26PM by lord-bazooka

Extra LearnNode.com Master Packages from Wes Bos ($20 each)

https://learnnode.comI bought a 15-person team package for my work during the black friday sale and I have 4 left. If you want one they normally retail for $139 and it can be yours for $20! PM me, I take venmo.Mods: If selling courses on here is no bueno LMK and I'll just give them away.

Submitted December 20, 2018 at 02:37PM by steveonphonesick

How to send data from a redis subscriber to an express route

I have a redis pubsub client where publisher is in one file and subscriber is in another file working perfectlyI have 2 controllers a home controller that handles '/' route and a data controller that handles '/data' routeInside my redis subscriber I want to update the state of a variable that I continuously get from publisherHow do I send this state to both controllers when they do a request​I was doingapp.get('/', (req, res) => {c = redis.createClient()c.on("message", (channel, message) => {// Send data here})})This does not look like a good idea, it is creating a new CLIENT for every request to the '/' endpointI want to be able to do// home controller fileapp.get('/', (req, res) => {res.json(state)})// data controller fileapp.get('/data', (req, res) => {res.json(state)})​How to implement this state

Submitted December 20, 2018 at 01:37PM by mypirateapp

A Pragmatic Overview of Async Hooks API in Node.js

https://ift.tt/2Ets5f3

Submitted December 20, 2018 at 12:50PM by kiarash-irandoust

Hiroki: build REST APIs faster than ever

Hiroki in npmi made this package Hiroki - npm package and a yeoman generator generator-hiroki.this package allows you to create a REST api using mongoose models as a base.Basic example:```javascript const express = require('express'); const hiroki = require('hiroki'); const app = express(); const UsersSchema = new mongoose.Schema({name: String}); mongoose.model('Users', UsersSchema);hiroki.rest('Users');//enable GET,PUT,POST & DELETE methodsapp.use('/api', hiroki.build()); app.listen(8012); ```Open source:hiroki use open source tools: * mongoose * express

Submitted December 20, 2018 at 12:09PM by perchopick

First Integration tests

I am developing an API service whose request handler is divided into 2 sub components who communicate through RabbitMQ. The requests are collected from a producer who sends the messages to a RabbitMQ queue, and on the other end a consumer pulls out messages from the queue and processes them.I have implemented tests for both the components separately, but now I would like to implement some integration tests. What are the first steps?

Submitted December 20, 2018 at 10:31AM by honestserpent

Is it smart to implement an api using websocket?

No text found

Submitted December 20, 2018 at 10:31AM by zSacrety

How and Which tool should use to make API-Gateway for polyglot Microservice Platform?

https://ift.tt/2QJcOhi

Submitted December 20, 2018 at 10:45AM by osmangoninahid

NodeJS - Using async/await in a for loop

https://ift.tt/2BtVfaJ

Submitted December 20, 2018 at 10:47AM by shrinivas28

Node.js API and Web Frameworks for 2019

https://ift.tt/2LeiPgg

Submitted December 20, 2018 at 10:18AM by katerina-ser60

Why You Should Consider hapi

https://ift.tt/2SjHO47

Submitted December 20, 2018 at 10:06AM by dobkin-1970

New DataStax Object Mapper for Apache Cassandra

https://ift.tt/2S7v7JM

Submitted December 20, 2018 at 08:12AM by linkpaper

extract-date: Deterministic and unambiguous automated date parsing

https://ift.tt/2SYypz3

Submitted December 20, 2018 at 09:28AM by gajus0

Wednesday 19 December 2018

Considerations for the Beginner Serverless Developer (x-post /r/serverless)

https://ift.tt/2RdT8Sa

Submitted December 20, 2018 at 06:08AM by nshapira

mail-promise: Simple email service for NodeJS and TypeScript

https://ift.tt/2NODOtK

Submitted December 20, 2018 at 04:25AM by theTypeScripter

Node JS for Beginners - Restful API App - Creating GET API and Testing our Routes.

Today we are going to be creating a GET route to grab all of our todos and also going to be testing the POST route, from the last video, and this new route that we are going to create with mocha.https://youtu.be/BIhMjXbCOmA

Submitted December 20, 2018 at 12:44AM by WebDevJourneyWDJ

Securing Your Site like It’s 1999

https://ift.tt/2E87Bca

Submitted December 19, 2018 at 09:36PM by r-wabbit

Announcing Gluegun 2.0 — A delightful way to build command line apps in Node

A couple years ago, we (at Infinite Red) built an NPM package to help us build out some CLIs in Node. We called it Gluegun.I've been putting a lot of work into it over the past year and finally have version 2.0 to show. So, here's a blog post announcing it!https://ift.tt/2QD7s7r few notes:We know there are a lot of options in this space. Yeoman and Commander.js are probably the two biggest.Gluegun sort of wedges itself into a unique space -- it is powerful (comes "batteries included") enough for most CLIs you might have to build. But it doesn't take over your world like Yeoman does.It's used by AWS Amplify's CLI, Infinite Red's Ignite and Solidarity, and several others.Happy to answer questions here if you have any!​

Submitted December 19, 2018 at 09:19PM by jamonholmgren

Intro to Data Structures in JavaScript — Part 1

https://ift.tt/2rJVZnP

Submitted December 19, 2018 at 07:26PM by JSislife

AVA 1.0

https://ift.tt/2EBwHjt

Submitted December 19, 2018 at 07:43PM by sindresorhus

what is the difference between a DataMapper and an ORM

I have been reading about different ORM's (I use a mariadb-cluster) . And there is much mention of datamapper as a design. After reading several pages, I can't really see the difference. Any ideas?I am using Objection.js right now, which is working really well for me. But I thought for more complex relationships for an API I need to build, another paradigm might make it easier. I like the idea of making a restful interface, but none of the info I want to build routes for are as simple as pulling rows from a database based on queries (where an ORM would shine, i think) I mean, would be ideal for a document storage db, however, all our data is in mariadb tables.​

Submitted December 19, 2018 at 06:25PM by s-keL

Struggling with ASYNC / AWAIT and Mongoose

Hello all,​I'm trying to use ASYNC / AWAIT with Mongoose, and I'm missing something:​I have a file that holds the functions for talking to MongoDB:​const mongoose = require("mongoose");mongoose.connect("mongodb+srv://niodbuser:We.like.M0NG0@nasquam-z7win.mongodb.net/exampleApp?retryWrites=true",{ useNewUrlParser: true }).then(() => console.log("Connection to the remote database made...")).catch(err => {console.error("Could not connect to MongoDB...", err.stack);process.exit(1);});const userInfoSchema = new mongoose.Schema({firstName: String,lastName: String,email: String,password: String,date: { type: Date, default: Date.now },isPublic: Boolean});const Users = mongoose.model("user", userInfoSchema);async function getAllUsers(){const users = await Users.find();let result = users;console.log(result);return result;}module.exports.getAllUsers = getAllUsers;​The routes file imports my user-auth fileconst user = require("../controllers/user-auth");const routes = function(app) {app.get("/api-v1/users", (req, res) => {let results = user.getAllUsers();res.send(results);});}module.exports.routes = routes;​When I do my get request with Postman the users print in the console, however nothing is being returned to my main file. An empty JSON object is being sent back to the browser.​What am I missing here?Kind regards​

Submitted December 19, 2018 at 06:08PM by sma92878

Top NodeJS libraries for machine learning

https://ift.tt/2rNAx1e

Submitted December 19, 2018 at 06:14PM by crowdbotics

Building Analytics React Dashboard with Cube.js

https://ift.tt/2EDhije

Submitted December 19, 2018 at 05:20PM by movshare

A JavaScript scratchpad that auto-evaluates as you type

https://ift.tt/2SIDxr5

Submitted December 19, 2018 at 04:55PM by lukehaas

Loggin'JS a Winston (logging) alternative

Loggin'JSHi, I've been working on a logger similar to Winston, and just wanted to showcase it a little. I made it for a work project where we needed a logger that was modular, heavely customizable, could log to diferent outputs and was simple. And this is the result.What is it?It's a little customizable logger for NodeJS with wich you can log to the console, to a file, to a remote service or create a custom Notifier.It's really simple to use and configure, it can also be really customized.What can you do?You canCustomize the formattersFilter logsCreate custom notifiers to match your needs if the premade ones don'tJoin loggers into one interfacePipe diferent levels to diferent filesSave logs and output when needed (as npm does)Color logsShow line number...ResourcesWikiNPMGitHubExamplesA list of some usage examples:Basic ExampleOnly log one severityLogging to a fileLogging RemotelyCustom Logger​If any of you is interested, please check it out and tell me what you guys think!Hope it helps someone as it helps us on our projects!Cheers!​PD: I'm looking for some help, if any of you is interested. I'm working on a big update.​

Submitted December 19, 2018 at 04:17PM by nombrekeff

Can anyone help me with Python-shell in Nodejs?

How to visualize 24 hours?

I’m mostly a front end dev with very limited experience in back end/using nodejs. I want to practice by building an app for time management and visualization.I would like to some how track user time based on activities that that create and put a color on to identify which activity they spend their time on. (Ex. They create a work activity that they would like to track and the choose the color red to see on the graph)I’m not sure exactly how to track time and store it into a format that can be graphed but I’m confident I can figure that out. The problem I’m having is how can I just develop one bar with 24 increments on it with each increment representing one hour? I’ve looked into d3 a little bit. Any pointers would be nice. I’d like to challenge myself but I’m in need of a little bit of guidance and creativity from someone a little more experienced in this sort of thing

Submitted December 19, 2018 at 04:42PM by MoveToPluto

Node Js For Beginners - Mongoose Tutorial - Create

Today we are going to be talking about incorporating mongoose into mongodb.We will be creating models, which define how a collection should look like. We will also be learning about postman and how that can help us test and help us look at the flow of our app.https://www.youtube.com/watch?v=cIUzm9cj9fA

Submitted December 19, 2018 at 03:20PM by WebDevJourneyWDJ

Podcast episode: I Don't Hate JavaScript Anymore

https://ift.tt/2SSoFGL

Submitted December 19, 2018 at 03:48PM by szul

JS .filter(), .map() and .reduce() on real world example

https://youtu.be/EzB6Pk66XW8

Submitted December 19, 2018 at 03:25PM by arboshiki

Over Explained – JavaScript and v8

https://ift.tt/2Ev7UNK

Submitted December 19, 2018 at 03:08PM by scmmishra

Get the entire Database and store the data in a huge object.

Accessing the Database is less performant than accessing an object. So when the server starts why not retrieving all the data from the database and store it in an object?

Submitted December 19, 2018 at 01:30PM by zSacrety

Serverless framework's CLI tracks all commands and sends it home by default

https://twitter.com/JiriPospisil/status/1075050470186631175

Submitted December 19, 2018 at 10:49AM by jiripospisil

Customer safe secure template engine

Can anyone point me in the direction of a template engine I could use that would be safe/secure to let customers edit templates in?I'd like to provide a template syntax as part of a CMS I am developing, where I provide a context with some objects customers can access and they use this to write their own templates.What I'm considering so far:liquid-nodeThis looks good, downside is it also looks a bit dated and hasn't had any work done on it in over a year from what I can tell, but it does explicitly state the goal as to what I'm looking for.liquidjsSimilar to above but more recent development, not sure if it is as secure though as it doesn't state anywhere explicitly that the intention is to be customer safe.HandlebarsLogicless and simple - would it be ok to execute customer templates server side?MustacheEven less logic than above. Could this be a safe bet?

Submitted December 19, 2018 at 10:13AM by deathtostackoverflow

AMF0 and AMF3 for Node.js

https://ift.tt/2RbtTQM

Submitted December 19, 2018 at 10:15AM by Zaseth

Async/Await with Arrays

A library which supports async/await callbacks for every, filter, find, findIndex, forEach, map, reduce, reduceRight and some methods in Array.https://ift.tt/2zZJuZw

Submitted December 19, 2018 at 09:20AM by geeganage

An Intro to Node.js That You May Have Missed

https://ift.tt/2UXHcDs

Submitted December 19, 2018 at 08:54AM by kiarash-irandoust

Tuesday 18 December 2018

NodeJS Async Reading a list of url from a file

I am new to NodeJS and would like to know is there a way to store the following urls in a files instead of a const strings in an array and still utilize the same async code to read and process the urls as in the example link below from github:https://ift.tt/2EEeCSi is the const urls example:const urls = ['https://jsonplaceholder.url01.com','https://jsonplaceholder.url02.com','https://jsonplaceholder.url03.com'];I would like to store the urls in either a JSON or a text file and have the application still perform async read to process the data from a file instead of the urls within the nodejs application.​Basically, I would like to store the following in a text file:['https://ift.tt/2ExwJJ7];

Submitted December 19, 2018 at 01:43AM by AutoGenModerator

Require auth token

I am working on an API that I need to require an auth token that is generated once and then is not shown to the user again. I know of JWT but was thinking that it might not be the best because everything I have found on it seems to point to it being used for web applications that have a UI. Not sure how well that would work for me.​Here is an example of a pseudo code curl command of what I want it to be​curl -H "Auth-token: 12345ABCD" -d payload.json https://api.mydomain.com/v1/event/create​​How could I best do this with node and express? Any packages that solve the problem or a guide that might give me ideas?

Submitted December 18, 2018 at 10:14PM by jsdfkljdsafdsu980p

Should i learn type script?

Is it worth learning ts? Why everyone prefers to go ts? I’d like to start learning ts too but how much time it’d take if you are good with js and what are some key benefits?

Submitted December 18, 2018 at 09:10PM by Saud381