Saturday 31 December 2016

scraping multiple pages

I'm having troubling looping over multiple sources to scrape, any suggestions on how I could make this work?var request = require('request'), cheerio = require('cheerio'), titles = []; msites = { site_1: 'site1link', site_2: 'site2link' }; for (msite in msites) {request(msites[msite], function(err, resp, body){ if(!err && resp.statusCode == 200) { var $ = cheerio.load(body); if(msites[msite] == 'site_1') { $('.pw-links-music ul li a div + div').each(function(){ var title = $(this).html(); titles.push(title); console.log(msites[msite]) console.log(titles); }); } else if (msites[msite] == 'site_2') { $('.penci-grid .list-posttt .grid-title a').each(function(){ var title = $(this).html(); titles.push(title); console.log(msites[msite]) console.log(titles); }); } } }); }

Submitted January 01, 2017 at 04:54AM by waveyrico

Concatenate & Minify server-side js

I am relatively new to node and I have been working on a project for the last few months. Recently I found out that the application will be deployed to the clients server (originally, it was supposed to be hosted in house).I've done some research on creating "binaries" and other methods of protecting the source code, but my efforts have been fruitless.I have used gulp to concatenate and minify/uglify the client-side JavaScript, and I want to do the same with my server-side code. I know the clients would still be able to view the source, but I want to make it as difficult as possible to follow the logic and I think this would be the route to go.Is there a package or an easy way to accomplish this? It's not really a small project and I'm not really sure how to go about this. Any help or alternatives would be great. Thanks!

Submitted January 01, 2017 at 03:15AM by pastafarianConQueso

@Decorators - the new way to write NodeJS applications

Hi guys,Regrading to popularity of NodeJS and Javascript, Typescript I decided to create basic and essential decorators for this stack. Everything that is available is on GitHub http://ift.tt/2hzwKNs this library I tried to make my life and life developers, that will decide to pick this library, easier. It could be implemented not in the best way or I missed something or something could be improved, of course. That's why I decided to post on reddit and Medium (http://ift.tt/2hzKtna) to get any feedbacks, pull requests or issues, to make library better and even more useful.So guys, if you are interested in it or / and you know how to improve /extend it, just let me know.Thanks.

Submitted December 31, 2016 at 03:20PM by serhiisol

What's the proper way to populate the the DOM with information from a post request without a page load.

I want make a post request and then take the response and update the DOM without a page load. Do I need to make an AJAX call within my app, or is there a node way to do this?For example//view .form(action="/api" method="POST" input(type="submit" value="Send some data" #return_value // put response in here // router router.post("/api", function(req, res, next) { res.send(data) } Then in my view update using the data above.

Submitted December 31, 2016 at 01:36PM by pm_me_gold_plz

help - simulating real time data over WS

hey, i have simulated real time data (array - with time stamp for each item) - json format and i need to built a server that reads the json file and stream (via websocket) the objects in simulated time (not all obj at once - in "real time" or X2 X4 etc..)1) tried to find in npm somthing like that - no luck seems perrty basic to me..im sure there is somthing any ideas?2) im taking about 1000 obj per second that needs to be sent it is smart to put it as a router in the complite server (simple express rest api - about 50 req per minute) - or to set it in a new server ?hoping i was clear! thanks!

Submitted December 31, 2016 at 02:56PM by Gabayto

Object Oriented file handling with node.js

http://ift.tt/2ii8mUv

Submitted December 31, 2016 at 11:14AM by dannyMcwaves

Friday 30 December 2016

Streaming data into a Node.js C++ Addon

http://ift.tt/2imrXkm

Submitted December 30, 2016 at 10:22PM by freezer333

Node version past 0.12.2 on Windows 10

Hi folks. Relative noob at node development here. I'm trying to get a little dev environment set up on my Win10 machine and I went to the node website and dowloaded the latest MSI installer for node v6.9.2.I ran the installer and node runs fine, but I keep getting errors when installing packages saying that they require node >v4.node -v returns 0.12.2Any tips on how I can get my node to recognize the current version? Should I just buy a mac? :PThanks in advance!

Submitted December 30, 2016 at 08:12PM by smithygreg

Making get/post requests to bootstrap modals. How?

I am having a really difficult time trying to make a request and communicate with modals from other websites. For regular html you can see the hyperlink when hovering over the link or find out all about the element when inspecting, but with modals it seems like all the code is hidden on their website somewhere, making me unable to send http get/post requests correctly.For ex when theres a button called "View containers" it opens up a modal and then theres a textarea field and a submit button. I know the ID of the text field, but there is like zero information on the submit button or where the submit button can lead to. I want to make a script that automatically sends a request , enter in the container # and clicks submit. But I dont know how to make the script click/send submit button

Submitted December 30, 2016 at 08:29PM by LuCas23332

Failed at deploying a meteor app to heroku

I get the following error message when I try and deploy my meteor app to heroku ,anybody knows how to fix it ?http://ift.tt/2hAsIaA package.json http://ift.tt/2ilRwlG

Submitted December 30, 2016 at 06:30PM by amrshedou

error deploying meteor app on heroku

I have deployed my app on heroku and locally it works just fine, however when I open my app I get this message "Application error An error occurred in the application and your page could not be served. If you are the application owner, check your logs for details." when I type "heroku logs" I get this http://ift.tt/2ilovqa

Submitted December 30, 2016 at 05:13PM by amrshedou

Anyone interested to learn 'Node.js' from novice to advanced collaboratively?

https://colearn.xyz/

Submitted December 30, 2016 at 05:16PM by spandey256

/r/node what's your thoughts on storing the JWT?

Right now im using passport-jwt and it doesn't store the jwt in the db at all. My thoughts are mixed on this as i'd think you'd want to store it in the db and look it up.The idea would be to create a model for users, and another for tokens, store all tokens in a collection/table and toggle the status based on revoked/expired. Each time the token is provided look it up in the db, and find the associated user.what is the general consensus on JWTs and if you should store them or not, why wouldn't you?

Submitted December 30, 2016 at 03:37PM by ndboost

Daemonize/automate start of node express server.

I've got a home server running Ubuntu Server 16.04.1 64-bit.Right now to keep my express server going I've got a manual screen session running the command "sudo nodemon server.js" to watch server.js for changes on the fly.But after a while and some reboots I've grown tired of having to start a screen session when I want the server running.I know what you're going to say, "Check out PM2 it's great for daemonizing node applications on linux." but when I run"sudo pm2 start server.js"I can't load my views/routes because it tries looking for them in my home directory. And if i try"pm2 start server.js -i 0 --name "servername"I can't connect to my MongoDB database.Any suggestions for a replacement to PM2, some script to automate a screen/tmux session automatically starting my server or if you know any solution to the PM2 situation is greatly appreciated.

Submitted December 30, 2016 at 01:42PM by joelpwnar

Should I create a jwt token when i POST to the /user?

So when I POST to /user I simply create a user object, hash the password etc.I was wondering if I should be creating a token at this time as well or should i leave it for /authentication as I have already.// create a new user account router.post('/user', function(req, res) { if (!req.body.username || !req.body.password || !req.body.email) { res.json({success: false, msg: 'Please enter a userame, password and an email.'}); } else { var newUser = new User({ username: req.body.username, password: req.body.password, email: req.body.email }); // save the user newUser.save(function(err) { if (err) { return res.json({success: false, msg: 'Username/email already exists.'}); } res.json({success: true, msg: 'Successful created new user.', user: {username: req.body.username, email: req.body.email} }); }); } });

Submitted December 30, 2016 at 10:21AM by farhansyed7911

Thursday 29 December 2016

How should I make a POST to create user, secure?

Im creating a restful api and i have passport & jwt integrated to create a token for a user for each request.All get, get/:id, etc are protected and require a token to access.But my POST to creating users isn't required to be authenticated do I need to integreate OAuth?

Submitted December 29, 2016 at 11:57PM by farhansyed7911

How should I go about this?

So I'm currently creating a restful api for a client like iOS.Many of the users who use my app will have various ecommerce accounts, like Shopify.Some users wont have these accounts like Shopify, where I can grab their data from.My question is how should i go about letting some users have a Shopify account where I pull their data from and some users store their data with me?

Submitted December 29, 2016 at 11:15PM by farhansyed7911

Elegantly validating HTTP PATCH request body in node

Disclaimer: this question is more about REST than it is node but I'm using node so I figured I would post it here anyway.I'm implementing a REST API using Koa. So far I have post and put implemented for a particular resource (using Joi for validation).So far I'm happy about all of this but now i'm moving on implementing PATCH for the ability to modify individual properties of a particular resource. I'm a bit thrown off because for post and put, my validation schema is required as a whole. For PATCH each individual schema holds true, but none of the other rules apply since i'm only updating a single property.How have some of you approached this?

Submitted December 29, 2016 at 08:50PM by SomeRandomBuddy

How is it possible to req.body from a function outside my post method?

I'm trying to clean up the code in my post method by putting all my req.body's into a function that will return the data I need to store in my mongodb.an example of one of the 6 that i have in my post isvar club = { clubName: req.body.clubName, clubAddress: req.body.clubAddress }

Submitted December 29, 2016 at 04:35PM by SparkDe

res.json not working when making rest API calls.

