Friday 30 November 2018

Simplest way for simple users + blog crud node + express app generation?

Preference for no front-end framework and doing everything from Node and Express, if front-end included, preference for React over Angular. I want the simplest scaffolded app possible. Can I do better (simpler) than mern.io/mean.js/mean.io? Expressjs generator is too minimalist - I want user model, sign-in, auth and cookies/sessions ready-made. Some add-on/fork to expressjs? Couldn't find it.​A tutorial would be acceptable, too (or both). (I see this Okta + expressjs, can we do simpler? https://ift.tt/2L26FJw)

Submitted December 01, 2018 at 06:37AM by maimedforbrowngod

Node Js by TechTechTuts 2018: How to Find latest Version of JS Frameworks and Packages using NPM View

https://youtu.be/C0OL0YSnCns

Submitted December 01, 2018 at 04:32AM by pwspk

How can I edit data from table and push to database?

I was given a MS Access database with 10k entries per table(total 7 tables). I used ag-grid to display tables and export some entries. I've seperated table view part from data entry because ag-grid will only be used to check the entries and export it in CSV.Each table has 18-25 columns and I have used sequelize(psql) to create table schema and add entries. Now I'm wondering how can I edit those entries. If I display entries used tables(w/o ag-grid) using simple css then add edit button to it then page will be filled with several tables.I'm looking for an alternative way to edit those tables. Can someone provide me some good ideas on how to do it.In short: I want to update and delete the entries from a table and each table has 10k entries.

Submitted December 01, 2018 at 03:58AM by pverma8172

Reuse/extend my tornado authentication for my node application.

Hello all,So I am running a tornado application which has users and they can use PAM authentication to authenticate to my application. I am also providing them to start a node js app.But that node app does not have any authentication. So if other users can get the url of my other user they can access it. Is there a way I could extend the already authenticated tornado server to my node. The node app does allows plugins so I could modify it.Thanks for all your help and sorry for such a noob question. I am just learning node for the very first time.

Submitted December 01, 2018 at 03:44AM by programmer_doga

ELI5: Why is npm a “broken” system security wise, compared to other package managers?

Why does npm get a lot of sh*t, compared to other package managers security wise? Why does something like event-stream happen on npm but not other package managers? Wouldn’t it be also as easy to publish a malicious e.g. pip package as on npm?

Submitted December 01, 2018 at 01:53AM by BrunnerLivio

Build a Simple Web App with Express, Angular, and GraphQL

https://ift.tt/2PaOZtq

Submitted November 30, 2018 at 11:05PM by leebrandt

Polyfill to JavaScript BigInt Proposal

https://ift.tt/2FMly14

Submitted November 30, 2018 at 10:45PM by fagnerbrack

ReactJS SocketIO bug or user error?

TLDR; When calling socket.emit inside of socket.on listener on the server, the emit is not received by react, but works in raw HTML.​I created a boilerplate example of this issue to try and nail down what is going on here. I have a simple server.js app that is running express and SocketIO on port 4001. I then created both a raw index.html page, and a simple react app (using create-react-app) to demonstrate the difference. Both have a button that sends a "test" emit to the server, and they listen for a "Hello World" from the server. When they receive "Hello World" from the server, they pop up a simple alert saying "Hello World Received." Interestingly enough, I only have an issue with this if I use socket.emit('Hello World') in the server-side socket.on('test') listener (specifically trying to send to the originating client). If I use io.emit('Hello World'), it works fine on both the html and react app. I have included snippets of my react App.js, the server.js node app, and the raw index.html. I have also zipped up the files here https://ift.tt/2PbvtwA so that someone can possibly verify what I am seeing.​To test, run npm install on both the main directory, and the socket-client subdirectory, run nodemon server.js from the main directory and run npm start from inside the socket-client subdirectory. As it is written, if you connect to localhost:3000 you will get the react app, and if you connect to localhost:4001 you will get the raw index.html.​In server.js, you can switch between io.emit and socket.emit by commenting out one of the two lines. The results of each are shown//io.emit('Hello World') //HTML: YES REACT: YES socket.emit('Hello World'); //HTML: YES REACT: NO If you go to localhost:3000, click on "Send Test Socket" button, you will not get an alert, despite the server getting the emit and sending the "Hello World" reply back, it's as if the client doesn't get the emitIf you go to localhost:4001, click on "Send" button, you will get an alert, which is what you'd expect from the server.js codeIf you go to server.js and edit lines 20-21 to uncomment io.emit and comment out socket.emit, suddenly both the react and index.html buttons work as expectedExtra: if you go to server.js and put a socket.emit('Hello World') on line 16 (inside the io.on('connection') listener), you will get the alert on both react and html versions, it's specifically an issue inside the socket.on() listenersBoth "clients" are pointing to the same server.js, so what is going on here? Am I doing something wrong with how I am listening on the react side somehow?​I hope this better documents the issue I am experiencing. Let me know if I can provide any further information.​​server.jsconst express = require('express') const http = require('http') const socketIO = require('socket.io') const port = 4001 const app = express() const server = http.createServer(app) const io = socketIO(server) app.get('/', function(req, res){ res.sendFile(__dirname + '/index.html'); }); io.on('connection', socket => { console.log('New client connected') // just like on the client side, we have a socket.on method that takes a callback function socket.on('test', () => { console.log('Test socket received') //io.emit('Hello World') //HTML: YES REACT: YES socket.emit('Hello World'); //HTML: YES REACT: NO }) socket.on('disconnect', () => { console.log('user disconnected') }) }) server.listen(port, () => console.log(`Listening on port ${port}`)) ​App.js (react)import React, { Component } from "react"; import socketIOClient from "socket.io-client"; class App extends Component { constructor() { super(); this.state = { endpoint: "http://localhost:4001", }; } send = () => { const socket = socketIOClient(); socket.emit('test') // change 'red' to this.state.color } render() { // testing for socket connections const socket = socketIOClient(); socket.on('Hello World', () => { alert('Hello World Received') }) return (
) } } export default App; ​index.html
​https://getyarn.io/yarn-clip/fb2399f1-b88c-4001-9a56-3cfbfb1caa2a​​

Submitted November 30, 2018 at 10:46PM by Sintex

Node Cluster: Database Concurrency Options

While deploying my app and clustering with PM2 I noticed, that sqlite does not like concurrency when writing to the db. In this case clustering is not essential which is why this is a simple fix for me but I am wondering what options I would have if it would be required:Use a different DB System: Preferably SQL and meant for concurrent writing. Postgres?Seperate instance of node only for writing to the DB? (not very nice).Master/Slave instances where one is a designated DB-writer and all other instances pass the data on?

Submitted November 30, 2018 at 10:58PM by Vivida

JSReport: This Week on npm v20181130: event-stream, qs, snapdragon-node

https://ift.tt/2AFpZoI

Submitted November 30, 2018 at 09:22PM by code_barbarian

Created a simple CLI tool to try out npm packages in a docker container

https://ift.tt/2E6LEuj

Submitted November 30, 2018 at 07:41PM by SutrangSucher

Zeit Now Builders for Node.js?

Hey guys!I'm learning a bit about deployment and I'm now fooling around with Zeit Now. There seems to be some recent changes in the build configuration process. Previously there wasn't a need for builder configurations. But now there apparently is one such need. I tried following their node.js builder documentation for a simple express and handlebars project I'm doing and cant seem to even get my Hello World on the deployment home route.Has anybody been toying with Zeit Now recently? I need some advice with this.

Submitted November 30, 2018 at 04:37PM by jbakebwa

What library should I use for creating a CLI?

Just curious if people are using oclif, commander, or a combination of chalk, and clui.

Submitted November 30, 2018 at 03:51PM by CutleryHero

Which is better - Node vs Python

https://ift.tt/2zwiMI4

Submitted November 30, 2018 at 04:20PM by AshishKhuraishy

npm trends show 0 downloads for a few days

I was looking at trends from npm on npmcharts.com and noticed that there were a few places where the downloads dropped to 0, namely May 30-31 and November 6-14. I looked at the status tweets from npm and they don't seem to show any major service failures, so I don't really understand where these trends are. The only thing I can think of is that the download rate api was down at that point and npm just didn't share any information about it. Anyone have any ideas?

Submitted November 30, 2018 at 03:00PM by CrispyBacon1999

Building web trading platform with node js

Hello guys,I have just received my first project to write in node, and it is web trading platform.This is my first ever real project, and will determine if i will get promotion as a node js developer or no, pretty much.At this moment i am kinda lost, dont really know where to start and how, if anybody can suggest how to start building it, which frameworks to use or any kind of suggestion, i will be extremely thankful.Thank you very much in advance

Submitted November 30, 2018 at 01:43PM by Garywil

Thursday 29 November 2018

N-API: The Next Generation Node.js API is Ready!

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

Submitted November 30, 2018 at 06:37AM by we_are_metizsoft

advice for web / data lab engine

