Wednesday 31 January 2018

I'm a self-taught full-stack javascript dev. What dependencies have you found using the most at your job?

I'm trying to compile a list of best practices for production. What are your most commonly used dependencies at work when building real-world applications in javascript? I'm currently using node(express), vue, mongodb, and sometimes I'll use an ORM with sqlite, but I'd like to learn raw SQL.Here's some node dependencies that I use: Axios Sequelize Mongoose Body-Parser Morgan Cors Express Helmet CompressionThis is not an exhaustive list and I'd like all your input on best practices and what dependencies to use both client and server side.

Submitted February 01, 2018 at 01:18AM by whowasjavascript

Node v9.5.0 (Current)

http://ift.tt/2nrKqzX

Submitted February 01, 2018 at 02:01AM by dwaxe

Rasperry Pi, Node and Johnny-five: Yes this is a JavaScript help post

I've been playing with Raspberry Pi and Node for fun. I thought for a simple experiment what if I grabbed some user input to turn an LED on and off.const readline = require('readline'); const log = console.log; const five = require('johnny-five'); const raspi = require('raspi-io'); const board = new five.Board({ io: new raspi(), }); const rl = readline.createInterface({ input: process.stdin, output: process.stdout }); board.on('ready', function() { const led = new five.Led('P1-7'); const recursiveAsyncReadLine = function () { rl.question('Command: ', function (answer) { switch(answer) { case 'on': log('Got it! Your answer was: "', answer, '"'); led.on(); break; case 'off': log('Got it! Your answer was: "', answer, '"'); led.stop().off(); break; default: } recursiveAsyncReadLine(); }); }; recursiveAsyncReadLine(); }); It works however I get 2 strange bugs. In the console output below you'll see it prompts for my input... I enter my input, then it repeats my input in a distorted string of text (see Example 1). Then after my verification message is output (Got it! Your answer was: " on ") I am met with a "ReferenceError: on is not defined" (Example 2) even though the LED lit up perfectly.Command: on oonn //Example 1 Got it! Your answer was: " on " Command: ReferenceError: on is not defined //Example 2 >> off ooffff Got it! Your answer was: " off " Command: ReferenceError: off is not defined >> on oonn Got it! Your answer was: " on " Command: ReferenceError: on is not defined >> off ooffff Got it! Your answer was: " off " Command: ReferenceError: off is not defined >> on oonn Got it! Your answer was: " on " Command: ReferenceError: on is not defined >> off ooffff Got it! Your answer was: " off " Command: ReferenceError: off is not defined I am thinking this is not so much a Raspberry Pi/Johnny-five thing and just a plain old JavaScript or Node issue. Any ideas?

Submitted February 01, 2018 at 02:06AM by joWebDev

Simple encrypt and/or sign (JSON) data into temporary tokens for untrusted environments (client-side).

http://ift.tt/2yIinD4

Submitted February 01, 2018 at 12:00AM by phtdacosta

How would I go about automating checking out on external sites via request?

Okay so what I mean is for example, This is a website item LinkYou click add to cart and it adds the item to your cart, then you checkout. How would that be possible via node JS? I’ve found something which will help me out.On this site if you use the url http://ift.tt/2DTzvoN (http://ift.tt/2EtGNR5 for this item) it will instantly take you to the checkout page where you just input your details, payment method then checkout via the checkout button.How would I use request to input text in each of the fields (name last name address etc) for example? I was getting somewhere a while ago but the data doesn’t save(I can fill in the text values) but when I go to the next page it takes me back so asking for advice herehow would I automate checking out on an external site using request?Thank you very much! (Ps I have experience with node so I would just need an idea on how it’d work)

Submitted January 31, 2018 at 10:26PM by AbrarKR

Service part 3: Organization strategies and setting up unit testing with Mocha.

https://youtu.be/zmBGIoO7Alo

Submitted January 31, 2018 at 06:21PM by sheffmaster

Announcing TypeScript 2.7

http://ift.tt/2GyB7pv

Submitted January 31, 2018 at 06:01PM by DanielRosenwasser

Thoughts on my architecture and async pattern?

Any good image compression package for node.js?

I'm using imagemin to compress images. It compressed from 2.7mb to 900kb.Polygon have images of very good quality, having size of only 100kb.Is there any way I can achieve compression of the same quality in node.js using any open-source package?Thanks!

Submitted January 31, 2018 at 04:52PM by epic_within

What actually are steps of a Developing a Software? I am only aware of git, docker, testing?

I am a newbie in Software Development, learnt node.js, express.js & started making small API based Applications, also deployed one on heroku using github. Now, I read and hear alot about Software Architecture i.e. MVC, MVVM, microservice etc, and i use github regularly to keep track of my codes. But, compared to other projects I have seen on github, my commits are not at par wrt when and why I am commiting. I need to know when I should commit, it seems. Also, i hear alot about docker. So, in short, what and how should I approach these steps and things used by experience organisations and coders. Thanks alot!

Submitted January 31, 2018 at 05:01PM by kartikverma

NodeJS + React Filemanager

http://ift.tt/2j9ksht

Submitted January 31, 2018 at 04:01PM by visortelle

What's a good way to organize my codes?

For a typical mid size application, I would have 2000+ lines in my index.js consisting of require(), .get routes, .post routes, static routes, the mandatory server.listen, and tons of db queries. Basically, EVERYTHING goes into index.js. Every time I want modify something, like say app.post('/profile', function() ..., I'd have to hit CTRL-F and find it.I recall seeing someone that I worked with organize them into different other .js and than requiring them in index.js. Are there ways to organize my codes better?

Submitted January 31, 2018 at 11:24AM by eggtart_prince

Diving Deeper in Nodejs: Authorization (not Authentication)

Ok, I'm in the process of refining my knowledge of the node.js world. I have learned about express.js, routing, db connections (i'm using postgreSQL), knex.js, migrations, seeding, objection.js etc. I have learned about authentication and implemented an authentication system using passport.js and bcrypto (using hashing and salting).Now I am at the point where I want to add authorization to my app, and I am hitting a wall since I cannot find a very good package out there that simply lets me add it.In particular, I have found something that allows me to perform role-based authorization, but I want to be able to have something more refined. Role-based authorization is ok when we need to give a set of users the permission to do some common things. For instance, we could have admins that are able to see everyone's information, or users that are able to post comments. BUT often times, this is not enough.What I am looking for is a resource-based authorization system, where a user have permission to work on a specific resource but not on others. For instance, the creator of a post can be the only one to edit it. Other users must not be permitted.What are best practices and best packages to perform this? Is there any good tutorial on this?

Submitted January 31, 2018 at 09:02AM by honestserpent

Am I using Multer correctly?

I'm using Multer to upload images. var newsSchema = new mongoose.Schema({ title : String, body: String, image : String //the name of the image } Multer uploads files in an "Uploads" directory, as expected and I store the name of the image in MongoDB, and I use it on my page.I've seen many tutorials on the internet, and what they've done is use fs to store the image in MongoDB. But wouldn't that double space consumption, since the same image is stored in "uploads" directory, and then in a MongoDB document?How should I be doing it?Thanks!

Submitted January 31, 2018 at 08:05AM by epic_within

Tuesday 30 January 2018

A new package to create mock-server

Hello :) This package is probably the best solution to create a fake server in Node.js, it uses Express.js and Faker.js to get the job done.GitHub (Just go and check the example :) )Personally, I created this project because I needed sth like this while developing a React appHere is an example that creates a dataset which contains 200 item based on the given schema :const Videos = Mock.dataset({ uuid: Mock.primaryKey(Faker.random.uuid), title: Faker.lorem.sentence, category: Mock.oneOf('PHP', 'Node.js', 'React', 'React Native'), tags: Mock.someOf('fun', 'google', 'summer', 'hello', 'sth', 'how-to') }, 200)

Submitted January 30, 2018 at 11:51PM by qti3e

Node Summit CFP is open

http://ift.tt/2rgiFwf

Submitted January 30, 2018 at 10:39PM by ecares

Choose the right DB System

Hey Guys,we are going to develop a Dating App, with peer to peer function, profiles, little news feed and so on. Maybe we need some times a Payment System. I am going to realise this with express and vue.js but i am not sure which DB we should run. I would pref MongoDB because i have some experience with it, but my friend mean Sequelize with a MySQL Database should be better.Can someone help out?Thanks!

Submitted January 30, 2018 at 08:16PM by xowl420

Course: Learn and Understand NodeJS is 95% off

https://twitter.com/whatsonsalenoww/status/958400405603602433

Submitted January 30, 2018 at 06:45PM by kulikapa

Best way to submit jobs to queue in an API?

Suppose you want to submit some data to a queue (RabbitMQ, in this case) when something is posted to a route. What would be the best way of going about this?I'm looking for anything, really, even just suggestions. I don't even feel like I've been searching for the right things. What I've done so far, because it's really all I know how to do, is to connect RabbitMQ (docker container) on each endpoint hit, and submit the job. As long as this is just a hobby project, that's fine, I guess. But suppose I wanted to build something production-quality like this one day.I feel like I should have an established connection that I could pass the job to for submission, but I'm unsure of how to properly do this without spawning a worker process to handle it for me, which I really don't want to do. Largely, I suppose, because most of my jobs have involved relatively small projects that run in single-core environments, so spawning a child process will only eat into the web process' available power. Even if only slightly. But, on the other hand, it's currently the only way I can think of, other than to do what I'm doing, which is connecting to the queue on every request.Would really appreciate some input, or just some hints at what I should ask google about to get more knowledge about how to approach this.

Submitted January 30, 2018 at 05:17PM by Maharyn

Cliffy - Framework for Interactive CLIs, an alternative to Vorpal

http://ift.tt/2nlKOQi

Submitted January 30, 2018 at 04:31PM by UberAtlas

Service: setting up Flowtype, Prettier and Nodemon on a node server. This is my second video in the series. I hope you enjoy.

https://youtu.be/l4ghJ4uqpTE

Submitted January 30, 2018 at 03:19PM by sheffmaster

CPU Profiling in Production Node.js Applications

http://ift.tt/2rRYkji

Submitted January 30, 2018 at 02:20PM by l0g1cs

Simple analytics library for Node/Express ?

I am looking for a simple analytics library for my Express application. I want to track user behaviour and store that analytics data in my MySql database. GA is free but querying data is anything but easy and I don't need something so full featured.Something that is lightweight, runs in MySql backend and easy to query and build a dashboard with.Suggestions ?

Submitted January 30, 2018 at 01:39PM by RedditorFor8Years

Controller "ignoring" method

Hello, there! I've been coding a method to create new users in my API, but I have to verify if that user exists, before creating it. I've coded a method to verify it, but it's not returning true or false as I expected...Usercontroller.jsconst Promise = require('bluebird') const UserModel = require('../models/UserModel')() class UserController { constructor() { this.User = Promise.promisifyAll(UserModel) } authenticate(req, res, next) { let json = req.body this.User.findAsync({ email: json.email, password: json.password }).then(data => { if (data.length === 0) { res.status(404) res.json({ status: 'failed', message: 'Ops, it seems this user is not registered!' }) } res.json({ status: 'success', data: data[0].email }) }).catch(next) } create(req, res, next) { let json = req.body if (this.alreadyExists(json.email, next) === true) { res.status(400) res.json({ status: 'failed', message: 'Ops, this user already exists!' }) } this.User.createAsync(json) .then((err, data) => { res.json({ status: 'success', message: 'Yeah, user registered successfully' }) }) .catch(next) } alreadyExists(email, next) { return this.User.findAsync({ email: email}) .then(data => { if (data.length >= 0) { return true } return false }) .catch(next) } } module.exports = new UserController()

Submitted January 30, 2018 at 12:35PM by giocruz

Protecting public JSON/REST endpoint. Can’t use CSRF. Recaptcha alone enough?

Is my endpoint protected from csrf attacks because of json/application content type?I have an SPA with a contact form that I’m looking to make as safe and spam free as possible. CSRF isn’t possible because the page which features the contact form is cached (and the CSRF cookies are unable to be properly generated per request). Because of this I must use REST.Right now, the REST contact endpoint has no CORS since I am always calling from same origin in my app. I am using recaptcha to serve as “single use” token auth.What more can be done to secure this endpoint to the fullest extent?

Submitted January 30, 2018 at 12:58PM by MyyHealthyRewards

How to accept file uploads when having multiple backend node servers?