Here i have this set up but i dont get what i expect it to show when calling onto the API.I expect this: { "success" : true, "message" : "Successful created new user" } but i get this: { "__v": 0, "username": "test", "password": "$2a$10$3khe9TBep0aECUaKxayPl.0NsUMguxhuHOnzqNYWWq0JDkN0Fk0bG", "_id": "5864d9afd6140cb7a6b6d4c9" } app.post('/user', function(req, res) { if (!req.body.username || !req.body.password) { res.json({success: false, msg: 'Please pass name and password.'}); } else { var newUser = new User({ username: req.body.username, password: req.body.password }); // save the user newUser.save(function(err) { if (err) { return res.json({success: false, msg: 'Username already exists.'}); } res.json({success: true, msg: 'Successful created new user.'}); }); } });

Submitted December 29, 2016 at 09:09AM by farhansyed7911

Cancelable JavaScript promises cancelled

http://ift.tt/2h7oS5n

Submitted December 29, 2016 at 05:34AM by fagnerbrack

Wednesday 28 December 2016

gapp - Generate Applications (in progress)

http://ift.tt/2i9QVFs

Submitted December 29, 2016 at 04:12AM by riotmusic

socket.io in router

Hi, I just started node.js and am currently doing some tutorials out there on google to create a socket.io based chat app.My app has /mainpage where clients can send a request to /chat/:room to create a chatroom, and /chat/:room sends html page (with scripts) back to clients. My issues is, I tried to use io.on('connect') in router.get('/chat/:room, function(...)) so that I can make socket join :room. However, every time clients hit /chat/:room, a new connection is created and causing events occur multiple times. I've been googling all day but haven't meet any satisfying solution... please help!router.get('/chat/:room', function(req, res, next) { // res.sendFile here to send 'chat.html' io.on('connect', function(socket) { // let the client join 'room' specified in the path socket.join(req.query.room); }) });

Submitted December 29, 2016 at 02:07AM by nodestarter

[FeathersJS] How do I access an object in its before remove hook?

I want to access data from an object before actually removing it from the database. Problem is the data attribute doesn’t exist in my hook, it only seems to exist in create, update and patch (like it’s stated in the docs).I tried using a get in the before hook, but that doesn’t seem to do anything, it does the console log so the code should be reached:console.log(“I’m in the before hook on remove”); app.service('products').get(hook.id).then(product => console.log(product)); But the second line doesn’t seem to do anything at all. I want to access some data of my product object before removing it, more specifically the image name so I can remove its images and thumbnails in their directories.Any help? Am I doing something wrong or is there a better solution for it? Thanks in advance.

Submitted December 28, 2016 at 07:20PM by De_Wouter

List of JavaScript Crypto libraries. 路 GitHub

http://ift.tt/1FQmXZR

Submitted December 28, 2016 at 05:20PM by indatawetrust

Linting in Nodejs using ESLint

http://ift.tt/2hwJzgn

Submitted December 28, 2016 at 05:27PM by shsh3

Node.js API Starter Kit - Node.js development inside Docker!

http://ift.tt/2iwT3UZ

Submitted December 28, 2016 at 06:07PM by koistya

Realtime Monitoring solution for Node.js/Express.js apps, inspired by status.github.com based on Chart.js & Socket.io

http://ift.tt/2bmLnET

Submitted December 28, 2016 at 06:24PM by thoorne

Best updated repo for Angular2, ts, and webpack together?

I've been through several repos now trying to get a grasp on how to use Express with Angular2 webpack and ts. Unfortunately, some of them are a bit dated causing so confusion to me with 1 or another. For example 1 used systemjs instead of webpack. Another had old typing examples that threw me off for some reason.Does anyone have an epic starter repo that's as clear and updated as possible?You rock.

Submitted December 28, 2016 at 04:54PM by kiro419

Express.js, fetch client IP address and put to BLACKLIST

http://ift.tt/2iqQogl

Submitted December 28, 2016 at 03:51PM by bananajsjs

Node.js Best Practices - How to Become a Better Developer in 2017

http://ift.tt/2hobBFL

Submitted December 28, 2016 at 12:46PM by hfeeri

Headstart Microservices Architecture using AWS Lambda in your favorite programming language (Node.js or Python or JAVA)

http://ift.tt/2idIgA4

Submitted December 28, 2016 at 11:57AM by mike_jack

Tabelpress – Node.js and postgres api development foundation

http://ift.tt/2izg6Cs

Submitted December 28, 2016 at 09:36AM by kapv89

What Is Node.js for Java Developers?

http://ift.tt/2i5R6PT

Submitted December 28, 2016 at 08:22AM by nilinte

Tuesday 27 December 2016

What engine should I choose for my Angular2 app in Express?

1. I'm checking out this guide:http://ift.tt/2hmPGyK this guy puts his Angular app in express. Now I'm still very new to Angular2, however I'm fairly certain that LiteServer or whatever comes with the default testing is only for dev purposes rather than production.That said ... is it decent practice to use Express with my Angular2 app?2. it's 99% working (GET's are all 200 OK until this point), only getting this err at last second:GET /app/main.js 500 6.796 ms - 1170 Error: No default engine was specified and no extension was provided. at new View (/var/www/http://ift.tt/2i6jYdg) at EventEmitter.render (/var/www/http://ift.tt/2iCS859) at ServerResponse.render (/var/www/http://ift.tt/2i6ddIi) at /var/www/http://ift.tt/2iCRsga at Layer.handle_error (/var/www/http://ift.tt/2i6dET9) at trim_prefix (/var/www/http://ift.tt/2iCReFK) at /var/www/http://ift.tt/2i617il at Function.process_params (/var/www/http://ift.tt/2iCYyl3) at next (/var/www/http://ift.tt/2i681nW) at Layer.handle_error (/var/www/http://ift.tt/2iD10Ia) However, every guide I've read says that as long as I put a static dir, I don't need to specify an engine, so this is strange. In my app.js:app.use(express.static(path.join(__dirname, 'client')));

Submitted December 28, 2016 at 06:44AM by xblade724

How to store "date of birth" using form in Node.js?

How to store "date of birth" using form in Node.js and MongoDB? Should I store "DOB" as a string or is there a better way? I am using Expressjs, Pug for view and Mongoose as ODM.

Submitted December 28, 2016 at 06:15AM by simplicius_

How can I wrap commands to a custom repl server?

Hi there, I'm running a custom REPL server like so:myrepl = require("repl").start() How can I wrap any command-line commands to it in a specific text? I'd like to just demo an idea, and wrap every command in a try catch. Thanks!

Submitted December 28, 2016 at 05:29AM by basiclaser

Data fields change to arrays on POST

I have a strange problem. I have some embedded data that I'm posting to my server written in NodeJS, and the data seems to be changing a little. I watch the data right up until it's posted to the server, and everything seems okay. When it is received by the server the keys within the data change and have square brackets '[]' around them. Here's what I'm seeing:Client-side ImgurServer-side ImgurThis is causing problems because the data is not matching between the server and client sides. Any ideas of what could be causing this? I can post whatever code needed.

Submitted December 27, 2016 at 07:00PM by adambear27

WIP: Faster HTTP for Node.js

http://ift.tt/2iAhCV4

Submitted December 27, 2016 at 06:05PM by _skankhunt43

Batching queries to postgres to minimize roundtrips from the application

Is there a way to batch various queries to postgres from node so that you minimize roundtrips to the database?The only thing I can think of is to use the multi-insert query like insert into sometable(column1) values (1), (2), (3) which would insert 3 rows in one round trip. But let's say I want to do something like thisinsert into table1(column1) values (1), (2), (3) insert into anothertable(column1) values (1), (2), (3) insert into thirdtable(column1) values (1), (2), (3) how can I do it in one round trip? It's slowing things down with all the unnecessary roundtrips. I can wrap it all in a begin and commit so that the 3 statements above are run as a transaction, all-or-nothing. But that doesn't eliminate the extra roundtrips.I'm not using any ORMs or anything like that, and would like to stay away from it if possible. I'm using http://ift.tt/1BYQ4u6 to connect to postgres from node.

Submitted December 27, 2016 at 06:07PM by nowboarding

Enterprise-grade Node.js Promises with Async and Bluebird

http://ift.tt/2irp0C1

Submitted December 27, 2016 at 04:17PM by _bit

Gracefully terminating node processes on SIGTERM/SIGKILL

Are there some good resources or examples that show how to gracefully terminate node processes when you do 'ctrl c' in the terminal to end the process?In the example I'm thinking about, there are queue worker processes that get a bunch of items from the queue and process them. When it successfully processes those items, it gets the next bunch of items from the queue and processes those. And it does all this in a neverending loop.Since I'm not handling this gracefully, when I terminate the node process, it kills the process right away and leaves an inconsistent state. I've never worked with gracefully terminating processes or handling SIGTERM/SIGKILL before, so any explanation or tutorials would really help.And how would you handle SIGTERM and SIGKILL differently? Or would they both have identical behavior?

Submitted December 27, 2016 at 01:49PM by nowboarding

Do you think I should learn Node over Ruby (and Rails)? (And why) (x-post from /Ruby)

Hi,I'm a game developer that want to learn some web dev to land some gigs to make some side cash. I've done some .net work back in ~2002-2003 that it came out and some ASP 3 before but nothing too serious. I know C/C++/C#, Lua (and some other scripting language) and mostly used C++/C# for the past decade or so.My web dev friend told me to go Ruby/RoR way and I did a bit and liked Ruby (haven't touched Rails yet), specially since it's difference to what I already know. Whenever I ask him about other frameworks or languages like Node.JS, he says they are inferior but his reasons are not solid, IMO.The reason I'm considering other alternatives like Node.js is apparently they are more popular (for whatever reason) and apparently JS is not going away anytime soon and I seem to find more job opportunities for it than RoR. Also from what I've learned, RoR is not good to act as a game server, since it's slow.So I was wondering, what you guys would think, which way do you think I should go to minimize effort and maximize revenue. (I don't care if I have to learn hard languages or ones that are new like functional ones, I like tech challenges)Thanks /ruby.

Submitted December 27, 2016 at 10:57AM by lastninja2

The Complete Node.js Developer Course 2.0

http://ift.tt/2icGx08

Submitted December 27, 2016 at 09:43AM by Helen791

Monday 26 December 2016

What do you use for API documentation in NodeJS/MEAN stack applications?

I am working for a client who wants me to document the API. I am looking at some options such as apiDocs, Swagger but don't know which is easy to integrate with an existing MEAN Stack application. Can you guide me?

Submitted December 27, 2016 at 07:44AM by simplicius_

JS backend devs, how often do you update Node? Are you stuck in some version? If so, why?

How often do you update the Node version of your app? Have you ever got stuck with some version (by compat reasons or something like that)? If so, what was the reason? Did you manage to create a plan for updating it?

Submitted December 27, 2016 at 02:21AM by TalyssonOC

Lazy Evaluation in Javascript

http://ift.tt/2hAnCJ2

Submitted December 26, 2016 at 10:46PM by dbalduini

Need help with making completely bare gcm app

Thanks in advance. I'm extremely new to this, I've done a heap of reading but still quite unsure on some things.I'm trying to set up a really basic gcm app. This is exactly what I'm trying to do:Start up a nodejs server that will send the messages. The app will have absolutely no ui, it will just be checking for a file and when a file appears send the contents in a push message to my mobile phone (I think through the chrome app on my phone?). I only want to send this to my mobile phone, so the registrationIds etc I want to just be hardcoded into the app. This is what I'm getting stuck on, all the tutorials I've found create a app with express, have a mongodb and generally a lot more to it than I want to have. Is it possible to make a registrationid/deviceid/whatever else and hard code it in my server without having my phone connect to the server and submit some registration form? Or what would be the best way to achieve what I'm trying to do? Thank you.

Submitted December 26, 2016 at 10:31PM by weiry6922

Where can I find U.S. Node conferences in 2017?

I've had a hard time finding U.S. Node conferences for 2017. It seems like everywhere I look I find an old page for a conference from a few years ago, or conferences for other countries. I don't have a ton of money to spend, but I REALLY want to meet up with other humans that are interested in Node. Help!

Submitted December 26, 2016 at 09:26PM by spatmonkey

Advice for creating graph database from scratch?

Hello, I'm interested in making my own graph database from scratch. Nothing crazy or too complex just something to maybe make a graph database of my immediate friends and their relationships to each other. This would strictly be a project to learn the ins and outs of how they are constructed and work. I would do this in my computers memory probably with a json file. I know that neo4j exists and every time I search to figure out how to make my own graph database system it's the only thing that comes up but I got to believe there is a tutorial or something out there to teach me to make one on my own or an npm package that allows you to do a simplified version. Any advice would be great and I thank you in advance!

Submitted December 26, 2016 at 04:07PM by FauxParisien

Build Automation with Vanilla JavaScript

http://ift.tt/2hHs2OA

Submitted December 26, 2016 at 03:41PM by koistya

8 things you must know about Async/Await in Javascript

http://ift.tt/2iaiMG6

Submitted December 26, 2016 at 03:02PM by bananajsjs

action on image request

Hey, so I've got an express server with a "/gif/gif1.gif" route. which serves a page with a gif from my public folder. I would like to execute an action every time the gif gets requested, how can I do it? I tried with router.get("/gif/gif1.gif", function(req, res){ function(){ .... } res.render(...) }but it doesn't seem to work, any suggestion?

Submitted December 26, 2016 at 02:13PM by utopy

[x-post from /r/javascript] I'm making REPEND a step by step guide for making an app using REact Postgres Express Node and Docker

http://ift.tt/2hYXAlT

Submitted December 26, 2016 at 12:14PM by WPMusicFinder

Writing websocket server using Adonisjs

https://www.youtube.com/watch?v=rQTIwBV_ZgY&feature=youtu.be

Submitted December 26, 2016 at 11:23AM by andycharles

Sunday 25 December 2016

My simple node app keeps timing out. Any idea why?

Making an Object look like an Array in a native addon

I'm implementing a native module for node and trying to return something that looks like an array but is backed by native data. At the moment I'm creating an ObjectTemplate and using SetIndexedPropertyHandler so I can handle attempts to get indexes from JS. This all works, but from JS this just looks like an Object, not an Array. Is there any way I can make this look more like an array?

Submitted December 25, 2016 at 08:07PM by Mossop

Control your Yeelight devices with Node.js

http://ift.tt/2ifNBGt

Submitted December 25, 2016 at 12:44PM by kostarelo

How's Strapi?

I just came across Strapi and was wondering if anybody is using it and how their experience is so far? Are there any production sites using it?

Submitted December 25, 2016 at 11:02AM by bliitzkriegx

How is ASP.net or uvloop faster than Node.js when they use libuv only?

No text found

Submitted December 25, 2016 at 07:50AM by zeal_kaiser

npm announces a revamped search tool for packages on a partnership with npms.io

http://ift.tt/2hnNBHV

Submitted December 25, 2016 at 07:05AM by fagnerbrack

Saturday 24 December 2016

Frisby is a REST API testing framework built on node.js and Jasmine

http://ift.tt/1s9rGO5

Submitted December 24, 2016 at 09:03PM by indatawetrust

How to Use Classes in Node.js - server.js refactor

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

Submitted December 24, 2016 at 06:40PM by jakblak90

Can't run 2 Socket.io based apps with Nginx

I have 2 Socket.io apps. The first one is running on localhost:3000 and the second is working onlocalhost:8878.What I want to do is to reverse proxy them in the way that the first one will work on localhost and the second one on localhost/myapp.This is the Nginx configuration that I'm using:server { listen 80; server_name localhost; location / { proxy_pass http://localhost:3000; } location /myapp/ { proxy_pass http://localhost:8878/; proxy_set_header X-Real-IP $remote_addr; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; # WebSocket support (nginx 1.4) proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; } location ~* \.io { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_set_header X-NginX-Proxy true; proxy_pass http://localhost:3000; proxy_redirect off; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; } } The first one is working fine, but the other one isn't working. Ps: even changing proxy_pass http://localhost:3000; in location ~* \.io to proxy_pass http://localhost:3000; doesn't make the second app work. Can someone please help me?

Submitted December 24, 2016 at 04:49PM by tigerosh

Moodle REST API Client for Node.JS

http://ift.tt/2ioIibg

Submitted December 24, 2016 at 03:22PM by aksunamu

The documentation on electron and node is horrible, ive been trying to find the answer to a simple problem for days

http://ift.tt/2i2DkOe <- main electron http://ift.tt/2hTienp <-- functions im trying to callcan someone please tell me how to do it. I keep seeing pages of half explanations and each is different than the other.

Submitted December 24, 2016 at 02:00PM by mushmushmush

Want to learn JavaScript? Join the SpeakJS Discord server and chat to over 500 members!

Hi, everyone! Our SpeakJS Discord server now has over 500 members and has really become the vibrant, friendly community I originally hoped for. It's come to life over the past couple of months and it's great to see all the learning, knowledge sharing, and general discussion about all things JavaScript.The server welcomes everyone and it's community-driven meaning that it will be shaped by what you all want. In the couple of months it's been around we've created lots of new channels and made changes to others to accommodate what best helps you to learn and be part of the community.We recently got a Jobs channel and have had people from companies like Squarespace getting involved and looking for JavaScript developers. This is just the beginning.Happy holidays, everyone. I hope you consider joining us – http://ift.tt/2eF1tra

Submitted December 24, 2016 at 03:10PM by speakJS

best cloud image upload service?

I've an express app that dropzone.js to upload my images to s3.But i want a cloud service that i can transform my images and so.Any recommendations?

Submitted December 24, 2016 at 10:42AM by raistlinthewiz

How does NodeJS work

http://ift.tt/2innG2P

Submitted December 24, 2016 at 07:19AM by dobkin-1970

Friday 23 December 2016

Need help writing Node.js server that can intake user data and persist it through multiple page loads, without using cookies.

Hi everyone. I'm fairly new to backend development, and I'm trying to understand how to accomplish this. I have a form with an input box and submit button, and would like to be able to enter a name, submit it, and then on the next page (http://ift.tt/2cDFMJB) the name appears. I repeat this again with another name, submit and on that page (http://ift.tt/2hh9eb5) the two names appear. Then, I would like to link back to the root page with both names sill appearing.Currently I am using fs.writeFile to write names to a json file.

Submitted December 24, 2016 at 12:01AM by ZappasBlackNapkin

returning a live search. Get or Post?

Hello I am unsure how to send data back to the user without reloading the page. I only want to update a certain element value.I have this for my AJAX request.var genre = document.getElementById("genre"); genre.addEventListener("keyup", function(event){ showGenres(event.target.value); }); function showGenres(str){ if(str.length == 0){ document.getElementById("livesearch").innerHTML=""; document.getElementById("livesearch").style.boarder="0px"; return; } var req = new XMLHttpRequest(); req.onreadystatechange = function(){ if(this.readyState == 4 && this.status == 200){ document.getElementById("livesearch").innerHTML = this.statusText; document.getElementById("livesearch").style.border = "1px solid #A5ACB2"; } } req.open("GET", "upload?q="+str, true); req.send(); } And this for my routesapp.get('/upload', function(req, res, next){ if(req.query.q){ console.log(req.query.q); db('genre') .where('name', 'like', '%'+req.query.q+'%') .then(function(search){ console.log(search); }) .catch(function(err){ console.log(err); }); } db('category') .then(function(categories){ console.log(categories); res.render('upload.html', { title: 'New Upload', messages: req.flash('alert'), user: req.session.user, accountImage: req.session.accountImage, isLogged: req.session.isLogged, categories: categories }); }) .catch(function(err){ console.log(err); }); }); do I need to make a separate route to handle the queries? Once the upload page is rendered I do not want it to be re-rendered. I want just one element, the "livesearch" to be the only thing that refreshed.Anyone help solving this would be greatly appreciated!Thank you.

Submitted December 23, 2016 at 09:05PM by clandest

Working on a separate API (Express.js) and frontend (React.js) project, have some questions.

Hi good people of reddit, So I'm currently working on a backend API in express for an application that'll later on need to have frontend built as well. Frontend is going to be built in React.My main question is - would it be enough for the frontend project to be ran on the server with something like webpack (in other words, something like create-react-app) or would it need to have a separate clean express project that it should then be embedded into?I remember reading somewhere about the usefulness of the latter, but I can't help but think of that as of complicating things too much? I mean, we're trying to split them, the backend and frontend, not glue them back together, IMO that seems to be redundant.But then again, I'm totally in the dark, first time trying to do this backend/frontend separation and would like to hear some feedback if some of you did this already. In my mind, React.js should simply interact with API using AJAX in the background and provide smooth UI/UX.My idea is to have (at start) one server (DO, AWS) that'll host a 1) express server, 2) react and would have nginx to do reverse-proxy for now.Best regards!

Submitted December 23, 2016 at 08:21PM by eXtremeRR

psql, knex, searching the database for a partial query.

hello. I am using psql and knex where I want to send a query to the database to search for similar rows.So If i type "a" it search the databses for any rows that contain "a"I searched some but haven't found a definitive answer for knex mainly..I've seen things like Like and iLike but not any resources that show good examples..Thanks for any help.

Submitted December 23, 2016 at 08:08PM by clandest

Best framework for a new purely RESTful API application?

I've started working on a new application where the backend will be nothing but a REST API. I'm fairly new to Node, so I started with Express. I'm still in the very early stages, so I'm looking for suggestions on the right framework to use.I've looked at Express, Koa, HAPI, and Restify. I like Restify but it doesn't seem like the most popular option out there.I'd love to use Swagger / OpenAPI in some form to document my API. I've seen a number of modules for Express that have also been modified by others to work with Restify.Any suggestions? Thanks!

Submitted December 23, 2016 at 05:26PM by kylemhall

I Wrote a small package to help with managing configs, Can I please get some feedback?

http://ift.tt/2hfC7UV

Submitted December 23, 2016 at 10:13AM by Tenac23

Node.js Weekly Update - 23 Dec, 2016

http://ift.tt/2i8MXKL

Submitted December 23, 2016 at 10:24AM by hfeeri

Problems ending a piped stream

I'm doing a GET request to a shoutcast stream and streaming the data to my node.js program. I'm piping the response stream over to a an instance of node-lame's (http://ift.tt/OGQ50p) decoder, and then piping it to node-speaker (http://ift.tt/1cz8zEC) to finally make the shoutcast stream's audio play through my speakers, like so:res .pipe(decoder) .pipe(speaker); But I have a problem. I'd like to be able to stop/resume the stream on command, without exiting the program. So let's say, on hitting spacebar, the stream would get cut off. And then on hitting it again, it starts over again.The logic for handling user input is fine. What I have a problem with is actually ending the stream. I looked through the node documentation and right now I've got:res.unpipe(decoder); decoder.unpipe(speaker); res.end(); But no matter what I do, I always get a "Write after end" error. I want to kill off the stream entirely without the program ending. Is that possible?

Submitted December 23, 2016 at 10:56AM by foulbeast

Solving IoT Problems with Node.js for Hardware

http://ift.tt/2he2MS4

Submitted December 23, 2016 at 07:01AM by nilinte

Thursday 22 December 2016

Comparing MobX with NX-Observe, an ES6 Proxy based observable library

http://ift.tt/2i7a1JW

Submitted December 23, 2016 at 12:56AM by solkimicreb

Node.js Express : Insert JSON from POST request into MongoDB

http://ift.tt/2hwl0Mu

Submitted December 22, 2016 at 09:21PM by bppereira

Need quick and simple auth solution, any tips?

All I'm looking to store is a username and password (hashed of course) what's the easiest way to do this and have users log in/ log out.

Submitted December 22, 2016 at 08:35PM by rapjs

Three integration templates of using AnyChart JS charts with NodeJS and MongoDB for data visualization

http://ift.tt/2bAIrmg

Submitted December 22, 2016 at 04:30PM by andreykh

How to keep a proper reference to "this" in callbacks?

If I want to wrap request so that encoding will be kept in mind...function requestWithEncoding(chosenURL,callback) { request({url: chosenURL, encoding: null},function(err,response,body) { if(err) return callback(err,response,body); else { var properEncoding = getEncoding(response); response.body = iconv.decode(response.body, properEncoding); body = iconv.decode(response.body, properEncoding); return callback(null,response,body); } }); } But then do something like "this.uri.href" in the callback, the script won't know what I'm talking about

Submitted December 22, 2016 at 03:31PM by DoomTay

Typescript nodejs framework with DI inspired by Angular 2

http://ift.tt/2h5s5m0

Submitted December 22, 2016 at 02:38PM by igorzg1987

Node Weekly Issue 168: December 22, 2016

http://ift.tt/2h4TPYb

Submitted December 22, 2016 at 11:41AM by hfeeri

AngularJS tutorial for beginners with NodeJS ExpressJS and MongoDB (Part I)

http://ift.tt/1DAR0BB

Submitted December 22, 2016 at 08:48AM by avi00

Best way to add dynamic content to an electron app with node?

Hi, I have an electron app, the background node.js connects to twitch and reads the chat. I am trying to have that text update the electron app in a chat window.I'm very new to electron and node, so not sure how to do it. so in my html page, I have a div called chat, and in the javascript file I tried to do getElementByID but that doesn't work in node.js.So I just used javascript to create an elecment, and append it to the html body. The problem with this is I cant control where it adds.Is there anyway of appending the data to a specified div? Im sure there is a way, but whats the easiest / best way?

Submitted December 22, 2016 at 08:57AM by mushmushmush

Node.js Express : Parse and insert JSON into MySQL Database

http://ift.tt/2h4RtbE

Submitted December 22, 2016 at 09:37AM by bppereira

Building Node.js Projects in Visual Studio

http://ift.tt/1rUBtYS

Submitted December 22, 2016 at 10:01AM by avi00

Wednesday 21 December 2016

How to properly parse URLs with Shift-JIS characters in them?

Take this page for example. Links on that page, for whatever reason, have what appears to be Shift-JIS encoded characters in them. If I do something like thisvar jsdom = require("jsdom"); jsdom.env( "http://ift.tt/2ihNTMj", function (err, window) { var links = window.document.links; console.log(Array.from(links,link => link.href)); } ); those encoded characters are encoded as if we're working in UTF8 even though it's not.What should behttp://afo.wtrpg.com/omc_view.cgi?sort=crname&crname=%82%C2%82%A9PON http://ift.tt/2hc1CXj http://ift.tt/2ihC4pl http://ift.tt/2hc6vj1 http://ift.tt/2ihNPvT instead comes out ashttp://afo.wtrpg.com/omc_view.cgi?sort=crname&crname=%E3%81%A4%E3%81%8BPON http://ift.tt/2ihMOUP http://ift.tt/2hcajAN http://ift.tt/2hc6vj1 http://ift.tt/2ihK3D1

Submitted December 22, 2016 at 04:11AM by DoomTay

Introduction to Node.js Development

http://ift.tt/2hXrUhh

Submitted December 22, 2016 at 04:18AM by chad791

Should i consider RethinkDB?

Soon i'll be starting a long-term project with big plans to scale later and possible splitting into micro-services. Was thinking about choice of framework and db. As a framework i'll posibbly use express powered by typescript and async/await(also considered koa, but it doesn't make to much sense, since the only one real advantage is pseudo-synchronous code, and you can do this with express and async/await now). On the side of database: i saw really cool things about rethink db, but we probably won't use realtime at all, and i'm not sure about speed and maturity of it at all. Is it suitable for being used in production on high-loaded project now? Are there good stable orms as mongoose out there?

Submitted December 22, 2016 at 03:09AM by Monyk015

This is what an express app powered by typescript 2.1 and inversifyjs looks like

http://ift.tt/2hITVsl

Submitted December 21, 2016 at 11:52PM by ower89

Who loves AngularJS code design and want to use it in NodeJS instead of require("../../module.js”)?

I am AngularJS developer. And really love AngularJS structure. Last few years I tried to be consistent and use same pattern everywhere where it is possible. So decided to implement AngularJS structure for NodeJS and solve the require("../../module.js") problem. Please checkout http://ift.tt/2icdquk

Submitted December 21, 2016 at 11:13PM by askucher

How to reverse proxy a Socket.io app with Nginx?

I want to reverse proxy the official Socket.io chat demo with Nginx. So, this is the server file:// Setup basic express server var express = require('express'); var app = express(); var server = require('http').createServer(app); var io = require('../..')(server); var port = process.env.PORT || 3000; server.listen(port, function () { console.log('Server listening at port %d', port); }); // Routing app.use(express.static(__dirname + '/public')); // Chatroom var numUsers = 0; io.on('connection', function (socket) { var addedUser = false; // when the client emits 'new message', this listens and executes socket.on('new message', function (data) { // we tell the client to execute 'new message' socket.broadcast.emit('new message', { username: socket.username, message: data }); }); // when the client emits 'add user', this listens and executes socket.on('add user', function (username) { if (addedUser) return; // we store the username in the socket session for this client socket.username = username; ++numUsers; addedUser = true; socket.emit('login', { numUsers: numUsers }); // echo globally (all clients) that a person has connected socket.broadcast.emit('user joined', { username: socket.username, numUsers: numUsers }); }); // when the client emits 'typing', we broadcast it to others socket.on('typing', function () { socket.broadcast.emit('typing', { username: socket.username }); }); // when the client emits 'stop typing', we broadcast it to others socket.on('stop typing', function () { socket.broadcast.emit('stop typing', { username: socket.username }); }); // when the user disconnects.. perform this socket.on('disconnect', function () { if (addedUser) { --numUsers; // echo globally that this client has left socket.broadcast.emit('user left', { username: socket.username, numUsers: numUsers }); } }); }); and this is the client side code:$(function() { var FADE_TIME = 150; // ms var TYPING_TIMER_LENGTH = 400; // ms var COLORS = [ '#e21400', '#91580f', '#f8a700', '#f78b00', '#58dc00', '#287b00', '#a8f07a', '#4ae8c4', '#3b88eb', '#3824aa', '#a700ff', '#d300e7' ]; // Initialize variables var $window = $(window); var $usernameInput = $('.usernameInput'); // Input for username var $messages = $('.messages'); // Messages area var $inputMessage = $('.inputMessage'); // Input message input box var $loginPage = $('.login.page'); // The login page var $chatPage = $('.chat.page'); // The chatroom page // Prompt for setting a username var username; var connected = false; var typing = false; var lastTypingTime; var $currentInput = $usernameInput.focus(); var socket = io(); function addParticipantsMessage (data) { var message = ''; if (data.numUsers === 1) { message += "there's 1 participant"; } else { message += "there are " + data.numUsers + " participants"; } log(message); } // Sets the client's username function setUsername () { username = cleanInput($usernameInput.val().trim()); // If the username is valid if (username) { $loginPage.fadeOut(); $chatPage.show(); $loginPage.off('click'); $currentInput = $inputMessage.focus(); // Tell the server your username socket.emit('add user', username); } } // Sends a chat message function sendMessage () { var message = $inputMessage.val(); // Prevent markup from being injected into the message message = cleanInput(message); // if there is a non-empty message and a socket connection if (message && connected) { $inputMessage.val(''); addChatMessage({ username: username, message: message }); // tell server to execute 'new message' and send along one parameter socket.emit('new message', message); } } // Log a message function log (message, options) { var $el = $('
  • ').addClass('log').text(message); addMessageElement($el, options); } // Adds the visual chat message to the message list function addChatMessage (data, options) { // Don't fade the message in if there is an 'X was typing' var $typingMessages = getTypingMessages(data); options = options || {}; if ($typingMessages.length !== 0) { options.fade = false; $typingMessages.remove(); } var $usernameDiv = $('') .text(data.username) .css('color', getUsernameColor(data.username)); var $messageBodyDiv = $('') .text(data.message); var typingClass = data.typing ? 'typing' : ''; var $messageDiv = $('
  • ') .data('username', data.username) .addClass(typingClass) .append($usernameDiv, $messageBodyDiv); addMessageElement($messageDiv, options); } // Adds the visual chat typing message function addChatTyping (data) { data.typing = true; data.message = 'is typing'; addChatMessage(data); } // Removes the visual chat typing message function removeChatTyping (data) { getTypingMessages(data).fadeOut(function () { $(this).remove(); }); } // Adds a message element to the messages and scrolls to the bottom // el - The element to add as a message // options.fade - If the element should fade-in (default = true) // options.prepend - If the element should prepend // all other messages (default = false) function addMessageElement (el, options) { var $el = $(el); // Setup default options if (!options) { options = {}; } if (typeof options.fade === 'undefined') { options.fade = true; } if (typeof options.prepend === 'undefined') { options.prepend = false; } // Apply options if (options.fade) { $el.hide().fadeIn(FADE_TIME); } if (options.prepend) { $messages.prepend($el); } else { $messages.append($el); } $messages[0].scrollTop = $messages[0].scrollHeight; } // Prevents input from having injected markup function cleanInput (input) { return $('
').text(input).text(); } // Updates the typing event function updateTyping () { if (connected) { if (!typing) { typing = true; socket.emit('typing'); } lastTypingTime = (new Date()).getTime(); setTimeout(function () { var typingTimer = (new Date()).getTime(); var timeDiff = typingTimer - lastTypingTime; if (timeDiff >= TYPING_TIMER_LENGTH && typing) { socket.emit('stop typing'); typing = false; } }, TYPING_TIMER_LENGTH); } } // Gets the 'X is typing' messages of a user function getTypingMessages (data) { return $('.typing.message').filter(function (i) { return $(this).data('username') === data.username; }); } // Gets the color of a username through our hash function function getUsernameColor (username) { // Compute hash code var hash = 7; for (var i = 0; i < username.length; i++) { hash = username.charCodeAt(i) + (hash << 5) - hash; } // Calculate color var index = Math.abs(hash % COLORS.length); return COLORS[index]; } // Keyboard events $window.keydown(function (event) { // Auto-focus the current input when a key is typed if (!(event.ctrlKey || event.metaKey || event.altKey)) { $currentInput.focus(); } // When the client hits ENTER on their keyboard if (event.which === 13) { if (username) { sendMessage(); socket.emit('stop typing'); typing = false; } else { setUsername(); } } }); $inputMessage.on('input', function() { updateTyping(); }); // Click events // Focus input when clicking anywhere on login page $loginPage.click(function () { $currentInput.focus(); }); // Focus input when clicking on the message input's border $inputMessage.click(function () { $inputMessage.focus(); }); // Socket events // Whenever the server emits 'login', log the login message socket.on('login', function (data) { connected = true; // Display the welcome message var message = "Welcome to Socket.IO Chat – "; log(message, { prepend: true }); addParticipantsMessage(data); }); // Whenever the server emits 'new message', update the chat body socket.on('new message', function (data) { addChatMessage(data); }); // Whenever the server emits 'user joined', log it in the chat body socket.on('user joined', function (data) { log(data.username + ' joined'); addParticipantsMessage(data); }); // Whenever the server emits 'user left', log it in the chat body socket.on('user left', function (data) { log(data.username + ' left'); addParticipantsMessage(data); removeChatTyping(data); }); // Whenever the server emits 'typing', show the typing message socket.on('typing', function (data) { addChatTyping(data); }); // Whenever the server emits 'stop typing', kill the typing message socket.on('stop typing', function (data) { removeChatTyping(data); }); socket.on('disconnect', function () { log('you have been disconnected'); }); socket.on('reconnect', function () { log('you have been reconnected'); if (username) { socket.emit('add user', username); } }); socket.on('reconnect_error', function () { log('attempt to reconnect has failed'); }); }); I tried this Nginx configuration:location /myapp/ { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header Host $http_host; proxy_set_header X-NginX-Proxy true; proxy_pass http://localhost:3000/; proxy_redirect off; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; } But im getting the following errors when i link to localhost/myapp:http://localhost/socket.io/socket.io.js Failed to load resource: the server responded with a status of 404 (Not Found) http://localhost/main.js Failed to load resource: the server responded with a status of 404 (Not Found) Can someone please help me?

Submitted December 21, 2016 at 08:18PM by tigerosh

I just published http://ift.tt/2i1CmBz a native multiplatform module to query the system OS for displays info.

http://ift.tt/2i1CmBz

Submitted December 21, 2016 at 06:50PM by parro-it

What do you think about require() taking a second, optional parameter: base path?

At some point you'll probably make a big enough Node app that you have to deal ../../with/this/path/problem to reach modules you want.There are a bunch of ways to mitigate this, but I feel that each has a drawback. For example, using a global var inline, you might do this;var Article = require(__base + 'app/models/article'); Which is fine, but it's both somewhat ugly and annoying to type. Also, it invites those little errors (e.g., did you remember to put the trailing / in your global path string?)The next would be with a module that expands the search path, but then you run into the issue of needing to know what is in your local path and what isn't. And it's a little unfriendly for other people who don't understand the structure of your code. You might accidentally include something you didn't expect because you didn't know the same name was in the local dir.I'm thinking it would be more elegant to add a second parameter to require that could be combined with a base path to explicitly show where you are looking for your module. And you could still use a global, so it might end up like this;require('app/thing/foo', __base); Using multiple globals, it also allows your app to be restructured (e.g., move base dirs around) by changing the path variable. So moving /models to /app/models would only require you to go update global.__models.require('user-model', __models); Anyone have any thoughts on that? I always like to vet out these ideas with others before bugging the dev channels with random requests.

Submitted December 21, 2016 at 04:43PM by khoker

The State of Strapi - Promising Node.js framework/CMS

http://ift.tt/2hcYaNP

Submitted December 21, 2016 at 04:42PM by fandusrfc

Could I get feedback on a node.js native addon I wrote?

Hi,I just published my first node.js module at http://ift.tt/2hV6CAE's a wrapper to Tulip Indicators, which is a C library.Since I'm new to this, I was wondering if someone might be able to look it over and let me know if it's ok, or if I've made some dumb mistakes.Specifically, I'm not if I'm doing error handling in an idiomatic way or not. Also, in the C++ code, I don't know if I'm handling things properly or not. I have a really hard time wrapping my head around the v8 and nan interface.Any feedback is greatly appreciated!Thanks!

Submitted December 21, 2016 at 03:13PM by CodePlea

The Ultimate Unit Testing Cheat-sheet For Mocha, Chai and Sinon 路 GitHub

http://ift.tt/2fnnal3

Submitted December 21, 2016 at 12:56PM by indatawetrust

Membranes in Javascript

http://ift.tt/2baNhKA

Submitted December 21, 2016 at 10:38AM by fagnerbrack

Tuesday 20 December 2016

ImmutableJS objects are not immutable javascript objects (they are not frozen)

http://ift.tt/2i88Wor

Submitted December 21, 2016 at 04:46AM by mSteckyEfantis

Bizarre situation with my live server URL - expert advice appreciated!

So I've been working on a node app for many months now and in the last couple months, we implemented angular on the front-end. So on my local implementation I could visit localhost:3000/p#/project, to see that page.When I put this on the server it automatically changes the url from: http://ift.tt/2h7tkVe to: http://ift.tt/2i7pehx'm using an Ubuntu server with Nginx. Is there an easy or obvious way to make it so that the slashes are not changed into their corresponding ASCII symbols?

Submitted December 20, 2016 at 09:11PM by snahrvar

Yo guys wanna learn how to make Twitter bots with Node.JS?

Yeah, me neither.

Submitted December 20, 2016 at 09:27PM by bokisa12

Siphon: A Node.js data extraction library built for scale

http://siphonjs.com

Submitted December 20, 2016 at 07:02PM by ganorberg

Razorframe: a plug-and-play Node.js module for empowering real-time applications at scale

http://ift.tt/2iaisDx

Submitted December 20, 2016 at 03:12PM by esangpark

The 10 Most Important Node.js Articles of 2016

http://ift.tt/2hPOhTe

Submitted December 20, 2016 at 03:18PM by hfeeri

How to Write Async Await Without Try-Catch Blocks in Javascript

http://ift.tt/2gXDeoW

Submitted December 20, 2016 at 01:22PM by KittenOfMine

Can't configure Nginx as Reverse Proxy for WebSocket

My Node.js application is running on localhost:8080 These are the server configuration files:var express = require('express'); var http = require('http'); var app = express(); var WS = require('ws'); var config = require('./config/main'); var Client = require('./client'); // HTTP var server = http.createServer(app); app.use(express.static(__dirname + '/../client/build/')); server.listen(config.httpPort, function() { console.info('HTTP listening on *:' + config.httpPort); }); // WebSocket var ws = new WS.Server({server: server}); console.info('Websocket server created'); ws.on('connection', function(ws) { var client = new Client(ws); console.log('New conection:', client.id); }); andmodule.exports = { /* HTTP PORT */ httpPort: process.env.PORT || 8080, /* WebSocket PORT */ wsPort: process.env.PORT || 8081 }; So I am trying to run it using the Nginx's reverse proxy:location /myapp { proxy_pass http://localhost:8080/; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; } Now, when I link to localhost/myapp the page appears normally, with all the static files loaded, but it seems like there is no WebSocket connection. PS: I am using Nginx V 1.11.7Is there something wrong in the configuration or did I miss something? Thank you

Submitted December 20, 2016 at 12:51PM by tigerosh

How can I send at least 250 unique responses per second if 400 requests are being made?

Hey!I have a problem I can't solve, hope you can help me figure this out!C# partI have a C# application that sends ~400 requests per second to my Node app. It asks for an element of an array. There's no way I can control the number of requests.Node.js partI have a simple array that contains 250 values, like below.var myArr = ["val1","val2","anotherval","amazingval","badval","goodval"];I want my Node.js app to send these values one by one to C# app when a request is made using res.send(), but it must send each value each second at least once. I don't care about the dupes.I can use Redis, MySQL, or something else.I can not send the values in JSON format and parse it in the C# app, somehow it crashes as it's not fully open source, you can only extend it to some degree using its editor. I have to handle this using Node.js.The elements of the array are static, they won't change in time.How can I achieve such a thing?

Submitted December 20, 2016 at 11:41AM by laraveling

Monday 19 December 2016

Node js express app not responding to ajax call

I've looked everywhere and I cannot find a similar problem to mine. I make an ajax call on a webpage to url localhost:80 or http://127.0.0.1:80, or similar. I have a node.js application listening on port 80 and when I press the button on my webpage the ajax call goes off fine but nothing happens on my node js app, it does not do anyhting even though I am sending the call on the right port. I have no idea what to do.Ajax call:$(document).ready(function () { $("#getimage").on('click', function () { window.alert("Working!"); $.ajax({ type: 'POST', url: 'http://localhost:80', success: success(), error: function() { $('#notification-bar').text('An error occurred'); } }); }); }); NodeJs app eaiting on port 80:var server = app.listen(80, function () { var host = server.address().address; var port = server.address().port; console.log("Example app listening at http://%s:%s", host, port); }); I run the node application and it sits there waiting to reply to the ajax call but nothing happens when I press the button, what am I doing wrong? Im using a wamp server on my local machine and the port on Apache is 80, I made sure the ajax call is working.

Submitted December 20, 2016 at 06:52AM by Jarmahent

check out this npm module I've made for you 🎅🏿🎄🎁 #is-deep-frozen

http://ift.tt/2hU1ASo

Submitted December 20, 2016 at 04:59AM by mSteckyEfantis

Jumpstart to Node - egghead.io playlist to get you started with Node.js

http://ift.tt/2h4x6hV

Submitted December 20, 2016 at 02:47AM by rekibnikufesin

Create a web app with user authentication in under 10 minutes

http://ift.tt/2hBHTRB

Submitted December 20, 2016 at 12:31AM by hobonumber1

I made a videochat app called Harf.io, what do you think?

https://harf.io/

Submitted December 19, 2016 at 11:36PM by aminozuur

What is Node.js? An explanation too late

http://ift.tt/2hkhIvI

Submitted December 19, 2016 at 10:35PM by juror-number-8

27 popular new github repositories for web developers in 2016

http://ift.tt/2h3YXyO

Submitted December 19, 2016 at 10:51PM by henry_tula

Getting Started with Amazon Polly using Node.js

http://ift.tt/2gEQuDD

Submitted December 19, 2016 at 11:03PM by anaptfox

ObjectionJS and Knex question

I was wondering if anyone has used two libraries and then tried to use the .update() method on an objection model and updated that record with an null value. Through my testing, the queryBuilder just ignores null and empty strings (" ") (data being pushed into "bindings" array). This won't allow updating records with null values. I can do this with an insert and I can do it with knex but I would like to run this through the model. Anyone ever run into this before?

Submitted December 19, 2016 at 07:45PM by maxwellsmart84

Safely migrating away from "prepublish" with npm 4

http://ift.tt/2hjb7lf

Submitted December 19, 2016 at 07:52PM by pimterry

Devlab v3 Is Here

http://ift.tt/2hMHolN

Submitted December 19, 2016 at 07:43PM by fluidbyte

Keystone.js Show Post Created On Specific Year

I want to make keystone show up posts from a category that was created by specific year for example on (select year) 2009 There are 3 categories(shows categories created that year) and then the posts from the selected category that was created that yearI am using Handlebars nodeJS v6.9.2 KeystoneJS 0.3.22 ps: i have read http://ift.tt/29Kx6Sw but i got confused

Submitted December 19, 2016 at 03:03PM by BillGR17

Utilize staging with PM2 for Node-apps?

I am looking into deploying to a VPS with PM2 and have some questions that I could not find answers to, could you please enlighten me?TLDR: PM2 is a tool to both run node-apps but also to deploy them to a different host. What is staging used for?Staging This term is often used when talking about deployment, but what does it really mean? Is it to deploy the last version to the environment as a separat app and to test it manually, for example with test.domain.com? What is the real purpose with staging?Using staging to test Well, if staging can be used to "test" the app on the VPS before also deploying in production mode, should not staging be seen as a separat app? (At least in the config file?) In PM2 the configuration ecosystem is used, but when I try to deploy staging the staging-app is not added to pm2 as a running service, only the production app is listed in pm2 list.This example of a ecosystem contains both a production and a staging deployment can be found here: http://ift.tt/2hAbHOl you!

Submitted December 19, 2016 at 03:08PM by ProfessorRekyl

[Question] Backspacing text in readline, removes process.stdout.write() ??

So I have been using the readline module with node and I noticed that in the code below pressing backspace in the input field in the console will actually backspace the "Send text: " string. If anyone can tell me how to fix this it would be greatly appreciated. Many thanks. const readline = require('readline'); const rl = readline.createInterface({ input: process.stdin, output: process.stdout }); process.stdout.write("Send text: "); rl.on("line", function(input) { process.stdout.write("Send text: ") });

Submitted December 19, 2016 at 01:54PM by Kempster3

[Question] MySQL Server Implementation in Production.

Hello. I have a Express Server and a MySql Server and at the moment I am stuck at the decision which way I should do my database requests. The biggest problem is that I don`t know which ways are good for production and which not.Some Ideas from myself: 1. Use a self made SQL-Query builder with partially hardcoded SQL Queries. 2. Use a query-builder npm module. 3. use a ORMI hope you can give me some answers and maybe also some example code.Sys0

Submitted December 19, 2016 at 02:22PM by Sys0_MKNR

Architecture question

I have a architecture question. I was thinking about haveing 3 servers which all 3 server had: 1 App server. 1 Redis Cache. 1 Mongo DB.So every time I add a Node to my server, all services get sharded +1. So my min. servers would be 3. And Max would most likely be 10 servers.Would there be anything wrong with this?

Submitted December 19, 2016 at 02:36PM by kiksen1987

Spawning new Node websocket servers on demand for private game lobbies?

I'm trying to figure out the backend for a game project and would love to get some ideas, since I've never used Node beyond simple static asset servers.I assume my approach has some pretty big flaws I haven't considered, so feel free to bash it and say how it should be done instead.Here's the first part:A client connects to the master server and they are presented with a simple UI to either join an existing lobby or create a new lobby.When they create a lobby, they receive a short code and direct connect URL for sharing other clients can use for joining.This server provides the private room for players, allows them to assign nicknames, keeps track of who is the owner of the lobby and handles automatic reconnection if a client drops and comes back.This bit is fairly trivial with Socket.io and I didn't have too much trouble getting it to work. Basically I've just got an object with room codes as keys, with the connected clients listed inside and synced to everyone in the room.However, here's the part I'm struggling with:I want to present a list of games to the players, which is generated through manifest files defining the names, "cover art" and such.I'd like each of the games to be an isolated module. It provides a server that is only concerned with game state, not the overall lobby system.The game would contain a client-side application, common constants for action types and a node server to manage the state based on the actions.Ideally, the master server would just spin up a new game server that receives the participating players and updates on their connection status. The state handling and websocket communication within the game isn't the master server's business, it only knows if the clients are currently in a game that exists at some point.And thus, a couple of questions:Would it be more feasible to start a new node server for each new game and communicate it's address to the clients from the master server? (e.g. "here's your client-side files for the game and here's the endpoint for communication")Since I'd want to provide the list of players with their roles and status from the master server, would it be a bad idea to establish websocket communication between the master and game server as well?The goal here would be to provide a single system for handling rooms and connections where players in each room can switch between games, which are kinda isolated projects/processes that can define their own UI and server-side logic.Again, any ideas much appreciated. I'm a front-end guy who is mostly clueless about how a system like this should work in the first place.

Submitted December 19, 2016 at 11:13AM by Voidsheep

How do write write a file and use HTML content?

I want to have a button that takes the content of a textarea, writes a file and then sends the file to a user. I can't find anything about using html content to write a file.

Submitted December 19, 2016 at 07:24AM by pm_me_gold_plz

Sunday 18 December 2016

How do I run node js from an html page?

I want to click a button on my html page and make node js run a js file and then get what it outputs. How would I come by doing that and is that a reasonable way of doing it?

Submitted December 19, 2016 at 04:55AM by Jarmahent

Best CMS for Node JS Apps?

I'm developing a site for a client that wants to be able to change copy on certain pages. How can I implement a CMS into my app? What frameworks are out there?

Submitted December 19, 2016 at 04:50AM by mikeynalikey

Using Wayback Machine's Wayback Save function appears to be really slow

I tried putting together a function that makes use of Wayback Machine's "save" URL to save multiple pages as part of a recursively crawling script. The idea is that the script visits the "save" URL, then waits five seconds to see if the page was actually saved. If not, it waits five more seconds.Thing is, it takes up to two minutes for a proper signal that the page has actually been saved, which is bizarre since using Wayback Machine's save function in an actual browser only takes a few seconds.function savePage(page) { console.log("Saving",page); request("http://ift.tt/MV4y8z" + page, function (err, response, body) { if(err != null) throw err; else checkPage(); }); function checkPage() { setTimeout(function() { request("http://ift.tt/2hygcZI" + page, function (err, response, body) { if(err != null) throw err; else if(response.statusCode == 200) processResponse(response); else if(response.statusCode == 404 || !response.request.uri.href.includes("web/2016")) { //Double check to see if the page is actually saved checkPage(); } else throw new Error("Unknown status code: " + response.statusCode + " " + response.statusMessage); }); }, 5000); } } If I were to put a console.log under the "is status code 404?" clause, I will in fact see the message pop up several times.What am I doing wrong?

Submitted December 19, 2016 at 01:54AM by DoomTay

Developing Azure Application Insights logging for Express

http://ift.tt/2gZZD8l

Submitted December 18, 2016 at 10:16PM by evilduck_pl

Can't run node in Bash on Windows 10

I can't seem to figure out why node isn't working. Whenever I use the node command in bash on my windows 10 computer this message pops up.Command 'node' is available in '/usr/sbin/node' The command could not be located because '/usr/sbin' is not included in the PATH environment variable. This is most likely caused by the lack of administrative privileges associated with your user account. node: command not foundI have tried adding these to my PATH environment variable but it still doesn't work. I have also tried putting sudo in front of the command. I am new to Bash and this is my first reddit post so I am not sure if there is something really obvious that I am missing. Thanks for the help!I have also just figured out that the command works in the windows default command prompt and in the prompt it says that the environment has been setup for using Node.

Submitted December 18, 2016 at 09:22PM by Jynx03

Using ES6 Generators To Recursively Traverse A Nested Data Structure

http://ift.tt/2hxPiB4

Submitted December 18, 2016 at 07:51PM by indatawetrust

ICU Loader - to load full ICU data in Node.js with JavaScript Intl API

http://ift.tt/2hxhc02

Submitted December 18, 2016 at 03:24PM by msudgh

How to get a performance boost using Node.js native addons – Developers Writing

http://ift.tt/2gZ0VSC

Submitted December 18, 2016 at 10:06AM by indatawetrust

Boost dependency manager for CMake.js based native modules

http://ift.tt/2heFklb

Submitted December 18, 2016 at 10:07AM by indatawetrust

Simple, fast, powerful parser toolkit for JavaScript.

http://ift.tt/1hmOhEX

Submitted December 18, 2016 at 10:11AM by indatawetrust

Saturday 17 December 2016

Benefits and tradeoffs of static types in JavaScript

http://ift.tt/2hbn67W

Submitted December 18, 2016 at 02:21AM by fagnerbrack

bash-repple brings bash history expansion support in node, as well executing builtin commands through node

http://ift.tt/2hdeg5O

Submitted December 17, 2016 at 10:06PM by 73mp74710n

What is your experience with knex and bookshelf?

I am starting a new project with React and Redux(similar to a fitness tracker) and I need to choose a backend. Node seems the perfect choice since I am already using javascript on the with react and react-native.Most of the node projects/tutorials seem to use Mongo but since my data is relational I want to use Postgres. I heard good things about bookshelf and knex but I cant find any big project/comany using it.What is your experience with it?

Submitted December 17, 2016 at 07:17PM by newdanny

Is keeping static queries in the server good practice to limit queries?

Hey, I have been learning to program by creating a Nodejs site using express as the middle ware. I have done the bulk of it but I am now focusing on limiting the amount of queries to my MySQL db. My current setup is I have a 3 server async waterfall functions, they update the database with data from a webAPI, 1st one runs every minute, 2nd runs every day and 3rd one runs every week. Then in my express I have about 4 sql queries that are static (They aren't changed by user input) and another 4 that are changed by user input if they click a button. My question is, What is wrong or right with putting the static queries in my server and have them rerun constantly, and then just pass a variable with the data to my middleware? This will make users only do queries when they press the button to give custom information.ThanksEdit: I just learnt that it's called Raw SQL vs ORM, I will start researching this, will still appreciate comments on my specific situation. Thanks

Submitted December 17, 2016 at 08:15PM by Djinnes

Check out my freezing npm module I've made for you 🎅🏿🎄🎁 #subzero

http://ift.tt/2hvrRIT

Submitted December 17, 2016 at 08:32PM by mSteckyEfantis

Integrating mysql connections pool with restify

I'm trying to create a REST service which deals with databases with restify and mysql.I have something like that:var restify = require('restify'); var mysql = require('mysql'); var server = restify.createServer(); //Empty db info on purpose var pool = mysql.createPool({ host : '', user : '', password : '', database : '' }); connection.connect(); server.get('/authenticate', function authenticate(req, res, next) { pool.getConnection(function(err, connection) { connection.query('SELECT * FROM sometable WHERE id = 1', function(err, rows) { if (err) throw err; connection.release(); res.send(rows); next(); }); }); }); server.listen(3000); Do I need to fetch a connection from the pool for each request like I'm doing or is it not supposed to look like that?It feels a bit cumbersome, especially since I'd have to repeat that connection logic in many other routes I'd like to add.I could create a class with a simplified interface that creates a query in a connection fetched from the pool and releases the connection once the query is resolved, but I feel like I'm complicating things that should already be simple.Did I get the concept right or am I misunderstanding something?

Submitted December 17, 2016 at 05:31PM by royibernthal

Express.js + React + ReactRouter :Unexpected token < error

So I've done some research in stackoverflow threads and found that it may the culprit:http://ift.tt/2hcnOOK, I am still having trouble getting rid of this error (perhaps I am not implementing correctly?)Here's my folder structure:Project | +-- dist | | | +-- bundle.js | +-- src | | | +-- client | | | ... holds my React Components, etc | index.js | | +-- server (run by express.js to hold server as API) | | | +-- controllers | +-- models | +-- services | -- index.js | -- router.js | +-- index.html | +-- webpack.config.js | | +-- babelrc | + So I've made the bundle.js available so that express can retrieve it via static file middlewaresrc/server/index.jsconst express = require('express'); const app = express(); const path = require('path'); const morgan = require('morgan'); const port = process.env.PORT || 1234; const bodyParser = require('body-parser'); const router = require('./router'); const mongoose = require('mongoose'); const db = process.env.MONGODB_URI || "http://mongodblocalhost:voteapp/voteapp"; const cors = require('cors') //DB Setup mongoose.connect(db); app.use(express.static(path.join(__dirname, '../../bundle.js'))) //App Setup app.use(morgan('combined')); app.use(cors()) //CORS middleware on express side app.use(bodyParser.json()); app.use(bodyParser.urlencoded({ extended: true })) router(app); //Server Setup(Express) app.listen(port,()=>{ console.log(`Server is listening on ${port}`) }) src/server/router.jsmodule.exports = function(app){ app.get('*', function(req, res) { res.sendFile(path.join(__dirname, '../../index.html')); }); app.get('/allpolls', AllPolls.allposts) app.get('/fetchvotes/:userName', FetchVotes.getvotes) app.post('/newpost', NewPost.newpost) app.get('/polls/:id', GetPoll.getpost) app.put('/polls/:id', CastVote.update) app.delete('/polls/:id', DeletePoll.deletepost) app.post('/signup', Authentication.signup) app.post('/signin', requireSignIn, Authentication.signin) } index.html
Here's the full detail of the repo in GithubWhat am I doing wrong?

Submitted December 17, 2016 at 04:22PM by KAMFlamenco

I used "npm link express" and it broke my project. How do I undo this?

My express project couldn't find a node_module. On stack overflow I was an answer that said to run "npm link express." I ran that, and now my project can't even find jade so I can't even to a view. What doesn't "npm link do" and how do I undo that command?

Submitted December 17, 2016 at 01:34PM by pm_me_gold_plz

Urgent: Helped needed to bring production server back up in AWS.

Our main server guy is not available and we need to get the servers back up, the servers are written in node.js and are deployed in AWS.This is extremely urgent and this will be a paid task if we can get it up.email: appdevroid@gmail.com skype: appdevroid

Submitted December 17, 2016 at 01:47PM by appdevroid

Modest argument options parser

http://ift.tt/2gVLJpw

Submitted December 17, 2016 at 12:29PM by tiaan-duplessis

How to build a faster search for app?

Iam building a node application and currently using mongodb to store data. I have to build a search functionality. My current system is a simple regex query. (And it does have a caching mechanism )What i need is:some kind of fuzziness in searchit has to be fast (TOP PRIORITY)what i know:I can add a property based on soundex source of searchable property for fuzziness.I can use elastic search OR apache Solr for search requirements (do not want to do if not last choice).I can user Amazon CloudSearch (will be my choice after elastic search not even considering it for now ).I do not want to use algolia for same reason as cloudsearch.Now is there a better way to implement search? How you do some complex search with faster response time?

Submitted December 17, 2016 at 12:54PM by tejpratap46

Help Needed Deploying A ExpressJS/React/MongoDB App To Ubuntu With A Filesytem

Hi everyone, I'm in the process of deploying my first proper ReactJS/ExpressJS/NodeJS/MongoDB app for a project which I've been working on for the last few weeks. I've been using the create-react-app with express and mongoDB but I have no idea how to deploy on ubuntu that allows images uploaded and displayed on my app.I have no idea how to implement a filesystem that will allow me to save photos uploaded through mongodb/mongo-admin and then saved and displayed in my app. So far I've found this resource, but I'm not sure how this would be done.As well as this I'll be following this guide to deploy on a ubuntu server of which I've been given access http://ift.tt/2hbv9Ol've been also looking at http://ift.tt/2eEA4Hp to figure out the filesystem, but 'simple' is kind of complex for me to work out how this would integrate with my react app.It's been a long few days of me trying to figure this out so pointers and places of reference will greatly be appreciated. It seems like there's a lot of info online on deploying to firebase and other PAAS but not as much on actually deploying from ubuntu servers with filesystems and mongo.

Submitted December 17, 2016 at 09:35AM by iamhonest1

How to standardize response objects across my endpoints

Hello.I'm just learning about nodejs and setting up my first project to get acquainted with it. Love what I'm experiencing so far.The website I'm building has a number of different endpoints that can be hit with GET or POST requests to do some operations and return some information. I have a js file where routes access my different collections of operations and return the response from those operations.What I have is working, but it is very clumsy - I have to remember what different fields are called in the responses and it is hard to handle error cases correctly.The pattern I'd like to follow is, every GET or POST request should return object with three fields - message, success, and data. Message will carry a simple explanation, this will be useful in an error case. Success will be a boolean representing whether or not the request succeeded. I'm imagining several operations where the user will attempt something, and if the attempt failed then the message from the response will be displayed to the user. Finally, the data field should contain the usable data if the operation succeeded.Is there a way I can force my routes to follow this pattern? Is there a way I can cleanly implement this kind of behavior without having to write something like "res.send({"message": "example problem", "success": false, data: {}})" in every case where I'd be sending a response?I'd also be interested in the commonly accepted pattern for handling cases like this.

Submitted December 17, 2016 at 08:22AM by electricfistula

Friday 16 December 2016

How to test how many concurrent processes my application can support?

I'd like to know how much memory/cores my application needs so that I can optimize the number of concurrent processes I start on my production servers.How can I do this?

Submitted December 17, 2016 at 03:43AM by mojoback

Why I built today's project with Node vs PHP, and fell in love

Synopsis: need a recursive system where items can have parents, have children or not, and possibly be orphans themselves.Requirements: server side rendering, high concurrency, tight securityPHP Pros: Well, its PHP, pretty straight forwardPHP Cons:Security was a concern. We need to accept uploads from unknown origins, unknown types. I'm looking at you "GIF98"Bigger reason: the blocking nature of PHP was a deal breaker, so it kills the concurrency requirement.Node Cons: I'll start with the cons for NodeJS, not many.Lots of non-blocking pyramid of death function call backs, I guess thats the first. That's mitigated by breaking the code into smaller pieces. Same can be achieved in PHP thoughServer front door is apache. However, ProxyPass, you magical bastard :) Not really a con after allNode Pros:NPM rocks. We get the same thing in PHP with composer, but its on a different level in Node worldDefined routes (via Express) which mitigates file upload vulnsTotally non blocking. "Here is the code I want you to run whenever you finish this function call".... love itTemplating, Jade: Specifically, being able to pass an array of objects returned from a database query and build the interface using widgets.My last Node build out was an API with a ReactJS front-end running in the client. Great solution, I highly recommend that combo when it meets the project's requirements, such as reduced network traffic and low server resources.But for today's project, straight up Node/Express and server side rendering was a dream to work with.

Submitted December 17, 2016 at 02:49AM by terrible_name

RamdaScript, Clojure-esque Lisp that compiles to Ramda.js

http://ift.tt/2hEafbE

Submitted December 16, 2016 at 10:40PM by yosbelms

BUILDING MODERN APPLICATIONS WITH MICROSERVICES

http://ift.tt/2gxinxp

Submitted December 16, 2016 at 08:07PM by StarpTech

Moving first app to production

http://ift.tt/2gSN6oN

Submitted December 16, 2016 at 05:55PM by crashspringfield

An in Depth Guide on Building a REST API with Node.js, Restify & MongoDB

http://ift.tt/2hLQGBi

Submitted December 16, 2016 at 05:06PM by nparsons08

Performance difference between Node 4 and Node 7?

Hey!I have a multiplayer game running on a homebuilt node server, currently running V4. We do hundreds of millions of calls (websockets through socket.io) to this server per day, and its starting to really max out our CPU.Would we see much of a difference in performance/cpu usage by migrating from node 4 to node 7?Thanks!

Submitted December 16, 2016 at 04:59PM by Travisism

Major release announcement of version v1.0 of Nodebeats, an Open Source Content Management System built using MEAN Framework

The Nodebeats Team is very pleased to present you a Major release version v1.0 of Nodebeats, the Content Management System built using MEAN Framework. This release includes the angular-cli implemenation to make building angular code extremely easy and fast, responsive html template integration using handlebars, database backup restore feature and reduce the number of files by significant amount, by code clean up and project directory structure changes. In the next major release version, we aim to introduce install setup wizard and some other features to make Nodebeats even more flexible and easy to use and also we will create and deploy the docker image of Nodbeats in docker hub so that you won't have go through the hassles of configuring the deployment environment.To know more, Go to www.nodebeats.com for official website and http://ift.tt/2h95Ex2 for github repository. If you want to check out the demo application, then go to http://ift.tt/2gSyLsD

Submitted December 16, 2016 at 05:04PM by nodebeats

Awesome Node.js Weekly - Issue 31

http://ift.tt/2gSdPQN

Submitted December 16, 2016 at 11:27AM by stanislavb

How you guys deal with "milion terminals problem"?

Hello!I've a question about managing usual node.js or frontend workflow - specifically about boostrapping whole development environment before you start to work.I am working on medium-size project that consist of three application servers written in node.js and 2 frontend applications. Basically the problem is that just before I start any work, I must launch 5 terminals with three nodemons and two webpacks running. Sometimes I also integrate with a legacy php server, that I am launching using php -s as well, and I also launch various tools like npm install or mocha test suites. So just before I put a single character in source, I must launch like 7-9 terminal tabs and launch various processes.Question is - how to deal properly with this thing? Is there any tool that allow me to specify a config file or something and then launch all my commands just in one window, allowing to examine console, restart processes or so? Or should I searcch an IDE inbuilt solution (I am using VSCode)? Or perhaps I just should stick with opening these terminals everytime I want to start work?I was looking for a tool like that, couldnt find any. If nobody yet have written a solution for this, I came to conclusion that there is easier way to bootstrap workspace, something obvious that I am missing?Because I am so tired with running those commands over and over and over, especially when I have to switch between few different project during single day.

Submitted December 16, 2016 at 11:35AM by Bloompire

Code Locally → Run Remotely | Cloud Development Environment Done The Right Way!

http://ift.tt/2hEF3Zk

Submitted December 16, 2016 at 10:09AM by athakwani

Node.js Weekly Update - 16 Dec, 2016

http://ift.tt/2gRdNu4

Submitted December 16, 2016 at 10:33AM by hfeeri

Thursday 15 December 2016

How would I create a proxy browsing web site (see link in comment) that lets me browse single page apps via a proxy

Similar to what this site does but I want to build it with node.js and full SPA support.http://boomproxy.com/I'm thinking I need to leverage phantomjs but I'm not sure how I would then render that page on the proxy site so users can fully access it.I noticed using one of these web proxy browsing sites like boomproxy.com will get me around cloudflare.FYI: the reason I want to build this is I use TorBrowser and increasingly more problematic are sites flocking to cloudflare which by default blocks Tor traffic.

Submitted December 16, 2016 at 04:56AM by agentf90

node.js cluster: Not just for HTTP

http://ift.tt/2hD9UFZ

Submitted December 16, 2016 at 04:35AM by mwillbanks

Developing a node application ... should I be using script tags in ejs files?

I'm learning how to develop a node application. It's an app where people can post events happening around the city.I have an ejs file, new.ejs, that allows users to submit a new event. Obviously there is an event start time and end time. I want to make sure that the end time is AFTER the start time, so I simply added a script to do that, as follows:
Now this works just fine, it does what I want it to do.However, I know that EJS is designed to take back-end (node) javascript code and render it out into the view.My question is:Is adding front-end code between

Creating a universal phone number using Twilio, Google voice and stdlib (x-Post r/travelhacks)

http://ift.tt/2gPfkAO

Submitted December 15, 2016 at 11:03PM by Nimsical

Some questions about javascript and objects

Hi, reddit. I'm just begining to developing in node and i have a question about working with objects. So if i has understand well, you can work with objects in node with doing somethink like this:function Point(x, y){ this.x = x; this.y = y; this.getX = function(){ return this.x; }; } var p = new Point(4, 4); console.log(p.getX()); // show 4 But when i begin to learn node, i looking in the source code of express and i see that they doesn't work like this. They work more like this:function Point(x, y){ var obj = {}; obj.x = x; obj.y = y; obj.getX = function(){ return this.x; }; return obj; } var p = Point(4, 4); console.log(p.getX()); // show 4 So my first question is: what is the best between this 2 practice and what is the real difference between this ?Secondly, on the second example, we can do "var p = Point(4, 4);" and the result is the same. What is the real difference between using or not using new? And i find weird to using new work well because in the end, it's not Point object that we get bug it's a object created in Point. Can you explain me this ?PS: i don't know if this subreddit is made for this or if it's authorized to ask questions like this here so if it's not, sorry and ask me to delete this post. PS2: i know that in ECMAScript 6, we will surely stop to work on objects like this and begin to use class keyword, but i want to understand actual working. PS3: Sorry if my English is poor. I try my best.

Submitted December 15, 2016 at 11:05PM by Ulas42

V8 ❤️ Node.js

http://ift.tt/2hpb2zi

Submitted December 15, 2016 at 05:38PM by natorion

Looking for per-review/advice on my express/psql/knex app. I got it to work, but not sure if its done correctly, or that it will cause headaches down the road.

Hello. I have simple commenting system that people can go to others profiles and make comments or replies to others profiles.I just recently switched from mongodb to postgres because I was needing more of a relational database than what mongo was offering.So I choose using express with postgresql database and knex to deal with all the dirty stuff.I am new to knex and I am not sure if I am making my queries correctly. It just seems off with all these if statements. Maybe someone can shed some light on the proper way to do what I am trying to achieve.My knex schemas knex.schema.createTable('users', function(table){ table.increments('uid').primary(); table.string('username'); table.string('password'); table.string('email'); table.timestamps(); }), knex.schema.createTable('profiles', function(table){ table.increments('id').primary(); table.integer('user_id') .references('uid') .inTable('users'); table.string('about'); table.string('flashBanner'); }), knex.schema.createTable('comments', function(table){ table.increments('id').primary(); table.string('body'); table.integer('user_id') .references('uid') .inTable('users') table.integer('profile_id') .references('id') .inTable('profiles'); table.integer('replies_id') .references('id') .inTable('comments'); table.timestamps(); }), ]) My routesThis is the main profile view, you can see all the comments and replies from here. Also make them.app.get('/p/:user', function(req, res, done){ db('users').where('username', req.params.user).then(function(profileUser){ if(profileUser != ''){ db('profiles').where('user_id', profileUser[0].uid) .join('users', 'profiles.user_id', 'users.uid') .then(function(profile){ if(profile != ''){ db('comments').where('comments.profile_id', profile[0].id) .join('users', 'comments.user_id', 'users.uid') .select('comments.id', 'comments.body', 'comments.created_at', 'comments.replies_id', 'users.username', 'users.profileImage') .orderBy('comments.created_at', 'desc').then(function(comments){ if(comments != ''){ res.render('comments.html', { messages: req.flash('alert'), isLogged: req.session.isLogged, user: req.session.user, accountImage: req.session.accountImage, profileImage: profile[0].profileImage, profileUser: req.params.user, comments: comments }); }else{ res.render('comments.html', { messages: req.flash('alert'), isLogged: req.session.isLogged, user: req.session.user, accountImage: req.session.accountImage, profileImage: profile[0].profileImage, profileUser: req.params.user, comments: comments }); } }); } }); }else{ req.flash('alert', 'no profile user: ' + req.params.user); res.redirect('/'); } }); }); This is where a comment is posted and submitted to the databaseapp.post('/p/:user', function(req, res, done){ var loginUser = req.session.user; var profileUser = req.params.user; var comment = req.body.newComment; var userId; var profileId; db('users').where('username', loginUser).then(function(user){ if(user != ''){ userId = user[0].uid; db('users').where('username', profileUser).then(function(profileUser){ if(profileUser != ''){ profileId = profileUser[0].uid; db('profiles').where('user_id', profileId).then(function(profile){ if(profile != ''){ profileId = profile[0].id; db('comments').insert({ body: comment, user_id: userId, profile_id: profileId, created_at: new Date(), }).then(function(comment){ if(comment != ''){ req.flash('alert', 'post successfull'); res.redirect('/p/' + profileUser); } }); } }); } }); } }); }); This is where a reply is POSTED to the databaseapp.post('/p/:user/comments/reply', function(req, res){ var loginUser = req.session.user; var profileUser = req.params.user; var reply = req.body.newReply; var commentId = req.body.commentId; var userId; var profileId; db('users').where('username', loginUser) .select('uid') .then(function(user){ if(user != ''){ userId = user[0].uid; db('users').where('username', profileUser) .select('uid') .then(function(profileUser){ if(profileUser != ''){ profileId = profileUser[0].uid; db('profiles').where('user_id', profileId) .select('id') .then(function(profile){ if(profile != ''){ profileId = profile[0].id; db('comments').insert({ body: reply, user_id: userId, profile_id: profileId, replies_id: commentId, created_at: new Date(), }).then(function(comment){ if(comment != ''){ req.flash('alert', 'post successfull'); res.redirect('/p/' + profileUser); }else{ console.log('error'); } }); }else{ console.log('no profile'); } }); }else{ console.log('no profile user'); } }); }else{ console.log('need to login'); } }); }); and then my view is treated like this So everything I have here is working how I want it to, I just want to make sure its not too messy before I get on to making more spaghetti.Thank you for any replies and insight!

Submitted December 15, 2016 at 05:22PM by clandest

I have a dumb question

so..I'm learning web development, I've wanted to be a game designer (Modeler) I've come to realize that i don't have the patients to do it, when it comes to retopolgiesing my mesh i get overwhelmed and get too daunting for me to handle. but, anyways, i'm wanting to maybe be a Web developer. Start with Node.js. As I understand Node is like the sister of JavaScript do i need to learn JavaScript before I learn Node or no?

Submitted December 15, 2016 at 02:59PM by Jncocontrol

Deploying Node.js Applications on DigitalOcean using Ansible

http://ift.tt/2gOW6d2

Submitted December 15, 2016 at 03:42PM by kostarelo

Hey guess what

That's right, I don't give a shit about making twitter bots with Node.js, for the 100th time stop sharing those shitty articles here.

Submitted December 15, 2016 at 03:49PM by bokisa12

MongoDB will not prevent NoSQL injections in your Node.js app

http://ift.tt/2hAJFzJ

Submitted December 15, 2016 at 03:11PM by sqreen

PlasmaJS Starter Kit

http://ift.tt/2gN3szu

Submitted December 15, 2016 at 01:59PM by akshay-nair

Node Weekly Issue 167: December 15, 2016

http://ift.tt/2hRqBfS

Submitted December 15, 2016 at 02:00PM by hfeeri

Differences in version handling between RubyGems and npm

http://ift.tt/2hPQtZx

Submitted December 15, 2016 at 02:15PM by tkadlec

NPM Blog:€” npm 5, Specifications, and npm's RFC Process

http://ift.tt/2hxlRNw

Submitted December 15, 2016 at 01:16PM by mira_m

How to make a Twitter Bot with Node.js (follow, like, auto-reply)

http://ift.tt/2hJbucs

Submitted December 15, 2016 at 11:38AM by hfeeri

Wednesday 14 December 2016

What is caching network requests when using node & cluster?

Background: I have a long running API call (.5 to 1 sec) and I created a node app with cluster for each of the CPU cores that I have. It all works fine. I plan on putting the app behind an AWS load-balancer with auto-scale, but this lead to my buffering question:When I do a small load-test, either the OS network stack or the node master process (or both) are queuing network requests, which is good as there are no timeouts or errors (small loadtest, didn't try to overwhelm it). But, I wanted to get an understanding of how this works and what to watch out for, so I can best setup the ELB/load balancer.I am using a mac for development and Linux on AWS for testing.thx!

Submitted December 15, 2016 at 03:01AM by okiloggedin

Why we switched from NPM to Yarn

http://ift.tt/2hvto29

Submitted December 15, 2016 at 01:46AM by devopsdj

Integrating Jenkins with Github, Node.js and Slack

http://ift.tt/2gMdFKG

Submitted December 14, 2016 at 08:58PM by juror-number-8

New to NodeJS. Wondering how y'all set up and pre-populate databases?

I recently made a website in NodeJS, Express, and Mongoose (MongoDB). My work around for setting up my database was to make a request that could only run if my user was logged in and it'd insert required records into the database. Wondering how other people set up and pre-populate a database? Is there a way to do it via the console?

Submitted December 14, 2016 at 05:39PM by DTheDeveloper

Learn Node.js by building 5 real world apps.

http://ift.tt/2gJjwC4

Submitted December 14, 2016 at 05:25PM by amirmasnda

The Node.js Maturity Checklist

http://ift.tt/2hvt5RJ

Submitted December 14, 2016 at 03:11PM by hfeeri

Does anyone here know how to solve this issue?

http://ift.tt/2huYiom

Submitted December 14, 2016 at 12:30PM by Snorrrlax

packages for walking file system and their popularity

anyone has a clue as to why klaw, the most downloaded package for this has only 27 stars on github while being downloaded almost 5 million times last month?Whereas a little bit outdated walk has only 523 000 downloads but has 323 stars on github?Never seen such a glaring disproportion in popularity numbers.

Submitted December 14, 2016 at 08:34AM by Capaj

Tuesday 13 December 2016

npm module with optional cli?

Does anyone know if its possible (or can point me to a guide) on exposing both a CLI and a module interface in my module?I want to be able to do this:// module const foo = require('foo'); foo.bar(); // or: npm -g install foo $ foo bar

Submitted December 14, 2016 at 03:44AM by agentf90

Building an API Backend with TypeScript and Express - Part One: Setup

http://ift.tt/2hsvhJM

Submitted December 14, 2016 at 12:12AM by cyanidepoison

Guide to Installing Node.js on a Raspberry Pi

http://ift.tt/1Y9P5As

Submitted December 13, 2016 at 09:09PM by attilad

Project setup/best practice for loading constants from files into Express/Node/React webapp

I'm trying to make a webapp with React, Express, Node, etc. I've been following this tutorial, and so have also been using Gulp, Babel, and Browserify. From what I understand of this, files I write are taken from app/ and get transpiled and bundled together into one js file and put into public/ for the Express server to serve, with the directories being specified in the gulpfile.I have a bunch of constants in a csv file that I want to be available to the webapp, without being hardcoded somewhere (so that I can just drop in an updated.csv on the server and have things work). So, I have a few questionsI tried including the csv files in public/ and reading the files client side (with d3-csv), but it seems like the files in app/ are getting run from the server, since the npm run watch console is outputting stuff and getting Error: connect ECONNREFUSED 127.0.0.1:80 errors? Is that supposed to happen? Or am I doing something wrong?My csv files aren't very large so it wasn't a problem, but if they were very large and I wanted to cut down on how much data was being sent, what would be ways of doing this without having to put the csv files in public/ somewhere as assets? Are my choices either A. Have the server load the constants, and then have the client make a call to pull them on load or something, or B. Somehow doing some weird pre-processing of the js files and edit the constants in?For option A in 2., where in my thing would I make the $.ajax call to the server in order for it to happen upon load - just at the beginning of main.js (before the ReactDOM.render call) or something? Thanks!(For specifics, the current (broken) repo is at http://ift.tt/2hBogK4)

Submitted December 13, 2016 at 07:07PM by colblitz

Can I start learning to code with Node, or should I start with that Dolly Python stuff people are gaga over or the javascript thing?

I want to make wonderful things.This page says I should bang around with the javascript first. Is that easier than dolly python, or is it just more conducive to understanding how node works (kind of like learning latin before spanish vs chinese before spanish)?Man, I'm itching to get started.This reCAPTCHA just asked me to click all the pics of sushi. Does a california roll count? It doesn't have any raw fish in it. Shit. This is a hard one. I'm going to click it. Who knows, maybe there's fake crab in that motherfucker.Damn. Gotta wait 2 more minutes because I was posting about the Holger Gershwinder on the Mavs subreddit. I bet he knows how to code. He has some cool software too I bet.36 seconds. Gaaaaah. You're killing me smalls.11 seconds. I keep getting that sushi captcha. I keep going back and forth on that California roll thing. Fuck it. California isn't in Japan. I'm not clicking it.

Submitted December 13, 2016 at 07:26PM by StooopidQuestions

Encrypt and decrypt Data-at-rest?

I need to Encrypt and decrypt data-at-rest located in MongoDB. In other words, there must be not plain text aside ids and some user info.I use parse server (http://ift.tt/1KdFpCr) on top of expressJSHow can I do that?

Submitted December 13, 2016 at 05:26PM by mescalito2

Asycn/Await BIBLE: Sequential, Parallel, Nest, Dynamic and Error Handle

http://ift.tt/2hih1py

Submitted December 13, 2016 at 02:46PM by bananajsjs

learn es6 the hardway: by coding, testing, running and debugging on go. simple, flexible and easy to use. Contains reference docs and already wriitten configurations to run, test, and transpile codes. A VERY DETAILED INTRO.

http://ift.tt/2gD0Sfj

Submitted December 13, 2016 at 01:23PM by dannyMcwaves

Node.js Clean Coding Best Practices

http://ift.tt/2hIFZLL

Submitted December 13, 2016 at 01:06PM by gergelyke

Monday 12 December 2016

Setting headers for images

How do you set headers for just your images? I know you do something like this in you server.js file:app.use(function(req,res,next){ res.set('Cache-Control','max-age=56789'); next(); }; But that only works for your landing page and doesn't affect images,css, etc. How would I go about just setting the Cache-Control for my images?

Submitted December 13, 2016 at 05:46AM by callback7

Introducing english2number: Parses English numbers into integers ("one hundred eighty seven thousand" => 187,000)

http://ift.tt/2hy2w1R

Submitted December 13, 2016 at 04:23AM by EvilGeniusAtSmall

Node.js web framework performance show down

http://ift.tt/2gyAfrT

Submitted December 12, 2016 at 11:22PM by CmdrKeen4

Node.js Performance Showdown (web frameworks) - DZone

http://ift.tt/2gtUfXu

Submitted December 12, 2016 at 10:46PM by TomEnom

What time module do you use, specifically for handling different timezones and events?

I was using "Time" but it doesn't seem to work out of the box with openshift or AWS. I got it working on both but I am sure there is a better module out there. I am currently only using it to get a time value from a specific timezone, but I'm curious how others have been dealing with regional times.

Submitted December 12, 2016 at 08:00PM by eatsnakeeat

Which is the best continuous delivery open source solution for nodejs in Production?

No text found

Submitted December 12, 2016 at 07:36PM by ratancs

unhomoglyph - replace similar chars in string with base form

http://ift.tt/2gxdxA4 you may wish to avoid similar strings. For example, prohibit users create similar nicks (when some characters have different codes but have the same look like AΑАᎪᗅᴀꓮ).This package "normalizes" all homoglyphs to base form, according to unicode security recommendations for international domain names. Then you can use normalized strings for compare and so on.

Submitted December 12, 2016 at 05:03PM by shvank

Data-Mapper ORM for TypeScript and JavaScript (ES7, ES6, ES5). Supports MySQL, PostgreSQL, MariaDB, SQLite, MS SQL Server, Oracle, WebSQL databases. Works in Node.js and Browser.

http://ift.tt/2hvFHvF

Submitted December 12, 2016 at 02:30PM by pleerock

Why I picked nodejs for my startup

http://ift.tt/2hAJS59

Submitted December 12, 2016 at 01:44PM by Dakuan808

MongDB: evil or misunderstood?

I'm generally a frontend developer with some experience in backend with Node.js, PHP, Python and Java. I always use SQL databases (generally PostgreSQL) due all benefits that we know.This year I start to use MongoDB, I found on it an very flexible database, very easy to learn and querying. I used it on some projects without problems. However, after read this post and this one, to be honest, I'm complete afraid about use Mongo in new projects.Is really evil as people said? Have you good experiences with Mongo? Recommendations?

Submitted December 12, 2016 at 01:57PM by guzgarcia

Kap 1.0 released - Electron screen recorder, now with audio capture, WebM export, and a suite of minor features and tweaks.

https://getkap.co/

Submitted December 12, 2016 at 10:05AM by _bit

Ruby, NodeJS and Go: advantages and disadvantages for backend development

http://ift.tt/2hkwjdG

Submitted December 12, 2016 at 08:07AM by avi00

10 Best Node.js Frameworks For Developers

http://ift.tt/1Kapyou

Submitted December 12, 2016 at 08:10AM by php03

Sunday 11 December 2016

Introducing proportionate - Convenience methods for dealing with proportions

http://ift.tt/2gC9HUR

Submitted December 12, 2016 at 05:18AM by EvilGeniusAtSmall

Whats it mean when a company is using Nodejs 4.4.0 version? It seems so outdated?

http://ift.tt/2gup979 it says 4.4.0 or higher but it says to use that version too. I know it says higher, but I was having trouble using higher one, but as soon as I did "nvm install 4.4.0" it worked but...I dont know if its me f'ing up with new version but still find it odd.

Submitted December 12, 2016 at 03:58AM by trapulator

Would people be interested in a book that teaches you how to make a complete web application using NodeJS + React?

Hey guys,Just wanted to gauge interest levels in an e-book that goes through building a complete web application using React and NodeJS?It would explain how to: - Create a webserver with user authentication - Hook up with databases - Generate API endpoints - Connect API Endpoints with a front-end framework - Build out a CRUD application - Security - MaintenanceQuestions:1) Would you be interested? 2) Would you pay for it if it was good, and had sample chapters? 3) Where do you get this information now?

Submitted December 11, 2016 at 09:09PM by hobonumber1

Some clarification on relationships in databases.

Hello currently I am using mongodb which I am getting ready to switch to postgresql, just because of the fact that I am using mongodb more and more like a relational database than what its intended for. So I might as well use a database meant for relational queries.So a user can have a profile, which other users can come to and comment to that profile. Other users can reply to comments in others profile.This is where the confusion sits in with my relation ships. Here are my tables I am working with. user: _id: username: password: profile_img: profile: _id: user_id: comments_id: comment: _id: user_id: profile_id: replies_id: body: created_at: reply: _id: user_id: comment_id: body: created_at: so right now I can use mongoose's populate command to pull out the comments and replies of a profile, I run into the issue when I want to show the reply.user.profile_img. The only information available from the original find query on comments is reply.user_idHow do people normally join multiple queries together to get all the information they need?Are my sql tables too bloated? Does it need to be condensed more?here is my current mongoose query to find the comments and display it with their replies. I just cant get any user information from replies. I dont now how to go deeper and still keep the replies linked to the proper commentsapp.get('/p/:user/comments', function(req, res){ User.findOne({ username: req.params.user }, function(err, profileUser){ Profile.findOne({ _user: profileUser._id }, function(err, profile){ ProfileComment.find({ _profile: profileUser._id }).sort('-created_at').populate('_replies').populate('_user').exec(function(err, comments){ res.render('comments.html', { title: req.params.user + ' Comments', messages: req.flash('alert'), user: req.session.user, profileImage: profileUser.profileImage, profileComments: comments, isLogged: req.session.isLogged, userProfile: req.params.user }); }); }); }); }); This is the rendering html file Thanks for any guidance and help!

Submitted December 11, 2016 at 06:20PM by clandest