I have been messing about with node for a couple of months now. Our company monitors industrial equipment and works more like a data lab than a website (though we do host our own website). We use MySQL, ruby, and python for most of the data processes and Rails for the website. Our process is mostly made up of different scripts running all over the place. I want to clean it all up and make it more efficient.My questions are these:1) If I built a server, like with express or somesuch, would that API through HTTP requests be as fast as simple socket servers to receive a machine report and process the data then save it to the database? Is there much overhead between a simple TCP socket and an HTTP request as far as speed goes?2) Our website is huge and synchronous in the way it loops through a customers list of machines to produce tables, etc. I wish to replace it all, but is it feasible to replace parts of it at a time? Not sure how I would configure Rails to do so (it's 2.3.5, yeah, i know) or if I could do it a page at a time. Or, how clumsy would it have to be to embed some processes or website components from a node server into a view served up by Rails? I think I could pull this off if I can configure it correctly and if I can do so without it being a convoluted mess.​I have been experimenting with Objection.js and so far, I really like it as an ORM'ish alternative. Sequelize looks good too, mostly because of the Rails throwback in syntax. Express looks good for web stuff and, maybe for some data processing server side. Anyone done anything similar? Like used express to process a lot of data or run process that are not web/api related?​thanks for any tips

Submitted November 30, 2018 at 04:02AM by s-keL

JSON parse

I want to find the number of 'ip' or keys in a json return. I have a function :getHostMatchRuleCount(ruleID, function (count) { }); function getHostMatchRuleCount(ruleID, eventCallback) { CT.getHostMatchRule(CT.options, ruleID, function(hosts) { console.log(hosts) var count = Object.keys(hosts).length; console.log(count); eventCallback(count); }); } Which returns:{ hosts: [ { hostId: 167772246, ip: '10.0.0.86', mac: '10ddb1ece7eb', _links: [Object] }, { hostId: 167772220, ip: '10.0.0.60', mac: '041e64edb10f', _links: [Object] } ] } 1 <--------- I expect the count to be two, as there are two entries.Any ideas?thanks!

Submitted November 30, 2018 at 03:35AM by Jacksonp2008

N-API: The Next Generation Node.js API is Ready!

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

Submitted November 30, 2018 at 02:28AM by fagnerbrack

Passing socket into a module

I've got a Socket.IO / NodeJS application I'm working on that has a module for handling various buttons (just to keep things clean and separate). If I make handleButtonScripts use io.emit, everything works fine, but I want to be able to notify just that one socket that pressed the button (hence client.emit) but I never get the HelloWorld emit on button presses. It's like the client var isn't passing through to the module the way I'm intending. Can anyone shed some light here for me?​Thanks in advance!​buttons.jsvar handleButtonScripts = require('../helpers/handleButtonScripts'); module.exports = function(io) { io.on('connection', function(client) { client.on('buttonClicked', (button) => { handleButtonScripts(io, client, button) }); }); }; handleButtonScripts.jsfunction handleButtonScripts(io, client, button) { client.emit('HelloWorld'); } ​

Submitted November 29, 2018 at 08:38PM by Sintex

Help please error handling ?

Hey , What are all the best way to handle error in nodeJS.Because whenever an error occurs the node restart right ?. At that time Gateway timeout error occurs for my client applications. What's your suggestion ? Help me please Thanks for your valuable time

Submitted November 29, 2018 at 08:03PM by MYTHiN07

Node.js 10 + Low-overhead performance monitoring with N|Solid for AWS Lambda

https://ift.tt/2Q00JUO

Submitted November 29, 2018 at 06:58PM by _bit

The Complete Guide to Node.js Developer Course

https://ift.tt/2uSMogH

Submitted November 29, 2018 at 05:30PM by kfgzro

Hosting Applications using DigitalOcean and Dokku

https://ift.tt/2FOiUIe

Submitted November 29, 2018 at 05:32PM by Ramirond

Node v10.14.1 (LTS)

https://ift.tt/2RpgcKI

Submitted November 29, 2018 at 05:15PM by dwaxe

🎥 Get information about your favorite movies!

https://ift.tt/2BH8k1L

Submitted November 29, 2018 at 02:01PM by xxczaki

Free eBook: Node.js Design Patterns (PDF)

https://ift.tt/2rdd0Go

Submitted November 29, 2018 at 11:19AM by PacktStaff

✍️Opinionated project architecture for Full-Stack JavaScript Applications.

https://ift.tt/2FOQ6PR

Submitted November 29, 2018 at 10:43AM by atulmy

How to deal with the event-stream vulnerability

After yesterday research combined brief and useful information about how to deal with the event-stream vulnerability, detect and fix.https://ift.tt/2Rh8NNv

Submitted November 29, 2018 at 10:39AM by AlexBV1

Build a blog application on Google App Engine: BlogPost module (part 4)

https://ift.tt/2r9ylAy

Submitted November 29, 2018 at 09:00AM by sebelga

How to break a Node.js app by using Async Stream Handlers incorrectly

https://ift.tt/2SfZv4r

Submitted November 29, 2018 at 08:23AM by pies

Wednesday 28 November 2018

Checking for page type

I have a place.ejs that can display three different types: country, city, attraction. I want to list the cities if the type is country, attractions if the type is city, and nothing if type is attraction. How do I compare which placeType is being used at the moment?
<% if ( placeType == 'countries') { %><% standinCity.forEach((city) => { %>
  • <%= city.name %>
  • <% }); %><% } %><% else if ( placetype == 'cities' ) { %><% standinAttraction.forEach((attraction) => { %>
  • <%= attraction.name %>
  • <% }); %><% } %><% else { %><% } %>
The only issue is in the if-statement comparisons. Everything within the statements work.

Submitted November 29, 2018 at 03:31AM by Charizma02

PSA: The latest LTS can make permanent changes to windows update and UAC, don't install the extra tools!

https://ift.tt/2P7Ydqn made the mistake of installing the latest LTS and installing the extra tools alongside it, now windows update is permanently disabled and this breakage survived even a system restore. It claims that there's some group policy managing it, but there is no such group policy. The devs seem to have no idea how to fix this, so the only option seems to be a full wipe which is somewhat unacceptableI have no idea how this was managed but its quite impressive

Submitted November 29, 2018 at 02:09AM by James20k

Express serving static files without actually making a call to 'res.sendFile(...)', help appreciated.

Hi, y'all, I've got a pretty standard express node / react app here but I'm getting some weird behavior.Like any typical setup, to serve static files I have,app.use(express.static(path.join(__dirname, "client/build")));...later in the file, we have,app.get("*", (req, res) => {console.log("hi");res.sendFile(path.join(__dirname + "/client/build/index.html"));});I would expect the request to reach that route, then serve the file. However, it looks like the file is served at the first line. I'm not sure what's happening, I haven't had this experience before when I've previously built react/express apps.I have a feeling it has something to do with the fact that when we pass the express.static( ) to the app.use( ), it's automatically serving the index.html...​I'll go ahead and post full code below.​const express = require("express");const app = express();const bodyParser = require("body-parser");const session = require("express-session");//pass session middleware to sesssion storeconst MongoDbSessionStore = require("connect-mongodb-session")(session);const userRoutes = require("./routes/user");const emailRoutes = require("./routes/email");const workoutRoutes = require("./routes/workout");const loginRoutes = require("./routes/login");const { mongoUri, sessionSecret } = require("./config/keys");const isAuth = require("./auth/isAuth");const path = require("path");// allow express to serve static content from react-build//init and configure storeconst store = new MongoDbSessionStore({uri: mongoUri,collection: "sessions"});const mongoose = require("mongoose");mongoose.connect(mongoUri,{ useNewUrlParser: true }).then(() => console.log("MongoDB connected")).catch(err => console.log(`There is an err:${err}`));//init session with store for the appapp.use(session({secret: sessionSecret,resave: false,saveUninitialized: false,store}));app.use(express.static(path.join(__dirname, "client/build")));app.use(bodyParser.json());app.use(bodyParser.urlencoded({ extended: false }));app.use("/user", userRoutes);app.use("/email", isAuth, emailRoutes);app.use("/login", loginRoutes);app.use("/workout", isAuth, workoutRoutes);// app.use(express.static(path.join(__dirname, "client/build")));// generic catch all routeapp.get("*", (req, res) => {console.log("Request never comes here lol wat??");res.sendFile(path.join(__dirname + "/client/build/index.html"));});//why are we hereapp.use((req, res) => {res.send("

Something went wrong

home");});const PORT = process.env.PORT || 9001;app.listen(PORT, () => console.log(`app starting on ${PORT}`));​Any help would be appreciated, thank you so much!

Submitted November 29, 2018 at 12:15AM by GGENYA

How to evaluate the values from user inputs?

Hello! I'm doing a simple application with MEN stack, and I need to evaluate if the user inputted the right answer or not, I know how to do this in other languages but I'm having trouble wrapping it up using Node.I want to know what's the best way to achieve the same feel as when programming with C# or Java:Example:if(textbox.text == "answer a"){conter++;}Something as simple as that but how do I get the value from the input and evaluate it correctly when the user hits a button to verify?Thanks in advance!

Submitted November 28, 2018 at 11:07PM by TheBlueGemini

Are there better ways of synchronously executing dynamic async functions/promises?

I was hitting an API that had strict rate limiting and therefore wanted to hit the API one request at a time, keeping track of how close I was to hitting the rate limit and pausing execution if necessary. I came up with this solution, but I'm not satisfied with its maintainability/readability/reusability and was wondering if there were other more standard ways of accomplishing the same thing. I've commented the code and removed the error-handling logic for readability. The gist of it is there's an array (queue) that stores async functions waiting to be called. When a client calls the call_api function a new async function is created which wraps the main api call and updates the rate-limiting info after receiving the response from api server. The async function is then added to the queue, where it waits to be executed. Execution happens in a loop that checks the rate-limiting variables first. There is example client code at the bottom. The effect is that the client code doesn't have to know about the rate-limiting - it just awaits the response.https://ift.tt/2PXXltD apologize for the length. I'm not looking for a code review necessarily, just seeing if I'm missing something really obvious about a better way to accomplish this using some idiomatic javascript concept that I'm unfamiliar with.

Submitted November 28, 2018 at 10:13PM by woeeij

Stay updated /r/node

With Node v8.11.4 installed on my laptop, and Nodemon v1.18.6 they then not to play well together.If you've run into this problem either uninstall Node via the terminal/CMD or simply head over to Nodejs.org for the most recent version.

Submitted November 28, 2018 at 08:15PM by CaribTech

10 Node Frameworks to Use in 2019 - scotch.io

https://ift.tt/2Q1WcRA

Submitted November 28, 2018 at 06:41PM by OogieFrenchieBoogie

Homebrew questions: (1) Are symlink problems still a big thing? (2) if Homebrew is so great, why don't Wes Bos, Andrew Mead, etc. recommend installing Node with Homebrew in their courses?

Not trolling, just trying to learn the details before I make a mess of my brand new computer trying to install things.If not clear, my two questions again are:are symlinks still an issue with Homebrew? Last time I tried to install with Homebrew, I ended up with a huge mess and if you Google 'symlink homebrew' you see a lot of people have problems with it (you don't even need to add 'problems' to your Google search, see?: https://ift.tt/2r7rWGc Homebrew makes life so great and easy, why don't some of the best teachers even mention Homebrew in their various courses? They're always on Macs, anyway, and they often recommend what they think is the best browser or best way to install something. I literally never see Homebrew mentioned in any instructions on Sitepoint, Wes Bos courses, Pluralsight, Udemy, etc. when taking courses involving Node, Gulp, Webpack, etc. There's got to be a reason none of these popular resources recommend Homebrew.Thanks!

Submitted November 28, 2018 at 06:11PM by NoMuddyFeet

What you definitely shouldn't do in software development

https://ift.tt/2SiyCNg

Submitted November 28, 2018 at 06:14PM by sandrobfc

Decoupling front-ends, why you should do it - an Open Source project

Popular solutions such as WordPress and Magento each have their own way in terms of front-end development. Usually these front-ends are coupled with the back-ends, which brings many complications with it. What if there was a way to reduce these complications? Decoupling to the rescue.Decoupling the front-end has many benefits:High Performance and ScalabilityImproved Developer ExperienceImproved Development and Testing speed - front/back-end developers can work independentlyEasier deploymentsIndependent UpdatesBetter securityMinimal complexityEasier recruitment - hiring specialists in a single domainMeet DEITY Falcon - https://ift.tt/2xYANxS - an Open Source project that does exactly the aboveThe project is built on the following stack:NodeJSWebpackReactJSGraphQLApolloKoaDo you wish to know more about the project? Please post any questions here, or join the slack channel: http://slack.deity.io

Submitted November 28, 2018 at 05:13PM by Cane_L

Can/should I outsource a login system with Node? Or should I do it myself?

I'm no security expert. I have basic knowledge of salting, hashing, two factor authentication, but I've never built a properly secure login system before.I'm building a website that will involve a user login system (no financial info involved), and I want to make sure it's done right. Are there cloud services or something similar that I can use to outsource this portion of my website? I love the idea of Facebook login, I use it a lot myself, but not everyone wants to do that or even still has Facebook for that matter. I may still offer that but I don't want to rely on it.Or perhaps I'm over thinking it. Is it as simple as using a secure hashing algorithm like BCRYPT on the password and be done with it? I'm not in the industry, just a hobbyist, so I don't know what the "standards" for security are. The only confidential information my database would store are password hashes.If anyone has any resources they would like to share, it would be much appreciated!

Submitted November 28, 2018 at 04:17PM by PM_ME_A_WEBSITE_IDEA

Need help figuring out an architecture for background processing of jobs on node.

So the idea is the client makes a request to a task manager. This task manager makes jobs from this request and stores each job state along with id in DB and returns the job ids back to client. The task manager then pushes it queue. After the queue consumer is done processing it sends an ack back to task manager (who was the producer). This task manager then marks this job as complete. Meanwhile client was polling task manager for state of job, which now comes back as completed.​I have looked into Kue, Agenda, Bull, bee-queue. But they dont have rest-api layer to communicate or persistence.Was thinking if there is any ready made solution out there for this job for node? Was thinking of using RabbitMQ but then would have to do state management myself.Please help.

Submitted November 28, 2018 at 12:21PM by fap_frenzy

Why You Should Consider hapi

https://ift.tt/2SjHO47

Submitted November 28, 2018 at 01:31PM by xenopticon

Does this method of connecting to mongodb create any memory leak?

So this is how I am connecting my nodejs app to mongo db,const mongoose = require('mongoose');const options = {useNewUrlParser: true, useCreateIndex: true};mongoose.connect('mongodb://localhost:27017/logindb', options);And I just imported it in app.js and all models which seem to be the only two places that it is required. By having it like this, am I creating too many connections or something everytime I import it? Because I recently saw a medium article writing the connection object as singleton and exporting it. So this question popped up although the app is working fine.The snippet from the article below.let mongoose = require('mongoose');const server = '127.0.0.1:27017'; // REPLACE WITH YOUR DB SERVERconst database = 'fcc-Mail'; // REPLACE WITH YOUR DB NAMEclass Database {constructor() {this._connect()}_connect() {mongoose.connect('mongodb://' + server '/' + database}').then(() => {console.log('Database connection successful')}).catch(err => {console.error('Database connection error')})}}module.exports = new Database()

Submitted November 28, 2018 at 12:14PM by ethoetho

Dominic's Response To The event-stream NPM Package Hack

https://ift.tt/2QixtrI

Submitted November 28, 2018 at 11:04AM by fagnerbrack

Spready will help you to create a RESTFul backend including basic CRUD functionalities with NodeJS, Express.js, Mongoose

https://ift.tt/2L1CTkw

Submitted November 28, 2018 at 09:19AM by osmangoninahid

Tuesday 27 November 2018

How TDD Can Prevent Over-Engineering

https://ift.tt/2r84AjX

Submitted November 28, 2018 at 07:42AM by fagnerbrack

How can I restrict users to SOME of my API

For example, if users are temporarily banned, they're not allow to access anything starting with /api/feature.Right now, I'm adding a check of users' ban in every middleware where I am restricting them to. Is there an easier way?

Submitted November 28, 2018 at 03:54AM by eggtart_prince

Node v8.14.0 (LTS)

https://ift.tt/2zppMGs

Submitted November 28, 2018 at 01:00AM by dwaxe

Should I use ES modules or CommonJS for my libraries and applications?

I'm a bit confused about the current (and future) state of ES modules in node...Is node considering ever dropping CommonJS in favor of ES modules?Is there a recommended and future-proof approach, or is this topic a holy war?I'm currently developing a small library, primarily for node, but I might want to port it to browsers at some point.Am I recommended to use ES modules or require?If I went for ES modules, I'd have to transpile my library using babel, right? I can't expect people to use --experimental-modules just for my lib... It wouldn't be a big deal, anyways, since I'm using @babel/plugin-transform-modules-commonjs already.What bugs me more than transpiling is require(...).default as it looks ugly and pointless - are there many packages out there doing it?And what should I use when I'm developing a program, rather than a lib?

Submitted November 28, 2018 at 01:07AM by oroep

Node v10.14.0 (LTS)

https://ift.tt/2PZZh4P

Submitted November 28, 2018 at 01:00AM by dwaxe

Node v11.3.0 (Current)

https://ift.tt/2RjbIW1

Submitted November 28, 2018 at 01:00AM by dwaxe

Node v6.15.0 (LTS)

https://ift.tt/2DYldXL

Submitted November 28, 2018 at 01:00AM by dwaxe

First project not using Mongoose, would love a code evaluation

Hey everyone,I'm used to having my project split up into routes/controllers/models and using Mongoose to handle the last one of those. Decided to give the native Node.js MongoDB driver a shot. Code works, but I suspect my project structure isn't 100% best practices. I figured I would just have my routes in index.js and only modularize the controllers - is that OK for such a small project? And basically anything else you can find that is wrong with the project, please mention.https://ift.tt/2KCGjv7 everyone!

Submitted November 27, 2018 at 11:45PM by ibrahimpg

Fastify 2.0.0 RC1 released!

https://ift.tt/2BD49UC

Submitted November 28, 2018 at 12:15AM by gibriyagi

I Need Help With node-browserstack

EDIT: Even though I have an active account, my current plan does not support the Unlimited Screenshots via API. The error makes total sense. Duh.I can't seem to get node-browserstack to work.When I run node index.js I get Error: You do not have access to the API. Upgrade your plan to get access.I have an active Browserstack account.I have tried all combinations of username, email, password and access key.package.json{ "name": "screenshot", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "author": "", "license": "ISC", "dependencies": { "browserstack": "^1.5.1", "dotenv": "^6.1.0" } } index.jsrequire('dotenv').config(); var BrowserStack = require("browserstack"); var browserStackCredentials = { username: process.env.BROWSERSTACK_USERNAME, password: process.env.BROWSERSTACK_PASSWORD }; // Screenshots API var screenshotClient = BrowserStack.createScreenshotClient(browserStackCredentials); var options = { url: 'https://www.google.com/', browsers: [ { "os": "Windows", "os_version": "XP", "browser": "chrome", "browser_version": "21.0", "device": null }, { "os": "ios", "os_version": "6.0", "browser": "Mobile Safari", "browser_version": null, "device": "iPhone 4S (6.0)" } ] } screenshotClient.generateScreenshots(options, function(error,job){ if (error) { console.log('ERROR', error); return; } console.log(job); });

Submitted November 27, 2018 at 08:52PM by P013370

Do I need to use authentication middleware to store oauth user information into my database?

New to node and middleware here. I'm working on an app that uses slack oauth 2.0 to login and the app needs to display their slack avatar and other details. Messages in the database also have a reference to user_id.So far I'm already able to return a JSON response containing the slack user's info when signing in, so I'm just wondering do I need to create or utilize an authentication middleware like `passport.js` for what I described above? I don't understand the why yet, I just see that there are examples of this: https://www.youtube.com/watch?v=KRCh6mSSsb8

Submitted November 27, 2018 at 06:21PM by littleQT

Question about npm package security and restricting access

If we run a package (not with elevated permission) from npm (I'm on Windows, if that matters) can it access the full filesystem? Or just within the the directory it was run from? If the former, is there a Node setting to restrict it? Does it matter whether the package is installed globally or as a project dependency?Also, more generally, if the package is malicious, assuming it is not run with elevated permission, are there are security risks with it, in terms of installing malicious software on the host, stealing data, etc. Or is it rather limited in what it can do?

Submitted November 27, 2018 at 06:23PM by Independent_Focus

The JavaScript Object Paradigm and Prototypes Explained Simply

https://ift.tt/2PXAgY6

Submitted November 27, 2018 at 04:55PM by theTypeScripter

Private dev site to share with team: Git and express-basic-auth?

I'm currently developing on a local machine and want to create a development or test site I can use to share with a couple other developers. I'm planning on using dev.mysite.com, but was wondering what the best practice is to prevent this from being indexed by Google or being seen or accessed by anyone.Would it make sense to install Git on the dev server, production server, and my local machine, push changes from local to the dev server for review, then to the production server when testing is complete?Is it okay to have the dev and prod sites on the same server but in different folders, instead of configuring a whole separate server for dev? Any advantages or disadvantages to this?Is it okay to use express-basic-auth with the challenge option to prompt for a username and password, and will that be enough to prevent indexing and access?Thanks

Submitted November 27, 2018 at 03:38PM by veryfloppydisk

NodeJS - The Complete Guide (incl. MVC, REST APIs, GraphQL) 94% off now

https://ift.tt/2RifqiL

Submitted November 27, 2018 at 02:43PM by DianeDLawyer

Is there anything bad about the Parcel module bundler I should be aware of?

I'm looking for an alternative to Webpack and Parcel looks to be a good fit, even better perhaps with the live server (so I don't need to use nodemon too). Are there any downsides to Parcel that you know of, /r/node?

Submitted November 27, 2018 at 12:46PM by beefyjon

Practical hosting options for Node.JS services

https://ift.tt/2FJ1CfR

Submitted November 27, 2018 at 11:16AM by isaacdiophant

Google image search with Puppeteer

https://ift.tt/2t6NKla

Submitted November 27, 2018 at 09:20AM by indatawetrust

Build a blog application on Google App Engine: Setup (part 1)

https://ift.tt/2DNYzAr

Submitted November 27, 2018 at 09:27AM by sebelga

[question] need help in video calling by using nodejs socket.io angular 2.

can anyone provide repo or site where i can get some resource on video calling with nodejs, socket.io angular 2 with the help of opentok? (newbie)

Submitted November 27, 2018 at 10:36AM by ZNYAK

Monday 26 November 2018

Compromised npm Package: event-stream

https://ift.tt/2QoA4Ak

Submitted November 27, 2018 at 02:18AM by nucleocide

Newbie help! Authentication strategy for storing data permanently in a database? And for different types of users?

Greetings!First, I'm very much a junior dev, but this is a great opportunity for me to learn and build something fun.I'm working on an app which, in essence, allows consumers to log in and favorite things they like, and store those things to the database. In other words, authentication can't just be a temporary token thing that'll expire and reset their favorites. Once the user clicks to favorite the item, it needs to go to the database and stay there, and the database needs to recognize them every time they log in. The only other things I might need to store are basic, like an email address and a city/state.I also need to create a login for producers, where they can post and edit the entries (which the users can then favorite). Like the consumers, the producers' posts need to be stored in a database and persist forever (unless they choose to edit it).They need to be completely separate -- meaning, consumers shouldn't have the functionality of producers (they shouldn't be able to post/edit items), and producers shouldn't have the functionality of consumers (they shouldn't be able to favorite things).If you were in my shoes, what would you use to authenticate these producers/consumers? This is my first time ever really messing with authentication, so I'm more than a little lost. I don't see how something like a temporary token is going to help with long-term data storage, so what program/strategy would you use to create those separate logins? Something like Passport?(This might be a really stupid question, but authentication is mind-boggling.)If it matters, I'm using React/Redux/Express/Node/MySQL.Thanks in advance!

Submitted November 27, 2018 at 12:38AM by PalmettoSpur

Enabling Latex in html textareas

Hey I am somewhat new to JavaScript and Node.js so I am wondering if anyone knows if there is a npm package that lets me implements latex in html textareas like Desmos does. (Cross post from r/javascript)

Submitted November 26, 2018 at 11:54PM by EnvironmentalHouse0

Publish-it - Node utility to generate lean library package for publishing

https://ift.tt/2QjnhiM

Submitted November 26, 2018 at 10:50PM by CanIhazCooKIenOw

Benefits of React over templating engines?

Im newish to node and so far Ive just been using EJS for any templating or displaying data on pages, but Ive heard so much about React/Vue/Angular, Im just not sure what it is they offer that compared to templating engines like EJS.​Thanks :)

Submitted November 26, 2018 at 08:19PM by MilkmanDan98

Backdoor found in event-stream library

https://ift.tt/2KAI4cp

Submitted November 26, 2018 at 07:31PM by xenopticon

Help me to understand this code :(

i understand why this workrouter.get('/', (req, res) => { item.find() .sort({date: -1 }) //desc order .then(result => res.json(result)) //callback }); but how this isn't working?router.get('/', (req, res) => { result = item.find() res.json(result) }); i'm getting a "Converting circular structure to JSON" error, i'm very new to node js, and i really want to understand more of it, btw i also want to know, how do i count all the elements of the query?, thanks in advance

Submitted November 26, 2018 at 06:56PM by Vasault

Is there any good Nodejs courses from Pluralsight?

No text found

Submitted November 26, 2018 at 04:44PM by maadurgadevi

Looking for feedback on my website built using Express/Mongoose

I recently used Express and Mongoose to build a website for a school project. The project's source code is hosted on GitHub. The backend code is included in the server folder, with routes in server/routes, and models in server/models. I'm not quite certain regarding the practices while writing my code, and whether I've successfully adhered to the correct standards, among other things. Any feedback is greatly appreciated :)

Submitted November 26, 2018 at 04:31PM by datskinnyguy_

Help with P2P (new to node and network programming)

Hello. I am in need of help. I study CS and need to make a P2P Hangman game. For starters, I have never programmed a P2P application nor a network program in general. I chose node because I thought it would be ok to go with it as there are no restrictions to language. The only restriction is that I need to use sockets, no frameworks. I'm struggling to figure out how I am to create an only program which is a potential server and client at the same time (that's what I understand from P2P). The first thing is... How am I to check if an instance of the program is the first to be executed or if there's another one (so that the first may open a connection to a server on a specific port)? Also, any great advice on network programming, P2P and node is welcome.

Submitted November 26, 2018 at 03:59PM by supmadud

Best Practice for Making Calls to Native Windows (C#) libs

I'm going to be developing an electron app shortly that will need to:Call iTextSharp to pick apart + read + write some PDF data (I suppose Java-based iText is an option as well)Make custom driver/API calls to access data on a USB-connected device (unknown if I'll have filesystem access to the USB device yet)Are there "best practices" and/or tutorials available for this? I'm something of a novice with electron (but not to JS and MVC development).

Submitted November 26, 2018 at 03:22PM by AmericanWigeon

Install npm globally

I try install npm without root,it can't install and show error but I run on root it works but I want it run globally what is the procedure for that

Submitted November 26, 2018 at 01:23PM by mohamedimy

Simultaneous Time Intensive HTTP Requests

I am running Node on a RPi as a backend. Every minute it needs to HTTP Request from 40 clients more or less simultanously. The payload is very small and needs only to be done every minute. The problem is that the response time is around 500ms per client + DB writes. I had problems in the past of them locking up the main thread which is why I now delay each request by some milliseconds and use tight timeouts. Is there anything more I can do besides writing everything as asynchronous as possible? Even though this is not a CPU intensive task, would this be a candidate for offloading work to another thread?​Thanks in advance!

Submitted November 26, 2018 at 01:30PM by Vivida

When to use what? (Clusters and Workers)

Is it something like, use clusters when you want to balance load (client requests per se) and use workers for CPU intensive jobs?

Submitted November 26, 2018 at 12:46PM by Prateeeek

Sunday 25 November 2018

What are the best practices for logging errors in Node?

Hey everyone! I'm an intermediate node developer, I've built a few projects, and so far I've just been handling errors using console.log, and outputting everything into a log.txt file. I'm guessing there's a better way, so I wanted to ask, how do professionals on big projects handle and log errors?What are some of the best practices? A tutorial/post/example would really help.

Submitted November 26, 2018 at 04:14AM by raymestalez

Announcing the official Javascript compatibility report

https://ift.tt/2DqNntX

Submitted November 26, 2018 at 02:23AM by fagnerbrack

Coinswitch.co fully tested node and browser API client

https://ift.tt/2zpmRgO

Submitted November 26, 2018 at 12:01AM by roccomusolino

Does anyone know if it's possible to run a tiny express server from MS Surface?

It is my understanding that the surface is just running Windows 10, so I can't think of a valid reason why it wouldn't work. This would be for a very small proof of concept application, so there isn't much that the server would be doing other than delivering very small http responses.Does anyone have experience running a node app from MS Surface tablet?

Submitted November 26, 2018 at 12:29AM by flashbck

Use TypeScript to Build a Node API with Express

https://ift.tt/2Q2PhqA

Submitted November 25, 2018 at 11:10PM by rdegges

if (req.body.password === process.env.PASSWORD) - Is this OK? Code example inside

Is this secure? This program I'm writing is meant to be used by one person or a small team. Surely there's no harm in authenticating in this way, or am I wrong?​https://ift.tt/2QloNAN

Submitted November 25, 2018 at 10:41PM by ibrahimpg

I recently read that Netflix uses Node.js, so why do people say it's not good for big projects?

...like in this thread?https://ift.tt/2Rdtudh

Submitted November 25, 2018 at 10:00PM by NoMuddyFeet

Testing express middleware

I'm trying to write a test for simple middlware function I'm implementing.​// middlewareconst Joi = require('joi');​module.exports = (req, res, next) => {​const schema = Joi.object().keys({memberId: Joi.string().required()});​Joi.validate(req.body, schema, (err, value) => {if (err) {return next(err);}​next();});};​// passing test when memberId is OKtest("Schema should be valid", () => {​const req = {body: {memberId: "MID 12345"}};​const res = {}​const next = jest.fn();​validateSchema(req, res, next);​expect(next).toHaveBeenCalled();expect(next).toHaveBeenCalledTimes(1);expect(next).toBeCalledWith();});​I'm having issues writing failing test when memberId param is not found. For example:const req = {body: {blahId: "MID 12345"}};​I would like to write a test to confirm that next(err) has been called but I'm having no luck connecting the dots: For example,test("Schema should be valid", () => {​const req = {body: {fakeId: "MID 12345"}};​const res = {}​const next = jest.fn();​validateSchema(req, res, next);​expect(next).toHaveBeenCalled();expect(next).toHaveBeenCalledTimes(1);// How do I test if next has been called with err and how could I assert against property of err object.expect(next).toBeCalledWith(err);});​​If I change my middleware to call​next(err.details)​then​expect(next).toBeCalledWith([{ "context": { "key": "memberId", "label": "memberId" }, "message": "\"memberId\" is required", "path": ["memberId"], "type": "any.required" }]);​works fine however this doesn't seem/feel right.​I also have a global error handler that looks like this​app.use((err, req, res, next) => {​console.log(err);​if (err.name === 'UnauthorizedError') {return res.status(401).send();}​res.status(err.code || 500).send(err);});​Thank you.

Submitted November 25, 2018 at 07:15PM by roboctocat

Set property on res?

On the client I have the code (not written by me): $.post( { url: 'myurl', data: data, contentType: 'application/json', success: res => { if (res.myprop) { So I am trying to set myprop in node by res.myprop = true before res.send(data) but it is always undefined on the client?Thanks

Submitted November 25, 2018 at 04:11PM by snicksn

Node.js Open Source of the Month (v.Nov 2018)

https://ift.tt/2DVUD1o

Submitted November 25, 2018 at 01:05PM by Rajnishro

Noob needs an example of aggregating results in a webapp's get function

Subject hopefully provides the gist of what I am having trouble understanding as a noob.On a get to my web app, I want to make three http requests to JSON services and send the JSON to an EJS page.The part I am having trouble with is the async/promise part of retrieving the external data:app.get('/', function (req, res) {x = make http request 1y = make http request 2z = make http request 3res.render('index', { x:x, y:y, z:z, error:null });});I think I should be writing a function to make an http request to an external service and return a promise. Then maybe use Promise.all to wait until they have all completed and failed.I really would appreciate an example/shell of exactly how to do this.

Submitted November 25, 2018 at 12:11PM by OrganicUse

Saturday 24 November 2018

What is the best way to connect client and server side?

In nodejs, what would be the best way to do if you want to log a message at the server instantly when a button on the client side is clicked?

Submitted November 25, 2018 at 04:12AM by frencojobs

Should I keep giving MVC a chance? Or is there a better way?

I'm taking Max Schwarzmuller's newish Node course and it's very cool so far, but I am a little frustrated with how convoluted MVC feels so far.Should I just keep riding it out and wait for the app to get more complicated so his MVC pattern feels more applicable?I had been learning Vue with the vue-cli3 and everything seemed a lot more straightforward, especially when using vuex. It feels a little like taking a step back.Is there another pattern I could look at that may make more sense? Is there a good breakdown of which patterns fit which situations better?Note: I am self-teaching, have a very slight comp sci background from a few semesters in college, but have mostly been learning Vue for the last two years or so.

Submitted November 25, 2018 at 12:30AM by Downvotes-All-Memes

The Forgotten History of OOP

https://ift.tt/2qnESre

Submitted November 24, 2018 at 10:12PM by fagnerbrack

Install a list of VS Code extensions via Node.js 🎉

https://ift.tt/2A5XPDb

Submitted November 24, 2018 at 09:17PM by RareYogurt

Taskbook: Like Trello but for the Terminal - Version 0.2.0 Released

https://ift.tt/2PBX1jO

Submitted November 24, 2018 at 08:39PM by kasandracity

Options for reading (winston-like) json objects from an application log?

tl:dr; i'm dumping json objects into a log file, server-side. what's out there for legibly presenting me that information through a simple node module? i'm open to serving it out to the browser but am leaning towards something at the command line so i don't have that security hole to patch up.i've inherited a project developing an ionic app and (unfortunately) a python server. the python server is basically a proxy to a third-party SOAP API and after some whittling, it's only real responsibility is to capture logs for debugging.the logic for dropping the requests and responses into the log a legible way was slowly getting out of hand, and the 12-factor app principle of dumping everything into a pipe for possible eventual consumption has been making more and more sense.meanwhile, i've started using winston for logging in the app and love it. 12-factor seems to hinge on the developer being able to pick through the logs for what's relevant but i've opted for a couple reporters that scrape the events, assemple them as needed (like matching requests to their responses) and show me what i'm looking for. i can look at events that were fired, api calls, snapshots from form submissions, etc. -- or just look at them in one big list. but with the browser at my disposal (i pop a new window) those lists are basically tall rectangles with dressed up object dumps stacked left-to-right -- so side-scrolling over past a long entry doesn't take any longer than a short one.anyway, i'm probably getting off topic so back to the server logs: i've switched them to dump json objects to the log file as winston would and assumed there would be existing options out there for what i'm trying to accomplish ,which is kind of open ended but boils down to "let me quickly read the end of the log file to debug issues".for now i've written a small utility that handles it but doesn't watch the log file -- i have to run it and it shows the last 50 logs (or whatever i've changed that variable to). i can certainly build on it and enjoy having my first excuse to use chalk, but i get the feeling i'm reinventing the wheel.i did find one npm package that i can't seem to find today that looked very promising, is built on ncurses and uses hotkeys for navigation. i ran into an error with that one and may poke into it, but i'm on Windows and have no idea whether that means ncurses is available. all i know about ncurses is that it somehow, you know, makes the console look way different from a CLI. and all i know about Cmd.exe is that it's the worst. linux is in my past and future but unfortunately not the immediate present due to the circumstances.

Submitted November 24, 2018 at 06:21PM by daveequalscool

JSReport: This Week on npm v20181123

https://ift.tt/2DD5nAy

Submitted November 24, 2018 at 06:40PM by code_barbarian

Cannot test a simple route with Jest

I have been trying to test this route for 4 hours now, and I can't seem to make it work.So i have a route like this:api.post('/register', (req, res) => { let hasErrors = false if(!req.body.name || !req.body.email || !req.body.password){ hasErrors = true } if(hasErrors){ res.status(errCode.invalid_input).json({ message: 'Invalid input' }) }else{ const NewUser = new User({ _id : mongoose.Types.ObjectId(), name: req.body.name, email: req.body.email, password: req.body.password }); NewUser.save().then(saved_user => { res.status(201).json({ message: 'User registered', user: saved_user }); }).catch(err => { res.status(500).json({ message: err }); }) } }) ...which I'm testing using Jest and Supertest:it('/register should return 201 if valid input', (done) => { //mock valid user input const NewUser = { 'name': 'John Wick', 'email': 'john@wick.com', 'password': 'secret' } request(app) .post('/register') .type('form') .send(NewUser) .expect(201) .end((err) => { if (err) return done(err) done() }) }) And the test is pending, and It gives me Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.I have tested this /register endpoint manually with Postman, and indeed, when I call the /register endpoint with Form URL Encoded data (name, email, password), it works and adds a new entry in my database. If I send the data as Multipart Form, it doesn't work and gives a 422 Invalid Input. Maybe that's the cause of my problem?Cheers!

Submitted November 24, 2018 at 07:06PM by pythonistaaaaaaa

Help with transform stream newbie here

I have 1m ohlc data coming live from a ws data source. I am trying to convert it to 5m 15m 30m 1h etc and am confused about something. I read the docs and understood that I implement a _transform method that takes input and calls a callback. Should my _transform method convert incoming data into all timeframes and push each one or should I have multiple Transform instances where each one does one specific conversionApproach 1 One Transform stream that pushes alllet r= new Source()let t = new Transform({_transform(chunk, encoding, done){this.push(data['5m'])this.push(data['15m'])...}})Approach 2 Multiple Transform Streamslet r = new Source()let t5 = new Transform("5m")let t15 = new Transform("15m")r.pipe(t5)r.pipe(t15)I noticed that I cannot nest pipe calls because it goes from output to input but I want 1m as input to eachThe second approach seems like it loops through all 'data' event listeners and fires each oneWhat is the right way to do this and is there a better approach? Thank you in advance

Submitted November 24, 2018 at 04:55PM by mypirateapp

.NET developer criticised by own community

Having left .NET for Node a few years ago when I switched companies, I found this quite amusing: https://ift.tt/2DF9Ene

Submitted November 24, 2018 at 03:51PM by ambitious6831

Refactoring Home Page

https://ift.tt/2m4zF6l

Submitted November 24, 2018 at 04:12PM by kapv89

ts-app: Full-stack TypeScript Development

https://ift.tt/2P1VHBF

Submitted November 24, 2018 at 02:56PM by lukeautry

This is why coupling is your worst enemy

https://ift.tt/2DtGpEE

Submitted November 24, 2018 at 01:06PM by tomasgold

Secure Node.js, Express.js and PostgreSQL API using Passport.js

https://ift.tt/2BvfSVa

Submitted November 24, 2018 at 01:22PM by didinj

Vulkan rendering API for node.js

https://ift.tt/2OFaPWt

Submitted November 24, 2018 at 01:09PM by Schampu

Friday 23 November 2018

real world application, more core or higher GHz, what is your choice?

Hi, i am about to upgrade my CPUi know nodejs is single threaded but can PM2 to easily scale out.there are two options.​1) 12 core 24 thread 2 GHz -> a lot of cores but lower GHz2) 6 core 12 thread 4GHz -> less core but higher GHz​which option would benefit the real world application?i know it is hard to tell, but let's say running MEAN or MERN full stack app in one server with plenty of SSDs in RAID.​which option would you choose and why?

Submitted November 24, 2018 at 05:18AM by jkh911208

Nodejs App in Firebase?

I am learning Nodejs for a demo app, can I use Nodejs app in firebase for hosting rather than using Heroku, what will be difference in hosting in firebase and heroku ? Also can I install mongodb in firebase and use it along side the real-time database ?

Submitted November 24, 2018 at 05:01AM by maadurgadevi

Super lean Mongodb wrapper. Use to start/close local db in unit/integration/e2e tests.

https://ift.tt/2PSYnag

Submitted November 24, 2018 at 05:58AM by general_tao_

How to only allow one user to login?

I'm trying to create a image gallery website and I want to login so i can upload pictures. I have heard passport is good for a login system but I'm not sure how to only allow one user. Any help?​

Submitted November 24, 2018 at 02:35AM by soggypizza1

request-promise, return value

I know this must be a common problem but I am yet to find the a working answer after many hours of digging so I am going to ask for help. Chaining the requests works as expected, however I am having trouble ending up with the result of the final web call being returned. I do understand that its the async nature of node, but I don't know how to get around it.const request = require('request-promise') const options = { method: 'GET', uri: 'https://ift.tt/1HYwxQm' } //should make multiple web requests and return the final value var x = request(options) // First call would be to get a JWT .then(function (response) { console.log('first:' + response); //need to modify some of the options for second call for data options.uri = 'https://ift.tt/2AflKjC'; }).then(function(){ return request.get(options); }).then(function(response) { //this is what I want returned console.log('second:' + response) }).catch(function(err) { console.error(err); }); console.log('Return value:' + x) The result:Return value:[object Promise] first:6 2 3 2 2 6 3 1 6 2 second:2 1 1 2 3 Everything works within the request, but since the final console.log runs before the requests have completed, it's just returning a promise and I need it to return the value of the final call.​Any help appreciated.Thanks!

Submitted November 23, 2018 at 11:42PM by Jacksonp2008

Data-Forge 1.3.0 is officially released!

The file system functions have been extracted from the core API to a new file system module. To continue doing your data wrangling and analysis under Node.js you now must also install "data-forge-fs". That allows you to continue reading, writing and transforming your data files.I've extracted the file system functions to make it easier for Data-Forge users to use it in the browser and specifically to work with the latest AngularJS. https://github.com/data-forge/data-forge-tshttps://github.com/data-forge/data-forge-fs​

Submitted November 23, 2018 at 10:18PM by ashleydavis75

Launch and auto authenticate to browsers/tabs

Hi,I have no clue how to do this. I have a simple Node/Express app setup and I am trying to figure out what library/technology I need so that I can load up specific websites (say trello.com) and I need to be able to authenticate the user automatically so they don't have to log in again (I already have the credentials - not worrying about security right now as its mostly just a personal project).Any help would be most welcome. Oh, it would also be nice to be able to log them out if possible.

Submitted November 23, 2018 at 09:55PM by AtooZ

Webcam -> Server -> Public Video Source Url

I am currently working on a project in which I would like to be able to have .webm urls that would display the content that is being streamed to a server by a webcam. Currently I have a webcam that streams a webm buffer using socketio to a server, but I have no idea what the best practice from there is to then have a route ending in .webm that would just resolve the video stream. I will be piping this .webm url into cv2 of python so the url needs to literally resolve a video stream in .webm format. Thank you for any suggestions and help in advance.

Submitted November 23, 2018 at 08:55PM by mrchriswindsor

Consider Top Node Courses to Learn

https://ift.tt/2qVBzb3

Submitted November 23, 2018 at 05:19PM by jhncna

NodeJS - AutoConvert a Folder with CSV files to an output folder for JSON files

I am trying to convert a folder with CSV files to an output folder for JSON files.Basically I am trying to convert CSV to JSON and am stuck with some errors.I have loaded 'fs" and 'path' via npm installer in the command line mode.I found the following NodeJS syntax from stackoverflow and it has the followingerror when I tried to run from the command line: fs.js:675 return binding.read(fd, buffer, offset, length, position);See Code Below:// Node packages for file systemvar fs = require('fs');var path = require('path');var filePath = path.join(__dirname, '/CSV_FOLDER');// Read CSVvar f = fs.readFileSync(filePath, {encoding: 'utf-8'},function(err){console.log(err);});// Split on rowf = f.split("\n");// Get first row for column headersheaders = f.shift().split(",");var json = [];f.forEach(function(d){// Loop through each rowtmp = {}row = d.split(",")for(var i = 0; i < headers.length; i++){tmp[headers[i]] = row[i];}// Add object to listjson.push(tmp);});var outPath = path.join(__dirname, '/JSON_FOLDER');// Convert object to string, write json to filefs.writeFileSync(outPath, JSON.stringify(json), 'utf8',function(err){console.log(err);});​

Submitted November 23, 2018 at 02:44PM by AutoGenModerator

You probably know what's wrong with this code

New to web dev, I'm trying to 'insert' into couchdb an array of tag's. I think I'm probably just not seeing the right 'angle' to tackle this problem. I'm trying to do a function in the app.js post function that takes in the string from the box and replaces the 'tag' section with what I want, but I'm not sure how to return it properly given I can't return it as a full string (i.e. "tag1, tag2, tag3") it has to be strings seperated by commas ("tag1","tag2","tag3"). Can you just point me in the right direction? maybe I should be doing this in the webpage js instead, or is there a cleaner way?​ //working, passing just the value couch.insert('master_db', { //accepts the following properly //tags: ["tag1","tag2","tag3","tag4"] //just takes in the whole thing like a string value (1 tag) tags:[tags]; }) /*couch.insert('master_db', { tags:[(function(tags){ console.log("got here"); console.log(tags); var array = []; var string =""; for (var i = 0; i < tags.length; i++) { if (tags.charAt(i)==","){ array.push(string); string=""; } else{ string=string+tags.charAt(i); } } return array; })] })*/ ​

Submitted November 23, 2018 at 02:23PM by Auklin

Node application manager I've built and keen to get some feedback on

I've built a node application manager which I'm keen to get some feedback on.If you are running several apps locally in your development environment, e.g. Several microservices (auth, search, checkout, etc) and find it difficult opening many tabs in your terminal, having to manually start each one, and then when one crashes having to cycle through each tab trying to find what crashed or searching for errors then this may help.By running all your apps in one parent process, you can run them all in one terminal tab, start them from one command and watch to output for all in the one tab.If this is of any help to you, please check it out and let me know what you think.https://ift.tt/2KthpxU

Submitted November 23, 2018 at 01:16PM by Triptcip

Node.js project to bypass anti-bot pages

I created a Node.js bot to easily scrape those pages protected by JavaScript challenge - like CloudFlare's anti DDoS protection.If you're not using a headless browser like Selenium (Which is a huge overkill for scraping tbh) those challenges are impossible to bypass with regular frameworks (axios, request, etc) and the site can't be accessed.My bot parses and solves them - and presents the HTML of the original protected site.You can check it out here - https://ift.tt/2BsrxUT hope I'll manage to find the time to expand it to handle other anti-bot mechanisms/techniques. Any tips and suggestions are appreciated :)

Submitted November 23, 2018 at 01:11PM by evya135

Using Events In Node.js The Right Way

https://ift.tt/2qs88Nl

Submitted November 23, 2018 at 07:42AM by fagnerbrack

Thursday 22 November 2018

can you auto generate API from database schema with express?

No text found

Submitted November 23, 2018 at 06:26AM by cariaga123

Render one file HTML page with AWS API Gateway+Lambda using node.js with PUG

https://ift.tt/2DPH7MN

Submitted November 22, 2018 at 05:53PM by lysywojtek

Serialism: serialize any JavaScript value to a binary buffer (works with any node version >= v8.13.0)

https://ift.tt/2FD2u5E

Submitted November 22, 2018 at 06:07PM by voodooattack

Node-Opus and trouble installing.

So doing a Discord bot and wanting to add audio streaming from an external source. Unfortunately, i am having trouble installing the package Node-Opus.So my question is, what are the steps i need to do, and in what order do i need to do them in to install Node-Opus?I'm trying to install the peer dependencies but i am currently getting a bunch of errors which are centring around the missing dependencies, even though a couple of them did install. So figuring start again from scratch and ask the amazing people of Reddit.

Submitted November 22, 2018 at 06:46PM by GreatSnowman

Which hosting is better for app made with react.js and node.js?(paid and free)

No text found

Submitted November 22, 2018 at 05:57PM by razmanoa

React Context API and Higher-Order Components – Shems Eddine – Medium

https://ift.tt/2AcX1wq

Submitted November 22, 2018 at 04:02PM by shemseddine

Hosting option for NodeJs app

Its a regular express app with MongoDB. As I have been developing, I have it hosted on Heroku free tier, using mLabs for the db. Now I was told that Heroku may get expensive soon if I plan on scaling the app. So what is a good alternative? AWS, DO or something like Next? I am looking for the most cost-effective one.

Submitted November 22, 2018 at 03:42PM by sioa

Swagger Core Implemented in Node

generate your api docs via types decorators & fluent apiarticle: https://ift.tt/2qYOiJV https://ift.tt/2FCPj4r

Submitted November 22, 2018 at 03:43PM by dearkitect

Creating pdf documents with node

Hi,​I have a letter saved as word document that i currently fill with certain fields for each user i have in my system. I do this manually and then save it as a pdf before sending it in an email.​I am developing a MEAN stack app that can send emails etc and store all the users for my system, and now want to start generating these letters at the backend automatically. The options I have come across so far would be creating pdf or templates using npm Javascript libraries or html. This is fine if i have one doc but if i plan on having more in the future, creating this template for each doc is quite time consuming. Is there a way in node to open a word doc replace place holders and then save as a pdf or something similar, so that i could use word to create templates rather than hard coding templates. (or any other interesting solution for that matter)​Thanks

Submitted November 22, 2018 at 12:35PM by arthurlc1

Node js back end structure.

Hello guys,​I have started learning back end development with node for about 4-5 month, i am kinda intern in the company, my manager hired me to do some CMS front end stuff meanwhile to learn nodejs and become back end developer in the comapany​My manager wants to move all the websites' back end to node in the future, so today he gave me project, to write a structure of websites back end (built in node), that website is currently up and running(i believe it is build mainly with php), so bottom line is i would like get as much information about how to structure node js back end of the website, if anyone can help with any useful information it will be amazing for me.Thank you for attention.

Submitted November 22, 2018 at 12:53PM by Garywil

How to use NodeJS without frameworks and external libraries

https://ift.tt/2SFqbNb

Submitted November 22, 2018 at 11:38AM by fagnerbrack

Wednesday 21 November 2018

How to make Firebase initialization faster?

My app takes 45sec - 1min to connect to firebase. Since, my app is completely online, it is useless unless it has connected. I am talking about this part:firebase.initializeApp(config);Is there any trick or method you guys use to make initialize faster or do I just have bear with it?

Submitted November 22, 2018 at 05:08AM by lcukerd

Hopefully simple question with a hopefully simple answer?

Let me know if this isn't where to post this sorta question!​I've been stuck for a couple hours, and this is kinda Node, kinda just JS related but...​I have 2 classes (class A, and class B) created in my app.js file, what Ideally I want is to have them be able to reference each-other, example:var a = new A();var b = new B();a.relation = b;b.relation = a;Something like this is giving me a Circular reference (as expected) but it's causing node to die because of a RangError.If this is not possible, my second question would be: can I have a variable declared and updated in app.js accessible in different classes? if so, how would I go about this?​Hope I've described what I'm trying to do well enough!​

Submitted November 22, 2018 at 03:29AM by lommaz

Parellel processing

Can some one provide a good resource to understand parallel processing in node. I found Napa but I don't understand it yet my problem statement is that I need to insert 1300000 records into mysql db and this is taking too long,my approach is to make an array of promises and use promise.all to execute them so I want to distribute this process across my 4 cores machine any suggestions are welcome. Thanks in advance...

Submitted November 22, 2018 at 01:54AM by BhargavMantha

Web app running into issues when multiple users upload files at the same time

I am quite new to node/javascript in general and I have an issue with my angular app that has the traditional client and server running on nginx. There's an authentication functionality that requires users to log in. Separate users can use the app to upload files, extract the data, store that information in a local sql database using sequelize, and then update the processed data in an AS400 database using odbc drivers.The problem comes up when the users hit the submit and confirm buttons on upload at the same time. As the processing of each request by the server can take up to a minute, different users uploading at the same time can cause the app to crash, suddenly returning partial results or undefined errors from null array values. I am not sure where the problem is because I tracked the progress of the data through the app's async/await functions and it stops in the back end, with arrays full of data objects suddenly being reset to empty.Could this because the app is not using object instances? Here is how I reference the document-upload.js file:const uploadHelper = require('./document-upload'); Here is how I call the methods in that file:await uploadHelper.processFile(file.path); const batches = await uploadHelper.getBatches(user, file); Would a possible fix to this be to create multiple object instances of the uploadHelper so that there's no interference between different users? Or is this an issue elsewhere?

Submitted November 21, 2018 at 04:53PM by dealin92

Understanding Memoization in JavaScript to Improve Performance

https://ift.tt/2zkTBb2

Submitted November 21, 2018 at 04:06PM by JSislife

This is why coupling is your worst enemy

https://ift.tt/2OVVzne

Submitted November 21, 2018 at 09:18AM by kiarash-irandoust

Tuesday 20 November 2018

Simple tutorial/example for creating a monthly subscription with Stripe and Node?

Hi! I'm trying to integrate Stripe into my app, I want my users to be able to subscribe to $10/mo plan. Can you recommend a good example or a tutorial that will walk me through the entire process?I want to make sure I won't miss anything, use the best practices, store all the right information I need in the future, handle errors and edge cases, etc.Also I'm not sure how to deal with this in my User model - what would be the right way to store user's payment plan, which information that stripe returns I need to save(customer id? Subscription id?), etc.I suspect that it shouldn't be very difficult, I'll figure it out eventually, but a good guide would still be very helpful.Maybe you can link to some open source project that handles this well?

Submitted November 21, 2018 at 06:23AM by raymestalez

November 2018 Security Releases

https://ift.tt/2qWj4Dn

Submitted November 21, 2018 at 01:35AM by dwaxe

Should I do internship in Ruby on Rails instead of Mean Stack for 6 months?

So I bagged internships in Full Stack Developer role at 2 startups.The first startup has an enterprise SaaS product. My work is going to be on Ruby, RoR, ReactJs, Nodejs, Scripting (on Python, Bash), PostgreSQL, Linux (Admin commands, user, process and memory management, shell scripting, sed, awk), AWS and web server. They are paying me $285 (I will save just $140 as it's in a better city, 3 hours away from my home).The second startup has a small e-commerce website and they also work on building websites acc to clients needs. So acc to the client requirements, they will make me work on any javascript framework, any css framework, any php framework, any database and linux. They are paying me $150 (and it's in my home city itself).I am very confused. Please help. The stipend is not really an issue for me. I just want to choose what will be better for my future and career.

Submitted November 20, 2018 at 07:09PM by Rkpandey123

Node v8.13.0 (LTS)

https://ift.tt/2DOVeli

Submitted November 20, 2018 at 07:09PM by dwaxe

The node_modules problem

https://ift.tt/2zgytD6

Submitted November 20, 2018 at 05:53PM by etca2z

create-yo, a little thing to use Yeoman generators from 'npm init'

https://ift.tt/2S1f3sA

Submitted November 20, 2018 at 05:23PM by boneskull

Springboot Web App on NodeJS

Hi all,I'm confused. I've developed a Springboot web application which I have no problem to run on my own workstation. However, I am unable to deploy it to the hosting service I bought (it uses DirectAdmin Panel). As far as I know, I should be able to deploy it as .war in Tomcat but was unsuccessful to do so (as my hosting does not have Tomcat installed (I guess?)). I've also tried to use this method but it did not work too.I asked my admin why it was not working and he replied that he has now installed nodeJS and I should not have any problems deploying it now, I just need to configure it.What I don't understand is how NodeJS stand in all this situation and how the hell should I deploy my JAVA app in NodeJS?I do understand that I am missing something somewhere but I fail to understand WHAT exactly.

Submitted November 20, 2018 at 04:10PM by murziusrokas

A boilerplate for Users database operations for beginners and lazy people

https://ift.tt/2QcQyeI

Submitted November 20, 2018 at 12:54PM by mehmetegemen

The Complete Node.js Developer Course (2nd Edition) Now Black Friday Deals 88% off

https://ift.tt/2S1TEje

Submitted November 20, 2018 at 11:19AM by GayleneGrande

10 Reasons that Make Node.js a Top Choice for Web Application Development, Every Developers Should Know

https://ift.tt/2InSHgh

Submitted November 20, 2018 at 08:57AM by mydevskills

Choosing process manager

Hello I am looking for a process manager for laravel-echo-server (NodeJs server for Laravel Echo broadcasting with Socket.io). I need process manager to track crashes bugs, keep process alive. But it is the only process I will be monitoring and I don't think I need much functionality, crash and events logs and maybe emails for crashes. I need an free program for this. Currently taking into consideration pm2 (runtime version, is it free for non open source projects too?), forever and supervisord (process control system for unix). Which one would you recommend?

Submitted November 20, 2018 at 08:09AM by zerociudo

Build and Host a Customizable Status Page in Under 10 Minutes with Standard Library Node.js

https://ift.tt/2DQDExa

Submitted November 20, 2018 at 08:15AM by notoriaga

Monday 19 November 2018

Node servers?

I'm looking into NodeJS servers, and am used to Linux, but am not sure it is the best thing to host Node with.https://ift.tt/2OPC6EU you state what server you use and how it was for you?

Submitted November 20, 2018 at 02:18AM by redskydav

How to Render Two SQL Queries

I am very new to Node and am having trouble trying to get the results of two different queries and rendering them to a view. I'm able to get the results of the first query and display it in my View but I don't know how to get the results of the second query to display in the view.JS filefunction getData(callback) {new sql.ConnectionPool(config).connect().then(pool => {return pool.request().query("select Name from Items")}).then(result => {console.log('This is the recordset ' + result.recordset);callback(result.recordset);sql.close();}).catch(err => {res.status(500).send({ message: "${err}" })sql.close();});​new sql.ConnectionPool(config).connect().then(pool => {return pool.request().query("select Code from Customers")}).then(result => {console.log('This is the recordset for Terms ' + result.recordset);callback(result.recordset);sql.close();}).catch(err => {res.status(500).send({ message: "${err}" })sql.close();});}//add routeapp.get('/add', function (req, res) {getData(function (itemData) {res.render('add_item', {title: 'Add Item',items: itemData});});});​PUG Fileextends layout​block contentform(method='POST', action='/add')#form-group.rowdiv.col-sm-12label.lbl-form Chain:select.form-controleach item in itemsoption(value= item.Name)= item.Name#form-group.rowdiv.col-sm-6label.lbl-form Termsselect.form-controleach customer in customersoption(value= customer.Name)= customer.Name​​​

Submitted November 19, 2018 at 08:40PM by crashBandicoot61

How to fix "Module Compiled in a Different Version of Node" error

When you get an error message from a module like:[YOUR MODULE] was compiled against a different Node.js version using NODE_MODULE_VERSION 57. This version of Node.js requires NODE_MODULE_VERSION 64. Please try re-compiling or re-installing [ETC.]....Do you just have to wait for the moderator to upgrade the package to be compatible, or is there a way to make it compatible on your end? (I've tried npm reinstall and npm rebuild like suggested, but no dice)Specifically, I'm troubleshooting for font-manager. Thanks!

Submitted November 19, 2018 at 07:56PM by justin2taylor

Need some help.

I'm working on an API and am hitting a stumbling block. I can find individual items in my database by ID and I can select all items, but I need to find all items with a specific identifier.My find all is structured like so :findAll() {let sqlRequest = "SELECT * FROM item";return this.common.findAll(sqlRequest).then(rows => {let items = [];for (const row of rows) {items.push(new Item(row.id, row.name, row.quantity, row.bin));}return items;});};My find by id:findById(id) {let sqlRequest = "SELECT id, name, quantity, bin FROM item WHERE id=$id";let sqlParams = {$id: id};return this.common.findOne(sqlRequest, sqlParams).then(row =>new Item(row.id, row.name, row.quantity, row.bin));};​But what I am looking for is to find all items that have the same bin. Any help would be greatly appreciated.

Submitted November 19, 2018 at 05:57PM by gwizard202q

Nodejs C++/JS Boundary: Crossing The Rubicon

https://ift.tt/2qW0smY

Submitted November 19, 2018 at 04:17PM by JSislife

autoComplete.js - Pure Vanilla Javascript library

https://ift.tt/2qSp0go is an easy-to-use pure vanilla Javascript library that's built for speed, high versatility and seamless integration with wide range of projects & systems.Please feel free to try it and let me know your thoughts.

Submitted November 19, 2018 at 03:38PM by TarekRaafat

Is this the correct way of doing AWS Lambda with Nodejs ?

For a big open source Terraform Module which serves as a module to simply deploy dockerized services to AWS, I've written a helper AWS Lambda in Nodejs. I've chosen Node as it's lightweight and it's important that it's readable to as many as people possible.You can find it here: https://ift.tt/2DNannd tested the logic, and it works fine, the problem however is that it looks like a script, and I'm guessing this can be done better.

Submitted November 19, 2018 at 02:19PM by _Maarten_

An infographics case-study on why node js is best for eCommerce platform development.

https://ift.tt/2MKHVDh

Submitted November 19, 2018 at 12:50PM by Shopymaniajess

Why Using reduce() to Sequentially Resolve Promises Works

https://ift.tt/2pYy7vB

Submitted November 19, 2018 at 01:11PM by fagnerbrack

People who hate ORMs or builders such as knex, how do you automate database migrations on a production server?

Seems to me that managing migrations and having them in source control is one of knex's best features while still letting the user use raw queries if needed. A simpleknex migrate:latest can then update your schema painlessly on your production server. How do you guys do it if you don't use this?

Submitted November 19, 2018 at 11:09AM by Nephelophyte

How do you bake security into your dev process?

We're planning how to make our overall dev *process secured. Not looking to mitigate specific/common risks rather how to mind security during our *ongoing development. For example, we thought to have monthly threat analysis meeting. Maybe bake some tools into our CI. Anything that is NOT a one-time shot. Ideas?

Submitted November 19, 2018 at 10:23AM by poothebear0

Node Js with angular front end, best way to integrate file uploads and downloads

Hi​I have a process where i receive a set of documents on an sftp, server and then move them into my internal filesystem and log them in excel. This is time consuming. I have been developing a system to streamline this whereby I receive a list of the documents received and put that through my system which will log the documents in a database and then automatically move the documents from this sftp server to cloud storage. I am not really sure what the best cloud system to use is. I do not really like S3's node SDK but it seems like the most commonly used system. I am also not sure how to go about moving files from the sftp server to S3. Would be looking for some ideas on how to best implement the flow of files from the sftp to a cloud provider. I will need to be able to download the files at a later date.​Thanks

Submitted November 19, 2018 at 10:43AM by arthurlc1

Sunday 18 November 2018

Looking for a (non tutorial) api that does tests well.

Hai there!So this weekend I have been digging my teeth into tests for an api, good stuff right?Well mostly. It seems as though every tutorial in existence has all the routes in the index.js and uses mongoose instead of the native mongodb driver.So do you know of any open source api that has:Good tests in it.Splits routes across different files and imports them into the main index.jsDoes not use mongoose (optional, I can probally work around this)If you want to see where I am coming from my (ongoing) project is here

Submitted November 19, 2018 at 05:14AM by Silveress_Golden

Setting up a personal command-line 'app generator' like with Express, Vue etc.

StreamDemux – An alternative to using EventEmitter and listener callbacks

https://ift.tt/2DPo8lk

Submitted November 19, 2018 at 01:29AM by jonpress

Question. Handle one event at a time.

So, lets say I have an event with a bunch of listeners. But among those there is one special - it is async, and, if this event is fired while previous special listeners are still not finished, I want it to wait for that previous listeners to resolve. So, these listeners can only work one after another. In the end, I came up with this thing:function queueify(handler) { handler.queue = []; handler.locked = false; async function dummy(...args) { handler.queue.push(args) if(handler.locked) return; else { handler.locked = true; while(handler.queue.length) { args = handler.queue.shift(); await handler(...args) } handler.locked = false; } } return dummy; } While it works, it looks over-complicated, I am sure there is a better way to do my task.

Submitted November 18, 2018 at 10:22PM by Haalonean

Node.js clustering

I'm starting to work with node.js, so have a few general technical questions about the clustering.What I understand is that a Node.js instance uses one CPU core. This means that I can start 8 instances of the same Node.js application on a computer with 8 core CPU, correct?That means if I want to start more than 8 instances I need another computer?How much HTTP request can a single node.js instance handle very roughly?If I do not use a monolith but a microservice system with about 100 microservices, could I only start 8 microservices per computer?If I start each Microservice in its own Docker container I could start any number of services on a computer (depending on the available resources) or are the containers also bound to the number of CPU cores?​Thanks for your help

Submitted November 18, 2018 at 06:41PM by xBlackShad0w

Facebook bot -> less harmful way how to leave fb for good.

Hi, I am trying to find out if somebody has build fb bot which does 3 things.auto replay to your private messages in your name.auto forward messages to either email or other form where you are reachableautomatically sends you an email what is happening this week in the city.if somebody did something like that please share, also any information is much appreciated.So far, I have found this github repo. https://ift.tt/264l3TY

Submitted November 18, 2018 at 05:33PM by danielstaleiny

Good book for Machine Learning with Node.js

Can anybody tell me or recommend me books for getting started with machine learning with Node.js? Video Tutorials will also be helpful.

Submitted November 18, 2018 at 01:28PM by psykes1414

help with twilio and ocr.space api. I got twilio to receive the mms from a number but i can't forward the picture to ocr.space

hello guys, How do I "forward" the picture from twilio to the ocr.api then return the extracted text back to twilio phone number as sms.const fs = require('fs'); const express = require('express'); const bodyParser = require('body-parser'); const twilio = require('twilio'); const request = require('request'); const ocrSpaceApi = require('ocr-space-api'); const MessagingResponse = require('twilio').twiml.MessagingResponse;const app = express();app.use(bodyParser.urlencoded({ extended: false }));//ttps://https://ift.tt/2A2GGKE var options = { apikey: 'xxxxxxxxxxxxxxx', language: 'eng', // English imageFormat: 'image/png', // Image Type (Only png ou gif is acceptable at the moment i wrote this) isOverlayRequired: true };app.post('/sms', (req, res) => { const twiml = new MessagingResponse();if (req.body.NumMedia !== '0') { const filename = ${req.body.MessageSid}.png; const url = req.body.MediaUrl0;// Download the image. //const imageFilePath = "imageFile.jpg"; ocrSpaceApi.parseImageFromLocalFile('url', options) //passing the image from twilio text .then(function (parsedResult) { console.log('parsedText: \n', parsedResult.parsedText); console.log('ocrParsedResult: \n', parsedResult.ocrParsedResult); }).catch(function (err) { console.log('ERROR:', err); twiml.message('Thanks for the image!'); } else { twiml.message('Try sending a picture message.'); }res.send(twiml.toString()); });app.listen(3000, () => console.log('Example app listening on port 3000!'));

Submitted November 18, 2018 at 08:14AM by teddyoliver

Saturday 17 November 2018

WebSockets - A Conceptual Deep-Dive

https://ift.tt/2CEXGtd

Submitted November 18, 2018 at 05:58AM by fagnerbrack

Structuring a Class for a third party API with Node.js/ES6?

Hey guys, I'm trying to restructure a small app I'm building. I'm using Spotify's API and at the moment I have all my logic in one file and just creating the routes there. I want to create a class for SpotifyClient and another class for my server but I'm unsure how to go on about this. I have these two routes specifically for Spotify Authorization that I want to remove and put into a class:app.get('/login', (req, res) => { const state = generateRandomString(16); res.cookie(STATE_KEY, state); res.redirect(spotifyApi.createAuthorizeURL(scopes, state)); }); app.get('/callback', (req, res) => { const { code, state } = req.query; const storedState = req.cookies ? req.cookies[STATE_KEY] : null; if (state === null || state !== storedState) { res.redirect('/#/error/state mismatch'); } else { res.clearCookie(STATE_KEY); spotifyApi .authorizationCodeGrant(code) .then(data => { const expiresIn = data.body.expires_in; const accessToken = data.body.access_token; const refreshToken = data.body.refresh_token; // Set the access token on the API object to use it in later calls SPOTIFY_TOKEN = accessToken; spotifyApi.setAccessToken(accessToken); spotifyApi.setRefreshToken(refreshToken); spotifyApi.getMe().then(({ body }) => { SPOTIFY_ID = body.id; }); res.redirect('/search'); }) .catch(err => { res.redirect('/#/error/invalid token'); }); } }); I have my API keys that I export as environment variables and store them in an object in a config.js file.So starting out, would be somehting like this:const config = require('./config'); class SpotifyClient { } But would I pass the keys in my constructor? How would I set up the routes? Should they just be class methods?Any advice would be appreciated!

Submitted November 17, 2018 at 11:56PM by RubyNewbie-

Storing user ID in a JSON web token's payload. Should the middleware function send it in req, or req.body?

I made a middleware function that validates a user's JWT. In the case that it's valid, it stores the user's ID in req and calls next() to handle the desired request.My question: Is it ok for the middleware function to store the ID in req.body, or should it only be in req?

Submitted November 17, 2018 at 09:55PM by v_95

I need a freelancer to take a look at my node app. I just want make sure it is efficient and secure, so I can deploy it to gcp

I forgot to mention, it uses mysql.DM me if you're interested

Submitted November 17, 2018 at 10:26PM by smiles_low

Limitrr: Better Express Rate Limiting. 3.0 Released.

https://ift.tt/2z4GzOV

Submitted November 17, 2018 at 08:22PM by m1screant

A basic terminal interface for git, written on Node.js

https://ift.tt/2QbvDsN

Submitted November 17, 2018 at 06:01PM by vaheqelyan

GitHub - joeattardi/node-profiler-report: Generate an HTML report from the data processed by Node's profiler

https://ift.tt/2A48i1J

Submitted November 17, 2018 at 06:02PM by thinksInCode

Inmemory-like database in Nest

I've started learning Nest recently and I've come up with a simple game based on websockets and there's a problem that I have to face now.There is A service that handles every fetch API requests with room creation etc. and then there is websocket gateway that handles the room on anything that requires data-sharing between players.So I need to access the same data structure that I've implemented for Room and that is an array. I'm not using any database.What I did was create state folder with state.module and state.service that handles everything that can be done with the room so like - creation, updating, new player etc. This state.service is then exported and imported in socket.module and room.module and injected (using Inject) into socket.gateway and room.service. This way I can access every method I've created in state and manage it accordingly. I was kinda okay with this but while rereading docs and hearing my colleague saying that it is not quite it and I'm not sure what should I do.Is it okay to leave it as it is or should I change it?

Submitted November 17, 2018 at 02:12PM by Azztyn

File Uploading using Cloudinary( Complete Workflow)

https://ift.tt/2OMfhC5

Submitted November 17, 2018 at 12:07PM by kiarash-irandoust

Nodejs tunnel-ssh

So i have two servers my mongodb is on "server 2" and my nodejs website is on "server 1" my goal is to connect nodejs to mongodbWhat do i put in these fields i can't figure out..var config = {agent : process.env.SSH_AUTH_SOCK,username:'',host: '',port: ,privateKey: require('fs').readFileSync('./id_rsa.pub'),password: ''dstHost: '',dstPort: ,localHost:'',localPort:};

Submitted November 17, 2018 at 12:53PM by marciusx1

Server side JSX view engine

Announcing Vertex a server side JSX view engine, production ready and supports partial views.you have no limit since in JSX you are using your JavaScript ninja at the end.https://ift.tt/2ONqn9D

Submitted November 17, 2018 at 10:57AM by amd__

Anybody able to help? I'm really desperate at this point

https://ift.tt/2FtZ8BX

Submitted November 17, 2018 at 08:49AM by merkur0

Friday 16 November 2018

Email verification strategy with Node?

Would this be an OK way to implement email verification?​1) Upon user registration, the user is created in the database with a field "verified" set to value "false". Another field "confKey" with a random string/hash as the value is also created in the user model.2) A message containing a link to an endpoint for email verification is sent to the user's email address3) That link contains a param which is the same random string/hash as the "confKey" in that user's data in the db.4) The endpoint compares the param to confKey and if they are equal, sets "verified" to "true".5) Endpoints that require a verified email check that "verified" is true before executing.​Does this logic make sense? Anything I'm missing here? Security vulnerabilities doing it this way?

Submitted November 17, 2018 at 05:45AM by ibrahimpg

Help with request-promises library, even endless googling has not helped me

I've been at this problem for at least a hour now. I am using the library https://ift.tt/1E2kbo6. My code is;const rp = require('request-promise'); rp("https://www.google.com/") .then(function (response){ console.log(response) }) .catch(function (err) { console.log(err) }); But I keep getting the error:{ RequestError: Error: tunneling socket could not be established, cause=getaddrinfo ENOTFOUND 8888 8888:80 at new RequestError (C:\Users\HellD\Documents\Testing\playnode\makeRequests\node_modules\request-promise-core\lib\errors.js:14:15) at Request.plumbing.callback (C:\Users\HellD\Documents\Testing\playnode\makeRequests\node_modules\request-promise-core\lib\plumbing.js:87:29) at Request.RP$callback [as _callback] (C:\Users\HellD\Documents\Testing\playnode\makeRequests\node_modules\request-promise-core\lib\plumbing.js:46:31) at self.callback (C:\Users\HellD\Documents\Testing\playnode\makeRequests\node_modules\request\request.js:185:22) at emitOne (events.js:116:13) at Request.emit (events.js:211:7) at Request.onRequestError (C:\Users\HellD\Documents\Testing\playnode\makeRequests\node_modules\request\request.js:881:8) at emitOne (events.js:116:13) at ClientRequest.emit (events.js:211:7) at ClientRequest.onError (C:\Users\HellD\Documents\Testing\playnode\makeRequests\node_modules\tunnel-agent\index.js:179:21) at Object.onceWrapper (events.js:315:30) at emitOne (events.js:116:13) at ClientRequest.emit (events.js:211:7) at Socket.socketErrorListener (_http_client.js:387:9) at emitOne (events.js:116:13) at Socket.emit (events.js:211:7) at emitErrorNT (internal/streams/destroy.js:64:8) at _combinedTickCallback (internal/process/next_tick.js:138:11) at process._tickCallback (internal/process/next_tick.js:180:9) name: 'RequestError', message: 'Error: tunneling socket could not be established, cause=getaddrinfo ENOTFOUND 8888 8888:80', cause: { Error: tunneling socket could not be established, cause=getaddrinfo ENOTFOUND 8888 8888:80 at ClientRequest.onError (C:\Users\HellD\Documents\Testing\playnode\makeRequests\node_modules\tunnel-agent\index.js:177:17) at Object.onceWrapper (events.js:315:30) at emitOne (events.js:116:13) at ClientRequest.emit (events.js:211:7) at Socket.socketErrorListener (_http_client.js:387:9) at emitOne (events.js:116:13) at Socket.emit (events.js:211:7) at emitErrorNT (internal/streams/destroy.js:64:8) at _combinedTickCallback (internal/process/next_tick.js:138:11) at process._tickCallback (internal/process/next_tick.js:180:9) code: 'ECONNRESET' }, error: { Error: tunneling socket could not be established, cause=getaddrinfo ENOTFOUND 8888 8888:80 at ClientRequest.onError (C:\Users\HellD\Documents\Testing\playnode\makeRequests\node_modules\tunnel-agent\index.js:177:17) at Object.onceWrapper (events.js:315:30) at emitOne (events.js:116:13) at ClientRequest.emit (events.js:211:7) at Socket.socketErrorListener (_http_client.js:387:9) at emitOne (events.js:116:13) at Socket.emit (events.js:211:7) at emitErrorNT (internal/streams/destroy.js:64:8) at _combinedTickCallback (internal/process/next_tick.js:138:11) at process._tickCallback (internal/process/next_tick.js:180:9) code: 'ECONNRESET' }, options: { uri: 'https://www.google.com/', callback: [Function: RP$callback], transform: undefined, simple: true, resolveWithFullResponse: false, transform2xxOnly: false }, response: undefined } ​

Submitted November 17, 2018 at 05:10AM by HellD

Detecting backspace in socket data (without key events; \b isn't working)

I'm writing a telnet server and I want to detect backspace without the client-user needing to configure their telnet app.The script handling keypresses and acting on data, receives the keypresses via net socket in realtime. So when the user makes a typo and then presses backspace, I'm trying this:else if (data.indexOf("\b") != -1 || data.indexOf("\u2408") != -1 || data.indexOf("\u0008") != -1) { // handle backspace console.log("Backspace detected"); this.currentInput = this.currentInput.substring(0, this.currentInput.length - 1); } There's gotta be a way to do this without access to key events, right?EDIT: updated source and added this note: the console.log("Backspace detected") never happens, but also the test data contains no garbage characters; just the typo plus the correction. E.g. if I type tesd(backspace)t into the terminal and hit enter, the server receives tesdt.EDIT: updated source again, still no luckEDIT: the data isn't being manipulated: this.socket.on('data', (data) => { this.onSocketData(data); });

Submitted November 16, 2018 at 11:46PM by poor-toy-soul-doll

JavaScript API for face detection and face recognition in the browser implemented on top of the tensorflow.js core API

https://ift.tt/2OwrryL

Submitted November 16, 2018 at 10:50PM by fagnerbrack

I'm a beginner, and I need some help

Hey guys, I'm a front end developer (html/css/js mainly), and I wanted to dive into node/angular. I started a new project, and wanted to play around with the Destiny 2 API. I found a npm package that is apparently a wrapper for the Destiny 2 API called the-traveler.So in my new project, I went to app.component.ts and pasted in the import/const:import Traveler from 'the-traveler';import { ComponentType } from 'the-traveler/build/enums';const traveler = new Traveler({    apikey: 'pasteYourAPIkey',    userAgent: 'yourUserAgent', //used to identify your request to the API});I do have an API key, but I'm not sure what goes in user agent, so I tried a few things - didn't seem to get any errors caused by that (that I know of).I then served the application and opened it, but I got the error that it failed to compile, along with all of these errors:ERROR in ./node_modules/aws-sign2/index.jsModule not found: Error: Can't resolve 'crypto' in 'D:\Drift\Code\testiny\node_modules\aws-sign2'ERROR in ./node_modules/aws4/aws4.jsModule not found: Error: Can't resolve 'crypto' in 'D:\Drift\Code\testiny\node_modules\aws4'ERROR in ./node_modules/ecc-jsbn/index.jsModule not found: Error: Can't resolve 'crypto' in 'D:\Drift\Code\testiny\node_modules\ecc-jsbn'ERROR in ./node_modules/http-signature/lib/signer.jsModule not found: Error: Can't resolve 'crypto' in 'D:\Drift\Code\testiny\node_modules\http-signature\lib'ERROR in ./node_modules/http-signature/lib/verify.jsModule not found: Error: Can't resolve 'crypto' in 'D:\Drift\Code\testiny\node_modules\http-signature\lib'ERROR in ./node_modules/oauth-sign/index.jsModule not found: Error: Can't resolve 'crypto' in 'D:\Drift\Code\testiny\node_modules\oauth-sign'ERROR in ./node_modules/request/lib/oauth.jsModule not found: Error: Can't resolve 'crypto' in 'D:\Drift\Code\testiny\node_modules\request\lib'ERROR in ./node_modules/request/lib/helpers.jsModule not found: Error: Can't resolve 'crypto' in 'D:\Drift\Code\testiny\node_modules\request\lib'ERROR in ./node_modules/request/lib/hawk.jsModule not found: Error: Can't resolve 'crypto' in 'D:\Drift\Code\testiny\node_modules\request\lib'ERROR in ./node_modules/sshpk/lib/dhe.jsModule not found: Error: Can't resolve 'crypto' in 'D:\Drift\Code\testiny\node_modules\sshpk\lib'ERROR in ./node_modules/sshpk/lib/identity.jsModule not found: Error: Can't resolve 'crypto' in 'D:\Drift\Code\testiny\node_modules\sshpk\lib'ERROR in ./node_modules/sshpk/lib/certificate.jsModule not found: Error: Can't resolve 'crypto' in 'D:\Drift\Code\testiny\node_modules\sshpk\lib'ERROR in ./node_modules/sshpk/lib/private-key.jsModule not found: Error: Can't resolve 'crypto' in 'D:\Drift\Code\testiny\node_modules\sshpk\lib'ERROR in ./node_modules/sshpk/lib/key.jsModule not found: Error: Can't resolve 'crypto' in 'D:\Drift\Code\testiny\node_modules\sshpk\lib'ERROR in ./node_modules/sshpk/lib/utils.jsModule not found: Error: Can't resolve 'crypto' in 'D:\Drift\Code\testiny\node_modules\sshpk\lib'ERROR in ./node_modules/sshpk/lib/fingerprint.jsModule not found: Error: Can't resolve 'crypto' in 'D:\Drift\Code\testiny\node_modules\sshpk\lib'ERROR in ./node_modules/sshpk/lib/signature.jsModule not found: Error: Can't resolve 'crypto' in 'D:\Drift\Code\testiny\node_modules\sshpk\lib'ERROR in ./node_modules/sshpk/lib/formats/pem.jsModule not found: Error: Can't resolve 'crypto' in 'D:\Drift\Code\testiny\node_modules\sshpk\lib\formats'ERROR in ./node_modules/sshpk/lib/formats/ssh-private.jsModule not found: Error: Can't resolve 'crypto' in 'D:\Drift\Code\testiny\node_modules\sshpk\lib\formats'ERROR in ./node_modules/sshpk/lib/formats/openssh-cert.jsModule not found: Error: Can't resolve 'crypto' in 'D:\Drift\Code\testiny\node_modules\sshpk\lib\formats'ERROR in ./node_modules/node-stream-zip/node_stream_zip.jsModule not found: Error: Can't resolve 'fs' in 'D:\Drift\Code\testiny\node_modules\node-stream-zip'ERROR in ./node_modules/request/lib/har.jsModule not found: Error: Can't resolve 'fs' in 'D:\Drift\Code\testiny\node_modules\request\lib'ERROR in ./node_modules/the-traveler/build/Traveler.jsModule not found: Error: Can't resolve 'fs' in 'D:\Drift\Code\testiny\node_modules\the-traveler\build'ERROR in ./node_modules/forever-agent/index.jsModule not found: Error: Can't resolve 'http' in 'D:\Drift\Code\testiny\node_modules\forever-agent'ERROR in ./node_modules/http-signature/lib/signer.jsModule not found: Error: Can't resolve 'http' in 'D:\Drift\Code\testiny\node_modules\http-signature\lib'ERROR in ./node_modules/request/request.jsModule not found: Error: Can't resolve 'http' in 'D:\Drift\Code\testiny\node_modules\request'ERROR in ./node_modules/tunnel-agent/index.jsModule not found: Error: Can't resolve 'http' in 'D:\Drift\Code\testiny\node_modules\tunnel-agent'ERROR in ./node_modules/forever-agent/index.jsModule not found: Error: Can't resolve 'https' in 'D:\Drift\Code\testiny\node_modules\forever-agent'ERROR in ./node_modules/request/request.jsModule not found: Error: Can't resolve 'https' in 'D:\Drift\Code\testiny\node_modules\request'ERROR in ./node_modules/tunnel-agent/index.jsModule not found: Error: Can't resolve 'https' in 'D:\Drift\Code\testiny\node_modules\tunnel-agent'ERROR in ./node_modules/forever-agent/index.jsModule not found: Error: Can't resolve 'net' in 'D:\Drift\Code\testiny\node_modules\forever-agent'ERROR in ./node_modules/tough-cookie/lib/cookie.jsModule not found: Error: Can't resolve 'net' in 'D:\Drift\Code\testiny\node_modules\tough-cookie\lib'ERROR in ./node_modules/tunnel-agent/index.jsModule not found: Error: Can't resolve 'net' in 'D:\Drift\Code\testiny\node_modules\tunnel-agent'ERROR in ./node_modules/mime-types/index.jsModule not found: Error: Can't resolve 'path' in 'D:\Drift\Code\testiny\node_modules\mime-types'ERROR in ./node_modules/node-stream-zip/node_stream_zip.jsModule not found: Error: Can't resolve 'path' in 'D:\Drift\Code\testiny\node_modules\node-stream-zip'ERROR in ./node_modules/assert-plus/assert.jsModule not found: Error: Can't resolve 'stream' in 'D:\Drift\Code\testiny\node_modules\assert-plus'ERROR in ./node_modules/combined-stream/lib/combined_stream.jsModule not found: Error: Can't resolve 'stream' in 'D:\Drift\Code\testiny\node_modules\combined-stream\lib'ERROR in ./node_modules/delayed-stream/lib/delayed_stream.jsModule not found: Error: Can't resolve 'stream' in 'D:\Drift\Code\testiny\node_modules\delayed-stream\lib'ERROR in ./node_modules/isstream/isstream.jsModule not found: Error: Can't resolve 'stream' in 'D:\Drift\Code\testiny\node_modules\isstream'ERROR in ./node_modules/node-stream-zip/node_stream_zip.jsModule not found: Error: Can't resolve 'stream' in 'D:\Drift\Code\testiny\node_modules\node-stream-zip'ERROR in ./node_modules/request/request.jsModule not found: Error: Can't resolve 'stream' in 'D:\Drift\Code\testiny\node_modules\request'ERROR in ./node_modules/sshpk/lib/ed-compat.jsModule not found: Error: Can't resolve 'stream' in 'D:\Drift\Code\testiny\node_modules\sshpk\lib'ERROR in ./node_modules/forever-agent/index.jsModule not found: Error: Can't resolve 'tls' in 'D:\Drift\Code\testiny\node_modules\forever-agent'ERROR in ./node_modules/tunnel-agent/index.jsModule not found: Error: Can't resolve 'tls' in 'D:\Drift\Code\testiny\node_modules\tunnel-agent'ERROR in ./node_modules/node-stream-zip/node_stream_zip.jsModule not found: Error: Can't resolve 'zlib' in 'D:\Drift\Code\testiny\node_modules\node-stream-zip'ERROR in ./node_modules/request/request.jsModule not found: Error: Can't resolve 'zlib' in 'D:\Drift\Code\testiny\node_modules\request'I've tried a few other destiny api wrappers and they are all giving me the same errors, so I'm just assuming I'm putting the code in the wrong place lol.I'm using the most up to date versions of everything as well fyi. Any help would be greatly appreciated.

Submitted November 16, 2018 at 08:57PM by cozyrobinson

What is the scalable approach for executing post tasks regarding on specific operation?

I'm working on B2B microservice platform. The scenario is to buying and sell product from one business to another business, I meant not a person to business like e-commerce. When one business order product from another business I've to send invoice over email, mobile SMS, push notification etc to both buyer and seller business employees (each business can have multiple employees).So what I'm doing now, when an order created I'm fetching employee information related both buyer and seller business from another service by API call and calling another service over API to send the invoice over sms email etc based on user preference. same for update the order.when demand increases as it's the basic feature of this platform sometime seems it slows down the ordering process. Here I'm using expressjs , mongodb in backend on ubuntu VM.Should I use any message-broker to handle those task? or another worker (child) process to handle them? whats your suggestion and how should I go forward?

Submitted November 16, 2018 at 09:33PM by osmangoninahid