If you have many backend node servers that accept file uploads, you don't want those servers to store the files on their local filesystems, because then the uploads will be divided across several servers.How can you take the uploads from each backend server and upload them to a central server that would serve those files using nginx? I don't want to use something like S3, I want to host these files myself.Do you know how to do this? I thought there would be more information on this since it seems like it would be quite a common problem... everyone who has more than 1 node server and accepts file uploads would need to solve this but I don't see much info about it.Is there a way to just issue a POST or PUT to an nginx server with the file? I don't want to upload it directly from the browser, the file first needs to get to the node servers for processing, and the node servers will then upload it to the file server.

Submitted January 30, 2018 at 01:09PM by nowboarding

Monday 29 January 2018

First ever complete course on AdonisJs

http://ift.tt/2rStqr4

Submitted January 30, 2018 at 01:48AM by andycharles

Is there a lighter weight alternative to Electron?

I like that Electron has (mostly) cross-compatible code and lets you use web technologies to make a consistent UI. I don't mind that the UI doesn't follow a particular OS's conventions. I don't like the 100MB+ install size with corresponding high uses of RAM and CPU. This goes for NW.js as well, although it's a bit smaller.I've seen Electrino and NodeKit, but neither support Windows.Is there anything else out there?

Submitted January 29, 2018 at 11:08PM by Skhmt

Best practice node.js

Hey, I've been learning node.js by looking at tutorial right and left. I was wondering if you guys could recommend me any best practice documentation?

Submitted January 29, 2018 at 10:14PM by Laudenlaruto

I want to learn Marko with Node.js & Express.js; need guidance

Hello,For a long time i was wanting to learn Node.js but could not start because of being stuck to PHP (ahem Wordpress). Today i decided to start learning Node.js + Express.js + Marko but there are very few resources about Marko. Anyone used it here? Can someone guide me?EDIT: Just learned about Koa; i think i might prefer it instead of ExpressThanks

Submitted January 29, 2018 at 09:17PM by BerkayOzturk

Would like to learn node developing. Share some good resources?

I would like to learn professional node development. Please share some books, tutorials or courses.

Submitted January 29, 2018 at 07:47PM by alerrce

User guide to FutoIn AsyncSteps concept

http://ift.tt/2DOPGHR

Submitted January 29, 2018 at 07:10PM by andvgal

How to make an Application that can act as Blocker/Filter between Source of Incoming Traffic and Open Port?

I am trying to make an Application, mostly in NodeJS, that can act as a door or filter or blocker between Traffic Incoming and Open Port. For example, If a GET Request is arriving for Port 80(Apache) on a Machine, a application should first receive that, process that and then forward it. Something like Filter + Port Forwarder. Should I try this with Other Languages(C/C++ might apt)

Submitted January 29, 2018 at 05:27PM by kartikverma

Asynchronous patterns in Javascript

http://ift.tt/2Ekg5KJ

Submitted January 29, 2018 at 04:06PM by pierreguilhou

Hapi.js: I am starting a web series on building an authentication API using Node and Hapi. Let me know what you all think.

https://youtu.be/ljtIfhF5bgQ

Submitted January 29, 2018 at 04:06PM by sheffmaster

Get a user press without input

How can I do for my node app get inputs even when it is not open?

Submitted January 29, 2018 at 03:01PM by imAndreSousa

Automated browser testing in 2018

http://ift.tt/2nl0jrT

Submitted January 29, 2018 at 01:45PM by krylovanatu

OverwriteModelError: Cannot overwrite `User` model once compiled

Hello there! I'm a newbie as a Nodejs Dev and I've been trying to use a model in two different routes. I don't know exactly what happens, but I've been receiving this error.http://ift.tt/2rP4BME I think it's something with the Schema that I've already declared once and I've been trying to declare again...

Submitted January 29, 2018 at 02:02PM by giocruz

Why is my afterRemote not working? (login/user management)

Hello,I am playing with the Loopback User Management example, and I noticed that the example has one issue.There is a /login route which takes care of the login mechanism:app.post('/login', function(req, res) { User.login({ email: req.body.email, password: req.body.password }, 'user', function(err, token) { if (err) { if(err.details && err.code === 'LOGIN_FAILED_EMAIL_NOT_VERIFIED'){ res.render('reponseToTriggerEmail', { title: 'Login failed', content: err, redirectToEmail: '/api/users/'+ err.details.userId + '/verify', redirectTo: '/', redirectToLinkText: 'Click here', userId: err.details.userId }); } else { res.render('response', { title: 'Login failed. Wrong username or password', content: err, redirectTo: '/', redirectToLinkText: 'Please login again', }); } return; } res.render('home', { email: req.body.email, accessToken: token.id, redirectUrl: '/api/users/change-password?access_token=' + token.id }); }); }); The issue here is once login occurs, you are still at the /login route, so if you refresh, you effectively login again and generate a new token.In order to get around this, I thought of adding an afterRemote but for some reason, that never gets triggered:user.afterRemote('login', function(context, user, next) { context.res.render('response', { redirectTo: '/settings', redirectToLinkText: 'Settings' }); }); Any ideas? Should I be going about this differently? Ultimately, I don't wan't a refresh of the page to generate new tokens.

Submitted January 29, 2018 at 02:36PM by explicitspirit

Node Legion is an ultra-simple solution for syncing a local Node.js project with multiple remote instance deployments.

http://ift.tt/2DK2M9b

Submitted January 29, 2018 at 08:44AM by bashardouba

The Open Sourcerer's Magic Spell Book

http://ift.tt/2rHTyok

Submitted January 29, 2018 at 09:06AM by ratancs

Why You Should Choose Luxon for Date Wrangling in Javascript

http://ift.tt/2n1mXVM

Submitted January 29, 2018 at 07:49AM by philnash

Sunday 28 January 2018

A fully functioning Node.js shopping cart with Stripe and PayPal payments

http://ift.tt/2BAmBKa

Submitted January 29, 2018 at 06:29AM by pmz

[Guidance] Looking for Information

Good evening everyone, or whatever time it is where/when you are. The internet is always. I have a question about any posts or articles that you may have seen on rendering multiple mongo collections into a single web page. If you have any information at all I'd appreciate it. My google searches are coming up fruitless, but I'll keep hunting. Thank you for any links in advance.

Submitted January 29, 2018 at 04:16AM by arrayStartAt1

Difference between an async function and a function that returns a Promise?

I'm confused. Does a function declared as async return an AsyncFunction or Promise? What's the difference? I thought async is just Promise underneath.

Submitted January 29, 2018 at 04:04AM by simoncpu

Mocking Database for Tests?

I'm using Express with Sequelize and even looking at other ORM solutions it doesn't really seem there is much for running tests and seeding data/clearing data for each test.I'm used to Rails where this stuff gets taken care of automatically. Currently I just load the fixtures via sequelize-fixtures and then truncate the tables every test run. Is this bad practice? Seems like there aren't too many solutions out there in this ecosystem.

Submitted January 29, 2018 at 12:45AM by howthewtf

Documentation review ?

Hello,Docs link : http://ift.tt/2njKCRL completely rewrite my documentation and I need some reviews about it. Feel free to say anything you think about it :)

Submitted January 29, 2018 at 02:07AM by GamesPassionFR

How to pass authentication token with every request?

I am using Loopback's user-management example to authenticate.Once a user logs in, a token is generated. How do I ensure that every request made by that user contains the token? I want to make sure that the user is authenticated every step of the way.Is there a built in way of achieving this?

Submitted January 29, 2018 at 12:21AM by explicitspirit

Express.Router differences between href and http get?

http://ift.tt/2FnPpbc think I have a routing problem that ties back to the differences between href and an http get. I'm not sure how to define the issue further. Does anyone have a moment to point me in the right direction?

Submitted January 29, 2018 at 12:05AM by ExpatTeacher

A simple React component that outputs text in a way that simulates human typing.

http://ift.tt/2DFK2nl

Submitted January 28, 2018 at 11:26PM by jonnyasmar

Best way to organize/template ejs

HelloI have a typical page layout with a sidebar with links on the left, and a big content area on the right (no header/footer). The page is called home.ejs.What is the best way to set up the routes and templates? Ideally, when I click on a link on the sidebar, the content area should change to reflect the desired content while the sidebar remains the same, since it is essentially a navigation tool that will not change.What I tried is to have every link in the sidebar point to a route. For example, on of the links is Preferences which has a route of /preferences attached. I also created a partial called preferences.ejs which has all the content that I need. My thought was to have a route that looks like this:app.get('/preferences', function(req, res) { res.render('home', { pageContent: '<% include ./partials/preferences %>' }); }); And my main ejs file (home.ejs) that has the sidebar would also have something like this somewhere in it:
<%= pageContent %>
Note: I am a noob at this and this is just me trying to stitch some concepts together that may or may not be related. Needless to say, this doesn't work as I thought it would. What are the best ways to achieve this? Essentially, I want the sidebar to be consistent for every page, while the content is dynamic based on the click actions. Am I going about this all wrong? Would I be better off just putting the sidebar code in another partial and having one page per sidebar link?

Submitted January 28, 2018 at 08:55PM by explicitspirit

Setting up a Node.js development environment | A pain-free guide

http://ift.tt/2DJKYev

Submitted January 28, 2018 at 07:49PM by allvoid

Need help with running console apps and get info back

Hey im working on a visual game server manager for desktop in electron since its the easiest and fastest way for me to make a good looking desktop app. It essentially will have tabs for each server and on each tab i want to be able to start/stop a .exe file which is pretty much just a console for a server. If its possible id like to get info back from the console (whenever new text is added). if thats not possible it updates a log file with its output so i could possibly check for updates in that. Then id also like to run commands in the console for electron too. If there are any libraries for this id greatly appreciate a link to them, if not then anything i can start from is helpful. Thanks

Submitted January 28, 2018 at 06:08PM by Alekaei

Show server download progress.

I am quite new to nodejs. I have it installed on my Pi. Basically i send a youtube link to the server and it downloads the video on my hard drive (using youtube-dl). So how do i show this download progress on the website?

Submitted January 28, 2018 at 05:03PM by coold007

xa - Beautiful & Customizable log messages in your terminal ❤

http://ift.tt/2mMZK9U

Submitted January 28, 2018 at 04:58PM by xxczaki

If you had a week to prepare for a backend software engineering startup job how would you prepare?

Asking for a friend :D

Submitted January 28, 2018 at 04:21PM by jacove

NodeConfig: IntelliJ-plugin

http://ift.tt/2DFDipw

Submitted January 28, 2018 at 12:23PM by festhk

how to start api function and display api results in html

