Sunday 30 April 2017

Saturday 29 April 2017

pkg: Package your Node.js project into an executable

http://ift.tt/2pJcVLV

Submitted April 29, 2017 at 07:25PM by _schickling

Is there anyway to use the forever daemon with a react app that starts via npm start?

No text found

Submitted April 29, 2017 at 06:54PM by judoka24

Looks like 'Node.js the Right Way' will have a new edition

http://ift.tt/2qqgwuF

Submitted April 29, 2017 at 05:35PM by vangelov

Help with pug views in koa

Anybody use pug views with koa ? if so can u help me with this http://ift.tt/2qi11Wv

Submitted April 29, 2017 at 01:31PM by furball514

How does cmd find npm if its executable file is not included in the environment variables?

No text found

Submitted April 29, 2017 at 01:49PM by moring1

I am having this issue when log in a user in Node.js and Mongodb app I am working.

http://ift.tt/2oSd4rM

Submitted April 29, 2017 at 12:21PM by simplicius_

Friday 28 April 2017

How is Nodejs for: web scraping thousands/millions of pages for data (i.e. scraping Amazon product pages).

A hypothetical:What if you wanted to scrap Amazon product pages for various pieces of data (product info, ratings, etc...), and you wanted to do this on a large scale (thousands/millions of products), how well equipped is Node.js at handling such a task?I know it can technically be done, but is it wise to use Node.js for such a task? I ask because I've read elsewhere that, for the project I'm describing, it would be better to use something like Python.

Submitted April 29, 2017 at 07:03AM by MonkeyOnARock1

5 reasons Node.js rules for complex integrations

http://ift.tt/2p0p8bK

Submitted April 29, 2017 at 06:19AM by nezeasnd

How to send response to client from form method=post

html
server app.post("/soandso", function(req, resp) { console.log(req.body.lalala); resp.send("success"); } In my .js, how do I get the response?

Submitted April 29, 2017 at 12:33AM by eggtart_prince

Unable to create HTTP GET request to heroku app with NodeJS. Is there something bad with my request?

I am trying to get a request from a heroku link using Node, but I don't know what in my code. The code in question is belowvar http = require('http'); var keepAlive = new http.Agent({ keepAlive: true }); var options = { hostname: 'http://ift.tt/1LYDP5Y', port: 443, path: '/', agent: keepAlive } http.get(options, (res) => { res.on('data', (res_data) => { console.log(res_data); }); }); Whether I have the agent in or not, I always get the following error:Error: getaddrinfo ENOTFOUND http://ift.tt/1LYDP5Y http://ift.tt/1LYDP5Y I really don't mean to make this sound like a general 'what's wrong with my code', but everything in the http library documentation matches up with what I am doing. Is there a small detail I looked over?EDIT: Never mind. I fixed it by taking out the http:// from the link

Submitted April 28, 2017 at 10:56PM by TheLegendOfCode

NodeJS and React: bundle.js is generated but I get error 404 (failure to load resource)

I have a very basic practice project -- I have some initial content ( a '...' string) and I after the JS environment loads, I want React to take over the div id="root and replace the js content with the react content (a 'hello react' string).I do an npm run dev and a bundle.js and a bundle.js.map are generated. Then I do an npm start but when I preview the page, only the JS content exists, and upon further inspection, the React script is not even loaded. I receive a 404 failure to load resource error on bundle.js despite the fact the file exists in /publicHere is my webpack.config.js:module.exports = { entry: './src/index.js', output: { path: __dirname + '/public', filename: 'bundle.js' }, module: { loaders: [ { test: /\.json$/, loader: 'json-loader' }, { test: /\.js$/, loader: 'babel-loader' } ] } }; Here is my .babelrc:{ "presets": ["react", "es2015", "stage-2"] } Here is /src/index.js which contains the reactdom.render:import React from 'react'; import ReactDOM from 'react-dom'; ReactDOM.render( React.createElement('h2', null, 'Hello React'), document.getElementById('root') ); Here is /public/index.ejs:<%- include('header') -%>
<%- content -%>
<%- include('footer') -%>Finally, here is my basic server.js in root directory:import config from './config'; import apiRouter from './api'; import express from 'express'; const server = express(); server.set('view engine', 'ejs'); server.get('/', (req, res) => { res.render('index', { content: '...' }); }); server.use('/api', apiRouter); server.use(express.static(__dirname + 'public')); server.listen(config.port, () => { console.log('Express is listening on port ' + config.port); }); I have tried searching everywhere for an answer, but haven't had any luck. Any feedback at all is very appreciated! Thank you!

Submitted April 28, 2017 at 09:37PM by judoka24

Does event emitter count as the "Observer pattern"?

Or is the observer pattern really having a subscribe function in the class that appends callbacks to a class-managed list, and on an action invokes all of the callbacks?

Submitted April 28, 2017 at 08:46PM by -proof

Just published: Event emitter supporting RegExp based subscription

http://ift.tt/2pqaRWm

Submitted April 28, 2017 at 08:14PM by Qoopido

How to use ESLint in Node.js Applications?

http://ift.tt/2qn4zGh

Submitted April 28, 2017 at 07:54PM by nodemonutil

Ecommerce site with Node quick start ?

Hi, To start off im front end developer using mainly React & elm I have an offer to build ecommerce website (shop) with database backoffice and ofc frontend Im not very familiar bith backend development but i have an idea to create react frontend with some nodeJs + mongoDB backend What should i learn / be aware of / read before i start Any general advices , tutorials, ready farmeworks ?

Submitted April 28, 2017 at 06:55PM by ziker22

Simplest Node API possible, still can't get cookies setting when front and backend separately deployed on Heroku - though set-cookie headers do send, cors is handled, and set proxy is enabled.

I have this API deployed to Heroku:const express = require('express') const cors = require('cors') const app = express() app.set('trust proxy', 1) const corsOptions = { 'origin': true, 'credentials': true, } app.options('*', cors(corsOptions)) app.use(cors(corsOptions)) const port = process.env.PORT || 8080 app.post('/', function (req, res) { res.cookie("firstTestCookie", {curious: "george"}) res.cookie("secondTestCookie", { charlottes: "web", the: "lorax" }, { encode: String, credentials: 'include' }) res.send('test sent') }) app.listen(port, () => { console.log(`listening on port ${port}`) }) On a separate dyno, I have the frontend which is nothing but a button that does this: function buttonClickFetch() { fetch(heroku_api_url, { method: 'POST', credentials: 'include', }) .then((response) => { return response.text() }) .then((text) => { console.log({res: text}) }) .catch((er) => { console.log({error: er}) }) } Cors is working fine, I get no cors warnings in the browser (Chrome) which I would otherwise have if I got rid of the cors stuff in the API. In fact, the set-cookie headers are visible in the browser dev tools > network tab for both cookies. They just won't set!

Submitted April 28, 2017 at 06:23PM by coderbee

Spotifork - Fork a Spotify playlist

http://ift.tt/2oBHlQg

Submitted April 28, 2017 at 05:20PM by xxbcbud420xx

Some advice on ORMs

Having never used orms like sequelize and bookshelf I have a few questions.1) Do I need to create the table first, or will the model create the table for me (similar to how models work in mongoose/mongo).2) Which is the prefered ORM? Bookshelf seems to have terrible docs.

Submitted April 28, 2017 at 04:38PM by Kilawaga

The 5 features of ES8 and a wishlist for ES9

http://ift.tt/2njwad6

Submitted April 28, 2017 at 12:47PM by fagnerbrack

The 100% Correct Coding Style Guide

http://ift.tt/2nAHJKe

Submitted April 28, 2017 at 12:51PM by fagnerbrack

How to build a Node.js API using Postgres, Lambda and API Gateway

http://ift.tt/2onxvOD

Submitted April 28, 2017 at 09:50AM by harlampi

Node.js Weekly Update - 28 April

http://ift.tt/2oDoYKR

Submitted April 28, 2017 at 09:54AM by hfeeri

Thursday 27 April 2017

Elasticsearch query builder for 5.x, 2.x

http://ift.tt/2p9sY49

Submitted April 28, 2017 at 04:17AM by sudo-suhas

whew - the ultra-simple and lightweight testing framework

http://ift.tt/2pnx8nK

Submitted April 28, 2017 at 02:25AM by Etha_n

Which CMS do you use?

Hello. What node CMS do you prefer? I've been looking into them recently and would like your opinion.For blogs, stores and generic websites, post your preferences and experiences.

Submitted April 28, 2017 at 12:25AM by Selhar

7 Convenient CI/CD Tools for Your Node.js Projects - NodeSource

http://ift.tt/2p8M5M0

Submitted April 27, 2017 at 11:47PM by _bit

REST Boilerplate: a minimalistic Nodejs/Expressjs boilerplate to quick bootstrapping

http://ift.tt/2qbsCc3

Submitted April 27, 2017 at 08:56PM by simplicius_

A simple chat architecture for your MVP

http://ift.tt/2oNGSFJ

Submitted April 27, 2017 at 08:01PM by k3rn3lx

Node server retrying requests after ~2 minutes

Have a node/express server that is rerunning requests after ~2 minutes for end points that can take a while (hitting neo4j db and querying a large data set). And when it reruns, the original is still querying neo4j and it’s causing more queries to queue of.Can’t seem to find where this retry is coming from, only see one network request in the browser. Anyone run into this?

Submitted April 27, 2017 at 08:17PM by dMyab

I rebuilt my open source blogging app in Node.js

Hi, I'm Cory LaViska and I created a blogging/publishing app called Postleaf. It launched previously as a PHP project, but I shutdown that version and completely redesigned the app for Node.js. It relaunched this week.Website: postleaf.org Source: github.com/PostleafI chose to switch platforms because I've been working with PHP for over a decade and wanted to dive into something new. I enjoy JavaScript quite a bit and experimented with Node on another project, so figured I'd give it a go. Overall, it was a great choice and I'm happy with the result. Node is pretty awesome.I'm not going to get into a PHP/Node argument here, but I will say that one thing users seem to be having trouble with this time around is installation.My question is, what's your approach to deploying Node apps? How can I make installation easier for the average user?

Submitted April 27, 2017 at 06:46PM by aksival

[Question] Client and server interaction with JWTs?

I'm currently making a custom CMS and I'm running two servers on separate ports.The client is an express server serving the API data which is templated using handlebars.The server is an express server acting as an API, I'm using passport and jwt for authentication.Which method would you recommend storing the tokens returned from the API? Currently I'm storing them in localStorage via an AJAX request upon login.In addition, what would be the best way of going about authorization with this project? I've got an entire admin section on the client server that I only want authorized users looking at. Would it be a matter of querying the users role in the database via the API once I verify the jwt then serving the pages?Many thanks.

Submitted April 27, 2017 at 05:56PM by wires55

Announcing TypeScript 2.3

http://ift.tt/2qc74yO

Submitted April 27, 2017 at 05:13PM by DanielRosenwasser

How to export router as an object?

All over the interwebs, the correct way to export a router is:module.exports = router;...how would I export it as an object? I thought:// ./routes/myRoute.js var router = express.Router(); ... module.exports = { router: router }; but this breaks things:/node_modules/express/lib/router/index.js:458 throw new TypeError('Router.use() requires middleware function but got a ' + gettype(fn)); ^ TypeError: Router.use() requires middleware function but got a undefined at Function.use (/home/dylan/tol-node-public/tol2/node_modules/express/lib/router/index.js:458:13) So it's returning an object. Ok, so I jumped into my .app.js, originally having this:var myViews = require('./routes/myRoute'); app.use('/', myViews); Changing it to:var myViews = require('./routes/myRoute'); app.use('/', myViews.router); Apparently this isn't the answer. What's wrong? is it because router: router is named the same?

Submitted April 27, 2017 at 04:33PM by xblade724

Best solution for presenting data in a page after running on the server?

I am trying to make an application which takes a user input (Via an IRC command) which runs a bunch of code on the server side and outputs a bunch of data. The issue is that IRC isn't the best for displaying large amounts of data and it's not pretty. Instead, I'd like to present the data in a webpage and simply return a URL to view the output in in the webpage.What would be the best way to do this using node?

Submitted April 27, 2017 at 03:00PM by haybros

7 Awesome Things you Can build with Node.js

http://ift.tt/1tHA33k

Submitted April 27, 2017 at 03:25PM by herohamp

Awesome logger for express apps

http://ift.tt/2ouTTsE