so I am using ACR Cloud API to identify a song and give me info about it. I have gotten it to run from terminal using node and I get the following information: {"status":{"msg":"Success","code":0,"version":"1.0"},"metadata":{"music":[{"external_ids": {"isrc":"USUM71710209","upc":"00602567107392"},"play_offset_ms":26320, "release_date":"2017-11-03","external_metadata":{"spotify":{"album": {"name":"Scarecrow In The Garden","id":"7qVmjzJwcjzBQ8ZxDjd2lS"},"artists":[{"name":"Chris Stapleton","id":"0rgNhjV1tJOP1ivceIH55a"}}},"artists": [{"name":"Chris Stapleton"}],"title":"Scarecrow In The Garden","label":"Mercury Nashville","duration_ms":200000,"album": {"name":"Scarecrow In The Garden"},"acrid":"23d39647c57b1a12fa62c7269b32845a", "result_from":1,"score":100}], "timestamp_utc":"2018-01-28 04:15:53"},"cost_time":4.3029999732971,"result_type":0}I'd like to do the following things:Get this to run by visiting an html pagetranslate this data to be in html tags.

Submitted January 28, 2018 at 07:14AM by scotdle

Saturday 27 January 2018

I’m learning Node.js and would love some pointers/tips on my current project 🤗

So I am learning Node.js. As my first project I want to get a couple of third party JSON API’s with slightly different data, process the data and send it to FireBase or MongoDB to be used by my website and app.Does this sound like a good starter project?Any tutorials or blogs similar to this, that I could follow?Would you recommend FireBase or MongoDB?Thanks 🙏

Submitted January 28, 2018 at 01:12AM by ajukco

Performance penalty of accessing env variables?

The express.js documentation mentions that accessing the value of environment variables comes with a performance penalty.I can't find much discussion about this online. Does anyone have opinions or recommendations on this?http://ift.tt/2GodsIj the NODE_ENV section)

Submitted January 28, 2018 at 03:27AM by kxerr

AES Encryption Helper Module

http://ift.tt/2Eef8n4 have written a small wrapper around the built-in 'crypto' package that provides a secure set of configurations and simple API. My motivation for writing this is I review quite a lot of code that implement encryption in an insecure way, so I wanted to just have something that is secure by default. This used AES 256 with GCM for the block mode.Please let me know what you think. I am not a developer by trade and fairly new to Node, so if you see I am doing something stupid, I would be happy to hear!

Submitted January 27, 2018 at 09:54PM by pentesticals

How can I make fs async/await with classes?

Hey /r/nodeI've posted this over in Stack Overflow http://ift.tt/2Bx1R6j I thought I might have an easier time here at Reddit. I'm trying to make an asynchrous parser, and I can't understand how I'm supposed to structure my class to await the data. Any help would be greatly appreciated. Some code:const fs = require('fs') class CSV { constructor (fileName, buffer) { this.fileName = fileName; this.buffer = buffer; } async parseCSV () { let csv = this.fileName let buff = this.buffer let stream = fs.readFile(csv, buff, (err, data) => { if (err) console.log(err) data = data.split('\r').toString().split('\n') return data }) console.log('---') console.log(await stream) return stream } } let test = new CSV('./topsongs.csv', 'utf8') let data = test.parseCSV().then(res => { console.log(res) }) // console.log(data) module.exports = CSV

Submitted January 27, 2018 at 09:11PM by hiphophipp0

Announcing The Node.js Application Showcase – Node.js Foundation

http://ift.tt/2DMG2m1

Submitted January 27, 2018 at 09:00PM by hackrboy

HTTP vs Websockets: A performance comparison

http://ift.tt/2FmFIKc

Submitted January 27, 2018 at 06:30PM by dluecke

How to store a whole C program in JSON?

Tests don't exit after upgrading to mocha 5.0.0

I have the following test (testing an event emitter) that worked fine on version 3.5.0.it.only('should run tasks when an event is emitted', () => { const watcher = gue._watch(__dirname, 'foo'); // don't restart the watch loop watcher.close = () => {}; const startStub = sandbox .stub(gue.gueTasks, 'runTaskParallel') .resolves(); watcher.emit('all'); expect(startStub).to.be.calledWith('foo'); }); Basically making sure that runTaskParallel gets called correctly when the watcher emits. Any idea why the test is no longer exiting?

Submitted January 27, 2018 at 04:54PM by skarfacegc

Measuring response times of Express route handlers

http://ift.tt/2BwCO35

Submitted January 27, 2018 at 11:03AM by sheshbabu

Friday 26 January 2018

PeerConnect a P2P implementation

http://ift.tt/2EaYnJy

Submitted January 27, 2018 at 12:16AM by justdoggneo51

Best Node, Express, and Mongo Courses

Does anyone have any suggestions for Udemy courses, or other forms of tutorials regarding these topics?

Submitted January 26, 2018 at 09:39PM by hutxhy

Looking for Firebase replacement. Adonis or Feathers?

In the process choosing a replacement for Firebase for an app that I built (React and Redux app). Framework must have authentication, realtime and be able to use a SQL DB. I have no experience with Adonis or Feathers. They both seem very good. Any one have any experience with either?

Submitted January 26, 2018 at 06:55PM by general_salt

Clinic diagnoses your Node.js performance issues

http://ift.tt/2Ffy2tf

Submitted January 26, 2018 at 05:11PM by ratancs

Weekly Node.js Update - #4 - 01.26, 2018

http://ift.tt/2GkGKaI

Submitted January 26, 2018 at 02:54PM by andreapapp

Completely stuck

I've been trying to insert some database records but keep getting,Parser.js:80 throw err; // Rethrow non-MySQL errors ^ Error: ER_PARSE_ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''2018-01-26T12:37:21.000Z', 'paymium', 8686.915, 8502.59, 8871.24' at line 1 What is wrong with the following insert?var values = [tick['datetime'], ex, fv, tick['b'], tick['a']]; var sql = "INSERT INTO table (data,ex,fv,b,a) VALUES ?"; con.query(sql, [values], function (err, result, fields) { if (err) throw err; console.log (tick['datetime'],'\t', ex,'\t', fv,'\t', tick['b'],'\t' ,tick['a']); });

Submitted January 26, 2018 at 12:44PM by normanu82

Front-end Presets for Older Laravel Frameworks

http://ift.tt/2EdAHEw

Submitted January 26, 2018 at 12:44PM by nacnicnoc

Node NPM Install error

Hi guys, I too am having this issue.I'm running Windows 7 professional with node 9.4.0 and npm 5.2.6.Any help would be greatly appreciated as I have tried restarting the computer,disabling the anti virus and the windows defender and other solutions so far that I have seen and no result.1152 warn react-template@1.0.0 No description 1153 warn react-template@1.0.0 No repository field. 1154 warn optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.1.2 (node_modules\fsevents): 1155 warn notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"}) 1156 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Valid OS: darwin 1156 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Valid Arch: any 1156 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Actual OS: win32 1156 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Actual Arch: x64 1157 verbose stack Error: EBUSY: resource busy or locked, rename 'H:\react-template\node_modules\detect-port-alt\bin\detect-port.1975550845' -> 'H:\react-template\node_modules\detect-port-alt\bin\detect-port' 1158 verbose cwd H:\react-template 1159 verbose Windows_NT 6.1.7601 1160 verbose argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "install" 1161 verbose node v9.4.0 1162 verbose npm v5.6.0 1163 error path H:\react-template\node_modules\detect-port-alt\bin\detect-port.1975550845 1164 error code EBUSY 1165 error errno -4082 1166 error syscall rename 1167 error EBUSY: resource busy or locked, rename 'H:\react-template\node_modules\detect-port-alt\bin\detect-port.1975550845' -> 'H:\react-template\node_modules\detect-port-alt\bin\detect-port' 1168 verbose exit [ -4082, true ]

Submitted January 26, 2018 at 10:26AM by oceanmachine14

Thursday 25 January 2018

Code review and improvements - help.

Hi, we have been working on a node js application using electron and need someone to review the code, make improvements, and add new features. Its currently a small project but has some potential to become a bigger project. Is there anyone here that would be willing to help? The project is related to a Ethereum hardware wallet. Please inbox me. Thank you.

Submitted January 25, 2018 at 10:04PM by jayduino

Where to track the progress of import/export getting into node?

What's the latest news on import/export making it into node? Is there a place I can track the progress of it?There were some articles about a year ago about the challenges of getting it into node, are there more recent versions of such articles?

Submitted January 25, 2018 at 08:49PM by nowboarding

Debugging Node without restarting processes

http://ift.tt/2DhfgB7

Submitted January 25, 2018 at 08:11PM by vcarl

A little help with looping over MySQL rows in node

I’m new to the node world and trying to write an api with node, express & MySQL. The problem I am having is when looping through a group of results and then running another select based on the id of the current row in the loop and adding the 2nd selects records to the current object in the loop. I think the issue may be that I am using standard js looping instead of async or a promise based approach and I end up sending the result back before all the queries have run. Can anyone advise on the best approach as there seem to be so many methods available, which is best and future proof??

Submitted January 25, 2018 at 07:22PM by Finrojo

What do you like node for noobies?!?

I am looking to use one of these three to learn API / server knowledge. The three are Nest, Kue, and Sequelize. I also looked into feathers and hapi.js (i dont know any of these).I dont know typescript that much eather so i am leaning more twords nest so i can learn that along with server api orm stuff.Give me any feedback on what you think and what you like to use yourself personally! Thanks!

Submitted January 25, 2018 at 05:59PM by djsneaks123

Is NodeJS suitable for a home server control panel?

At my home we have a Ubuntu Linux home server deployed to manage files and backups. As a fun side project I would like to make a web-based control panel I can access from any device on the same network to check if all the (file) servers are still running and even add buttons to run backup scripts and reboot the server.I would like to know if Node can see the status of services (from systemd), see temperatures of a PC and reboot the computer.Thanks!

Submitted January 25, 2018 at 03:21PM by SeniorSpace

Node.JS Development 2 ppl on 1 project

Hey guys,what is the best way to develop a node.js+express application when 2 people work on this project from 2 other places?I was thinking about the free trial AWS service, but is there any other solution, or should we create a basic project and push this always to github?Hope someone can help me out!Thanks!

Submitted January 25, 2018 at 02:25PM by xowl420

How do I deploy/finalize my NodeJS app (on Linux)?

Hey Guys, I have been working on a lot of small NodeJS command line applications. At this point I just navigate to the project folder where the source code is, and run node app.js to run the program but I would like to make real programs out of them so I can run them from any folder (like top, ls and grep). I read about a few ways to do this, like making a shell alias but I would like to know a 'formal' way to do this. It would also be awesome if there was an easy way to update the deployed app too :).

Submitted January 25, 2018 at 03:11PM by SeniorSpace

Testing your npm package before releasing it using Verdaccio + ngrok

http://ift.tt/2FdiSEE

Submitted January 25, 2018 at 10:40AM by Aurelsicoko

StdLib Platform Updates: Functions Run on Node 8.9.4, Automatic Error Logging

http://ift.tt/2Bqo4TA

Submitted January 25, 2018 at 08:11AM by J-Kob

Windows installation size decreased by half?

I just updated from Node 9.2.1 to Node 9.4.0. I noticed before I updated that the installed size shown in Control Panel was 104MB. After updating it now is only 52.5MB - that's nearly half as small!How was the Node team able to accomplish this and what did they change to achieve this?Note: Both installations were 64-bit.

Submitted January 25, 2018 at 08:26AM by BTOdell

An up-to-date and curated reading list for designing high scalability , high availability , high stability back-end systems

http://ift.tt/2DDYBLC

Submitted January 25, 2018 at 07:54AM by ratancs

Wednesday 24 January 2018

Confused about what node can do

I understand that node replaces server side languages like PHP, but I don't understand if it can also function as a replacement for a web server like ApacheRight now I'm in a course that's building off of a project done by a group in a previous semester, we just got their source code and that's it. The middleware that connects the front end web site to a backend database is mostly written in node it appears.I've had to set up our rack mounted server (where I put the database), and also installed apache to our server. I put all of the front end html files developed the previous semester in the var/www/html directory and apache served those files to the browser correctly!But the more I read about node, the more I realize that it can also function as a web server. Looking thru more of the source code, I see things like require('express') which seems to me like I don't need apache at all because node can do all of the web server work. Am I on the right track? Can node replace apache in this project?Thanks for reading btw, I'm pretty noobish in all things servers and in node!

Submitted January 25, 2018 at 12:37AM by i_love_chess

Sockets

Someone can explain to me why sockets are bo innovating? We cannot just use events and http protocol?

Submitted January 24, 2018 at 10:08PM by imAndreSousa

API without API

How can some guys made her own API when a certain game have no a official API or website to extract data? How can i do it too?

Submitted January 24, 2018 at 11:28PM by imAndreSousa

I used to hate JavaScript. Now I like it. – Hacker Noon

http://ift.tt/2n3F50u

Submitted January 24, 2018 at 08:51PM by joeyclover

Node.JS is really useful?

My main language is PHP but someday some people said that NODEJS will be the next PHP...Why is Node so good, when we dont talk about the scalable power? All what I do with NODEJS using node I use easier with PHP. Explain pls

Submitted January 24, 2018 at 06:16PM by imAndreSousa

Random Practice Questions

Let's say I have some async method which checks some datastore. If a result is there, it returns result.dataToReturn, otherwise it will return undefined1.) is using cb(null, (result || {}).dataToReturn) bad form?2.) what about using cb(new Error(404) and checking for the error downstream?Which practice do you prefer? Any thoughts or comments welcome!

Submitted January 24, 2018 at 05:37PM by ShatteredVisage

vuln(fastify): CVE-2018-3711 Fastify denial-of-service vulnerability

http://ift.tt/2F9gz5s

Submitted January 24, 2018 at 04:23PM by ecares

A set of best practices for JavaScript projects

http://ift.tt/2sj545H

Submitted January 24, 2018 at 02:07PM by ratancs

Alveare (hive in italian) lets you listen for incoming reverse connection, list them, handle and bind to the sockets.

http://ift.tt/2Boo2M1

Submitted January 24, 2018 at 11:47AM by roccomusolino

Thirsty: Drink water every 2 hours

http://ift.tt/2E7JoQN

Submitted January 24, 2018 at 10:41AM by deadcoder0904

Tuesday 23 January 2018

Learn how to build simple Node & Express servers to work with React

http://ift.tt/2DBeKCg

Submitted January 23, 2018 at 10:55PM by nirvanaperk

This is probably the best beginner to intermediate course in this platform right now for node and express. It is also a great resource for learning all new ES6 aspects. The teacher is very thorough and makes updates when needed. I would recommend both the teacher and the course.

http://ift.tt/2F72fdW

Submitted January 23, 2018 at 10:48PM by kevinmbehrends

npm WARN makes me wanna go back to PHP

Seriously... I've never seen so many warnings every time I run a command or follow instructions... I thought PHP threw too many warnings.

Submitted January 23, 2018 at 10:19PM by davecreeker

npm install ridiculous CPU/RAM

My computer has slowed to a crawl after running npm install in a WordPress theme Sage folder... not sure if this has to do with Node or Sage, but the CPU is over 70% (by default it shouldn't be allowed to go over 50%) and it's using over 1GB of RAM, and grinding the hard drive. No other program has done this on my PC yet. I have 1GB of RAM left out of an 8GB PC and am having trouble even closing other programs to try to free up RAM.Is there some better way to do this? While waiting for Node I shouldn't have to sludge through everything else or leave my computer for some unknown amount of time; it's already been 15 minutes.My computer: Windows 10 Pro 64-bit, Intel i7, 8GB RAM, 250GB hard drive with 75% free space.

Submitted January 23, 2018 at 10:03PM by davecreeker

Help - Having trouble relating an oauth access token to local user account when using Angular

Specifically for instagram... I can't find a way to connect the local username (which is unique in the database and is not related to the instagram username) to the instagram access token provided in the instagram redirect_uri. I want either to save the access token in the user model, or just pass it to the angular component so I can fetch that users images. I've been considering using angular universal which can render the pages from the server and I can pass the token in that way, but I was hoping there is something easier. I've tried cookies, sessions but they won't work as the redirect_uri request is made by instagram to your server not by the user. Maybe I'm missing something. Alternatively I also thought about making a non angular page just to get the instagram token and save it in the model which can then be used by the angular component.Thanks, any help appreciated!I'm using npm instagram-node (http://ift.tt/1FrVvW5) to assist with the api calls.This is my instagram component typescript function that runs when the "Connect instagram" button is clickedthis.http.get('http://ift.tt/2rvTaJH => { window.location.href = data.url }) This is in app.js//instagram exports.authorize_user = function(req, res) { res.redirect(api.get_authorization_url(redirect_uri, { scope: ['likes'], state: 'a state' })); }; exports.handleauth = function(req, res) { console.log('req user in handlauth'); console.log(req.user) api.authorize_user(req.query.code, redirect_uri, function(err, result) { if (err) { console.log(err.body); res.send("Didn't work"); } else { console.log('Yay! Access token is ' + result.access_token); res.send('You made it!!'); } }); }; //authorize isnta link app.get('/auth/social/ig', exports.authorize_user); // This is your redirect URI app.get('/oauth/done', exports.handleauth);

Submitted January 23, 2018 at 08:47PM by are_videos

ninjadb - a *super simple* json database

http://ift.tt/2ruhyLH

Submitted January 23, 2018 at 07:21PM by Glutchpls

Understanding Synchronous and Asynchronous Callback Functions in Node.js | Part 1

http://ift.tt/2F6Hu1M

Submitted January 23, 2018 at 07:26PM by nodexplained

Looking for a developer to help install IRC

Looking for a node.js developer to help me install kiwi IRC.

Submitted January 23, 2018 at 06:30PM by Subtlefm

Should I move everything to MongoDB?

I’ve always used relational databases, but recently gave MongoDB a shot and it’s amazing. Especially for things such as storing users, where the number of columns can become too many to manage in MySQL.Should I make the move? If not, what should i definitely keep in MySQL?

Submitted January 23, 2018 at 05:05PM by allvoid

Realtime features in Nest.js under 5min with Pusher

http://ift.tt/2n7IQST

Submitted January 23, 2018 at 03:45PM by zemcunha

Vulnerability disclosure for Node.js third-party modules on HackerOne

http://ift.tt/2G8upqn

Submitted January 23, 2018 at 02:16PM by _bit

how to add array of objects in keystone list ?

User.add({ tokens:[{ access:{ type:String, required:true }, token:{ type:String, required:true } }] }); i tried this way but it give me errors .

Submitted January 23, 2018 at 11:53AM by a7me6_azza8

Just wrong Node.js syntax, I'm sure. [Twitter]

https://twitter.com/tarunbatra/status/955761918110658560

Submitted January 23, 2018 at 11:23AM by tarunbatra

[redis-commander] Reflected SWF XSS

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

Submitted January 23, 2018 at 10:30AM by ecares

[lactate] Static Web Server Directory Traversal

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

Submitted January 23, 2018 at 10:30AM by ecares

[augustine] Static Web Server Directory Traversal

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

Submitted January 23, 2018 at 10:30AM by ecares

Monday 22 January 2018

Awesome flow editor - Visual programming node.js

Hello everyone,this I must share with all, it's crazy. This is really awesome, you make application realtime. See this video and read post to more informations. http://ift.tt/2ruHpmC api with model (schema), middlewares all available inside flow designer.It's future or no have chance use something like flow designer in real "life".Thanks

Submitted January 23, 2018 at 12:18AM by tomee03

Three Exciting Node.js Community Topics in 2018

http://ift.tt/2DuHCrH

Submitted January 22, 2018 at 10:39PM by jcasman

Firebird NodeJS C++ client node-firebird-libfbclient v.0.1.2 updated with a few fixes

http://ift.tt/2DBH8Da

Submitted January 22, 2018 at 05:38PM by mariuz

Make your web app use HTTPS in 30 minutes with Let’s Encrypt and NGINX

http://ift.tt/2F2JLLu

Submitted January 22, 2018 at 05:38PM by calum1232

Help with node and Heroku.

Hi. I am making a bot for my discord server and for now i just merged two bots and it worked perfectly on my pc. But when i try to upload it to Heroku i get the following error: http://ift.tt/2DBH5Y0 I am wondering if anyone has ever gotten anything like this and maybe knows how to fix it/has some discord.js experience. I am quite new to stuff like this so don't judge me if i missed something big.

Submitted January 22, 2018 at 05:47PM by CreeeX

Debugging Memory Leaks in Node.js Applications

http://ift.tt/2F1F9VT

Submitted January 22, 2018 at 03:56PM by vladmiller

Must read books by every Microservice Professional

http://ift.tt/2Dugu05

Submitted January 22, 2018 at 03:21PM by pramodjazz

Stubbing Node Authentication Middleware with Sinon

http://ift.tt/2F2M4hw

Submitted January 22, 2018 at 02:59PM by michaelherman

Debugging Electron Memory Usage

http://ift.tt/2Dt2402

Submitted January 22, 2018 at 11:44AM by Saltones

Nested Node Modules

My question is, what is the correct way to have node modules inside other node modules, but not as dependencies downloaded from the main NPM repository.I work in a team of web developers and build many of our sites on top of WordPress.Each project is a private NPM Module and we use NPM scripts and webpack and so on to concatenate / minify js and css.We have also developed some plugins that we import as git submodules. We can not have these as npm dependencies because they need to go in a specific folder for WordPress rather than node_modules. What I would like is, from the main project, to be able to run npm install and it installs the dependencies for the main project and the dependencies for the plugin submodules.Is this possible?

Submitted January 22, 2018 at 11:19AM by Jab2870

How We Simplified our Tooling Setup for Node.js Projects

http://ift.tt/2DnqZ18

Submitted January 22, 2018 at 09:28AM by cangoektas

Creating Microservice for existing SPA

Hello! I'm currently working on an SPA which loads specific set of data (5 sets) through ajax calls.Sadly, my boss isn't satisfied with linear loading of request and wanted me to create a microservice to load all request at the same time.Is there any way to achieve this using Node? Your help would be much appreciated!

Submitted January 22, 2018 at 09:46AM by jheyjheyjhey

Build User Registration with Node, React, and Okta ― Scotch

http://ift.tt/2DCakdt

Submitted January 22, 2018 at 07:54AM by pmz

Sunday 21 January 2018

how to approach authentication SPA & mobile app?

Alright so here is the scenario I am building a web api with node and express framework as a back-end. I wpuld like to build both a web app (SPA) and (hopefully) follow it up with a native mobile app.The app will allow users to authenticate using facebook/google as well as email/password.And thats where i hit the wall. Reading up it seems oauth is what is widely used but apparently there is different grants recommended for SPA and native mobile applications.JWT seems to be used but comes with a lot of negativity. And it can be used with oauth.And apparently sessions being stateful and all do not scale well.And cookies not being very well handled in native mobile applications.......The only mitigated solution i can think of is to build separate api end points for the mobile and web apps (for the oauth point)How do popular apps such as fb, reddit, twitter do this?What is the standard way building a web api to be consumed by different types of clients?Can someone just please point me in the right direction?

Submitted January 21, 2018 at 10:48PM by featurecritic

Saco 1.1.0: a Production NodeJS server for single page web apps

I created this project after seeing many companies where i worked hosting the front end servers in production with 10 lines of code or many other low quality solutions that are not intended to be used in production!I am still updating and maintaining this project because i keep seeing people making this huge mistake over and over.If you do not understand what i mean read the readme file in my github repo.Link to npm package page: http://ift.tt/2BhHMAP!

Submitted January 21, 2018 at 06:25PM by yarauuta

What is exports?

If I'm using a library in the js file and I have this: const functions = require('function'); //get the required modules exports.func =functions.database.function(ev){...} what is the exports? Im not able to understand it, I know require it lets us use stuff related to the require module in the js file. But what is exports here? The func is a functions defined by me. Thank you for the help!

Submitted January 21, 2018 at 03:32PM by androidjunior

For developers and CS:GO fans

Hi nerds and cs:go fans!Since september 2017 i started to learning javascript / nodejs. So, in some point i learned about creating CLI commands with JS and started to training.I created the cs-go CLI. A command line that retrieve some CS:GO informations:Teams ordered by HLTV.rank (players info, map win statistics, recent results) Live / next matches Last matches results Live streams Github: http://ift.tt/2mYYRv8 free to contribute adding new commands or refactoring some code :D Cheers!

Submitted January 21, 2018 at 01:40PM by crew_Love

Free Video Tutorial: Creating A GraphQL Server With Node.js And Express

http://ift.tt/2rmC7K8

Submitted January 21, 2018 at 10:47AM by codingthesmartway

Saturday 20 January 2018

Question about node from a beginner

What can I do with node if I install it from the website and not use other technologies?What are node's strengths, weaknesses and limitations?

Submitted January 20, 2018 at 08:44PM by pf2-

Building a Serverless REST API with Node.js and MongoDB

http://ift.tt/2EDKnYA

Submitted January 20, 2018 at 03:38PM by adnanrahic

Importance of Middleware order in Express.js application

http://ift.tt/2DiHITL

Submitted January 20, 2018 at 01:07PM by nodexplained

Possible to run browserify from a .js file instead of via npm script / cmd line?

Pretty much the title.In package.json/scripts I have..."browserifyHome": "browserify src/static/javascripts/home.js > dist/static/javascripts/bundleHome.js"If I wanted to pull that line out into a separate js file is it possible and if so what would the syntax be? I've only found examples of using browserify from a terminal so far.Can you have a separate js file with something like..var browserify = require('browserify');browserify(__dirname + 'src/static/javascripts/home.js', __dirname + 'dist/static/javascripts/bundleHome.js');cheers again!

Submitted January 20, 2018 at 12:09PM by longcraft

Does anyone successfully installed Nodejs on Chromebook without Crouton

Hi allGot a CB Pro recently Am trying to setup node without the use of Crouton. Found a few articles online but each time it leads me to /usr/bin/node not foundMay I ask if anyone successfully setup Nodejs on your chromebook without Crouton. Could you share how you did it?Thank you very much :)

Submitted January 20, 2018 at 12:23PM by Kopi99

How do you ensure redundancy of your file server?

If you have multiple node webapps all uploading files to a single file server (e.g. nginx), how do you ensure redundancy of that file server? You can have RAID on that file server to help minimize the risk of data loss, but if the whole machine gets destroyed, you're out of luck.What strategies can be used to ensure redundancy of files across physical servers in the same data center, or perhaps even across data centers? It seems risky to only have 1 file server.I could take regular rsync backups to another server in a different data center which would probably be good enough, but if I needed to restore from that backup file server there would be an inconsistent view of the files. Some files would be partially uploaded, and others that would be expected to be present by the application weren't included in that backup.What are some options for handling this?

Submitted January 20, 2018 at 10:05AM by nowboarding

pkgsign 0.1.3, a tool for signing and verifying NPM packages, now available

http://ift.tt/2EXBrwE

Submitted January 20, 2018 at 09:48AM by hachque

Friday 19 January 2018

I made Janeway: a Blessed based REPL with object inspection, indicators, clipboard support, ...

http://ift.tt/1UblZ1k

Submitted January 19, 2018 at 09:33PM by skerit

npm scripts to copy dir on a windows machine

Hi, I've started learning about npm as a build tool and I was loving it after struggling with webpack and finding gulp clunky.But I've hit a small snag..I'm using the windows command "robocopy" to copy some directorys within npm scripts. It works but I think robocopy returns an exit code that npm reads as having failed (I think this is what's happening at least). So npm chucks out a load of errors.I went off down a massive rabit hole installing ubuntu thinking to use the "cp" command from bash but I couldn't get the ubuntu environent to see the path variables to the npm directory.What options do I have? - Throw windows away for ever because it's turd? - Find some kind of linux terminal thing on windows that lets me use "cp"? - Just ignore all the npm errors? (I hate this the most).Thanks kindly.

Submitted January 19, 2018 at 09:54PM by longcraft

Node Inseptor

Hi all,If you don't mind, I would like to show an internal project which we just made public. We call it Inseptor.Inseptor is effectively a hook which once installed allows an external process to monitor all requests and responses that go through a node server. It is useful for debugging but also for security research and bug hunting. Unlike node-inspector, the chrome dev tools and other debugging features that already exist, the implementation is minimal. Also, the websocket message protocol we use is straightforward which means that the client can be implemented in anything. Other languages can also be supported by the same client.While I am sure there are probably better tools, my experience thus far is that I don't find them intuitive and often I am left doubting if they work at all. This tool is pretty much tailored towards HTTP. The code-base is very small and simple (101 loc). We think that most of the work needs to be done by the client and not the server.Although we buffer requests and responses at the moment, the plan is that going forward, it will be a streaming server. I am hoping to implement WebRTC soon. In non-prod environments, provided you have the right sessions keys, it will be pretty awesome if you can get a full live-stream of what happens and when instead of sifting through log files. This can be achieved by connecting to multiple of these feeds. Obviously, it is discouraged to use anything like this in production environments unless it is relatively unimportant.I also wrote a blog post about Inseptor today. It is early days but it will be amazing if we can get some feedback.

Submitted January 19, 2018 at 04:51PM by _pdp_

Vorpal REPL Inception - a Vorpal extension to embed a node REPL in your CLI

http://ift.tt/2DqDz2X

Submitted January 19, 2018 at 02:52PM by AdrieanKhisbe

Weekly Node.js Update - #3 - 01.19, 2018

http://ift.tt/2FQPTrn

Submitted January 19, 2018 at 01:43PM by hfeeri

Problem with VSCode (nodejs) [Repost from /r/VSCode]

Hello, I am using VSCode for a few days now and really like it. I am developing a small project in javascript/nodejs.I have a small problem that started a few hours ago. Until then I could compile and run my code without any problem, but I have now a problem. Everytime I run the debugger the following error occurs :Error: ENOENT: no such file or directory, stat 'c:\Users\Me\Documents\Projects\MyProject\Project\node_modules\require_optional\index.js\package.json' In my opinion something is clearly wrong since it's trying to access a file located in a file (\index.js\package.json) and the problem should be related to a function which role is to find the "package.json" file. Do you have any idea on how to solve this problem ? I found people with the same problem, so this could be due to VSCode itself (http://ift.tt/2mV5BKg already tried to update and rebuild with Npm (like mentioned in the other reddit post) but without success.Thank you for your answers.

Submitted January 19, 2018 at 12:47PM by tuilop

Modern node API starter project

http://ift.tt/2BhaqlG

Submitted January 19, 2018 at 01:06PM by scopsy

Easy automated testing in NodeJS with TestCafe (video tutorial)

http://ift.tt/2BdSE2w

Submitted January 19, 2018 at 12:22PM by krylovanatu

ws with socket.io?

Hey, I'm writing an application with Express.js and I'm using socket.io to create the server.On the other hand I'm having a bot and I'm trying to connect into the websocket server I've created using socket.ioThis is my code for the botThis is the socket.io serverIs it possible to make the bot connect to the socket.io server? right now I'm getting socket hang up when trying to connect

Submitted January 19, 2018 at 10:26AM by TheOnlyArtz

When uploading a file to node, how to stream that file to multiple other servers?

In a webapp that does a POST request of a file upload to a node server (I'm using Koa), how can I stream that file upload to a couple of other servers at the same time?So basically the webapp uploads to the main server, which uploads the file in parallel to 2 other servers. I'd like the upload to be streaming, so that as it is uploading to the main server, the main server is uploading it as it comes in piece by piece to the other servers.Could anyone suggest how this can be done in node (and Koa)?

Submitted January 19, 2018 at 10:34AM by nowboarding

AWS Lambda Go vs. Node.js performance benchmark

http://ift.tt/2DnSfjj

Submitted January 19, 2018 at 09:56AM by Timnolet

Want to use a more functional style in node? Making Functional Programming Click

http://ift.tt/2EU2qJj

Submitted January 19, 2018 at 08:22AM by FrancisStokes

Need some Node.js Advice for using Bitbucket API (Node NOOB)

Hey all,I've been given a project to pull some data from Bitbucket's API and I havn't used much node or really tried to consume an API. So I was wondering if anyone would have any tips on getting started. Really broad I know just kinda stumped and need something to get started (even a good resource!)NOTE: It just needs to be a command line tool displaying the data from a pull request from Bitbucket

Submitted January 19, 2018 at 08:31AM by pd145

Thursday 18 January 2018

I am trying to download/use penplot for my Axidraw and help would be great....

http://ift.tt/2FQTo0W

Submitted January 19, 2018 at 01:59AM by Rainbowquarts

Migrating your Node.js REST API to Serverless

http://ift.tt/2r8Y5QG

Submitted January 18, 2018 at 11:15PM by adnanrahic

Internationalizing Node.js – Node.js Collection

http://ift.tt/2FQw5Vd

Submitted January 18, 2018 at 06:48PM by _bit

standalone TCP and Web server

So i have created a TCP server which communicates with a hardware, using the hardware's own protocol. Now I have to create a web server which should serve endpoints to communicate with already connected devices. Have any of you done something like this? thanks

Submitted January 18, 2018 at 06:57PM by hanem100K

schemas in Node

http://ift.tt/2DrbGsg

Submitted January 18, 2018 at 07:21PM by diegohaz

Upload a file to S3 without writing to disk

http://ift.tt/2Dg6MKA

Submitted January 18, 2018 at 04:03PM by wjwang

Need some help on choosing a method of running groups of async operations as singular jobs in Node. App is a simple crypto trading platform.

A group of async operations to fulfill a trade would be something like:fetch trades from dbapply a matching algorithmcreate and update multiple db entriesnotify connected users via websocketsWhat technology makes the most sense to this? It needs to be fast (users should only have to wait a few seconds to get a confirmation), it needs atomicity, and it needs to have reliable ordering.I'm looking at 1) using something lightweight like bull or kue or 2) using something heavier like rabbitmq or amazon sqs. Anyone have experience doing something similar with these services?I'm new to node and the ecosystem is still unfamiliar to me! Am i missing a better or simpler option?

Submitted January 18, 2018 at 04:07PM by antique_swordfish

A quick and easy way to create REST API with swagger and restify

http://ift.tt/2DlGnPs

Submitted January 18, 2018 at 03:38PM by jobando89

My friend's new npm module: express-controller-routing

Hello. My friend doesn't use reddit yet and I thought I would shamelessly promote his npm module express-controller-routing. I have been using it for about a year. It would be great if you guys would have a look at it.Basically it allows you to write express routers in a very succinct way that is easier to read, and easier to test. Here is some example code where i define a router (taken from a real project), and how it is required in app.js.// app.js const controller = require('express-controller-routing'); const clubhouseRoutes = require('./routes/clubhouse.routes')(knex); // knex is my database dependecy for my router const clubhouseController = controller(clubhouseRoutes); app.use('/clubhouses', clubhouseController); // clubhouse.routes.js 'use strict'; const assert = require('assert'); module.exports = function clubhouseRoutes(knex) { assert(knex, 'Knex must be provided'); return { '/': { get: function getAllClubhouses(req, res, next) { return knex.select().from('clubhouses').limit(20) .then(clubhouses => res.json(clubhouses)) .catch(next); }, post: [someMiddleware, function(req, res, next) { //@todo }], }, ' /:id/image': { get: function getClubhouseImages(req, res, next) { req.checkParams('id', 'Clubhouse id must be integer').isInt(); const errors = req.validationErrors(); if (errors) { return next(errors); } const { id } = req.params; return knex.select('image').from('clubhouse_images').where('id', id) .then(images => res.json(images)) .catch(next); } } }; } This is great for unit testing and partial integration tests, because your route definitions are no longer coupled to express. Also this is just a very simple way of organising your routes. Let me know what you think! And try it out!

Submitted January 18, 2018 at 03:43PM by davidmdm

Building a static blog using Gatsby and Strapi

http://ift.tt/2EQRZGv

Submitted January 18, 2018 at 02:41PM by pierreburgy

A crash course on Serverless with Node.js

http://ift.tt/2wwUcmP

Submitted January 18, 2018 at 02:44PM by adnanrahic

[HELP] Someone knows how to use `node_modules` in a forced require.js enviroment?

Someone knows how to use node_modules in a forced require.js enviroment?

Submitted January 18, 2018 at 11:18AM by TheOnlyArtz

Battle of the Next-Gen languages: Golang vs NodeJS

http://ift.tt/2FQXiai

Submitted January 18, 2018 at 10:37AM by LiamBigDataDonoghue

Wednesday 17 January 2018

Implementing Event Sourcing (for Dummies) in Node.js & GraphQL

http://ift.tt/2EOuSML

Submitted January 17, 2018 at 08:13PM by marcusstenbeck

Crash course on TypeScript with Node.js

http://ift.tt/2DeWj1S

Submitted January 17, 2018 at 05:39PM by 4DaftPanda

Beginners guide to e2e testing with TestCafe

http://ift.tt/2q0Xb8b

Submitted January 17, 2018 at 02:50PM by krylovanatu

A tutorial with 2 MongoDB Collections?

Has anyone ever come across a CRUD/REST tutorial that deals with more than a single MongoDB Collection if so please share?

Submitted January 17, 2018 at 12:20PM by MongoMcMichael

File Upload with Node & React

http://ift.tt/2B8t7aW

Submitted January 17, 2018 at 12:04PM by treyhuffine

Why passportjs does not provide a "isloggedin" middleware to be used by default?

I am having troubles understanding why passportjs does not provide this by default, but I have to create my own function like:function loggedIn(req, res, next) { if (req.user) { next(); } else { res.redirect('/login'); } }and use it as a middleware in the paths I want to protect:app.get('/myendpoint', loggedIn, function(req, res, next) { // my handler }); Why?

Submitted January 17, 2018 at 11:50AM by honestserpent

Distributed Caching and Compute for NodeJS (Hazelcast)

Hi all, I wanted to let you know that Hazelcast has released 0.7 of its NodeJS client.http://ift.tt/2DFnST5've been spending quite a bit of time working on this and we'd be really happy to hear your feedback. We think you'll find that Hazelcast provides you with the fastest and easiest Caching and Compute experience available, especially if you use our Near Cache features which are a Redis killer in terms of performance.If you're looking for highly available and scalable data structures we have you covered...MapQueueSetListMulti MapReplicated MapRingbufferReliable TopicNear Cache support for MapLockSemaphoreAtomic LongEvent ListenersEntry ProcessorsPredicatesDisclaimer : I'm the Product Manager for Hazelcast. If you have product suggestions for the next version of the NodeJS client, please let me know.All the best David.

Submitted January 17, 2018 at 09:51AM by dbrimley

Start/Stop Node CLI App via Node Web App?

I need some help -- I feel like this has been done 100 times before, and I'm just not finding it.I've got a node CLI app -- slack-keep-presence -- that I'm trying to start/stop whenever I hit a specific URL (or a simple page with a single Start/Stop button).Is there any Node module or app that anyone knows of that can do this?

Submitted January 17, 2018 at 06:44AM by grgisme

Tuesday 16 January 2018

Rest API : How to handle multiple queries on the same table

Alright :I'm building a Rest API with MSSQL (using mssql package).I started building it and everything was going create. I could write an url : 'host/users?nId=2&nAge=12&orderby=nId_Desc'and it would be building a query WHERE nID = 2 AND nAge = 12 ORDER BY nId DESC.It was great.Then I remembered : SQL Injection. Damn. All my code could be abused with sql injection.Now I have to start over and I have a hard time building a REST Api where you can build up your condition in the url while using the anti injection system of mssql package.How do you guys handle it? Do you build a route for every query?Lets say I want to query users - By ID - By Name - By ID and By Name - Order by - Top 100Do I have to build a route for every case? I also have a hard time finding documentation for mssql with node.Thank you!

Submitted January 16, 2018 at 10:22PM by Kardiamond

How to lock all versions in package.json?

I'd ask on stackoverflow, but they're too prissy about this kind of thing.Basically, I want to remove all the ^s and ~s from package.json, but I can't simply do that because those aren't the exact versions that are presently installed.Yes, I know all about package-lock.json and yarn.lock, but they're too much of a pain to deal with when there's a merge conflict, so we usually end up just deleting the file and rebuilding it. Usually this works fine, but it causes all of our packages to get upgraded. I've been burned one too many times by broken minor versions, so now I want to lock it down more.Yes, I also know that specifying a specific minor and patch version doesn't guarantee I'll get the same package next time, but I'm willing to take my chances.So, is there a command I can run that will "refresh" my package.json with my currently installed packages, sans [~] modifiers?

Submitted January 16, 2018 at 06:18PM by xcOoE22awjiaLmyAxepO

Avoid these 35 habits that lead to unmaintainable code

http://ift.tt/2pblJpj

Submitted January 16, 2018 at 07:03PM by mattdev_

${ } ? what kind of template engine is that?

From Firebase Cloud function Docconst functions = require('firebase-functions');exports.bigben = functions.https.onRequest((req, res) => { const hours = (new Date().getHours() % 12) + 1 // london is UTC + 1hr; res.status(200).send( ${'BONG '.repeat(hours)}); });Just going over some cloud function examples on firebase; ${} <- what kind of template engine is that? does anyone know?

Submitted January 16, 2018 at 03:46PM by whoiskjl

can i use a proxy or api gateway with nodejs apps?

if its possible can anyone recommend any library or framework can i use to make integrate api gateway with nodejs apps?

Submitted January 16, 2018 at 03:07PM by a7me6_azza8

This is the ALPHA VERSION of PostGraphile v4 (previously known as PostGraphQL); use with caution and monitor

http://ift.tt/2EO3TB3

Submitted January 16, 2018 at 12:49PM by KiranKiller

What is the difference between swagger and loopback?

Are loopback and swagger doing the same thing?

Submitted January 16, 2018 at 11:25AM by a7me6_azza8

Monday 15 January 2018

Petrolette RSS NewsReader

http://ift.tt/2B4tMKm

Submitted January 16, 2018 at 12:28AM by yPhil

Having some trouble understanding how NPM can be used with a WordPress theme

Please bear with me as I'm having difficulty articulating what I'm trying to do.I develop custom WordPress themes for a number of clients. These themes run on PHP, and Node JS is not installed on the server. I want to be able to use npm install to include certain scripts with my themes.Swiper, for example, is a native JS touch slideshow script, which offers installation via NPM. This can be done with npm install swiper, which also adds swiper to the project dependencies in package.json. Here's where I get stuck: how do I actually include that dependency at build time?I use Node JS in conjunction with Gulp in order to concatenate scripts & styles, optimize images, etc. When I run my task gulp, my theme gets compiled out of /src in to /dev.For the particular case of Swiper, I initialize it at /src/assets/scripts/swiper.init.js. Is this where I would pull in the file from node_modules, and if so, how can I do it in such a way that the module gets concatenated with the rest of my scripts?

Submitted January 15, 2018 at 09:29PM by revxx14

PostGraphile creates a GraphQL API from a PostgreSQL schema

http://ift.tt/2mAMt3d

Submitted January 15, 2018 at 05:41PM by velmu3k

IS there a module to interface with Fabric.io or crashlytics?

Hello,I'm working on an Electron app and I would like to log crashes ino Fabric.io or crashlytics but I can't find something for NodeJs...

Submitted January 15, 2018 at 01:02PM by hthouzard

Web screenshots at scale using headless chrome

http://ift.tt/2D7gQp5

Submitted January 15, 2018 at 11:57AM by ashubham

Fastest and Extensible REST builder for Backend Development With JavaScript

https://twitter.com/k1r0s/status/952855763805929472

Submitted January 15, 2018 at 10:54AM by k1r0s

What Node topics are not/poorly covered?

What are some important topics that you feel are lacking in tutorials or documentation ?I was thinking about making some screencasts related to NodeJS and want to find out what content the community would be interested in.

Submitted January 15, 2018 at 11:15AM by EpicOkapi

NestJS: beautifully crafted Node.js framework we’ve all been waiting for

http://ift.tt/2EJFwV3

Submitted January 15, 2018 at 08:13AM by mateuszsojda

Top 10 Programming Languages of 2017, strictly based on GitHub’s data and TIOBE Index for June 2017

http://ift.tt/2v0lrEC

Submitted January 15, 2018 at 05:12AM by mydevskills

Sunday 14 January 2018

express-marshal: a suite of decorators built to easily wire up express.js controllers

http://ift.tt/2AYy85L

Submitted January 14, 2018 at 08:30PM by kykythemagicguy

How do sessions work?

Hey there, I'm using Express.js and express-session for sessions (And MySQL to save them).When I'm Authorizing on my PC it saves the session in the DB And if I'm trying to get on my website again I don't have to re-login because it picks up the sessionID from the DB But, when I'm restarting my PC and trying to get back on the website, I need to login again because there's a new session ID? what can I do?

Submitted January 14, 2018 at 02:09PM by TheOnlyArtz

Using node as a middle/communication layer between the front and back end

I am in the process of architecting a very large enterprise application that will have an Angular 5+ front end and a Spring based Java back end with a multiservice setup. I am thinking about using node as a middle layer between the 2 to keep my rest end points and the basic validation that matches the front end validation.1st, is this a common/good practice. 2nd, are there any recommended frameworks for this setup such as sails or nest? And last, is there any advice or recommended articles you know of before I start down this path?Thanks in advance!

Submitted January 14, 2018 at 03:52PM by GetDaStick

Unofficial NodeJS Tidal CLI client

Hello, I use Tidal, an alternative to Spotify for music. I work on Arch Linux as my main OS and as you may know there is no dedicated Tidal client for it, but fortunatly I am a programmer and recently I made my own terminal-based Linux client for Tidal in NodeJS. Today I have finished one of the first versions of this app and I want to share it with you.Here is my github page of it: Github link In readme you have all the information about installation and usage.I'm asking You for feedback and maybe you can use it :) Thank you! John.

Submitted January 14, 2018 at 01:41PM by okonek83

How to use a JSON array after requiring the file?

Hello, I have an issue with a JSON file, I have been searching around various other sources of code and found that requiring the JSON file should just work as they did not have to parse it or use fs.Here is the issue:My Code:JSON: { "AdminID": ["101"] }Node.JS:const config = require("./config.json"); var admin = config.AdminID; if(admin == "101"){ console.log("True"); }else{ console.log("False"); }; Console: FalseI want it to display True instead of false because the adminID in the JSON file is the exact same as what is written in the program however for some reason no matter what I try it doesn't work.I need the adminID to be a JSON array as I have planned to add more but for at the moment, to keep it simple I have just kept it with one.

Submitted January 14, 2018 at 11:24AM by nightfuryninja1

JS things I never knew existed

http://ift.tt/2Cj7vhC

Submitted January 14, 2018 at 10:47AM by fagnerbrack

How to use Mongoose better

http://ift.tt/2mzpWVu

Submitted January 14, 2018 at 10:08AM by spaces_tabs

What i am doing wrong here(requesting private API)

Ok, this is what docs say: http://ift.tt/2D0utWR code:let request = require('request'), crypto = require('crypto'), URI = "http://ift.tt/2DxFOz7", API_PUBLIC_KEY = "", //my api here POST_PARAMS = new Buffer("BTC").toString('base64'), NONCE = 4465456, SIGNATURE = API_PUBLIC_KEY + "POST" + URI + NONCE + POST_PARAMS, url = "http://ift.tt/2DxFOz7", auth = 'Basic ' + encrypt("", API_PUBLIC_KEY + ":" + SIGNATURE + ":" + NONCE); //my secret here in 1st parameter slot function encrypt(key, str) { var hmac = crypto.createHmac("sha512", key); var signed = hmac.update(new Buffer(str, 'utf-8')).digest('base64'); return signed } request.post( { url : url, headers : { "Authorization" : auth } }, function (error, response, body) { console.log(body); } );

Submitted January 14, 2018 at 08:44AM by dedaloodak

Issues with node.js files

Hi everyone, I didn't know node.js existed until today. Hoping that someone with some patience could help me out.I found a file that I have been looking for, for quite some time now. What it does, is allows a scoreboard for basketball to be read through the script, and then be put into .txt files so that we can update our LiveStream with the game time etc. It's more commonly known as OCR. A good guy created this file, and I have downloaded it, but I don't understand how to start it. I've downloaded node.js from the internet, and I've looked up all the support on YouTube and other online sources that I could possibly find, but nothing.http://ift.tt/2AZi57J are the files. It should create a server from what I know. Could anyone guide me on how to load/run this script? Because I am stuck.Thank you!

Submitted January 14, 2018 at 07:03AM by Liam13C

Saturday 13 January 2018

knexJs Help please

Hello I am starting to use knexjs with a basic sqllite3 configuration for development.Here is my knexfile.js:module.exports = { development: { client: 'sqlite3', connection: { filename: 'src/db/db.sqlite' }, migrations: { directory: 'src/db/migrations' }, seeds: { directory: 'src/db/seeds' } }, production: { client: 'pg', version: '7.2', connection: { host: '127.0.0.1', user: 'your_database_user', password: 'your_database_password', database: 'myapp_test' } } } Production is just dummy variables.I have followed the migrations and seeds instructions.here is my initial migration and seeds:exports.up = function (knex, Promise) { return knex.schema .createTable('countries', table => { table.increments(); table.string('name').notNullable(); }); }; exports.down = function (knex, Promise) { return knex.schema .dropTable('countries'); }; andconst countries = require('../fixtures/countries.json'); exports.seed = function (knex, Promise) { return Promise.resolve() .then(() => knex('countries').del()) .then(() => knex('countries').insert(countries)); }; When i run the migration and seeds I get a db.sqlite file. When i run the file sqlite viewer, my countries table is there and all the data. So far so good.However in my route everything goes too shit:app.get('/', (req, res, next) => { return knex.select().from('countries') .then(data => res.json(data)) .catch(next); }); I get the error: "message": "select * from countries - SQLITE_ERROR: no such table: countries",I am starting to lose my mind. Please help.

Submitted January 14, 2018 at 04:00AM by davidmdm

Map a file to another file in Node.js

http://ift.tt/2r2cdv0

Submitted January 14, 2018 at 01:35AM by ryanve

PM2 spawning too many processes on Ubuntu

So I have a basic Express web server running on a DigitalOcean Droplet (running Ubuntu 17.10 x64), and I am using PM2 to run it in the background.When I first run it, everything is fine and nothing uses too much memory. After a few days of it running, I see that the memory is slowly increasing in usage, so I run htop on the server and see this - there are 2 screenshots, one with tree mode and one sorted by memory usage %.As you can see pm2 seems to have multiple processes running and my web server also seems to have multiple instances running, all using memory. Even my Redis server has several processes running as well as other system processes.Why has this happened? How can I stop it?

Submitted January 13, 2018 at 04:40PM by thatguywiththatname2

Creating use with passport while logged in with passport

http://ift.tt/2DvGnJL

Submitted January 13, 2018 at 05:03PM by jsdfkljdsafdsu980p

Not being able to require a directory, But being able to require a file inside it.

http://ift.tt/2EAWZPt

Submitted January 13, 2018 at 08:20AM by TheOnlyArtz

Friday 12 January 2018

reactjs - How to use a Service Worker to cache a virtual file?

http://ift.tt/2FvCc0O

Submitted January 13, 2018 at 02:43AM by jonnyasmar

KeJo - unified Joystick and Keyboard - working in web, need modification for node?

http://ift.tt/2FyXj2u

Submitted January 13, 2018 at 02:21AM by TryingT0Wr1t3

Need help pulling API data with snekfetch

This is my first time using Node JS, Discord JS, and API.. Hoping someone might be able to help me out. My console is returning the "id" correct, but the entry is showing "undefined"I'm trying to search the API for "MarketName" and match it with id.example: id = "BTC-:+parameter"search for LTCid = BTC-LTCsearch API for "MarketName: BTC-LTC" or "BTC-LTC" or whatever will work. Then returning only the data for that object.Hope that makes sense, and thanks..const api = "http://ift.tt/1xBrJdL"; const snekfetch = require("snekfetch"); module.exports.run = async (bot, message, args) => { snekfetch.get(api).then(r => { let body = r.body; let id = "BTC-"+args[0]; if(!id) return message.channel.send("Provide a ticker"); if(!isNaN(id)) return message.channel.send("Not a valid ticker"); let entry = Object.entries(body).find(post => post.id === id); console.log(id); console.log(entry); if(!entry) return message.channel.send("This entry does not exist"); }); }

Submitted January 13, 2018 at 02:24AM by b0red88

Redis pubsub - Listening to a specific channel : How to do it?

I want to use a better way than the way I achieved below (it feels tacky), how can I make it listen to a specific channel rather than using if statements?pubsub.jsvar redis = require("redis"); var subscriber = redis.createClient(); var publisher = redis.createClient(); subscriber.auth("mypassword", function (callback) { console.log("subscriber is connected"); }); publisher.auth("mypassword", function (callback) { console.log("publisher is connected"); }); module.exports = { publisher: publisher, subscriber: subscriber }; test.jsvar express = require('express'); var router = express.Router(); var path = require("path"); var async1 = require("async"); var client = require("../databases/redis/redis.js").client; var subscriber = require("./realtime/operations/pubsub").subscriber; var publisher = require("./realtime/operations/pubsub").publisher; subscriber.subscribe("test1"); subscriber.subscribe("test2"); subscriber.on("message", function (channel, message) { if (channel == "test1") { console.log("test1 " + message); } if (channel == "test2") { console.log("test2 " + message); } }); router.get('/pubsubTest', function (req, res, next) { async1.waterfall([ function (callback) { publisher.publish("test1", "test1 - message 1"); publisher.publish("test2", "test2 - message 1"); publisher.publish("test1", "test1 - message 2"); callback(null, 'done!'); } ], function (err, result) { res.sendStatus(200); }); }); module.exports = router; Thanks!

Submitted January 13, 2018 at 12:32AM by laraveling

What's New in Mongoose 5: Improved Post Hooks

http://ift.tt/2Da47Fb

Submitted January 13, 2018 at 12:15AM by code_barbarian

What is the best Node.js course you ever studied from?

Doesn't matter if it is free or paid, for beginner or advanced.

Submitted January 12, 2018 at 07:28PM by CarmenMcCray

A starter kit to create game leaderboards on Azure Functions with Node.js and Cosmos DB with Mongo API

http://ift.tt/2D57vlv

Submitted January 12, 2018 at 06:42PM by dgkanatsios

futoin-hkdf - the fastest fully compliant HKDF implementation for Node.js

http://ift.tt/2AUcyzz

Submitted January 12, 2018 at 06:06PM by andvgal

Planning for Apostrophe 3.0, an open-source in-context Node.js CMS

http://ift.tt/2EAUb4Z

Submitted January 12, 2018 at 03:23PM by stuartromanek

Node.js Weekly Update - January 12

http://ift.tt/2CU3ufI

Submitted January 12, 2018 at 01:58PM by andreapapp

Najs Eloquent - a library with very nice and elegant syntax like Laravel Eloquent, supports MongoDB

http://ift.tt/2FuvjNu

Submitted January 12, 2018 at 01:05PM by tonysphan

[Help] Not able to get JSON API response using module.export.

I am banging my head on the wall since yesterday. I am new to Nodejs. Recently I got involved in a project where I need to create a npm module. I understood async nature of network and file in nodeJS.In the lib, I fetched JSON response and make it available to the user through module.export . But instead of the JSON data, I am getting undefined.How can I solve this?Code Snippet: http://ift.tt/2Fu9gXj

Submitted January 12, 2018 at 10:29AM by avicoder

[Help] Passport and Express Authenticated Redirect

So my function that's not working properly is:function ensureAuthentication(req, res, next){ if(req.isAuthenticated()){ return next(); } else { res.redirect("/"); } } The function that it's called in is:router.get("/adminIntro", ensureAuthentication, function(req, res){ res.render("mainSite/intro"); }); What is happening is taht the ensureAuthentication is redirecting to the 'encorrrect' route. This is happening even after a successful login here:router.post("/login", passport.authenticate("local", { successRedirect: "/", failureRedirect: "/login" }), function(req, res){ }); Any idea where to look where I could solve this issue.To clarify I looked on stack overlfow. There were some suggestions to mix up the order of session and the passport initializer. This caused the whole application to fail. There are some other things that were angular based so they didn't really apply to my specific purpose.I tried another login route that used req.login(). That didn't work either.

Submitted January 12, 2018 at 10:26AM by randygbiv

[Express] How to redirect user when his session is expired?

So far, I've tried to redirect the user when his JWT is expired via res.redirect(403, '/logout') with middleware, but nothing happens. I have a console.log right before that, and it definitely realizes the users token is expired, but the redirect does nothing. I didn't find a lot via google, but I think it has to do with my backend and frontend being split.How do you solve this issue? When the user's token is expired, I want him to get 'logged out' and told to re-login, not to continue to browse the page with plenty of errors.Thanks! :) Help and resources to read are welcome (or showing/telling me how you've handled this issue)!

Submitted January 12, 2018 at 08:17AM by zonq

Thursday 11 January 2018

Top Node Js Courses are just for $10.99

http://ift.tt/2lAWcpH

Submitted January 12, 2018 at 02:22AM by xscene

State of MySQL w/ Node.js/ExpressJS

Planning on running a Node.js ExpressJS application with MySQL, hows the package? Easy to use? Painful to use? I don't want to get half way through the project only to realize I'm in for a bad time.

Submitted January 12, 2018 at 01:27AM by howthewtf

Protect your Node.js app from Cross-Site Request Forgery

http://ift.tt/2msz6D2

Submitted January 11, 2018 at 10:34PM by gregbaugues

pkgsign: package signing and verification for npm

http://ift.tt/2FcSI5Y

Submitted January 11, 2018 at 09:33PM by ilesinge

Render array on a single page with nodejs

I'm developing a little web application that post tweets. One thing I want to do is display information about the tweets posted, like retweets,like etc. I'm using nodejs + mongodb. I have an array pulled from mongodb with the IDs of the tweets, then I use every single ID to query the twitter API and then try to render the results. The problem is that I can't render the page multiple times, so it gives me an error. Here's some code of the structure:This is in the index.ejs, to print the results in the div result:$.ajax({ type: 'GET', url: '/pullData', success: function(result) { $('#results').html(result); } This is in the app.js , the main nodejs app:app.get("/pullData",function(req,res){ mongo.pullData(twitter,res); }); Function pulldata in mongodb.ejs:exports.pullData = function(twitter,res){ MongoClient.connect(url, function(err, db) { if (err) throw err; db.collection("tweets").find({}).toArray(function(err, result) { result.forEach(function(entry) { twitter.loadTwit(res,entry.id); }); db.close(); }); }); } The twitter function to interrogate the API:exports.loadTwit = function(res,value){ T.get('statuses/show/'+value, function (err, data, response) { res.render('db',{data: data}); }); } The db.ejs page to be writed in the previous result div:ID: <%=data.id%> Retweet Count: <%=data.retweet_count%> Favorite Count: <%=data.favorite_count%>

Submitted January 11, 2018 at 07:20PM by snakethesniper

Questions about Node, Express, and Nginx

I'm new to Node and am kind of overwhelmed by some aspects of it. I'm working on a Vue project now and am having trouble understanding a few things. Any help would be much appreciated.I see Node can serve files as well. Is it common/good to have your production environment use Node as a server? Or is it just for serving dev projects?Is it necessary to even use Node as a server for Node projects? If I were to use Nginx instead would I have to set it up as a reverse proxy for the Node server?Express isn't a server, right? It's just middleware and when the request it made to the server itself it will tell Express what it wants and Express will decide what happens from there?Thanks for your help

Submitted January 11, 2018 at 07:49PM by aesamattki

What are some good Node.js job service packages, which are not dependent on Redis or MongoDB?

Hi everyone,I am looking for a few node.js packages for job services that should have job scheduling options, ability to add events (i.e. publish events to a message service like RabbitMQ), and compatible with both SQL (DashDB, DB2) and nosql (Cloudant) databases. The package should not have dependencies on any other architecture/technology (i.e. Redis, MongoDb, etc.) than mentioned above.So far I have found the following packages, but just wondering if there are other packages out there?node-schedule and later.js combined with schedule.jsThanks in advance!

Submitted January 11, 2018 at 06:20PM by skiddypopz

RxJS in Node — How to beat the callback hell with Observables

http://ift.tt/2CVdYLX

Submitted January 11, 2018 at 05:08PM by enricopiccinin

I never considered this before but Node migrations would be an awesome feature.

I work on big projects with other people. We need to inform each other that we should remember to run npm install on next pull.It has occurred before that I end up debugging the application because it isn't working and finally realize that I missed a mail.So I look up node migrations and find out that this exists. The ones I look up require you to manually run a command to get the latest migrations.Maybe it would be cool to run node migrations on start up if the environment is development. The program will start normally and check up on migrations later as to not affect start-up time. If there is a need for running the recent migration it will run one and restart the command. Does this exist?If this doesn't exist, is there an interest for it? I could try my hands on developing a module.

Submitted January 11, 2018 at 04:36PM by brogramming102

Google Trends for NPM packages

http://ift.tt/1MRgJu2

Submitted January 11, 2018 at 03:49PM by d4nyll

Udemy course: Learn and Understand NodeJS is 94% off. Less than a day left at this price

https://twitter.com/somethingometh/status/951452783349202947

Submitted January 11, 2018 at 02:12PM by plakucisa

[new to Linux] npm command not found but..

Heya,I'm not root on the system so I installed Node with following instructions here http://ift.tt/1ter1hp (the first code block, I also replaced npmjs.org with www.npmjs.org so it could find the install.sh file)Command node works perfectly, but I really don't know if npm is installed or is not :PMy /local/bin/ folder have one file, node, and two symlinks(?)npm -> ../lib/node_modules/npm/bin/npm-cli.js npx -> ../lib/node_modules/npm/bin/npx-cli.js When I change folder to ~/local/lib/node_modules and run ls -laFR I get result:npm -> ../../../../../../tmp/npm.27218/package Still in same folder, but neither npm or ./npm commands work ( command not found, and ./npm no such file or directory )Well I'm clueless, any help with this will be greatly appreciated. Thank you in advance

Submitted January 11, 2018 at 11:55AM by thebeeq

How does bcrypt.js compare passwords and hashes?

So, I want to use bcrypt to perform salting, hashing and password validation for my webapp, but there is something I am missing: I am having problems understanding how it works.So, in order to safelty store passwords, I need to hash and salt them, then store both the computed has and the salt.Say I have a user foo_user, which has a password foo_pass. To safely store it I would have to perform the following steps:generate a unique salt for the user, done in bcrypt by genSalt(rounds): say the generated salt is thisisasaltgenerate the hash of the password+salt, done in bcrypt by hash("foo_pass"+"thisisasalt", salt): say the resulting hash is "thisisthehash"Store in both the hash and the saltSo, my DB would be something like:usernamepassword_hashsaltfoo_userthisisthehashthisisasaltNow, when the user wants to log in, he sends username and password. At this point, to check the password I need to compute the hash again and compare it with the stored one. In order to compute the hash again, though, I need the salt.Instead, the docs for bcrypt says the to compare all you have to do isbcrypt.compare(myPlaintextPassword, hash, function(err, res) {...}) without any indication to the salt, but instead referring to the plainTextPassword. I don't understand how this works, if the hash has been created using a salt.What I would do is instead to recompute the hash again from the password the user sent to the app and the salt, using bcrypt.hash(myPlaintextPassword, salt_from_db) and then using the resulting hash for comparison.Am I missing something? Why does the documentation talk about comparing the hash with the plain text password?

Submitted January 11, 2018 at 10:24AM by honestserpent

List of popular sites, blogs and tutorials for learning Node.js

http://ift.tt/2EwRn8X

Submitted January 11, 2018 at 09:44AM by weblister

Importance of Middleware order in Express.js application

http://ift.tt/2DiHITL

Submitted January 11, 2018 at 04:48AM by nodexplained

Automatically move a module into a Web Worker

http://ift.tt/2AK5oO6

Submitted January 11, 2018 at 07:32AM by ratancs

Native ES Modules in NodeJS: Status And Future Directions, Part I

http://ift.tt/2D3VT2o

Submitted January 11, 2018 at 06:34AM by giltayar1

Wednesday 10 January 2018

Running a Node app on Amazon ECS

http://ift.tt/2AadLX4

Submitted January 10, 2018 at 07:05PM by speckz

Express, socket.io and Heroku question

I've got an app that is a multi-user drawing program. I'm using Express for the server and am using socket.io to deal with the multi-user aspect. Right now I am running the app on my machine locally using one port for the socket.io calls and a second port for api calls for things like user authentication, etc.When I deploy to Heroku, I only get one port. Is there a way to get around this single port limitation? I don't want to break the project into two seperate servers.

Submitted January 10, 2018 at 06:13PM by MoviesAndCocktails

Node v9.4.0 (Current)

http://ift.tt/2AMh5nB

Submitted January 10, 2018 at 04:58PM by dwaxe

What GruntJS tasks are commonly used in an Express app?

I am trying to implement Grunt tasks into my development cycle, but I am having trouble understanding how they fit into an Express application. For example, Concat and Uglify are two of the most common Grunt tasks, but they seem to favor front-end static JS files. If I could use these packages to concat and uglify node_modules, I can see how it would be helpful to me, but it doesn't seem like this is something commonly done.The only task I've found that is helpful to me is JSHint, which I use for linting. I haven't gotten to the point where I am comfortable writing tests for an Express app, so I am not using any testing tasks.Could any of you provide some insight?

Submitted January 10, 2018 at 05:10PM by Jsimps72

Building a custom E-commerce site using Node

http://ift.tt/2qPiCcS

Submitted January 10, 2018 at 04:39PM by L33-the-3rd

Node Project Assessment?

I have a little experience with Node, but it's been awhile. I'm not sure if this is the appropriate place, and apologies if it isn't, but I'm interested in a project that's using Node.js (http://ift.tt/2E57B8S), and would like to get some non-biased opinions/assessments about it. Specifically in terms of the value of the dependencies chosen.

Submitted January 10, 2018 at 03:24PM by blogenlust

I’m harvesting credit card numbers and passwords from your site. Here’s how.

http://ift.tt/2D1QrtA

Submitted January 10, 2018 at 03:46PM by io33

Hey r/node. Me and another redditor want to start building a chrome extension that net neutrality proponents can install to keep track of internet speeds en masse and analyze for secret throttling. What do you guys think? If you want to help just comment or shoot me a message!

http://ift.tt/2Dha294

Submitted January 10, 2018 at 01:16PM by backprop88

Create a Wikipedia Bias Tracker in 4 Steps with StdLib and IBM Watson

http://ift.tt/2qOUIy0

Submitted January 10, 2018 at 10:11AM by notoriaga

Deploying MERN stack to digital ocean

Hi, I am trying to deploy MERN stack to digital ocean... I have the front-end and back-end running, but I cannot get them to communicate!I have no idea where to go from here. And I don't quite understand what's going on.Basically when I go to www.mywebsite.com, I see my front-end react app running.I have my node.js server running on port 8080. So when I go to www.mywebsite.com:8080, I get my server.However, all of the ajax calls to the server end up with 404 no found. What do I do?

Submitted January 10, 2018 at 08:42AM by SupahSayan

Node.js + face-recognition.js : Simple and Robust Face Recognition using Deep Learning

http://ift.tt/2qL6TvE

Submitted January 10, 2018 at 04:39AM by oprearocks

Tuesday 9 January 2018

I want to create a main Node application that accepts all requests, retrieves all the other Node web apps on the Linux server run by different Linux users and displays them.

So basically you are met with a dashboard that lets you click into each website.Is this a very wrong thing to do? I see no info on it which usually is a sign that it shouldn't be done.I'm the owner of the server and can guarantee that I wish to display all running web apps on the server.If it's feasible then how can I do it? What should I search for? Any code examples that have accomplished it? Or modules that can help?

Submitted January 10, 2018 at 03:22AM by decayingteeth

How can I get the github repo link onto my npm package page?

I'm still brand new to publishing modules, and most npm pages have the link to their github repo, but I can't seem to get mine to appear.Link: http://ift.tt/2EsrGWW: http://ift.tt/2CWNoWB

Submitted January 10, 2018 at 03:13AM by TfwCantSingBCGay

My API is getting slower as I get more data. Any ideas for optimisation? (MongoDB, Express, Node 8)

Hey guys,This recently came to mind because some API I'm working with is getting progressively slower as I get more data. Things like hitting the memory limit and asking to enable 'allowDiskUse' when using aggregate to taking around 20 seconds to work with larger sets of data.I have pondered about the following:Remove the use of mongo's aggregate and try and apply my own transformations outside of mongo?Piping results straight from mongo, though I'm not sure how I'd handle doing some transformations of the data between the streaming and the cursorMove to a different database technology like PostgresQLSo I was wondering if you guys have any idea on how to handle working with large amounts of data coming out of Mongo, handling it on the server and how to serve it. Never really had much experience working with this sort of problem so a bit of guidance would be appreciated. Thanks!

Submitted January 09, 2018 at 10:48PM by cruzcontrol56

Node.js + face-recognition.js : Simple and Robust Face Recognition using Deep Learning

http://ift.tt/2qL6TvE

Submitted January 09, 2018 at 09:47PM by justadudewhohacks

[Node.js beginner question] How would I send the var data from this API request to an ejs file?

This code currently lives in my app.js file which I use to start my server. It pulls data from coinmarketcap's API and I would like to send the var data to an ejs file where I can manipulate and display it.http://ift.tt/2EpgABS

Submitted January 09, 2018 at 10:01PM by BrakeGliffin

Meltdown and Spectre - Impact On Node.js

http://ift.tt/2mjSqSH

Submitted January 09, 2018 at 07:08PM by dwaxe

node-lambda to speed up production

I am creating a lambda function and I was trying to get node-lambda set up locally to deploy my package. For some reason it sends my index.js but none of my node_modules directory is never deployed. Can anyone let me know what I am missing?Options: -h, --help output usage information -e, --environment [development] Choose environment {dev, staging, production} -a, --accessKey [your_key] AWS Access Key -s, --secretKey [your_secret] AWS Secret Key -P, --profile [] AWS Profile -k, --sessionToken [] AWS Session Token -r, --region [us-east-1] AWS Region -n, --functionName [node-lambda] Lambda FunctionName -H, --handler [index.handler] Lambda Handler {index.handler} -o, --role [your_amazon_role] Amazon Role ARN -m, --memorySize [128] Lambda Memory Size -t, --timeout [3] Lambda Timeout -d, --description [missing] Lambda Description -u, --runtime [nodejs6.10] Lambda Runtime -p, --publish [false] Lambda Publish -L, --lambdaVersion [] Lambda Function Version -b, --vpcSubnets [] Lambda Function VPC Subnets -g, --vpcSecurityGroups [] Lambda VPC Security Group -K, --kmsKeyArn [] Lambda KMS Key ARN -Q, --deadLetterConfigTargetArn [] Lambda DLQ resource -c, --tracingConfig [] Lambda tracing settings -R, --retentionInDays [] CloudWatchLogs retentionInDays settings -A, --packageDirectory [build] Local Package Directory -G, --sourceDirectory [] Path to lambda source Directory (e.g. "./some-lambda") -I, --dockerImage [] Docker image for npm install -f, --configFile [] Path to file holding secret environment variables (e.g. "deploy.env") -S, --eventSourceFile [] Path to file holding event source mapping variables (e.g. "event_sources.json") -x, --excludeGlobs [event.json] Space-separated glob pattern(s) for additional exclude files (e.g. "event.json dotenv.sample") -D, --prebuiltDirectory [] Prebuilt directory -T, --deployTimeout [120000] Deploy Timeout -z, --deployZipfile [] Deploy zipfile -y, --proxy [] Proxy server

Submitted January 09, 2018 at 07:50PM by CodingWithChad

App is hanging since yesterday morning. Local code hasn’t changed, but notice a lot of differences is node_modules folders of working and non-working versions.

We are using vue.js and retrieving static JSON data from a url that is easily reachable via any browser. I am strictly in the UI and it seems to hang in one of the service calls.The node_modules folders are very different(lots of folders in one and not the other and vice versa), between the working and non working. Even took the working version, put in non working, rebuilt, and it then worked. I’m really looking for suggestions as to what to look into and what has changed since yesterday morning, and will happily provide details.Thank you!

Submitted January 09, 2018 at 07:52PM by dballz12

Nodesource?

Hi!I have a question and I hope someone can offer some advice here. Does the NodeJS community find this product commercially relevant today or in the future? Say next 12 months?

Submitted January 09, 2018 at 07:54PM by atxandy

I'm hosting a private instance of the Cloud9 IDE, so how do I serve it through Nginx?

Right now it's being served just through Node. I know I need to set up a file in /etc/nginx/sites-available/ and I know the basic nginx /sites-available file setup. Specifically, I don't know what the documentRoot is or what the index file is (the entry point to the server. I know there is an index.html, but is it the entry point to the node app as defined in the nginx config file?). i'm not sure what either of those are in this case.I also don't know about any other configuration issues I may come across beyond the basic nginx configurations i've used for php sites and static sites.

Submitted January 09, 2018 at 06:49PM by dmfreelance

Marinate: Small Library making use of ES2015 Tagged Template Literal to help in chunking

http://ift.tt/2ErVpzf

Submitted January 09, 2018 at 05:01PM by bogas04

The 30 most popular Node.js development blog posts of 2017

http://ift.tt/2CXhARJ

Submitted January 09, 2018 at 02:23PM by mwarcholinski

Building a new file manager

I am sick of everything I have found online for web based file managers, everything looks too dated or if even somewhat good looking it lack in features.Now as to why I am here.. I have built multiple software applications before (think SaaS) but never had to interact with the file system directly other than log files. What packages should I be using? They need either great documentation or be popular enough that there is tutorials on it.

Submitted January 09, 2018 at 02:35PM by jsdfkljdsafdsu980p

8 Tips to Build Better Node.js Apps in 2018

http://ift.tt/2mas5WA

Submitted January 09, 2018 at 12:17PM by andreapapp

Newbie question: How to deploy a Nodejs application on a webserver ? (like A2 Hosting)

Disclaimer : Sorry for my bad english. I'm french.Hi everyone, I'm currently learning Nodejs and i wanted to make a personal blog. I learned PHP for 4 years at university, I already deployed some PHP apps (with Hostinger for example) and I wanted to start making Nodejs apps.Since I already bought a domain name for my website and subscribed to a Swift plan at A2 Hosting. I could access to my account with SSH and install Nodejs and NPM in my shared hosting. Everything is ok.Now, I'm using Filezilla to access to my server and I am uploading my project. The thing is: I understand that there is a 'public_html' folder, with a sample PHP file (index.php) with a 'cgi-bin' folder. I know I have to make this command to run my app with PuTTy :nohup node app.js & I put the index.php sample PHP script in a 'old' folder. I understand that A2 Hosting only accept running Nodejs apps on 49152 and 65535 ports. So i tried replacing Express port in my app.js with one of these ports :var express = require('express'), routes = require('./routes'), api = require('./routes/api'); var app = module.exports = express.createServer(); var port = process.env.PORT || 65535; app.configure(function(){ app.set('views', __dirname + '/views'); app.set('view engine', 'jade'); app.set('view options', { layout: false }); app.use(express.bodyParser()); app.use(express.methodOverride()); app.use(express.static(__dirname + '/public')); app.use(app.router); }); When I try to run my Nodejs app. "nohup: ignoring input and appending output to `nohup.out'" is displayed in PuTTy. And when I look to the website URL, I have a 503 Service Temporarily Unavailable error.As a newbie, I'm wondering what I should do. I tried looking at Stack Overflow, every A2 Hosting customers seems to have good experience with them and I don't find a topic with a similar issue (so I suspect I made a very newbie mistake). Someone can help me with this issue ? Is there someone who's deploying Nodejs apps with A2 Hosting ?EDIT : grammar

Submitted January 09, 2018 at 08:35AM by tommywalkie

Monday 8 January 2018

Best practice to return on send in express?

Hi! I've been using express.js for quite some time.In our last project (pretty huge one) we've got 11 bugs related to code that accidentally gets executed after res.send() in expressjs routes.I am now looking for a best practice to avoid this in the future. An obvious solution is to always write return res.send(...), but this looks weird and unfamiliar to new developers, since the return value is discarded by Express.Is there a better solution?

Submitted January 08, 2018 at 10:35PM by smthamazing

Is there a way to import a zip file and get individual files in it, using Webpack + ES6 imports?

I have a standard node+webpack environment set up, and I am using ES6 imports with npm packages (the usual import name from 'package'). I'm using webpack-dev-server as my dev environment, and the standard webpack build for building the output directory.I have a zip file in my source containing a large number of XML files, and in my JS program, I want to be able to read that zip file in and be able to extract individual files from it, so I can get the text from those files and process the XML in them.I am currently using the xmldoc package for transforming XML text to a JSON object for processing, but I have not been able to find a reliable package for reading in a zip file (using the path to the file) and being able to get the individual files in it. In the ones I have tried, I have run into trouble with node's fs module. If I try adding the target: 'node' property to my webpack config file, I receive an error stating require is not defined.Is there a reliable npm package compatible with ES6 imports that can read a zip file into my program? I realize that means the zip must be included in the build files to be sent to the browser, but that is better than including the hundreds of individual files without zipping them. Thanks!

Submitted January 08, 2018 at 09:59PM by Mastermind9513