Submitted April 27, 2017 at 01:36PM by avoronkin

🌸 Express Mvc Boilerplate

http://ift.tt/2ie4Ecv

Submitted April 27, 2017 at 11:18AM by zuhig

The Definitive Guide for Monitoring Node.js Applications

http://ift.tt/2oIFKa0

Submitted April 27, 2017 at 11:48AM by dobkin-1970

Wednesday 26 April 2017

Remote development on Windows PC

SSH CLI editing is a drag (I've been using Joe editor, which has been my fav thus far for CLI, but still) -- What is the best Windows IDE that has excellent SSH integration and will allow me to even interact with npm, gulp, and git from the IDE? Pretty much I want to do common stuff from my Windows IDE without having to SSH in for common tasks.I'm looking into Intellij Idea Community vs Visual Studio 2017 community. Thoughts? Experiences? Other suggestions?I can't find a true difference between intellij idea vs webstorm... anyone know? Webstorm is premium, but I can't really see what it does for me.

Submitted April 27, 2017 at 05:36AM by xblade724

Best practices for Node.js, relational DBs and authentication

I am learning Node.js and I've followed a few tutorials and video courses but no one is explaining best practices, how to deal with relational databases and authentication and security. Do you have any resource to learn all of this?

Submitted April 26, 2017 at 09:38PM by ettzzi

Building a Next.js App With MongoDB

http://ift.tt/2oNk21W

Submitted April 26, 2017 at 09:54PM by code_barbarian

Creating Native Addons - General Principles - Gabriel Schulhof, Intel Finland

https://www.youtube.com/watch?v=6hkMaknbElw

Submitted April 26, 2017 at 09:24PM by r-wabbit

My API on Heroku sends set-cookie headers as intended. Postman sets the cookies, Chrome does not. Is this because of the Vegur proxy?

I expected to find WAY more info on Vegur than I did. I'm using client-sessions for session cookies, and my own implementation of an auth token system using express's res.cookie(). In development, I ironed out all the CORS issues of the separate API and SPA running them on different ports. At that point, Chrome and Postman exhibited identical behaviors and all was well. When I uploaded everything to Heroku, Postman still got the headers correctly and set the cookies. Chrome got the headers correctly but DID NOT set the cookies. I'm thinking Vegur is the culprit but I'm not sure exactly how or how to proceed.

Submitted April 26, 2017 at 07:30PM by L000

assert-match: assert + matchers

http://ift.tt/2nlfccp

Submitted April 26, 2017 at 06:21PM by rmdmoO

Identif: Helper class to verify one's identity via personal channels(SMS, Phone, E-Mail and more!)

http://ift.tt/2q64ckf

Submitted April 26, 2017 at 04:13PM by posquit0

How to create a mongodb based API with nodejs quickly?

Hello world,I think everything is in the title. I'm beginning with NodeJS. My goal is to create a versatile API to access datas of a mongodb server. This API should allow me to customize the output of each values. For example for any key, i would like to be able to apply custom code (a function) in order to modify the output. Is there any open source project somebody can recommend to me please for basic API stuff. For instance access control / managing API-key, limit the number of request of a specific API-key etc. Thank you for your help and consideration

Submitted April 26, 2017 at 02:46PM by oxad122

How and When to Use Loopback Hooks!

http://ift.tt/2q4P1rc

Submitted April 26, 2017 at 02:54PM by Gabriel_andrin

TestCafe v0.15.0 release happened just now. Take a look at the new Docker image and support for proxy servers.

http://ift.tt/2q5ruGD

Submitted April 26, 2017 at 02:31PM by churkin

How to implement automatic cache invalidation

Hi,I followed this tutorial and now have a working CRUD ToDo API. That's great, but now I want to implement some caching.If you request all existing ToDo lists, it should try to fetch that list from the cache first. If you update, create or delete a ToDo list it should invalidate the cache that contains the list of all ToDos.Is there anyway of doing that automatically (with some middleware) ?Here's a sample code to retrieve all ToDos:controllers/todos.jslist(req, res) { return Todo .findAll({ include: [{ model: TodoItem, as: 'todoItems', }], }) .then(todos => res.status(200).send(todos)) .catch(error => res.status(400).send(error)); } and here's the update code: update(req, res) { return Todo .findById(req.params.todoId, { include: [{ model: TodoItem, as: 'todoItems', }], }) .then(todo => { if (!todo) { return res.status(404).send({ message: 'Todo Not Found', }); } return todo .update({ title: req.body.title || todo.title, }) .then(() => res.status(200).send(todo)) // Send back the updated todo. .catch((error) => res.status(400).send(error)); }) .catch((error) => res.status(400).send(error)); }, How can I implement some sort of caching in that code. Is there a way to automatically delete all cache from the models that are updated (and any model that is included)

Submitted April 26, 2017 at 07:51AM by sofuj

Tuesday 25 April 2017

Rules of Thumb for MongoDB Schema Design

http://ift.tt/2ouqYoH

Submitted April 26, 2017 at 06:04AM by ratancs

Use JSON files as a lightweight "database" for Node.js applications!

http://ift.tt/1UhpfXP

Submitted April 26, 2017 at 05:05AM by realYusufR

Best node package for SQL CRUD

We are .NET developers who are trying to setup microservices. We just realized that making numerous web applications for API using ASP.NET Web Api and deploying them to IIS can be a bit tedious.So now we are teaching ourselves Javascript and Node as we found out that it is much easier to do microservices in Node.However, as someone new to this, we are not entirely sure which Node package to use to do CRUD operations and execute stored procedures in a MS SQL database.We found Knex but we want to know too what you guys are using? Thanks!

Submitted April 26, 2017 at 01:57AM by parxyval

fucking node-gyp (win 10 node dev)

This is a preemptive post, I've not had the perennial problem yet. Last I knew, node-gyp still needed to compile. Fine, whatever.I thought I read somewhere that windows based compilers and all that shit was available separately from the 10gb Visual Studio download. . . something similar to a build essential.Is there?

Submitted April 25, 2017 at 07:16PM by monsto

Create lean Node.js image with Docker multi-stage build

http://ift.tt/2pePdnV

Submitted April 25, 2017 at 06:07PM by alexei_led

Best github description yet.

http://ift.tt/1xc7Nrz

Submitted April 25, 2017 at 06:45PM by monsto

Setting up multi-platform npm packages

http://ift.tt/2nrrGNQ

Submitted April 25, 2017 at 06:51PM by r-wabbit

Socket.io - CLIENT SCRIPT authenticating with a website login

I made a nodeJS script to automate a few actions on a website - which is not mine!To have a bit more control over what is going on, I would like to listen to the events on the website's socket.io stream.Works in NODE so far:Logging into the website and receiving their cookies as a string for further requestsSending requests with the cookies from the login (do the actual actions)Open a websocket connection and listen to the public (!) eventsDoesn't work in NODE yet:Read "private" events that are only being sent to a specific user (me)I inspected a XHR request that is happening in chrome when clicking a specific button on this website. After this request has been sent, the websocket connection on chrome emits events about the status of my action. Of course, these events are only being sent to the user who performed this action.Doing the exact same request in node (with the cookies from the website login) gives the right response (success), but the socket stream i opened before, only shows some public events - nothing about my actions.As seen here, it logs in, displays the website's cookies, opens a socket stream. Then it sends a XHR POST request with the displayed cookies in the headers. The response says "success", but the socket.io events popping up once a second are only the public ones (userCount).http://ift.tt/2q2a1lu sending the request, there should be events like "step_calc" popping up, displaying the status of my action.My scriptAfter receiving the website's login cookies as a string, I am running this:const io = require('socket.io-client'); const request = require('request'); main() function main() { var socket = io(socketURL, {}); socket.on('connect', function () { setTimeout(function(){ performAction(); // Send XHR to server console.log(" > Sending XHR request...") }, 1500) }); socket.on('step_calc', function (data) { // Personal event about my action console.log(" >>> Event = step_calc: " + data) }); socket.on('login_time', function (data) { // Personal event being displayed every few seconds IF LOGGED IN (chrome) console.log(" >>> Event = step_calc: " + data) }); socket.on('userCount', function (data) { // Public event console.log(" >>> Event = userCount: " + data) }); socket.on('disconnect', function () { console.log(" > [Disconnected]"); }); } 1500ms after being connected to the socket, it would send the XHR request that should make the server emit information to the socket - performAction().When I check the chrome console:step_calc follows to a successfull XHR request (account specific)login_time is being displayed every 2 seconds, but only if i am logged in (account specific)userCount is being displayed all the time - to everybody I checked the socket.io-client's API guide and found out about socketIDs. But it only says, how to get this id after connecting to the server...http://ift.tt/2qazWDK... and yes ... when opening the website, the first thing chrome does, is send a GET request to the website, with data like this:EIO=3&transport=polling&t=1493058868222-0The response contains some kind of "sid".{"sid":"gmqoOS_________bHb","upgrades":["websocket"],"pingInterval":25000,"pingTimeout":60000} Well...Now that I have gathered all of this information, how can I use it?How can I make the socket connection be "connected" to the cookies that I got from the login (which I am using to send requests to the website)?  Additionally:I already tried to add the same cookies as chrome uses for the handshake (the one's I get from the website login).var socket = io(socketURL, { extraHeaders: { Cookie : '...' } }); One weird thing is, that the first XHR it does when i open the website (which seems to be the handshake), already contains a cookie named "io", which is then replaced by a new one. If I check the chrome console>application>cookies, I can't see this cookie at all. Where does it come from? I can't add it to the extraHeaders.Left side: The request under the XHR tab on chrome Right side: This is being displayed under the Websocket tabhttp://i.imgur.com/VkRouQf.jpgAre those two different requests or is it the same one in some way?Does this information help somehow help to solve my problem?  I really hope that my question is kind of understandable. I had to write a bit more to make it clear. Any help is appreciated, I have already put a lot of time into trying to make it work by myself.Thanks a lot!

Submitted April 25, 2017 at 02:23PM by MrInka

Nvidia: Use Node.js directly to interact with Windows APIs.

http://ift.tt/2p9O6I9

Submitted April 25, 2017 at 01:45PM by 13378

How to read (redirected) stdin line by line?

Hi there. I'm trying to use JS (Node) in some coding contests to get a better feel of the language. The problem is, judge systems are checking the code by redirecting stdin and stdout. Right now I do it this way:let text = ''; process.stdin.setEncoding('utf-8'); process.stdin.on('readable', () => { let data = process.stdin.read(); if (data !== null) { text += data; } }); process.stdin.on('end', () => { console.log(solveStuff(text)); }); It works, but it eats a lot of memory since all the input is stored and not processed line by line. I found out Readline and I'm trying to do it this way:const readline = require('readline'); const rl = readline.createInterface({ input: process.stdin, output: process.stdout, terminal: false }); rl.question('', (line) => { let [a, b] = line.split(' ').map(Number); console.log(a + b); process.exit(); }); The problem is, it only works in the interactive console. The moment I redirect a file to stdin, the output disappears completely. I suppose I'm doing something wrong here, but hours of googling brought me nothing. Any help, please?

Submitted April 25, 2017 at 01:09PM by Rinnve

How to Debug Node.js with the Best Tools Available

http://ift.tt/2pgHxU4

Submitted April 25, 2017 at 11:58AM by hfeeri

Updated version of my open source Node/React/Redux blog. Dockerized, Isomorphic, has Auth. I hope you'll find it useful as an example or a starter project. I would love to hear some feedback!

http://ift.tt/2pg4DdK

Submitted April 25, 2017 at 08:13AM by raymestalez

RethinkDb vs Redis?

Has anyone tried to use both of them, and know what their best use case and/or if rethinkdb works better? Im thinking of using rethink for my next realtime app, but id like to hear thoughts!

Submitted April 25, 2017 at 08:14AM by tootalboot

Monday 24 April 2017

Saw this outside a library

http://ift.tt/2oFlra8

Submitted April 25, 2017 at 06:23AM by goods_and_services

[Javascript] ES7 Async Await BIBLE

http://ift.tt/2i2JBsl

Submitted April 25, 2017 at 01:26AM by bananajsjs

[Express] Unable to process same GET request multiple times. How do I get around this?

I'm making a Node.JS app where the user sends commands to a robot. These requests are received from Angular.JS $http.get() requests. This is what the code looks like server side:app.get('/control/:dir/:amount', function(req, res){ var dir = req.params.dir.substring(1); var amount = req.params.amount.substring(1); networking.sendCommand(dir, amount); }); I know everything is sent properly, but it can only process a certain request once (so no matter how many time localhost:8080/control/forward/100 is sent, it only gets processed once). Is there any way around this?

Submitted April 25, 2017 at 01:57AM by TheLegendOfCode

Having problems reading data from mongodb

here's my code:http://ift.tt/2pYS0EI this point i'm only trying to console.log the data from a specific collection.

Submitted April 24, 2017 at 09:43PM by Chigurhshairdresser

'cors' module works between different ports on localhost, but breaks when API is deployed to Heroku

I have:const express = require('express') const cors = require('cors') const app = express() .... const corsOptions = { 'origin': true, 'credentials': true, } app.use(cors(corsOptions)) // the rest of the routes... This got everything set up for when the API was running on one port, and the SPA on another. Generally separate ports do raise CORS errors in Chrome, but then everything was fine when I implemented the above, which was awesome. According to the docs that sets all the appropriate headers, and it was working. No more complaints from Chrome in the console. So it came time to deploy. API is up on Heroku no problem. When I go to update the SPA locally, it can't interact with the API because of CORS! The headers are now unreliable. I even tried setting them manually. But somehow now that half of this thing is live everything has changed.POSTS get No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3001' is therefore not allowed access. The response had HTTP status code 503. And in dev tools Network sure enough they are not there. Gets seem to work, but I'm only seeing the credential header, not the origin one, which is supposed to set it to request url, and did during dev when everything was local (though still separate).What am I missing here? How come this works port to port, which counts as different origins, but not local to remote, and what is breaking and how can I fix?

Submitted April 24, 2017 at 07:51PM by L000

Image vectorisation

I am trying to vectorise png images using node.js. I am using a slicer (also node.js) that spits out png files, I need to vectorise these images that I can later use the vector information to send to a DAC that will drive a galvo. This all needs to be back end and happen automatically when a folder called slices is created and I need it to delete the folder once it is done vectorising all the images. Pretty new to js and node.js so please bear with me. I am open to all suggestions if there is a better way to do this.

Submitted April 24, 2017 at 08:02PM by jgoo95

NodeJs rest can't find GET method with query

Hi, I wanted to make a test for a REST app.This is the url I use: localhost:3000/movies/find?year=2011&orderby=titlerouter.use('/movies', movieService);And this is the code I wrote:// GET movie ids by query params router.get('/find', (req, res) => { let yearParam:Number = req.query.year; let fieldParam:String = req.query.orderby; console.log(yearParam); var moviesByYear = new Array(); Movie.find({}, (err, movies) => { if (err) res.send(err); for (var i = 0; i < movies.length; i++) { if (movies[i].year == yearParam) { moviesByYear.push(movies[i]); } } if (fieldParam == "title") { moviesByYear.sort(compareMoviesByTitle); } else if (fieldParam == "director") { moviesByYear.sort(compareMoviesByDirector); } var newMovieIdList = new MovieIdList(); for (var i = 0; i < moviesByYear.length; i++) { newMovieIdList.id.push(moviesByYear[i].id); } res.json(newMovieIdList); }); }); When I try to get the results it does nothing...GET /movies/find?year=2011&orderby=title 200 4.293 ms - -

Submitted April 24, 2017 at 07:37PM by gabegabe6

ESLint Rule Set?

I'm trying to get ESLint setup to validate my code. I created a default .eslintrc.json file, but it seems like there should be more to it.{ "env": { "browser": true, "commonjs": true, "es6": true, "node": true }, "parserOptions": { "ecmaFeatures": { "jsx": true }, "sourceType": "module" }, "rules": { "no-const-assign": "warn", "no-this-before-super": "warn", "no-undef": "warn", "no-unreachable": "warn", "no-unused-vars": "warn", "constructor-super": "warn", "valid-typeof": "warn" } } What set of rules is most common? Can anyone point me to a file I can use as a starting point?

Submitted April 24, 2017 at 06:57PM by fyzbo

Using Postman to GET request an express API, I will get back my intended route only. Putting the same URL into Chrome, I will get that route as intended but ADDITIONALLY the wildcard route beneath it will also be hit. What's going on with that?

No text found

Submitted April 24, 2017 at 03:08PM by L000

Meet the people who make Node.js: James Snell

http://ift.tt/2pWfreT

Submitted April 24, 2017 at 02:13PM by ecares

Node/MongoDB a must?

Hello fellow Node peps,So I am at a crossroads with the battle of deciding my DB for some little projects I am taking to fully learn Node. I've done a good amount of research on MongoDB (& NoSQL in general) - very cool stuff. Every time I search and hear NodeJS (tutorials, other projects, etc) seem to always use MongoDB and Node versus another NoSQL solution or a relational Database.My question is: why does it seem so obvious to use MongoDB with Node. I assume async functionality plays a decent part in the development.Also, benchmarks and usage information seem to be very bare/non-existent. To try and keep costs down (small VPS's) I want to try to keep resource utilization as low as possible (while providing a quick experience). As it seems MongoDB is more of a resource hog, but I'd like to get some opinions/experiences from others regarding that.This is mainly a learning experience in the end, so I'd like to develop on the DB system that would be best suited.The first project will be a website (probably running express.js), this site will have a social network feel (posts, profiles, etc). No big data or major transaction logs planned.Anyone care to share their input?

Submitted April 24, 2017 at 01:52PM by Miles360x

Cardboard Boxes Manufacturers

http://ift.tt/2pWfjfn

Submitted April 24, 2017 at 01:59PM by naeem122

Parallelizing in NodeJS: It Ain't as Hard as You Might Think

http://ift.tt/2pVPpbK

Submitted April 24, 2017 at 12:20PM by avagadbro

Sunday 23 April 2017

modify HTTP requests on the fly and aid on web security testing.

http://ift.tt/2oqMMgS

Submitted April 24, 2017 at 05:28AM by ratancs

How can I generate dynamic javascript with express for a google maps script?

Say I wanted to generate markers on the map based off whats in the database. In my map.jade how can I iterate of the array to generate dynamic js for the google maps script that makes the map?Say I have this hardcoded in my gmaps script in maps.jadevar irouleguy_coords = [{ lng: -1.405220, lat: 43.270706 },{ lng: -1.404190, lat: 43.271206 }]; Say I now wanted to generate a bunch of these based off:for region in regionslist and use #{region.coordinates} to generate dynamic variables like var coord_1 = #{region.coordinates}Do I have to do this in my route and then pass to the template?

Submitted April 24, 2017 at 04:23AM by mineralwatersoda

NodeJS-Api-Boilerplate

Hey, everyone :) I'm working on a Node.JS boilerplate for fun + for help me kickstart some project. I would appreciate to get some feedback on it and maybe some help :) I know we have so many other but that's was a really good learning process :).http://ift.tt/2pVjlY6

Submitted April 24, 2017 at 03:30AM by EQuimper

Node, ECS, and Redis. Need a worker to save huge redis data into memory?

We have a node server on Amazon ECS that gets hit around 30,000 times per second at max peak times. Since javascript is single threaded, we don't want to block the event loop. So we need to create a worker that periodically fetches 11 million rows of data from Redis and loads the data into memory. This may take a while, so we want to create a worker so there's a different event loop. How can we do this with ECS? Can we just use an npm or do we have to do anything special like setting additional stuff up on the Amazon console to have a separate worker?Furthermore, is this a good design pattern? Do I need a worker to do this? If I use a worker in Node, after I query the 11 million rows of redis data and save this object into memory, can the main server (main event loop) access this object?The previous design pattern was: for every time out server is hit, we would query one key in the Redis database. This operation takes 100 ms, which is too slow for our purposes. Hence we want to load the entire 11 million row database every 5 minutes and save it into the server's memory. So we wouldn't need to make an additional round trip to call Redis. Do we need a worker to do this redis loading operation?

Submitted April 24, 2017 at 01:30AM by thejavascripts

Two-Part Blog Post about Memory Leaks and the Recent Problems with 6.10.1

http://ift.tt/2p7wpHf

Submitted April 24, 2017 at 01:31AM by avagadbro

Question about Node.js servers

From what I've read, 200 is the HTTP status code for success, but how can we write 200 before we know if the program will be successful?var http = require('http'); var server = http.createServer(function(req, res){ res.writeHead(200, {'Content-Type': 'text/plain'}); //What I mean res.end('Hey ninjas!'); }); server.listen(3000);

Submitted April 23, 2017 at 08:30PM by jimmypixel

Making RESTful Web Services the Easy Way with Node.js

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

Submitted April 23, 2017 at 08:09PM by brunocborges

How to send json data with request in nodejs?

how can I send application/json data (post method) using request js in nodejs express application

Submitted April 23, 2017 at 02:59PM by maxyspark

Mark Hinkle, the new Executive Director of the Node.js Foundation AMA on Medium

http://ift.tt/2oAifQq

Submitted April 23, 2017 at 01:52PM by fagnerbrack

Using a node SQL ORM with complex filtering

I've had some experience with Node API development previously, but my main ORM experience is with loopback's build in ORM which has limitations.I'm looking into both Sequelize and Knex (with Objection.js) at the moment, leaning towards Knex.However, I'd like it to be able to expose some of the filtering power on the client side. E.g. if I have some models like:Country -> hasMany -> City -> hasMany -> CustomerI'd like to do a query like find all customers in the United States.I understand this is easy to do in Sequelize as well as Objection/Knex. However, sequelize looks like the filter syntax may be almost ready to open up fully to the client?Has anyone had any experience with evolving query requirements on each ORM?

Submitted April 23, 2017 at 09:50AM by TheLegendOfZero

A step-by-step guide to building a simple chess AI

http://ift.tt/2ojubHg

Submitted April 23, 2017 at 07:31AM by fagnerbrack

Saturday 22 April 2017

What are the things you wish you had known before starting with Node.js?

Hello folks, I'm starting to write a book with tips and tricks about Node.js and I would like to know the bad experiences that you had before using Node.js. My personal opinions:Passing by reference vs. passing by copy (it's a JS thing I know)Module caching and how to deal with itCircular references

Submitted April 23, 2017 at 05:53AM by alanhoff

[Help] Can't make webpack-dev-server to work ?

Hello,I just start node a week ago and I wanted to make a small project (Angular/node) so I made a DockerFile :FROM node:boron # Create app directory RUN mkdir -p /usr/project WORKDIR /usr/project EXPOSE 3000 CMD ["npm", "start"] And a docker-compose (I also got a postgresql)version: '2.1' services: node: build: ./docker/node volumes: - ./server:/usr/project ports: - 3000:3000 links: - database tty: true Here my node architecture:-config //for futur webpack configs -node_modules -public (output folder If I understand correctly) |---javascript -src |---app |---|---app.component.js |---|---app.module.ts |---|---main.ts |---resources |---views |---|---index.pug -package.json -server.js -tsconfig.json -webpack.config.json Here the package.json:{ "name": "node_angular", "version": "1.0.0", "description": "Node.js and Angular on Docker", "author": "-----------", "main": "server.js", "scripts": { "start": "npm install && webpack-dev-server --public --progress --profile --watch --port 3000 --content-base src/" }, "dependencies": { "express": "^4.13.3", "pug": "^2.0.0-beta.12", "@angular/core": "^4.0.2", "@angular/common": "^4.0.2", "@angular/compiler": "^4.0.2", "@angular/compiler-cli": "^4.0.2", "@angular/platform-browser": "^4.0.2", "@angular/http": "^4.0.2", "@angular/platform-browser-dynamic": "^4.0.2", "@angular/router": "^4.0.2", "@angular/forms": "^4.0.2", "@angular/platform-server": "^4.0.2", "@angular/animations": "^4.0.2", "webpack": "^2.4.1", "webpack-dev-middleware": "^1.10.1", "webpack-dev-server": "^2.4.2", "bootstrap": "^3.3.7", "typescript": "^2.2.2", "zone.js": "^0.8.5", "rxjs": "^5.3.0", "ts-loader": "^2.0.3", "webpack-node-externals": "^1.5.4", "awesome-typescript-loader": "^3.1.2", "html-webpack-plugin": "^2.28.0", "html-webpack-pug-plugin": "^0.0.3" } } Here the tsconfig.json:{ "compilerOptions": { "module": "commonjs", "moduleResolution": "node", "target": "es5", "sourceMap": true, "emitDecoratorMetadata": true, "experimentalDecorators": true, "lib": [ "es2015", "dom" ], "noImplicitAny": true, "suppressImplicitAnyIndexErrors": true, "types": [ "node" ] }, "exclude": [ "node_modules" ] } Here the webpack.config.json:const nodeExternals = require('webpack-node-externals'); const webpack = require('webpack'); const path = require('path'); // Webpack Plugins var HtmlWebpackPugPlugin = require('html-webpack-pug-plugin'); module.exports = { target: 'node', externals: [nodeExternals()], entry: './src/app/main.ts', output: { path: path.join(__dirname, '/public/javascript/'), publicPath: '/public/javascript/', filename: 'bundle.js' }, module: { rules: [ { test: /\.ts$/, loader: 'awesome-typescript-loader', exclude: [/node_modules/] } ] }, resolve: { extensions: [".ts", ".js"] }, plugins: [ new webpack.optimize.UglifyJsPlugin() ] }; Here the server.js:'use strict'; //using express const express = require('express'); const path = require('path'); // Constants const PORT = 3000; // App const app = express(); app.use(express.static(path.join(__dirname,'public'))); app.use(express.static(path.join(__dirname,'src'))); app.set(path.join(__dirname, 'views')); app.set('view engine', 'pug'); app.get('/', function (req, res) { res.render('src/views/index'); }); app.get('/test', function (req, res) { res.send('Hello world!'); }); app.listen(PORT); console.log('Running on http://localhost:' + PORT); What I don't get is :node_1 | Project is running at http://localhost:3000/ node_1 | webpack output is served from /public/javascript/ node_1 | Content not from webpack is served from /usr/project/src ............ webpack: Compiled successfully. It seems that my server is running but when I tried to access the serverhttp://localhost:3000/Nothing shows, can you explain what I didn't get right ?

Submitted April 22, 2017 at 09:40PM by frennetixsc

Friday 21 April 2017

6 Reasons Why JavaScript’s Async/Await Blows Promises Away

http://ift.tt/2nIIHHn

Submitted April 22, 2017 at 04:20AM by fagnerbrack

What's the best way to learn how to deploy an app?

Hi guys, I made an app with a friend that's made up of two servers. 1 for the React client and one for a Node GraphQL API.I was wondering what is the best way to deploy that? I have a little list I'm following but I feel lost, there must be a proper way of doing this that I don't know.SSH to DigitalOceanSet up Postgres Database user on itClone GitHub repo, set it up and Yarn installRun node app with PM2Learn NginxTry Docker??I know these things are sort of close to the truth but I have no idea what to do in what order...

Submitted April 22, 2017 at 01:19AM by savovs

stmux: Simple Terminal Multiplexing for Node.js Build-Time Environments

http://ift.tt/2pMBDb2

Submitted April 21, 2017 at 09:40PM by engelschall

Request for Code-Review and Feedback of my Node Library SimplyREST

SimplyREST (http://ift.tt/2pz8cw0) is a node library to create REST APIs with the help of Annotations. SimplyREST is based on ExpressJS, hence all the features of ExpressJS such as Middlewares, Error Handling, Multilevel Routing, etc are available in SimplyREST (Tutorial available in the repository).To Expose any Route, you only need to create a Class and a Method and Annotate them with predefined Annotations (Tutorial available in the repository).Need some help to test the project and get some honest feedback.Thanks

Submitted April 21, 2017 at 09:06PM by ab0027

Resources or tutorial to learn Koa 2?

new to node

Submitted April 21, 2017 at 05:45PM by zildjian939

WordAct: a developer-friendly, deployment-ready, boilerplate project with WordPress and React

http://wordact.io/

Submitted April 21, 2017 at 01:01PM by ethanz5

Node.js Weekly Update - 21 April

http://ift.tt/2oXQuzq

Submitted April 21, 2017 at 10:53AM by hfeeri

Abusing NVIDIA's node.js to bypass application whitelisting

http://ift.tt/2oZJWm2

Submitted April 21, 2017 at 10:02AM by SecResearcher29a

Thursday 20 April 2017

I'm stress-testing an MMORPG server built in Node.js. Come check it out!

http://ift.tt/2pJU0QQ

Submitted April 21, 2017 at 05:28AM by booptey

Awesome Node.js Weekly - Issue 49

http://ift.tt/2o9FJgp

Submitted April 21, 2017 at 01:09AM by stanislavb

Redux store or component state?

Just finishing up my first app with Redux, and really like it. But as I'm going over the whole process at the end here I'm noticing that I drifted back toward using the component state. At first I was putting everything in the store. And that was awesome. Then I started to put little bits of things that I thought really only were relevant to the component on its own in its state. And then slowly more and more stuff started to seem only relevant to individual components and I realized by the end that I was only using the store for user data that needed to be constant throughout all routes.I did, toward the end though, have to put things in the store again that components with totally divergent lineages needed to share. Like if a modal component that was going to pop up and need to change a component beneath it which it wasn't really related to. It felt really hacky but it was the easiest way.To do it again. I'm not sure which way I would go. More heavy on the store, more minimalist on the store. It seems like one approach is definitely just put EVERYTHING in the store. If I were to do this, I'd have some sort of key system that described the component it was about. I'd have a huge store. But then again little things do make sense in the component state though. But then sometimes they end up adding up and drifting toward regular react implementation like my app did. Basically you could put my components on a timeline, the ones more dependent on the store were made first as I was learning the ins and outs of redux, the ones with more internal state were made last as I was... I don't know... regressing?What do you think?

Submitted April 21, 2017 at 01:54AM by L000

Basic Functional Programming With Async/Await

http://ift.tt/2pIwQaW

Submitted April 20, 2017 at 11:12PM by code_barbarian

Something cool is happening: Blockchain and Decentralized Apps. We are interested in your opinion about these topics.

This is why we are looking for developers to participate in a temporary online community/forum on Slack that lasts 6 days from April 25th to 30th. Participate and earn yourself 200 USD in your favorite cryptocurrency. If you are interested, please answer a few questions at http://ift.tt/2ohAer4 by April 18th and we will get back to you.

Submitted April 20, 2017 at 07:20PM by BlockchainGroupBER

[Nodejs][React] Isomorphic-Fetch: the suspicious part

http://ift.tt/2pVODuc

Submitted April 20, 2017 at 04:28PM by bananajsjs

Clustering

How would I spread something like this across multiple CPUs using the cluster module instead of async? I've read a few tutorials such as this, however I dont quite see how the express app is applicable to my code

Submitted April 20, 2017 at 04:30PM by programmingbackup

Express Middleware with multiple Promises in sequence and Error Handling

Hi, I have an Express route handler that needs to start multiple operations asynchronously. These operations are indepentend and do not interfere with each other.I tried to do this with Promises, but I have problems when I have to handle errors from Promises.Let me explain with an example. router.post('/data', function (req, res, next) { // do something before anything else next(); }, function (req, res, next) { promise1(req.params) .then((data) => { // do something with data }).catch((err) => { next(err); }); promise2(req.params) .then((data) => { // do something with data }).catch((err) => { next(err); }); }, function (err, req, res, next) { // error middleware }); The problem is that if both the 2 promises incur into errors, so they both end up calling next(err) in the middleware and there is a problem here.The second call to next(err) ends up in nothing and the middleware does not handle anything.I'm looking for suggestions on a couple of things:Is calling multiple promises in sequence an ok design somehow?If yes, how should I handle errors?If no, what is a good design pattern in this case?Cheers ;)

Submitted April 20, 2017 at 04:36PM by honestserpent

Enterprise-grade backend pattern

HiI want to build "entreprise grade" server side using node.js for a personnal project. I want to put together TDD, continous integration like if i need to create business app which can scale well.I will use react/react-native at client side and node (express ?) at server side.I will use typescript as client and server side for checking type. ( i think it's good practise if we work with lots of people on the same project) I've check some example for see how other people do. I've see this interesting repo : http://ift.tt/2o7QYWN example use "repository pattern" at server side with typescript. What did you think about it ? Have you other example / best pattern for "enterprise-grade" node application ?Thank's for your ideas and help :

Submitted April 20, 2017 at 03:17PM by node53

I have an internship this summer and I will be using Node js to create my application. What nodejs textbook would you recommend I read?

No text found

Submitted April 20, 2017 at 02:22PM by imgurceo

Announcing Free Node.js Monitoring & Debugging with Trace

http://ift.tt/2o6LJqj

Submitted April 20, 2017 at 10:10AM by hfeeri

Wednesday 19 April 2017

Open Data + Node.JS + Elasticsearch — 13 million street addresses and counting

http://ift.tt/2oRjSHS

Submitted April 20, 2017 at 05:53AM by matthaywardwebdesign

[For Beginners] How to install Node.js and serve a static webpage and small services with Express

https://youtu.be/rbGb7rm16o4

Submitted April 20, 2017 at 06:28AM by thecharmingnerdguy

Please help me write a proper JSON file

I would really appreciate any help on this issue I'm having or feedback on this code in general.http://ift.tt/2ooQVBG file that this code writes ends up looking like this [{...},{...},{...}][{...},{...},{...}]...This is invalid JSON. How would I make sure that it's valid like this [{...},{...},{...},{...},{...},{...}]I've tried so many things to make it work including applying a regex to the entire file after the fact, wrapping superagent in a function that returns a promise, and editing the file after the fact in the code that relies on this script to run. All to no avail. I know there must be a better (proper?) way to do this.

Submitted April 20, 2017 at 03:11AM by sha256md5

Hard-won lessons: Five years with Node.js

http://ift.tt/2oWKVDA

Submitted April 20, 2017 at 02:36AM by stanislavb

Developing and Testing Node Microservices with Docker

http://ift.tt/2pDGkqy

Submitted April 19, 2017 at 11:14PM by michaelherman

Synchronous HTTP call

I have this API that I am using that is doHttp.get(someUrl) and it returns the response, and depending on the response, I can do stuff with it.I am able to run this in the browser via an XMLHttpRequest and set the async flag to false.In Nashorn I am able to run this synchronously without any problems out of the box.I am working on a Node implementation, and I cannot figure out how to do this synchronously. I have found a library, sync-request but there are known security vulnerabilities according to the GitHub page.Is there a way to do this synchronously in Node?

Submitted April 19, 2017 at 05:43PM by SpoilerAlertsAhead

rltm.js - swap between Socket.IO and PubNub

http://rltmjs.com/

Submitted April 19, 2017 at 05:30PM by mattdavidlucas

KyVe key value data store for node browser and Cordova • r/javascript

http://ift.tt/2pdM8Ye

Submitted April 19, 2017 at 02:36PM by fmerli1

A shell based on gnu readline?

Is there a shell for node which uses gnu readline internally?As you know node shell sucks in 2 ways (just important ones):It doesn't have search for history. This can be solved by using http://ift.tt/2pR3GWm's so poor. Shells that use gnu readline (like psql, ipython, python, bash, etc) has lots of features out of the box and all share a configuration you set in your ~/.inputrc. For example I have good vim-mode in all above shells I listed because they all use gnu readline internally. If there's a shell for js that uses gnu readline internally too, then it'll be in harmony with my other shells.

Submitted April 19, 2017 at 12:10PM by sassanh

A look back at the 'left-pad' incident

https://mobile.twitter.com/i/moments/847043675364507648

Submitted April 19, 2017 at 11:45AM by fagnerbrack

Auto Generate Node Swagger CRUD APIs for your Salesforce Instances

http://ift.tt/2pB9SCu

Submitted April 19, 2017 at 10:43AM by _orcaman_

The Definitive Guide to Object Streams in Node.js

http://ift.tt/2oUlUc8

Submitted April 19, 2017 at 10:08AM by hfeeri

A javascript library that lets you add stories EVERYWHERE.

http://ift.tt/2nWCo45

Submitted April 19, 2017 at 08:09AM by ratancs

Create amazing 360 and VR content using React

http://ift.tt/2mqCd0m

Submitted April 19, 2017 at 08:16AM by ratancs

Tuesday 18 April 2017

REST API Development Framework

I was searching for some easy REST API Framework but couldn't find one. So thought to make one using Annotations.SimplyREST (http://ift.tt/2pz8cw0) is an easy to use REST API Framework. You can expose REST APIs via Annotations. Just Make some classes and methods (tutorial available in the repo), and Annotate Them with predefined Annotations to expose them.Need help to make it more robust and a good framework that can be relied upon. Feel free to test it out and raise any issues on the GitHub Repository.Moreover, I couldn't find any good Annotation Parser for NodeJS. So I've developed nodeannotations (http://ift.tt/2oMsmjr) and used it in SimplyREST.Use nodeannotations to get a full set of Classes and Methods to parse an Annotated File.

Submitted April 19, 2017 at 06:19AM by ab0027

Iterate through multiple pages within the same site using Cheerio and Node JS

Hi guys,I am having trouble scraping data from a site with multiple pages. I can scrape through the first page but not sure how to scrape through the following 10 pages on same site?script.jsvar express = require('express'); var path = require('path'); var request = require('request'); var cheerio = require('cheerio'); var app = express(); var port = 8080; var url = "https://www.example.com"; request(url, function(err, resp, body){ var $ = cheerio.load(body); if(err){ console.log(err); }else{ $('#div').find('li').each(function(i, element){ // everything i want to scrape i do under here console.log(element); }); } }); app.listen(port); console.log("server running on port "+ port);

Submitted April 19, 2017 at 04:26AM by tht_chico

Patched a FormData object with fetch.js. Can't really tell from looking at the req how it worked (even though it did). Didn't seem to send a body object, didn't seem to append queries to the URL... what happened?

Everything is working. I used new FormData and appended a photo file to it so I could fetch from a react component, then multer successfully picked it up at my express api on the other side. ... but I'm not used to actually submitting real HTML forms so I'm actually a little foggy about the lower lever stuff even though the high level stuff is working (I know that's a little dumb but diving right in sometimes means the basics get missed, or forgotten as they are sped through toward actually building things).Any help greatly appreciated!

Submitted April 18, 2017 at 11:39PM by sherlockcoder

grawlix v1.0.5: now with grawlix-racism plugin that targets racial and ethnic slurs

grawlix -- free NPM package, swaps out obscene words for random character glyphs:npmgithubgrawlix-racism -- plugin for grawlix, focuses on replacing racial and ethnic slurs:npmgithubSo here I take my first steps towards the main idea here, a highly-customizable profanity filter with modular plugins that can be mixed and matched as the dev sees fit. Am curious to know what other people think about the code in this release. I'm a little worried that I might be overcomplicating things, or that there might be a more intuitive way to structure all of these options that I'm just not seeing right now. What do you think?Otherwise, are there any other features that people would suggest? Anything else that might make this easier for devs to use? Let me know in the comments.

Submitted April 18, 2017 at 09:23PM by jon_stout

Detect public IP + more info via different APIs

http://ift.tt/2pxpkC8

Submitted April 18, 2017 at 09:08PM by code5code

Those of you who use MongoDB, how do you survive without support for transactions?

Recently I posted on here about deciding to make the switch from mongodb + mongoose to using postgres: http://ift.tt/2o037wR of my biggest frustrations with mongo was the lack of support for transactions. I've come across stackoverflow posts about this and have seen npm packages that try to solve this, but nothing looks very solid or worth using in production.So what do you guys do when you need to update/save multiple types of documents? Do you use any of these npm packages? I've seen some people say that you could save a Transaction object to mongo, and not mark it complete until all of it's work is done. I've also thought about using a worker queue / task manager to handle multiple saves/updates and then let it deal with any failures, but all of this sounds like a pain to implement when you could have just used an ACID compliant db in the first place.I'm genuinely curious to see how you guys dealign with this and solving these problems in production.

Submitted April 18, 2017 at 06:07PM by m9js

NodeJs+Ionic2+Socket.Io newbie question.

Seven Reasons to Choose Node.js for Your Startup

http://ift.tt/2oCZb4c

Submitted April 18, 2017 at 04:31PM by eugeniyak

How can setTimeout slow down?!

I'm building a very simple web crawler with node 7 and have come across some strange issues. I've fairly new to node/async type things but this seems strange.I have a timer that gets a job from beanstalk every 20ms (to throttle my requests to ~ 50/sec to sites) .. I have the function keep track of the time each time it runs. When i just do request() i see consistent timestamps where req #50 is at the 1s mark and #100 is very close to the 2 second mark etc.. But when I introduce cheerio into the mix after the request, suddenly my timer slows way the hell down. How could cheerio screw up a function that calls itself every 20ms?

Submitted April 18, 2017 at 02:54PM by hecktarzuli

Is there an alternative to logio.org?

So, http://logio.org/ is a nice project. But it is no longer maintained and does not work on Node v6+. Are there any lightweight alternatives for aggregating live logs on a dev machine?

Submitted April 18, 2017 at 02:58PM by gajus0

Babel plugin for partial application inspired by Scala & Kotlin (x-post /r/javascript)

http://ift.tt/2oIRxU0

Submitted April 18, 2017 at 03:21PM by citycide

ioredis and async/await

I inherited some crappy JS code that I have to optimize, by adding a Redis-based cache layer. So I have been toying with ioredis, which is a great lib.The whole codebase was written by people who have no experience with functional programming. So it's basically a billion functions that return values. All this is fine and dandy in a synchronous world, but here I come with asynchronous stuff.I can't afford to rewrite everything on Promises. So my best shot seems to be async/await to manage the execution flow around (asynchronous) redis queries. But after toying around for a few hours, I can't seem to manage to write a function that :"pauses" while Redis is queried"resumed" when Redis answersreturns the result it got from Redisoverall behaves in a synchronous waySeems to me it's the perfect use-case...but maybe I just don't async/await ?

Submitted April 18, 2017 at 01:37PM by captain_obvious_here

RESTful API nodejs, can't find examples/tutorials.

Hey, I'm trying to find an open source/examples/tutorials of node, mongoose, authentication. I want to learn how to develop an API with all these features but I can't find any good tutorial or even a complete project to look in the code.thanks!

Submitted April 18, 2017 at 12:32PM by baaraak0

WANTED: Node/react front-end developer to join our cryptocurrency project

WANTED: Node/react front-end developer to join our cryptocurrency projectCryptoAi is looking for a node/react front-end developer to join our project. In the cryptocurrency space, we have noticed a distinct lack of applications for traders. In particular, apps that deal with opportunity finding and capital/portfolio management appear to be in high demand. CryptoAi seeks to capitalize on this by releasing a trading suite to assist traders and investors.We currently have a working prototype written in python and flask, however, our plan is to release the public client in javascript/react. The javascript back-end is complete and we’re now looking for an enthusiastic developer to join the team to help work on the front end.In addition to implementing solutions for traders/investors, CryptoAi is also operating an in- house fund. We have a dedicated research team using both technical and fundamental analysis in the construction of a proprietary trading system. All members directly benefit from this as shareholders of the fund.Interested in learning more about our project, or becoming a member of our team?Contact us at:contact@cryptoai.iowww.cryptoai.io

Submitted April 18, 2017 at 11:17AM by CryptoAi

Built a node.js web app, feedback please?

Hi Guys,I just created a web app that allows users to view events happening in Canada. It also allows users to register and post events. I used a script to populate the database with random data, so right now there are over 1000 events listed, with really weird titles, and animal pictures for event images. Ignoring that, I'd love your feedbackhttps://eventfulcanada.herokuapp.com/Feel free to register, post events, delete events etc. If you find a bug, please let me know!Background: used node, express, mongoDB, bootstrap, google places api, amazon aws for image storageNote: please use google chrome. Some front end fixes need to be made for other browsers.

Submitted April 18, 2017 at 06:57AM by permanent_me

Monday 17 April 2017

Latest version of Node.js (version 6.x.x). Everything

http://ift.tt/2nVMVfQ

Submitted April 18, 2017 at 03:20AM by papudag

Rebooting server

Hey all, I'm having trouble trying to reboot a server using nodeJs. I have an electron app, and I want to reboot a test server when a specific button is pressed. I've looked at simple-ssh and it doesn't seem to have/do a reboot command. I've looked at nodedaemon but I want to incorporate rebooting the server in an html file versus calling it at the command line.Any suggestions? I would need to ssh into the server (hence the simple-ssh), and I was given a hint that I want to do a "sudo reboot 0" command.

Submitted April 17, 2017 at 11:18PM by BrittF41

Server-side Rendering With Preact and Firebase

http://ift.tt/2opwQvT

Submitted April 17, 2017 at 09:58PM by code_barbarian

Same like nat-upnp, xml2js replaced + dgram reuseAddr is on

http://ift.tt/2pr3OPG

Submitted April 17, 2017 at 06:06PM by code5code

Building a Big Boy/Girl App With Node (x-post /r/webdev)

http://ift.tt/2oPjviJ

Submitted April 17, 2017 at 04:44PM by TheSimonator

Multiple cloud servers running the same app

I'm currently working on a Node application for some clients, that would each run the same app on their own cloud server. We're getting close to deployment and was wondering what is the best tool when adding a new feature or fixing a bug. Right now, we simply use git and GitHub to access the new code on the cloud servers, but that is going to become too cumbersome as we deploy more.I think I remember seeing an npm package for exactly this situation, but can't seem to find it. If you have any other suggestions let me know. Thanks.

Submitted April 17, 2017 at 04:17PM by poopstrap

So how about we not try to automate all the things with one thing?

http://ift.tt/2ppYWu0

Submitted April 17, 2017 at 03:04PM by psaia

Request for npm module code review

Hi /r/node.I'm about to publish v2.0.0 of my most popular module. This new version accesses an internal macOS database which, if somehow corrupted, could cause loss of lots of personal data of the user.I've tested it fairly thoroughly myself, and I've included protections such as opening the database readonly.However I'm still quite new to sqlite and would greatly appreciate a vote of confidence from somebody more experienced than I.http://ift.tt/2pqjD9l in advance.

Submitted April 17, 2017 at 03:17PM by wtf_are_my_initials

The Complete Node.js Developer Course

http://ift.tt/2oDtUft

Submitted April 17, 2017 at 02:29PM by vasira

Where should I put assets, html, etc?

Where should I store my assets: images, css, js and html, ejs and other files in my Express application? What's an idiomatic way to do that?

Submitted April 17, 2017 at 12:28PM by mikase81

Sunday 16 April 2017

duty: command line todo application

http://ift.tt/2pHta8r

Submitted April 17, 2017 at 06:28AM by 73mp74710n

Saturday 15 April 2017

Flexible model fields using NodeJS and Mongodb

Itemname Stringmanufacturer Stringdescription StringInventoryusername { type:String, index:true}items { item: Array, quantity: Array }Hopefully that was clear enough to understand how I'd like to structure my collections. I have multiple items, of which only have names and info about them. The inventory will be specific per user, but will have more detailed information about those items that will be stored in the Items field. Though I'd like it so a user may have one item or a googleplex of items with information such as quantity, age, etc.I want it structured like this so when users add items to their inventory they may choose from a pool of previously stored items.Would I be able to store inside Inventory > items > item[] an item name from the Item collection (to later fetch an item by name for the rest of the data), and pair up information collected in a form from the user (such as a quantity) about their unique item inside Inventory > items > quantity[]To then later access it and pair them up such as:inventory.items.item[0] inventory.items.quantity[0]

Submitted April 16, 2017 at 02:21AM by JayHerlth

xqq - Ultra-lightweight Promise-based request module

http://ift.tt/2oCE7KH

Submitted April 15, 2017 at 10:26PM by Etha_n

CMSless for early stage startups

Hi Everyone When you are building a startup in few days I cannot spend time on content management and try to delegate this task to students. So, in this case, it is better to keep articles, posts, intro, etc.. on GitHub and just loads it into the website by simple script. This is simple solution "http://ift.tt/2pDqXe0".

Submitted April 15, 2017 at 05:39PM by askucher

Node is confusing and hard, should I switch to PHP?

I'd love some clarification because it feels like I'm lost in the depths with node atm. My goal is to be a fullstack dev with proficiency in some back-end language.I started node about a month ago, prior having a basic understanding of js. I can do some basic things like auth with the help of tutorials, and I don't remember any of it by heart. I also can work mongodb a bit, (pushing things into it and taking data out), but the models/schema concept is still complicated to me. Basically I can make things work with the help of google, but I always feel a little lost with these little things like app.use or app.set.Are we suppose to just copy and paste everything and then google when it breaks? At this point I'm thinking I should try out php because I've heard it's beginner friendly.

Submitted April 15, 2017 at 06:24PM by caseyboyswag

User authentication for mobile and web application

I am trying to develop a small application for mobile use and for web use. I only want the user to be able to login with facebook.I am wondering how to do this? I am thinking about giving the user a token (jwt) that the user stores somehow and then they will provide this with every request.As of now I have created something where I use passport.js and use the FacebookStrategy so it saves the user in the session. I have looked at passport-facebook-token, but I am having trouble using this.Maybe what I am searching for the most is a good article or tutorial on how to make this basic authentication system since it is my primary problem, because the application in itself is being kept very simple. I just want to learn about node, mongo, express and later on iOS development (on a side note, I study Computer science, but we do not learn about node and such in our courses. I do however develop in Java daily and work as a student programmer, so I learn quickly).I hope that people can provide me with a nice tutorial or article, as I haven't really found something that works yet.

Submitted April 15, 2017 at 06:26PM by lidttilvenstre

Stuck installing learnyounode

I'm currently stuck like this: http://ift.tt/2oKaQOy when I try to install learnyounode on my machine. I tried running cmd as administrator, tried waiting and reinstalling. Any help would be appreciated. Thanks!

Submitted April 15, 2017 at 01:57PM by Azarl

How safe is data in req.user with Passport?

Where is it stored? Is it coming from the user with every request? If so, can I trust that a malicious user hasn't modified it?I don't know the underlying code at work so I'm not sure if it's safe for me to just trust req.user, cause it contains info like how far the user the progressed in a game, and I don't want them to be able to cheat.

Submitted April 15, 2017 at 10:11AM by NSDCars5

Friday 14 April 2017

weird issue when linking to css file on different pages

/blog 'index' page css file works fine when css is linked to just href ="main.css".But on /blog/new or /blog/edit, the css file only works with href=" ../../main.css".Blog index and other blog views are all in the same directory with the same partial header files. Also javascript isn't being linked to the same way as the css file.

Submitted April 15, 2017 at 04:13AM by caseyboyswag

A seamless way to keep track of technical debt in your source code

http://ift.tt/2pA4y1i

Submitted April 14, 2017 at 06:12PM by ratancs

Looking to make the switch from mongo + mongoose to postgres. Have some questions.

Like many new devs to node every course or tutorial I ever went through used mongo + mongoose. They've served me well so far because of the ease of use and flexibility of the schema but after doing more and more research I can't help but feel like I'm always using the wrong tool for the job. Pretty much all of my apps end up having relational data and I feel like I need to switch to a relational db asap. I realize there are tradeoffs for both but I feel like I've been forcing mongo to act as a relational db, when I could just be using a relational db in the first place.That being said, I've been doing research on both basic SQL and the current node tools available for interacting with SQL db's. I don't have much experience at all with fundamental SQL concepts so I'll probably go through a basic SQL course on Pluralsight. They also have a course on there for using Knex with Postgres which looks promising.I've found some good knex + postgres tutorials as well:http://ift.tt/2ouyKvC still have some questions that I was hoping you guys could offer some help with:I've been using some great mongoose features like validation for my models, pre-save / post-save hooks, and being able to call populate to populate a model's relationships. What is this like in Postgres / Knex? Anything missing or any tradeoffs?Am I correct that Knex is one of the most popular node libs for using Postgres? I've also seen mentions of Bookshelf, pg-promise, etc. but not sure what their current standings are. I'm basically looking for ease of use, power, and flexibility. Also promise based helps I'd like to avoid callbacks.Are there any cool things that you can do with Postgres and any libs that I should know about? I've heard people say Knex is easy to do unit tests with.Any problems or tradeoffs I should be aware of when making the switch? I've heard people say that Postgres can be harder to work with because of the need for migrations but don't have a ton of database experience so I need to look into some of this stuff.I've been building REST API's backed by mongoose, and there are some libs that will automatically create endpoints based on your mongoose collections, create a query object from your query string, etc. Are there any tools like this for Postgres?I'm planning on starting the switch this weekend so any help is greatly appreciated thanks!

Submitted April 14, 2017 at 05:08PM by m9js

Ruby on Rails vs. Express.js

http://ift.tt/2pegeKq

Submitted April 14, 2017 at 02:22PM by milo_pl

Node.js Weekly Update - 14 April, 2017

http://ift.tt/2pgdp9b

Submitted April 14, 2017 at 10:10AM by hfeeri

Thursday 13 April 2017

Please recommend a DB for E-commerce (Performance is number one priority)

Hey folks, first post in here.I want to make a fairly simple web shop (one language, no rating/reviews, basically no bloat).I want to make it ridiculously fast, and to have a very good SEO (that's why Server Side Rendering is important for me).I am planning to use http://ift.tt/2od3vmT. Have tested it, satisfied by rendering speeds (300 ms), requests per second (1.7K), and survival in ab.exe -n 100000 -c 100 without even requests per second decrease :) But the only concern, which I have is about MongoDB.So far the requirements are such: 200 products 21 categories (5 of which are subcategories) 4 product variants sale / regular price basic stock management (just in stock / out of stock to disable the ability to add to the shopping cart) Shopping cart, user management, orders by userQuestion #1:Will MongoDB degrease the original performance (with such simplest design). And if so, from what I understood, the competitors are RDBMSes such as Postgres.From what I understand ORMs are huge decreases in performance with them and it's better to use something like http://ift.tt/2pzs3Y6 #2:Has anyone had experience with http://knexjs.org and what response rate to expect from it on basic operations with pagination (count all the products in category, divide by set items per page, and to display first pagination, then second and so on).If you have better suggestions, please let me know, but keep in mind I want to keep the lowest rendering time + SSR, so need fast respond rate.

Submitted April 13, 2017 at 11:48PM by ngDev

Merge sql data fetched from node and populate/merge with table from html?

Hey Node community I was able to connect and retrieve data from the data base using node, serve html pages to a browse and now I have to use that data to populate a table that is HTML based. Is there any way to do this . I haven't found a way for node to talk to pass that info to HTML or found a way for HTML to expect data from node. Essentially how do they talk to each other efficiently. I am aware of sequelize but i just want to render the html file and the data i get from the relational database. here is some code. I am able to only show 1 at a time per route. Either the data retrieved from the DB or the html file i am serving but i need to serve both because i essentiall need to popululate a grid from html with data from node and My relational db(MariaDB).//conecting to data base var mysql = require('mysql'); var express = require('express'); var path = require('path'); var app = express(); var http = require ('http'); var fs = require('fs');var connection = mysql.createConnection({ host: 'localhost', user: 'root', password: '1234', database: 'testdb' }); //-------------// sql app.get('/', function(req, resp){ //sql call connection.query ("SELECT full_name FROM users WHERE user_id = 2 ", function(error, rows, fields ){ if (!!error){ console.log('error in the query');} else { console.log('successful query') resp.send('Hello ' + rows[0].full_name ); } }); })app.get('/', function(req, resp){resp.sendFile('index.html');}) //sets the port app.listen(8080);

Submitted April 13, 2017 at 09:40PM by cyberninja007

Looking for specific types of Node learning materials

I'm a "tutorial learner" - I learn best when working through a tutorial. So, I'm looking for tutorials that take you through the process of building a non-trivial app. Obviously I'm looking for something Node related, probably MEAN stack but I'm open to alternatives to Express and Angular, as well as the database used.I've tried NodeSchool and didn't care for it.Bonus points for written tutorials but videos are OK, as long as the presenter does a decent job presenting the material.

Submitted April 13, 2017 at 09:02PM by botchlings

Prettier is an opinionated JavaScript formatter.

http://ift.tt/2m6jweG

Submitted April 13, 2017 at 08:16PM by ratancs

Communicating with other languages to use Node.js as a plugin system.

I'm using Go to write a forum software. I've been experimenting with a few different ways to implement a plugin system in a language that would be more familiar to potential contributors I figure JavaScript would be a good idea here to cut down on the number of different languages a contributor would have to know (Go, JavaScript, CSS, HTML right now). Does Node.js have a way to communicate with other programs via RPC calls or stdin/out to act as a pre-built plugin system? There is a V8 package, but V8 is huge and a pain to build every time, and I don't want to going through the trouble if it turns out to not work. Ideally, a plugin system would be able to have my server send Go functions (not results of a function call) to JavaScript and vice versa. Is this possible or would it be a waste of time?

Submitted April 13, 2017 at 07:29PM by eggbertx

How to deploy fault-tolerant Node.js apps with PM2 and NGINX

https://youtu.be/2X4ZO5tO7Co?list=PLQlWzK5tU-gDyxC1JTpyC2avvJlt3hrIh

Submitted April 13, 2017 at 06:29PM by insane-architect

Node module for statistics

Which node module for statistics can the community recommend? To calculate for instance a quantile of the standard normal distribution of a sample, etc.

Submitted April 13, 2017 at 04:18PM by Gattermeier

Can't seem to get cookie testing working in Chrome at localhost or even at 127.0.0.1:[port] doesn't work.

I've found a lot of information on this. I think this is the best resource I found. But still I'm unable to get a cookie accessible in the JS, in the console, or in Dev Tools > Application > Cookies no matter what. I'm using client-sessions for sessions which is working and I don't care that I'm not able to access that cookie. But I'm just using res.cookie(...) and cookie-parser for handling a token and I need to be able to work with that. Postman receives them both no problem, but I just can't seem to get it going in Chrome.Here's how the cookie in question looks in Postman when it comes through:token=j:{"id":5}; path=/; domain=localhost; Expires=Tue Jan 19 2038 02:14:07 GMT-0500 (EST); Wish wish wish I access get that in Chrome!Thanks!

Submitted April 13, 2017 at 04:42PM by L000

NPM, yarn, and Ubuntu 17.04

ELI5: How do I install npm and yarn on Ubuntu 17.04? I installed on windows by downloading/running installers from the websites; works great there.Context: I've tried the obvious stuff and google search links. The official repos are old to the point of not working. The most promising approach seems to be adding the binaries on the NPM site to the home directory, then adding the bin directory to /etc/environment ; still doesn't work, looking like this:PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/david/node-v7.9.0-linux-x64/bin"The PPA etc link that show in searches all break when trying to install.

Submitted April 13, 2017 at 04:46PM by firefrommoonlight

NodeJS and Good Practices - Separation of concerns doesn't need to be boring

http://ift.tt/2o69Hgq

Submitted April 13, 2017 at 05:02AM by TalyssonOC

Why does net.connect() give read ECONNRESET but telnet is fine?

var client = net.connect(43, server, function() { client.write(domain + '\n', 'ascii') })yields{ Error: read ECONNRESET at exports._errnoException (util.js:1050:11) at TCP.onread (net.js:581:26) code: 'ECONNRESET', errno: 'ECONNRESET', syscall: 'read' }However,telnet xxxx 43yieldstelnet xxx 43 Trying xxx... Connected to xxx. Escape character is '^]'.

Submitted April 13, 2017 at 06:07AM by zllovesuki

JSON to (LaTeX) PDF as a NPM package?

I'm looking for a solution for the following problem:I have JSON data.I want to pass this to a NPM package (that I'm making) that will take the data (and a stream) and result in a PDF generated from the data (on the stream).The resultant PDF needs to be quite detailed; I've looked into some packages that do this directly and found they lack the level of detail needed.For reference, the resultant PDFs are going to be a (less graphical) version of this. The ability to flow text over two-columns is a huge plus, but if you have a solution that only works for one column I'd consider it.My initial thought is to use LaTeX as an intermediate package, creating a TeX stream that is passed to a LaTeX engine and piping the result to the output stream.The bit that's causing me issue is finding a decent "TeX to PDF" engine that:Can be run in NodeHas no other dependencies other than what comes with the package (e.g. some are simple wrappers around CLI commands, which requires they be available in your system).Is able to handle varied input data (i.e. can smartly deal with wrapping columns/pages).Anyone had any luck with this before? Packages I've looked at but drawn a blank on because either lack of features, extra dependencies, or simply not getting how it works:node-latex - simple wrapper around the CLIpdftex.js - uses Emscripten, something I am not familiar or comfortable with. If this is viable for use in an NPM package please do point me at how to go about using it.texlive.js - as per pdftex.js, seems to be roughly the same sort of thing but wrapped differently.If you've got a non-LaTeX solution that supports what I need, definitely shout it out as well! pdfkit doesn't seem to have what I need without making my own layers on top to make rendering text properly not a huge chore. If that's what I need to do then I'll do it, I just want to get on with the project rather than the infrastructure around it.

Submitted April 13, 2017 at 06:13AM by Tidher

Node v7.9.0 release notes

http://ift.tt/2o4iaS1

Submitted April 13, 2017 at 06:55AM by fvilers

Wednesday 12 April 2017

Looking for a nice model package, any suggestions?

I need to create super simple app (thus I don't see any need to put React in it) the only feature will be pretty much filtering through dictionary of ~5k short strings.In the past I used Qt framework a bit and it had a nice Proxy Model (QAbstractProxyModel) class that was used by the view, and it did the job nicely. I'm looking for something similary convienient like this.Any suggestions? Thanks!

Submitted April 12, 2017 at 11:28PM by mlewand

What about a combination of zookeeper and in-memory caching for web-farm/cluster scenarios?

When choosing caching locations, people either choose in-memory solutions, or out-of-process solutions (redis, etc).When running a web-farm/cluster setup, people almost always choose out-of-process, for obvious reasons.There are still drawbacks for using out-of-process.Network latency. You are still making network requests, but to a fast end process.Serialization. Send data has to go over the wire, you have to worry about serialization (json, protobuf, etc).Probably more, but this makes my point.The main problem with using in-memory solutions for a web-farm/cluster, is that different instances may have different/stale data. So, you have to worry about load balancing and sticky sessions. Even then, there are other issues that would have to be dealt with.What about using this caching pattern for in-memory providers in cluster scenarios:Add data to the cache using in-memory provider. Don't worry about serialization, async, etc.When a request is made to clear the cache, send a global event to all instances (using ZooKeeper, or something similar) to flush the local in-memory cache.There may be issues with this approach, in that some memory providers use local timeouts for expiring data. This would potentially cause data in-consistency issues, but this wouldn't be a problem as long is proper care is given when updating data that may be cached (clearing the cache manually).I've never seen this approach used anywhere, so I think I am missing something that others haven't.What do you guys think?

Submitted April 12, 2017 at 09:13PM by theonlylawislove

Running Node on WSL.

Is anyone else trying to do this?The Windows 10 Creators Update went live yesterday, which includes some major updates to WSL (Ubuntu on Windows). So I figured I'd try installing Node and see how things go.Node actually installed correctly, and it appears to run fine. But npm is another story, running npm -v says:: not foundram Files/nodejs/npm: 3: /mnt/c/Program Files/nodejs/npm: : not foundram Files/nodejs/npm: 5: /mnt/c/Program Files/nodejs/npm: /mnt/c/Program Files/nodejs/npm: 6: /mnt/c/Program Files/nodejs/npm: Syntax error: word unexpected (expecting "in") One of the updates to WSL is the ability to launch Windows executables from WSL. It's obviously trying to run the npm that's installed in Windows. Which is strange, because whereis npm returns /usr/bin/npm as the first result (and the Windows npm as the next). In fact, if I run /usr/bin/npm, it works, but obviously I shouldn't have to do that.

Submitted April 12, 2017 at 08:37PM by EntroperZero

Module to check for file changes by comparing against a saved file with sha/md5

I'm looking for a module that does the following:Given a glob/list of files calculate checksums (pref sha but md5 is fine) generate a file that contains the checksums for each file passedGiven a checksum file and a glob/list of files tell me which files have changed/been added/been removedI can roll this myself, but I'd prefer to not re-invent the wheel if something already exists. I've found quite a few modules to generate the checksum file, but not much in the way of checking the file, and nothing that does both.

Submitted April 12, 2017 at 07:13PM by skarfacegc

Backslide: CLI for creating self-contained HTML presentations using Markdown, and more...

http://ift.tt/2p6TrAt

Submitted April 12, 2017 at 07:40PM by sinedied

Best Package for Money Arithmetic?

Hey Node Friends. I'm going to have to build a system that deals with currency and money arithmetic for the first time. We are all aware that using floating points is problematic for these sort of calculations.Is there a preferred library by the community that deals with this stuff?The best I've found on my own is http://ift.tt/2oyfgIm

Submitted April 12, 2017 at 11:12AM by IQUESTIONSHARD

Node.js IoT project: Home Explorer Rover with LEGO, SBrick & Raspberry Pi

http://ift.tt/2oyfaAt

Submitted April 12, 2017 at 11:36AM by hfeeri

Frontend Local Setup 8 - Installing GIT on Windows For more video tutorials subscribe to our Youtube channel https://www.youtube.com/channel/UCw4cxFG34-cCbG5RdA-7mTw

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

Submitted April 12, 2017 at 10:09AM by TutorialsDojo

Create a YouTube App with React and Node.Js

http://ift.tt/2orHgx2

Submitted April 12, 2017 at 08:56AM by gdangelo

Tuesday 11 April 2017

Node js Multiple Server Architecture.

Hi, I am sure I botched the title, but I don't know a better term for this. So, in my use case, I am trying to set up a node app which will accept a image that I upload and do some processing on it and return back some result. But the image processing that I have to do is compute heavy and requires a GPU. So I need to send the image from the initial server(A), running node to another server(B) containing a GPU to do the processing. So do I do this. An high level idea, is the server A will send the image to server B using some protocol.1) But how do I implement this in node ? Like how do I tell node, send this here.2) how do I specify server B to server A? IP address yes, but do I feed the network architecture, say some blob specifying server B is at this IP into server A so that it knows where server B is ? Can I use a private DNS or something like that ? Are there any tutorials specifying how to do this ?3) I wanted to introduce load balancers in front of A's and also in the connection between multiple A's to multiple B's . That is if a request comes up in say A' it has to send data to another B set, say B', instead of the B instance which is already running the previous request ?4) I want to set this up on AWS, so any AWS specific tutorials would be great !I apologize for the many questions, this is all pretty exciting and new to me, so I wanted to understand it better. Thanks!

Submitted April 12, 2017 at 03:55AM by robot_t0

Passportjs deserialize and reading from session vs database

If passport deserializes the user on every request to a route that uses passport for authentication, assuming we use the following function which is used in most examples: passport.deserializeUser((id, done) => { User.findById(id, (err, user) => { done(err, user); }); }); In that case why not just read data from req.user for GET requests rather than going to the database for an additional lookup of data that already exists in req.user?Is it because we might use something like redis in the future instead?

Submitted April 11, 2017 at 11:42PM by linasmnew

AsyncJS vs Promises vs async/await

Which approach in NodeJS is best/most used these days? Would love to have a technical insight in deciding which is better.

Submitted April 11, 2017 at 08:38PM by spirits0n

Help with unit testing.

I am learning how to unit test on my own and was wondering if someone can help me test this file? I have mocha and chai installed, but I'm not quite sure how to test the res.render part of the router.get function. Here is the codevar express = require('express'); var router = express.Router();/* GET users listing. */ router.get('/', function(req, res, next) { res.render('about', {title: 'About'}) });module.exports = router;

Submitted April 11, 2017 at 07:25PM by ObiJuanKanobe

Electron is flash for the desktop

http://ift.tt/2f7vS57

Submitted April 11, 2017 at 05:07PM by ratancs

How do I insert a row every 2 columns with Jade/Bootstrap/Express?

Right now I have: .row each partner in partnerlist .col-xs-6 p #{partner.name} p #{partner.phone_number} p #{partner.website} img.logo(src='#{partner.logo}') But what if I wanted it to appear like this:


Submitted April 11, 2017 at 05:13PM by mineralwatersoda

Use the Node.js event loop effectively: How to avoid unexpected results in your Node.js apps

http://ift.tt/2p1Jt3h

Submitted April 11, 2017 at 04:32PM by turbotodd

How to not let anyone POST/PUT/DELETE on my API ?

Currently I have a API that when I go to the URL of "localhost:3000/api/todos" I can get a list of all the todos from my MySQL Database. If I go to /api/todos/1 I will get a single todo...if I POST to /api/todos I can create a new todo and PUT to /api/todos/1 I can update the todo with id of 1 and yeah so on, very simple.Now, say I want to build on this... I want to create a site where.You make an account and can login.View your todos, edit todos and so on.For the front end/client side. I want to use ReactJS to retrieve the todos of the logged in user via the API URLs I created. ReactJS will also POST and PUT to my api url /api/todos and so on.However, anyone can go into, say, PostMan or any REST client and POST, PUT into the API URLS that I have setup.How do I fix this ? A middleware that checks if the user has a session ? What if I want to make this API available for anyone ? How will I make sure the user is logged in ? Is this where headers come in ? What if I only want ReactJS to post/put to my own api, how do I prevent people from using my api urls that I setup.How do I add that to my express app ? Middlewares ? I want to make this secure as possible. Here is a rough example of what my current POST 'api/todos/' looks likeapp.post('/api/todos/, (req, res) => { Todos.create({ title: req.body.title, desc: req.body.desc }).then( (todo) =>{ res.status(201).json(todo) }). catch(// blah blah); }) TL;DR: With the code above, anyone with a REST client can create a new todo...I do not want that. I only want MY CLIENT/ReactJS to be allowed to POST , DELETE, PUT. If I want to make this API available, how do I check so that not anyone can PUT and POST and DELETE a todo with a API client.

Submitted April 11, 2017 at 04:48PM by HappyZombies

Data driven website with node help?

Hey fellow node developers you guys inspire me. I hope to become as good as you one day. My question is how can i use node.js to grab HTML/CSS & and javascript data from a relational database to render in the browser? My question probably sounds simple but i am stuck as a newbie . Some has advised me to use MONGO but I am not familar with nosql.

Submitted April 11, 2017 at 02:44PM by cyberninja007

Mastering the Node.js CLI & Command Line Options

http://ift.tt/2nYl7CP

Submitted April 11, 2017 at 10:39AM by hfeeri

Trying to create a script to login to a website

I want to create a sccript to log into: http://ift.tt/2poqdtj i dont really know how to go about this. In some forums i have read that i should use the request module. When i try to post the name and pw in a form it doesnt work tho.Can someone tell me if this is actually possible? And maybe give me some advice how i could program it.Thanks in advance

Submitted April 11, 2017 at 10:03AM by Darkness969

Frontend Local Setup 7 - Updating Node and NPM on MAC. For more video tutorials visit tutorialsdojo.com

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

Submitted April 11, 2017 at 09:36AM by TutorialsDojo

Monday 10 April 2017

Question about streams and accessing file content

I'm trying to create an Excel worksheet with Node.JS and be able to upload it to Dropbox using their API. This is how I create the Excel spreadsheet.const Excel = require('exceljs') const workbook = new Excel.Workbook() workbook.addWorksheet('My Worksheet') const myWorksheet = workbook.getWorksheet('My Worksheet') myWorksheet.columns = [ { header: 'Name', key: 'name', width: 32 } ] myWorksheet.addRow({ name: 'John Doe' }) workbook.xlsx.writeFile('my_worksheet.xlsx') .then(() => { console.log('Worksheet created successfully') }) This works great, but I don't want to save it to a file. I would like to know a way to save the contents of the file in a variable/stream? (I'm a beginner at node). The ExcelJS docs mention something about using streams but didn't say anything about accessing the file content.This is how I upload a document using Dropbox's API.const Dropbox = require('dropbox') const fs = require('fs') const dbx = new Dropbox({ accessToken: '' }) fs.readFile('./test.txt', 'utf8', (err, contents) => { if (err) console.log(err) dbx.filesUpload({ path: '/test.txt', contents: contents }) .then((response) => { console.log(response) }) .catch((err) => { console.log(err) }) }) Thank you.

Submitted April 11, 2017 at 03:37AM by 39103910319vbrhbvfb

Angular 2 + Node.js - Build Socket Chat Application

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

Submitted April 11, 2017 at 02:53AM by jakblak90

Learn NodeJS With Me (Part 5) - ECMAScript 5 - Object.create and Propert...

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

Submitted April 11, 2017 at 12:18AM by grouseydaryl

Employer here: Is anyone looking for part-time or full-time work?

We're running a Node / Mongo stack. I'm the technology director, looking for talented people that can quickly add value.If interested, send me a PM with any relevant info and I'll call you to discuss.Very relaxed work environment. Work entirely from home. Just have experience and a grasp of the tech, please, because I'll be working with you directly and often reviewing your code. Thanks.

Submitted April 10, 2017 at 11:16PM by wuh_happon

Demo node site for interview

Hey guys. I had an interview recently where part of it was to see if I could spin up a node server and get a site working.I created http://ift.tt/2oYRXYX you guys take a look and see if I flubbed the interview or not? I only spent like 6-8 hours on the site. The core fun functionality is on the game page... Please let me know your thoughts I got like no feedback from them that I could gauge a positive or negative from. You can use the chat app if someone else is online also to play a game of tic-tac-toe. Just refresh browser after your done with the game to create a new session.

Submitted April 10, 2017 at 10:10PM by ALegionOfOne

Easy and production-ready library for configuring Node.js servers

http://ift.tt/2okk9nZ

Submitted April 10, 2017 at 09:59PM by mjlescano

Why Node is better than PHP

http://ift.tt/2pmyga4

Submitted April 10, 2017 at 09:29PM by samrapdev

Origins of JavaScript, or ECMAscript - from 1997 to 2017 and beyond.

http://ift.tt/2oYEgJe

Submitted April 10, 2017 at 07:57PM by sunnykgupta

The Node.js Interactive CFP ends at midnight PT - be sure to submit talks if you've not already!

https://twitter.com/nodejs/status/851474867337797632

Submitted April 10, 2017 at 07:19PM by _bit

Writing a library: return Date or Unix timestamp?

I'm currently writing a library to be published on npm. Some of the data returned is a date/time.Is the best practice to return a JavaScript Date object or a simple unix timestamp number?

Submitted April 10, 2017 at 07:29PM by wtf_are_my_initials

Last Week in Node.js Working Groups - April 3, 2017

http://ift.tt/2okgdC9

Submitted April 10, 2017 at 06:15PM by _bit

Handle validation in knexJS?

How to handle validation using KnexJS? Is there's a way to handle 'field-specific' errors when using knexJS? , I could easily get the error through the error code BUT I need to provide a more meaningful message to the end user, for instance, instead of replying with "Duplicated Entry" I want to reply with "User name already exists".Thanks in advance

Submitted April 10, 2017 at 05:27PM by munzman

Solr engine nodejs library

http://ift.tt/2o1Oo3Y

Submitted April 10, 2017 at 12:23PM by _dmomer

CSV & Excel: escape from the encoding hell in NodeJS

http://ift.tt/2oXpLCX

Submitted April 10, 2017 at 12:48PM by georgesbiaux

How to enforce foreign key constraints using KnexJS?

Created a sqlite3 schema using KnexJS and everything went fine. There's an issue though. I have two tables , one called "todo" which has a foreign key "userID" that references the "id" field in "users" and the other table obviously is "users".The issue is that If i add a new entry to the "todo" table and leave the "userID" field empty , i dont get any error!!! i.e i can have the "userID" field empty which mean the constraints dose not work. any idea WTH am i doing wrong? thanks in advancehere's the code// Todo migration exports.up = function(knex, Promise) { return knex.schema.createTable('todo', function(table){ table.increments(); table.text('title').notNullable(); table.integer('priority').notNullable(); table.text('description'); table.boolean('done').notNullable().defaultTo(false); table.timestamps(); table.integer('userID').unsigned(); table.foreign('userID').references('id').inTable('users').onDelete('CASCADE').onUpdate('CASCADE'); }); }exports.down = function(knex, Promise) { return knex.schema.dropTable('todo'); }// Users migrationexports.up = function(knex, Promise) { return knex.schema.createTable('users', function(table){ table.increments(); table.string('name').notNullable().unique(); }); };exports.down = function(knex, Promise) { return knex.schema.dropTable('users'); };

Submitted April 10, 2017 at 12:09PM by munzman

Mightyql – A higher-level abstraction of the node-mysql2 driver with strict types and convenience methods for common operations.

http://ift.tt/2ouixFj

Submitted April 10, 2017 at 10:41AM by gajus0

Sunday 9 April 2017

On form submission, how to get value of div if its not a textarea/input with name attribute?

In my route ill have something like:var blogName = req.body.name;But how would I get a div value that is contenteditable because for some reason contenteditable doesnt work on textareas.

Submitted April 10, 2017 at 01:51AM by mineralwatersoda

Best tutorial for node?

In what tutorial helped you learn node the most?

Submitted April 10, 2017 at 12:33AM by caseyboyswag

How come nobody mentioned Lambda now supports 6.10.0?

Guys, this is embarrassing. This is THE best place for all node news. And nobody says anything? AWS published the news last month!Well, whoever else has been waiting for that news, you got it now :)

Submitted April 09, 2017 at 07:42PM by rnemec

10 Must know terminal commands and tips for productivity (Mac edition)

http://ift.tt/2oeGQtJ

Submitted April 09, 2017 at 03:18PM by 29-97-frames-per-sec

Make npm's flat dependencies easier to find and sort

http://ift.tt/1ON3bSE

Submitted April 09, 2017 at 12:58PM by bittered

Moving from Python to JS

Hi all, I am wanting to learn some JS/Node to help a friend develop some systems. While not a developer by trade, I use Python to automate tasks at work and building simple programs.I am just wanting to know if anyone can recommend a good resource. Basically how I learnt Python was using the Python official manuals and O'Reilly's Python Pocket Reference. Can anyone recommend resources similar to this that don't focus on front end programming?

Submitted April 09, 2017 at 09:26AM by abyssofmyass

Saturday 8 April 2017

includes in NodeJS

Is there a nodeJS version of like ?I have index.html, room.html, chat.html, forum.html and in each of these html, there is a div called user-cp.Instead of coding content into user-cp individual in each html, is there a way to just code it once and put it into the div?They also have the same top div where banner and links go. If I want to edit this part of the page, I have to go through all 4 html to change them.There has to be a more efficient way in nodeJS.

Submitted April 09, 2017 at 05:17AM by eggtart_prince

Functional JavaScript: Decoupling methods from their objects

http://ift.tt/2mk5Iww

Submitted April 09, 2017 at 02:39AM by fagnerbrack

Functional Programming library for JS that supports named-argument style methods

http://ift.tt/2mXZGFR

Submitted April 09, 2017 at 02:34AM by fagnerbrack

Has there been any recent progress with node frameworks?

I'm speaking out of use of express both back in ~2012 to today, it feels like the same thing. Is there any frameworks more evolved for web app / api development?

Submitted April 09, 2017 at 01:42AM by sorry_mother

Sending SMS Messages from my Node.js Application

I am developing a node.js app for management of a school and one of the features requested is the ability to send messages to the parents. The providers in the country do not have email gateways (don't know if that is the right term), so I would like to send messages by connecting the phone. Is that possible?

Submitted April 08, 2017 at 08:44PM by SuperKXT

How's the Node development experience on the Windows Creator's Update?

The last time I tried Node development on Windows I was turned off by how clunky it was, I hate having to do workarounds for everything. But I also dislike having to dual boot into Linux or run a Linux VM.I've seen a lot of hype about the new Windows Subsystem for Linux, but how well does it actually work? I need Node, Rails, docker, and PhantomJS.

Submitted April 08, 2017 at 06:49PM by sparkbusiness

Help request: Koa routes broken with HTTPS

Hey guys, banging my head against the wall and hoping someone can help. I'm setting up HTTPS on my koa2 API with letsencrypt, using the last part of this DigitalOcean guide. I'm using a nginx reverse proxy. Everything works fine with HTTP but with HTTPS my routes are broken, and I'm having a hard time finding the cause. For example, with plain HTTP, making a request to http://ift.tt/2nrEngs, I'd see a request looking something like{ request: { method: 'GET', url: '/api/some-route', header: { 'origin': 'https://myapi.com', accept: '*/*' } }With HTTPS it looks like { request: { method: 'GET', url: '//some-route', header: {accept: '*/*' } } The request.url is funky and the origin header is missing. I'm wondering if it's an issue with my nginx config, but having a hard time figuring out where to start.

Submitted April 08, 2017 at 07:00PM by harumphfrog

CSS Rebase Gulp plugin

http://ift.tt/2o9Ic7i

Submitted April 08, 2017 at 02:33PM by RobinCK

Deploy a Node.js with Couchbase Web Application as Docker Containers

http://ift.tt/2o5XV9z

Submitted April 08, 2017 at 10:52AM by harlampi

Do any frameworks offer native sdks for Android/ Unity 3d

I miss parse.I'm looking for a backend framework like feathers js with an sdk for calls from Android / Unity ( C#)Does this even exist

Submitted April 08, 2017 at 06:56AM by QaThrower

Friday 7 April 2017

open source RESTful dungeon generation API server

http://ift.tt/2ohwLMV

Submitted April 08, 2017 at 05:23AM by tonechild

Is loopback any good? I'm not sold on it

I've been looking into loopback recently. Just wondering if anyone here is using it and has any opinions of it.Having a thorough read through the documentation I've come to the conclusion that I personally don't like it. My reasons are:The documentation is average at bestI don't like how it abstracts the database behind a very generic 'storage' interface. Yes I understand it's possible to configure how the loopback fields map to the underlying database field but say I wanted to use Postgres' JSONB field. There isn't a way to query it via the storage api.I hate how it exposes it's its own DSL via the rest interface e.g. http://localhost:3000/api/locations/findOne?filter[where][city]=Scottsdale. This effectively couples your API consumers to loopback's idea of REST.It lacks a built-in migration framework. How do you add a non-nullable field to a table you have in production?!?To me it seems loopback is purposefully opinionated which I guess is fine if you don't have an opinion or if you're a frontend developer without any backend experience.Would love to hear other peoples thoughts or be convinced why loopback isn't that bad.

Submitted April 08, 2017 at 05:30AM by Groady

My life is a lie...

I have been mostly a LAMP developer for the past few years, and despite the huge community and great opensource projects, I always feel kind of tired of developing with PHP.Hard to keep my projects consistent, clean, easy to maintain and motivated to work with. Lots of shared code, tons of frameworks, but its like nobody speaks the same language and everybody is doing things their own way.Laravel brought a lot of people together, but still....Today watching a video about Node, and it was BEAUTIFL... I feel like my life has been a mistake, a lie, and that NodeJS is the light of the truth. Oh God, forgive me but I feel like I want to worship Javascript and become a God myself with NodeJS as my base of creation.I'm in love!!Now... my dear people, give me some more light, and let my eyes see the way to the infinite of possibilities with NodeJS.As a mostly backend developer with php and limited front end using Javascript and JQuery, I want to know if there's any Node tutorials best suited for coders with php background, and not used to advanced javascript.Namaste!!

Submitted April 08, 2017 at 03:18AM by estupor

Trying to filter Twitter JSON object by keys always returns undefined error eventually

I'm using the 'twitter' npm package. I can receive some of what I want but it eventually returns an undefined error without fail. Is anyone experienced with the streaming API?

Submitted April 07, 2017 at 11:52PM by Chigurhshairdresser

Building & Deploying a Ghost Blog with Nanobox

http://ift.tt/2pbD0iz

Submitted April 07, 2017 at 11:24PM by scott_dsgn

Why is my wildcard route firing even after the res is sent at the correct route above it?

A simplified version of my app and issue:const express = require('express') const app = express() const router = express.Router() app.use(router) router.get('/', function (req, res) { res.send('Hello!') }) router.get('/*', async function (req, res) { console.log("NO!!") }) If I go to http://localhost:7000 I get BOTH 'Hello' in the browser - indicating that the request has been routed and handled by my first route... but then I ALSO get 'NO!' in the log - indicating that multiple routes are responding to the same request. This is surprising, and not preferred behavior.

Submitted April 07, 2017 at 07:36PM by L000

How is NodeJS async function calls different from native threads implemented using C++ (say using Qt5)?

I was wondering how would the performance vary for an event-driven application in following two implementations:Using Node, where events are handled by callbacks, and the language is built with concurrency in mind from ground-up.Making a GUI application using Qt5, where callbacks are connected using signal and slot mechanism. This is more tedious than the previous one but is widely used. I might use a thread pool of workers and a queue of tasks.How and why would the performance vary in either?

Submitted April 07, 2017 at 06:04PM by himanshub16

ELI5 - when is concurrency/asynchronousity awesome?

I'm relatively new to node, and finding out a lot about when concurrency/asynchronously is not awesome.One thing plaguing me is the multiple asynchronous database calls. If they are related, I want them all to work, or none at all. But as they all go at once, or else are chained together in Promise.all, or a try block, or a christmas tree of .then() statements, or awaiting on each other they are still independent, and that's a real problem for me, a partial success in terms of only a few out of multiple calls being successful is an issue in terms of ruining the dependent data, and none of these strategies seem to handle a rollback.But I know there is awesomeness. Where is the awesomeness? How does it work, and when does it come into play?

Submitted April 07, 2017 at 03:00PM by coderbee