Friday 31 March 2017

What are some common/noob mistakes you find with JS/NodeJS development?

I getting into the NodeJS world, what are some noob mistakes I should be aware of that may save me a ton of time!

Submitted April 01, 2017 at 03:16AM by Miles360x

React + Sails

I'm just starting to learn about scaffolding after a friend showed me some Rails stuff for the first time. I know SailsJS is the typical go-to answer for this on Node, however while the React-On-Rails repo has over 2800 stars on Github, a similar project for Node is difficult to find. There seem to be a handful of attempts but nothing with a good amount of support. Has anyone tried any of these solutions? Did any of them work well?

Submitted April 01, 2017 at 02:52AM by ZeroCarbsSince96

Unshorten (expand) short URLs with Node.js

http://ift.tt/2nFzHk0

Submitted April 01, 2017 at 12:42AM by loigiani

OrientDB, ArangoDB, Neo4j

Have you ever used OrientDB, ArangoDB or Neo4j in node.js? What are your opinions about them (it) ?

Submitted March 31, 2017 at 09:42PM by blu3pegasus

A simple skeleton for MEAN apps. Follows MVC structure and best practices. Could be used for quick starting node apps. Contains session based auth with Angular.

http://ift.tt/2ojTEQA

Submitted March 31, 2017 at 07:13PM by paashabhai

CodeDoesGood is looking for Node.js volunteers to build solutions to important problems in the world. We have 5 iOS to every Android and JS volunteer, we really need you guys!

http://ift.tt/2oGUpzs

Submitted March 31, 2017 at 04:27PM by earthabbey

All the tricks that help you debug TestCafe tests

http://ift.tt/2nDvzRQ

Submitted March 31, 2017 at 02:20PM by churkin

Taming Node_Modules at Facebook

http://ift.tt/2ooRUCq

Submitted March 31, 2017 at 02:21PM by allllamas

Node.js Streams and Reactive Programming Primer

http://ift.tt/2nr8nFg

Submitted March 31, 2017 at 03:53PM by kharandziuk

The state of reactive: a small comparison between JavaScript RP frameworks

http://ift.tt/2oiCnqZ

Submitted March 31, 2017 at 12:58PM by kharandziuk

"let\nlet": Probably the smartest test from ECMAScript's Test262

http://ift.tt/2mPopvO

Submitted March 31, 2017 at 11:38AM by fagnerbrack

Node.js Weekly Update - 31 March

http://ift.tt/2oG1sbA

Submitted March 31, 2017 at 11:40AM by hfeeri

DevšŸ“”Admin access to production - using the nodejs REPL

http://ift.tt/2nm9KEg

Submitted March 31, 2017 at 10:17AM by davidav

grawlix v1.0.4 released -- first go at plugin framework (feedback appreciated)

npmGitHubDirect link to Plugin docThread introducing the projectOpinions? In addition, I'm thinking I should probably create a plugin myself as a demonstration / proof of concept. Figure it'll probably be aimed at a select group of racial slurs. Any thoughts?Thanks.

Submitted March 31, 2017 at 04:42AM by jon_stout

Thursday 30 March 2017

Node.js Task Scheduling With Agenda and MongoDB

http://ift.tt/2nkTdkh

Submitted March 30, 2017 at 11:11PM by code_barbarian

Building a mongodb / mongoose query directly from URL query string?

I've built a couple of APIs using node, express, and mongoose but the one I'm working on right now is a lot more complex and works with more data than the ones I've built in the past. I'd also like to eventually release this API to the public. I'd like to make my endpoints flexible so that users of the API can pass up various parameters in the URL's query string. Possible use cases would be filtering, sorting, and populating mongoose model references. After doing some research I've found some good StackOverflow posts talking about needing to sanitize query input to avoid things like operator injection. I also found some npm packages that look like they were built for helping you take the query string and building a mongo/mongoose query out of it.Here they are:http://ift.tt/2om0ody (github: http://ift.tt/1wvLTlB)http://ift.tt/2odwACO anyone used any of these packages or something else to accomplish what I'm talking about? I wanted to ask on here because the concept seems really powerful but also dangerous if you don't know what to sanitize for. I assumed there would be a go-to package that most of you use for something like this, but none of the above really stick out to me as being incredibly popular on github. The 2nd one is failry popular but I'm not sure I like some of the conventions it uses. Also, with most of the above, it becomes pretty obvious to the API user that you're using mongo/mongoose since the query string params have the same exact name eg. "populate". I guess there's nothing wrong with this but feels kind of strange that it's that obvious to the API user.Have you guys used any of the above, or something else? I'd love for my API users to be able to create flexible mongo/mongoose queries using the URL's query string but not completely sure how to go about this.Thanks for the help cheers!

Submitted March 30, 2017 at 05:52PM by m9js

A beautiful template engine for Node.js

http://ift.tt/2nA1UZJ

Submitted March 30, 2017 at 06:50PM by andycharles

Serving static files of Node.js application with Nginx

https://youtu.be/-7fxvD9kHi8?list=PLQlWzK5tU-gDyxC1JTpyC2avvJlt3hrIh

Submitted March 30, 2017 at 04:40PM by insane-architect

Is there a Beginner book that is still "up-to-date" on learning Node?

I know with ES6 out things have changed, and a lot of the Node books are quite old by now.Is there any that are still relevant? I was looking at: http://ift.tt/2ocxcsd sort of an intro to it...but didn't know if that would be good. It seems relatively up to date though thankfully.

Submitted March 30, 2017 at 03:38PM by mercfh85

Optimize your Node app by simply upgrading Node.js

http://ift.tt/2oeJdxU

Submitted March 30, 2017 at 03:40PM by ecares

Happy left pad anniversary day!

https://twitter.com/john_papa/status/847281500609368065

Submitted March 30, 2017 at 02:47PM by shalotelli

Built a node starter kit for Alexa

Hi!I wanted to boost up custom skill development speed, so I made a starter kit for Alexa.Generates intent schema, utterances, value slots while coding. It writes them to files that are separated by skill name, so all that developer has to do is to copy-paste generated config to Amazon Developer Console when setting up new skill.No need to setup/edit server code. All skills are kept in a folder and server code reads and uses them to initialize intents.Development is being done locally using Express server and nodemon. Localhost is exposed to web using ngrok. Server restarts everytime the code is changed. In this way all changes to intent responses can be tested immediately.Supports deploying to AWS LambdaSo please take a look and give your feedback: http://ift.tt/2okp1r3!

Submitted March 30, 2017 at 12:41PM by CrowOnTree

Thorsten Lorenz - Memory Profiling for Mere Mortals

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

Submitted March 30, 2017 at 09:07AM by dobkin-1970

Hosting my bots from home.

I have some chat bots made using Node JS, one for Discord and one for Twitch. I want to run these 24/7. I want to use my laptop to do this (not an online server), what OS do you recommend me using? I am currently using Windows 8.1 but is it better to use Linux for this - if so, which distribution?

Submitted March 30, 2017 at 02:34AM by Rusty_TV

API to transform XML or JSON to high quality documents in PDF, HTML or Image

https://prexview.com/

Submitted March 30, 2017 at 02:58AM by limedamocloids

Wednesday 29 March 2017

Routes handling with Apex and AWS LambdaReq

http://ift.tt/2nwM5CW

Submitted March 29, 2017 at 10:56PM by doomhz

storing html tags in mongodb?

Lets say I have a blog site and I have the collection blogposts with the fields username:"user123", title:"

random title

", text: "

blahblahblahblah

". I store them with tags so I don't have to manually write every blog post in the ejs file, but the text comes out like this ex.

dasdASDASD



Submitted March 29, 2017 at 10:13PM by caseyboyswag

What should I expect as a node js developer?

First of all, I'm a first yeard student who likes to code almost all the time. So far I enjoy working with node js and golang. I've managed to get in touch with a company who's mainly based on node js. From the interview I've seen that they like express, mongo and redux and they also showed me some mobile apps with react native..I haven't really worked in production so far and they didn't tell me what they really do.. What should I expect for the first day, basically I've no idea what I'm gonna do. I'm more on the backend than frontend, but working with react is a pleasure as well ;). Looking to hear some experiences from other users here :)

Submitted March 29, 2017 at 09:07PM by shark1337

Ideal way to append line-separated list to file?

Let's say I have to append a line-separated list to a file at different points in time, like, say, in different event loopsvar array1 = ["foo","bar","queff"]; var array2 = ["lorem","ipsum","diksum"]; fs.appendFileSync('test.txt', array1.join("\r\n")); //Some time later fs.appendFileSync('test.txt', array2.join("\r\n")); The problem with that is that the last element of the first list and the first element of the second list are put right after one anotherNow if I did thisfs.appendFileSync('test.txt', array1.join("\r\n") + "\r\n"); Then the file will have an extra line break at the end.That was just a simple example, but if, say, these were in different loops, then I might not be able to just do a single fs.appendFileSync with them both together

Submitted March 29, 2017 at 06:55PM by DoomTay

New Firebird 3 high-level native client for Node.js / TypeScript

http://ift.tt/2njXV2t

Submitted March 29, 2017 at 07:03PM by mariuz

Deploying Node.js Microservices to AWS using Docker

http://ift.tt/2ogEoAN

Submitted March 29, 2017 at 03:36PM by hfeeri

Continuous Deployment of a Dockerized Node.js Application to AWS ECS

http://ift.tt/2o74qcn

Submitted March 29, 2017 at 02:47PM by mmaksimovic

A step by step guide on creating a NodeJS API. Do share your feedback.

http://ift.tt/2oxteqz

Submitted March 29, 2017 at 12:13PM by zingbhavya

Espruino on NodeMCU (step-by-step guide)

http://ift.tt/2nujFJH

Submitted March 29, 2017 at 10:39AM by paolomainardi

Why aren't more people using rethinkdb? Its pretty awesome

I have done 2-3 small apps using rethinkdb. It was disappointing when the company rethinkdb closed shop but now Joyent has managed to get them into the Linux Foundation under open-rethinkdb.This database is a great match for node.Aside from hyping it, I am curious why people haven't tried or if you did try why did you stop using it?

Submitted March 29, 2017 at 09:14AM by agentf90

Is NodeJS even right for me?

First I'd like to says thanks to the NodeJS community! Last topic/question I had some awesome responses. I'm for sure going to be using NodeJS regardless, it seems super powerful. However I have an upcoming project (starting beginning of Summer). I was wanting to make sure if NodeJS is even right for me.My plan is to use a simple stack: NodeJS, ExpressJS, MySQL, and Nginx.The project? A community driven website that has a "social network" feel (posts, applets, profiles, etc). My primary focus is speed and reliability. In addition to speed I'm trying to save as much on server costs as possible because the project isn't going to be a commercial product. The website will have a lot of interactive bits, live updating stats, pulling stats from APIs and hopefully setting up a cache system for optimal performance.I have experience in: Python, PHP, JavaScript, HTML/CSSI have experience with: Django and Laravel (very little)I've used Django, but there is a lot I don't like and some I do. I love their database migration system, which is one reason that's making me rethink and just use Django. However I always feel like I have to work around Django and I want something with low overhead.If you have any opinions and/or input that would help me out tremendously. Regardless if this isn't the system for this project, NodeJS looks really promising.

Submitted March 29, 2017 at 04:40AM by Miles360x

Tuesday 28 March 2017

How do I handle errors in ytdl-core?

Are URL parameters considered secure when used like this with passport and https in production?

http://ift.tt/2o3Prjv

Submitted March 28, 2017 at 11:02PM by Telcrome

Memory leak in the latest 4.x and 6.x versions of Node.js

https://twitter.com/mylesborins/status/846790049438089220

Submitted March 28, 2017 at 08:03PM by ShermheadRyder

Learning to use Node for Web

HiI'm currently trying to learn NodeJS for web development with MongoDB as my database.However, i'm having some issues regarding frameworks - Every single guide on the internet is using either Mongoose, Express, or some other framework to make the connection between node and the frontend page.However, i want to learn how to display data on a webpage with just pure Node and MongoDB with no frameworks.I do know that frameworks are a great help and they speed up development by A LOT, however i believe in learning stuff from ground up. Same as i learned how to use javascript before i learned how to use jQuery.Can anyone help me with this?Also, it seems to me that an API is the way to go if you want to make an application that can perform CRUD operations - is that the only way?, or is there some way to make nodeJS work kinda like PHP.Thanks in advance :)

Submitted March 28, 2017 at 07:19AM by Kacxer

Proxying WebSockets with NGINX

https://youtu.be/zutCD7HMgwA

Submitted March 28, 2017 at 05:00PM by insane-architect

Testing an express app by mounting it on hapijs

http://ift.tt/2nc4Tqd

Submitted March 28, 2017 at 01:26AM by devinivy

Peoples are spreading wisdom on internet.

http://ift.tt/2otSIoS

Submitted March 28, 2017 at 11:55AM by naeplus

Giorgio Regni & Lauren Spiegel - High Performance Node js: learn how to full throttle your code!

https://www.youtube.com/watch?v=bE-KlVHscEM

Submitted March 28, 2017 at 08:31AM by harlampi

What convenience functions you'd like for a MySQL interface and how'd you name them?

In Node.js, there are two drivers to use MySQL:http://ift.tt/2o1HZp2 drivers are low level interfaces to MySQL that share an identical API. I see a lot of projects directly depending to these modules. The problem is that these projects lack at least one level of abstraction.I have set out to improve this. My main beef with the existing projects is:lack of strict typeslack of convenience methods for common operationshard to debug/ logerror handling requires tapping into the error codesI have started to write http://ift.tt/2ouixFj to address all of these issues. It is not a complete project – I develop it as new requirements crystallise. (Note, it is a thin layer on top of mysql2, no one wants to reinvent the wheel here.)At the moment, mightyql allows to:log queries using DEBUG=mightyql*. The log includes the original query, execution time and the count of the rows.includes convenience methods: one, many, any, insertone returns one row. Throws error if no rows found. Throws error if more than one row is found. (Query should be constructed with LIMIT 2)any returns rows array (unlike query, it does not return fields)many returns one or more rows. Throws error if no rows found.insert returns {insertId} object.I'd like to add methods that return the first column value. I was thinking oneColumn, anyColumn, manyColumn. Though, this naming is slightly confusing (any column especially). What you'd suggest for alternative names?Note: The reason for using a different method for each result type is to enable simple use of strict types (Flow type in this case).Regarding the error handling, I've madeWhat operations with MySQL you often perform in your code base and have you thought of higher-level abstractions?

Submitted March 28, 2017 at 01:48PM by gajus0

TestCafe v0.14.0 is out with authentication via user roles, client-side debugging and other cool features.

http://ift.tt/2o7kI5G

Submitted March 28, 2017 at 03:07PM by churkin

Everytime I run my node app, I have to hit cancel and restart the script. Is there anything better?

Say if my index.js route in an Expressjs/nodejs and as soon as im done saving, the app can restart eg. restart the node process. Is there some standard way to do this or the smart/easier way?

Submitted March 28, 2017 at 03:49PM by mineralwatersoda

New online Node.js game: What are your thoughts?

My latest project has been a multiplayer HTML5 game built in Node.js. Here's the link: http://deepspace.blue. I would appreciate it if I could give some feedback on the game and good ways to get it out there. I really don't want to advertise if I don't have to. If you like the game I'd appreciate it if you'd leave an upvote and share it with some friends. The source code will be available soon.Edit:I forgot to mention, there are power-ups. You can see your current power-up on the scoreboard. To get a power up you have to eat a little white thing.

Submitted March 28, 2017 at 03:06AM by Triforcey

LTS or no?

Hello all,I'm going to be making a project with NodeJS for the first time. It seems likes version changes are happening super frequently. Should I simply use the current LTS for development or are the changes in the NodeJS pretty compatible between versions?Thanks!

Submitted March 28, 2017 at 04:56AM by Miles360x

The Definitive Guide for Monitoring Node.js Applications

http://ift.tt/2nvS50t

Submitted March 28, 2017 at 12:50PM by hfeeri

Monday 27 March 2017

Inheriting corporate node stack, looking for a compilation of info to ramp up fast

I hope this is the right forum in which to be posting this, apologies if it's not. I'm inheriting a large node api stack, as well as a mature cms/devops/scripting stack. I'm comfortable in JavaScript itself, but node is something I'm still new to working with. Right now my only training are a few Udemy classes.Are there any more efficient ways to get up to speed fast and learn the ins and outs, especially quirks and pitfalls. Looking for a direction to throw myself at for the next series of 100 hr work weeks.Thank you in advance.

Submitted March 27, 2017 at 10:14PM by adamos486

Tutorial: how to build a Rails web app ready to receive webhooks to track mail in real-time!

http://ift.tt/2oaez5p

Submitted March 27, 2017 at 07:20PM by ult1matejedi

Caching images with fs or service workers? (x-post from r/electronjs)

Hi! I'm currently working on an Electron app which will display dozens of images returned from a JSON response, and one of the project requirements is to cache those images to view offline. What would be the best way to cache those images?Originally I had thought about making a proxy server that intercepts image requests, saves the image if it doesn't already exist, and then returns the contents of the local file. However, I just found out about service workers, which sounds like it could automatically take care of all that caching overhead.Also, am I going about this the right way, or is there another option I'm not considering? I'm pretty new to the whole Node/Electron eco-system, so I'd be open to a different, better-suited methodology as well.Any advice or pointers would be very much appreciated!

Submitted March 27, 2017 at 03:59PM by mrfusion2000

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

http://ift.tt/2oqPxyg

Submitted March 27, 2017 at 05:26PM by shsh3

How Do I Prevent Exceeding Heroku (or any Server) Memory Limit?

Hey friends!Right now I have a node.js app in Heroku that has to do some image processing. Everything works super fine!Except when I have to process lots of images.Right now I'm using promises and graphicsmagick to handle the image processing. Vaguely whats happening right now is that a promise.all is happening in which for all image I resize it and then save it.But I don't limit anything.Since I really don't know how to limit anything.... Would limiting the promise concurrency improve something? Or do I need to call the garbage collector or something? I'm not well versed in these topics so I don't know what Info you need to be able to answer! Please ask anything you consider I must say!Is there any way to tell node "If you exceed this level of memory then wait a little before creating new calls to imageResize()" ?

Submitted March 27, 2017 at 05:36PM by sandalphone

Setting up NiginX as reverse proxy for Node ("Deploying Node" tutorial series)

https://youtu.be/ng5DsxYp-Bk?list=PLQlWzK5tU-gDyxC1JTpyC2avvJlt3hrIh

Submitted March 27, 2017 at 04:22PM by insane-architect

how would you approach this?

I have a bot written in node. (entirely backend)I use knex to get info from my DB.-I want to build a simple "front-end" [1 page] with the values I retrieve from my db.-then screenshot that page and save as an image (using horseman for this, although not sure if it will work on a localhost address?)I was thinking vue/ or react to generate the page. But would that mean I have to also add something like express/koa into my existing project? Or Should I do that front-end page as a separate project?

Submitted March 27, 2017 at 03:44PM by sayurichick

Solr nodejs wrapper (mongoose inspired)

http://ift.tt/2o1Oo3Y

Submitted March 27, 2017 at 03:11PM by _dmomer

How API Request Signing Works (and how to implement HMAC in NodeJS)

http://ift.tt/2ns8cwe

Submitted March 27, 2017 at 03:15PM by r-wabbit

Before you bury yourself in packages, learn the Node.js runtime itself

http://ift.tt/2lfAwCp

Submitted March 27, 2017 at 01:33PM by fagnerbrack

Nest RELEASE canditate is here! Introduction to modern Node.js framework

http://ift.tt/2nXG0Cc

Submitted March 27, 2017 at 01:25PM by mysliwik

Muenchhausen: Cli of a faker.js competitor?

http://ift.tt/2nPGBpk

Submitted March 27, 2017 at 10:36AM by dodo_number_1

Scaling Socket.io to multiple Heroku dynos -- how?

I'm trying to scale Socket.IO to multiple dynos on Heroku. I have determined that I need to use a sticky-session module (for multiple processes), enable session affinity on Heroku, and also use the socket.io-redis adapter + socket.io-emitter modules to enable emitting events to clients connected to another dyno.I was pretty confident of sticking to this approach, until I read this: http://ift.tt/2nZlilL article says that when using Socket.IO, here is all the info that is saved:Handshake data, the handshake data includes ALL request headers, query strings, ip address, information, urls and possible custom data that you’ve added during authorization.Ids of all connections that are open, connected and even closed.Room names and each id that has joined the room.Apparently, this is not all saved in Redis:All this data will be synced through pub/sub to every connected Socket.IO server. So if you have 2 node process and they both use Socket.IO stores they will both have all the data of all connections in their own process memory.This causes the following problem:...it can actually be used as an attack vector against Socket.IO servers which are connected using the Socket.IO stores. The attacker only needs to create a script that initiates a handshake request with your server which connects with the longest query string allowed with as much custom HTTP headers possible and you could easily blow up a server in a matter seconds because all this data is serialized using JSON.stringify which will start blocking the event loop for all the serialization and when you receive such a large packet it also needs to parsed again by JSON.parse and eventually it will be stored in the V8 heap of your node’s process. This will eventually cause it explode out of memory due to the V8 heap limitations of 1.7 GB and your whole cluster will be FUBAR.Does anyone know if these are legitimate problems with using Socket.io on multiple dynos? If so, has this been fixed in a subsequent update?One solution I am considering is to implement similar functionality myself. Every dyno of mine would be subscribed to Redis using a unique channel ID. Redis would also store a mapping of client ID to dyno ID, so I can figure out what dyno a client is connected to. If a dyno wants to send a message to a client connected to another dyno, it would figure out which dyno is connected to the client (using Redis), then publish the event on the corresponding Redis channel. This way, every socket's connection info/overhead is saved on just one dyno, with the whole thing tied together using Redis pub/sub.Any advice would be greatly appreciated!

Submitted March 27, 2017 at 09:15AM by STOP_SCREAMING_AT_ME

Middleware: THE core of node.js backend apps

http://ift.tt/2nmzx0V

Submitted March 27, 2017 at 09:29AM by hfeeri

Sunday 26 March 2017

Should I transpile server-side code?

Hi guys, I'm using Webpack client-side but I wonder if it's too much hassle to do it on the server. Is it worth it to do only for import/export statements?

Submitted March 27, 2017 at 12:05AM by savovs

[Recording] Node, Redis, and You! at SF Microservices

http://ift.tt/2n5X4Bx

Submitted March 26, 2017 at 06:36PM by nucleocide

Npm Organisation is Now Free for Public Packages

http://ift.tt/2mBuCvR

Submitted March 26, 2017 at 03:19PM by shsh3

[DUTCH/EU] 15 euro for 10TB bandwidth VPS?

So I need a server to host Node.js application, but anyone knows this Dutch VPS: http://ift.tt/2nBUcjF realistic is this? Most of the competitors give just the half of what they give.

Submitted March 26, 2017 at 03:37PM by XalAtoh

any dummy project for web development using node.js?

hi everyone, I'm near completing the basic node.js course and soon will take a course on mongodb or any db that is good on node.js. and i just want to know any dummy project or exercise to improve my skills in web development especially in node.js. here are my current set of skills, all on basic to intermediate levels: html, css(plain,bootstrap,basic sass, js(plain, jquery), node.js(basic), datbase(basic)

Submitted March 26, 2017 at 01:17PM by jrdn128

Generate tests to find strange corner cases

http://ift.tt/2nO9gbF

Submitted March 26, 2017 at 10:21AM by get-finch

Best i18n library for an Expressjs app?

I am looking into Internationalization libraries for an Express app I am developing.Best for me would be easy to use and concise, very fast, taking little resources and being actively maintained.If it matters, the way the language will be set is from the url (http://ift.tt/2nVqtTN) and I should be able to have a default language (http://ift.tt/1CFGpsj). I will not be using cookies to set the language.I will also need some sort of nice output to give to translators and it should be easy for them to return a locale file.Searching npm and github I found i8n and y18n. i18n has a lot more stars on github, but y18n has a lot more downloads on npm.

Submitted March 26, 2017 at 06:33AM by Ozyzen

Saturday 25 March 2017

Yields & generators vs Promises

Hi everyone!Because of my interest in NodeJS i'm going to make a API in NodeJS, just to learn more about node. I used some frameworks like SailsJS before, but I think creating a API from scratch can help me more understanding node. In SailJS i always used promises for the sake of readability. But I read a few articles about yields and generators and I think this improves the readability in node when working with async code. Now i'm wondering if I should use Promises or Yields and generators in my API. What do you developers think??

Submitted March 25, 2017 at 10:04PM by goodnoodlesoup

Tunnel TCP through WebSockets. Access anything you want, even from a crappy WiFi which only allows HTTPS.

http://ift.tt/2n51Z6A

Submitted March 25, 2017 at 09:43PM by ratancs

Testing socket.io with a jQuery client

The app is a fairly simple multi-player game meant to be played via a browser. I use express.io and passport.io for the login and authentication, and also to establish a non-persistent session.Once authenticated, I pass the user to the game room where they'll pick-up the jQuery client and establish the socket.io client connection. From here multiple users can join the room, and the room owner can start the game once there are enough players.To test, I'm using FF with Firebug and Multifox to establish unique sessions for each player. I log in with 4 different ids, one for each Multifox session. I then have to manually go through the game logic to get to the area I want to test.Now that I'm getting deeper into the game logic, the testing time is killing my productivity. For each test I have to bring up at least 4 new browser tabs, set the Multifox session, login, commit some game functions, etc, etc.I'm curious if anyone has come across an easier way to test in these types of scenarios. I've looked through most of the node test solutions, but none seem to give you the ability to simply record the steps from the client and then replay those steps through the browser, versus scripting out client interaction for unit testing.Is there a way to automate any of this?

Submitted March 25, 2017 at 04:32PM by opusprime

Need suggestions for a redis host

HiI am hosting my app on Google Cloud and am looking for a redis host.I am using redis as a session store and will include at most 4 of my variables ( strings <20 length ). I am hoping to get about 5000 unique visitors. The site will be live for about a week only. RedisLabs has free plan for 25MB but i dont know if it will be enough. Their $4 plan may be defintely enough but is billed by the month.Bitnami Redis on GCloud has a ~$5 plan which is billed by the second but I have zero experience with it. I am used to redis labs. Will it be as easy ? Is there any performance issues ?I am making a Que/Ans site for my university therefore funds are not given and all of it is coming from my pocket

Submitted March 25, 2017 at 03:18PM by abkibaarnsit

Best authentication system for a node.js back-end with a React front-end?

I'm building a single page application using React and then node.js for the back-end API routes. I've researched a lot about the different authentication strategies. I've narrowed down my options to the following:SessionsJSON Web TokenOAuth?The problem with JWT is that revocation is difficult and sparsely documented, refreshing tokens also.I want to get this right the first time while also maintaining room for scalability. I am an experienced developer but not so much in terms of the norm of what is to be used in the face of a problem like this.Any help would be greatly appreciated.

Submitted March 25, 2017 at 03:55PM by _shahram

Please help us design a better Node.js tutorial

http://ift.tt/2mQc8HV

Submitted March 25, 2017 at 07:51AM by Mikhail-Kotykhov

Managing Node.js Versions Without External Tools

http://ift.tt/2oeUqu6

Submitted March 24, 2017 at 11:28PM by code_barbarian

(coming from php to node) building a forum website in node. on initial load am I best using a templating system such as jade, or inject json data into static(ish) html file?

I'm sorry that I can't word this properly. English isn't my native language.but let's assume I were to recreate reddit.com front page. would it be best if I process the home page with a template engine, then serve that, or should I serve a "barebone" static HTML template and let the client-side render the json data I include in the static template?templating just feels unnecessarily complicated to me. I don't want to learn a whole new way to write HTML... I don't need an engine that converts " html " to ""... I just want to be able to fill the template with data... but there doesn't seem to be a way to do it like php does it... e.g. '; } ?>I feel like the "right" way to do it is to serve a html file statically, and load the data via json/javascript. render at client side, you know?I just want the fastest page load time and response time without having to spend $4k/month on servers just to convert whitespace to brackets.unrelated: absolutely love node. but I'm really getting annoyed with how many options you have for different things. all the tutorials I've read use express.js for example, but I can think of at least 3 popular packages that do similar stuff and might even be better.

Submitted March 25, 2017 at 01:20AM by mysqlnoob4

TDD the RITE Way

http://ift.tt/2m4Iqxo

Submitted March 25, 2017 at 03:06AM by fagnerbrack

Developers want me to pay between $3,000 to $20,000 for an "investigation" phase. Am I getting ripped off?

Before giving me an exact proposal, several node and javascript developers are telling me I need to spend $20,000 to review my application idea before starting designs or development of the app. I'm starting to feel like I'm getting ripped off. Is this normal? Do I need to pay a developer $100/hour to listen to my idea?

Submitted March 25, 2017 at 01:24AM by ineedhelpcoding

Friday 24 March 2017

node-bowshock npm package to interact with the NASA api.

http://ift.tt/2nx4NfM

Submitted March 24, 2017 at 09:57PM by johnnywebdev

Node & API Development

Preface: Just as a means to kick-start this discussion, I have heard quite a lot about hapi being the best framework for API's built on node, but my job as a developer is to stay relevant so I gotta wonder, why hasn't hapi gained as much momentum as express has been continuing to grow? It looks so great and overall more applicable to the general use case, and I want to toss express and use hapi as my go-to, but that sounds scary.What is your most preferred way to develop an API with node?

Submitted March 24, 2017 at 10:20PM by nativereact

Why does lodash start with "_."? eg. _.trim(names) instead of names.trim()

Kinda confused why its implemented like this versus how jQuery does it at the end.

Submitted March 24, 2017 at 06:08PM by mineralwatersoda

How to test Node.js Application using Mocha

http://ift.tt/2nw4vpr

Submitted March 24, 2017 at 06:05PM by shsh3

Async/await, exceptions and logic question

Hello, I would like to start a discussion regarding handling of errors/exceptions in async/await code.When we were using callbacks, we used to write code that with standard node convention of callback(err, result). So we used err to signal that something didnt go as expected, meaning we could handle logic through err. For example, function called getUser(id, callback) could return an error in callback saying that user wasn't found, or that the DB is not available, or something else. Now, naturally, the (err, result) style callbacks moved to promises, and err became rejection cause. This was natural. But now we are here with async/await in node 7.6.0 and the rejection cause is now exception thrown. Now this is weird, because the logic flow moved from 1st argument of callback to exception. This is actually discouraged in many languages, to use exceptions to control non exceptional flow (providing wrong user name is not that exceptional at all). for example lets have an async function authenticateUser(login,password) which may return an user or may throw(reject with) many different errors like user not found, wrong password, email not confirmed etc. Now all these errors become part of the API of this function.This doesn't feel right.How do you feel about it? Should the errors be returned in form of a pair of values instead, like they do in Go?

Submitted March 24, 2017 at 03:24PM by newreddit0r

Requiring API from Kue Module

I'm working on a UI using Kue.js as a backend. Because Kue comes with a UI, I'm struggling to figure out how I can use the API without the built in UI. I can launch my epxress app on a different port, but then I run into cross-origin issues when I try making API requests to the Kue port.Anyone run into a similar situation elsewhere or with Kue? Any suggestions?

Submitted March 24, 2017 at 02:45PM by amplify895

Node.js 7.6.0 Tackles Asynchronous Operations

http://ift.tt/2nLeU18

Submitted March 24, 2017 at 10:56AM by nilinte

Top 5 Most Rated Node.js Frameworks for End-to-End Web Testing

http://ift.tt/2mYaM9l

Submitted March 24, 2017 at 11:16AM by ginger-julia

Node v6.10.1 (LTS) Released

http://ift.tt/2mqDYuA

Submitted March 24, 2017 at 08:16AM by hfeeri

Node.js Weekly Update - 24 March, 2017

http://ift.tt/2obCZKX

Submitted March 24, 2017 at 08:16AM by hfeeri

Awesome Node.js Weekly - Issue 45

http://ift.tt/2nJcgck

Submitted March 24, 2017 at 12:47AM by stanislavb

a newbie question about deploying a node application into production

I was reading a lot about deploying a node js app into production. All what I can see is something similar to development, when I get the package.json file and do npm install and then run the application.But I compare it to browser, where in the browser I can combine and minify all javascript files into one. Is there something similar in node? and is that the standard? and why all documentation about production deployment mention that I have to run npm install on production? So why the minification is not common?

Submitted March 24, 2017 at 02:15AM by gkarwchan

grawlix - extensible profanity filter, replaces words with comic book-style nonsense symbols (%!&#, etc.)

npm | GitHubFeedback and suggestions for additional tests would be appreciated. I know there must be some other common scenario I didn't think of...

Submitted March 24, 2017 at 06:45AM by jon_stout

Node_Redis Wrapper - Inspired From Callback Hell

Today at work I found myself in callback hell with some legacy node code.It appears node_redis doesn't have first call promise support without bluebird decoration. This being said bluebird is a completely viable option assuming you want to append all your commands with "Async". I personally didn't want to append all my commands... It felt like code noise.So I wrote this library that decorates the redis commands with promises. I would prefer to make the decorator less invasive to the underlying api, but for a single night's work, I will live with it.If anyone else could possibly find this useful, shoot me a star or an up arrow and I will put more effort into making it a viable option around the existing implementation.http://ift.tt/2n0t7DN

Submitted March 24, 2017 at 05:46AM by shadestone

Thursday 23 March 2017

Module import / export in Node.js

Is ES6 import / export syntax supported in current stable (6.10.1) Node.js version?

Submitted March 23, 2017 at 09:22PM by blu3pegasus

Getting your nodejs site in Google index

As the title says, i have no clue on how to get indexed in Google. Should i add keywords metatag in the html, or keywords in package.json or install a module ?

Submitted March 23, 2017 at 09:22PM by Kosovar_

Learning Node. Please Share Good Resources.

Hey all,Like the title says, I am looking to pick up Node. Not new to JS by any means, just wanna get into back end as well. Would really appreciate it if you can share some of the resources that you found helpful.I know FrontendMasters have some good courses on Node. WesBos is coming out with one soon. Any blogs, or books would be good as well.Thank you!

Submitted March 23, 2017 at 04:22PM by shaheer123

Event-driven programming, Finite State Machines and NodeJS - The Floppy Disk

http://ift.tt/1SAFGRh

Submitted March 23, 2017 at 03:34PM by shsh3

Great article on understanding how async programming with generators and async/await work under the hood. Reviews callbacks and promises.

http://ift.tt/2nryTRN

Submitted March 23, 2017 at 03:12PM by tylernappy

I'm considering hiring a Node.js developer. But, all of their references are out of business or didn't have anything good to say. Is this a bad sign?

I'm looking to hire a developer but a majority of their past work and references either went out of business or stopped their project. The only person I could get in touch with said the company did a bad job. Is this a bad sign?

Submitted March 23, 2017 at 02:19PM by ineedhelpcoding

Nodejs mssql connection error port not found

Hello,I am pretty new to nodejs and want i to connect with my sql database. I wrote some code but i constantly get a connection error that tit cant find the right port. I checked everything and it is on default 1433, i also tried multiple other port names but nothing seems to work.Here are a screenshot of my code and of the error message.http://ift.tt/2mU5609 you guys can help me!

Submitted March 23, 2017 at 12:45PM by ricobr1990

Sharing my experience in testing ExpressJS on Node.js without a Supertest dependency

http://ift.tt/2ngscSi

Submitted March 23, 2017 at 01:35PM by lirantal

Using Node.js to Interact with Facebook's Graph API

http://ift.tt/2nvYmax

Submitted March 23, 2017 at 01:48PM by ms-maria-ma

Wednesday 22 March 2017

Set up a continuous testing pipeline for a Node.js app

I wrote a new guide on creating a continuous integration, delivery, and testing pipeline with a Node.js app.Full post: Set up a continuous testing pipeline with Node.jsExample repo: http://ift.tt/2mtVNsw tutorial goes over the different components of a complete CI pipeline:Push code to GitHub, build and run unit tests on CircleCIDeploy new app version to HerokuPost-deployment tests with AssertibleThe whole workflow is surprisingly easy to set up, so I'd love to hear some feedback on this approach and how other teams manage their CI setups.What does your CI pipeline look like? Anything you would add or change about this workflow?

Submitted March 22, 2017 at 09:15PM by CodyReichert

Take Data Validation Seriously - Paul Milham, WildWorks

https://www.youtube.com/watch?v=3A73G5xntJI

Submitted March 22, 2017 at 08:05PM by r-wabbit

Looking for advice: How should I handle partial free text search on top of MongoDB with scalability in mind?

I'm looking for a way to replace my current regex-based search implementation which simply runs a wildcard find query on a MongoDB collection that consists of users' personal expenses:const where = { user: currentUserId, description: {$regex: new RegExp(`.*${escapedSearchString}\.*`, 'i')}, }...where an escapedSearchString value of 'star%20wars' would match descriptions like 'Star Wars action figure' and 'Rogue One: A Star Wars Story Blu-ray'.The main concern here is that regex queries are very expensive to execute especially as the collection grows, so I'm looking for scalable alternatives. MongoDB's $text search does not fit the bill because the app does not particularly target individual words in any particular language, but instead focuses on partial matches. So if a user submits a search string like 'tar w' it should match 'Star Wars'.I was thinking that spinning up an Elasticsearch instance might be an option, but I would probably have to replicate the entire Expenses collection, including most of the fields, in Elasticsearch for optimal performance (i.e. without having to run a separate MongoDB query with the matching IDs to fetch the remaining data). Does this make sense or should it be further optimized somehow?Thanks in advance and I hope other developers pondering similar questions can get something out of this too!

Submitted March 22, 2017 at 07:55PM by Mjoldur

Technique for querying the string "node" in regard to web app development, but not Node.js

From time to time I need to query for the word "node" to refer to a general connected data point in a web app, but not in reference to Node.js, and I am finding it increasingly more difficult to obtain relevant search results. Has anyone else encountered this problem, and if so, how did you address it?

Submitted March 22, 2017 at 08:02PM by jsejcksn

Kill a particular process on windows bootup using Node

I am a web developer with theory knowledge of NodeJS.I want to kill Skype app when I open my system from home. So I will need a code which runs on windows bootup, checks my wifi's name and if its home one, killls the Skype process.Is it possible with NodeJS?

Submitted March 22, 2017 at 05:47PM by lakshaydulani

From Node to Go: A High-Level Comparison

http://ift.tt/2nRXVqZ

Submitted March 22, 2017 at 04:10PM by westyler1

NEAT - Application "Framework" - How to explain it?

Hi,I and a few coworkers have put together an application framework that basically is supposed to replace all the things you would constantly build again for no apparent reason (setting up sessions / user auth / crud routes / permissions / rendering for frontend / routes for apis / exports ... all the nice things) now this is already being used by us internally but i want to improve the documentation of this over the next few weeks.So my question here would be if anyone could give me some hints how to best start a Documentation / Tutorial of sorts for a really big system. Currently it consists of the following git repos (& npm packages)http://ift.tt/2msPky2 of them are not even remotely done but some are getting more stable every day and can already be used very efficiently.The thing is that just explaining for example the frontend module can take up to 2 hours with the person sitting next to me, not because its that hard to learn just because there is an absurd amount of possibilities ...A lot of them also interconnect and give other modules more features (neat-projection is the prime example of this)So where should i start explaining what it can do for you ? Would you rather have a simple backend with an api that could be used by any kind of app / SPA, or an example how this can be used to make a simple blog?I'm happy for any help on how to get the Documentation / Getting started articles on this started... Also if anyone would like to try it or help with some sort of screencast or something we could do, please pm me :)Cheers, NexumTL;DR: Big big framework int he works, need help on where to start explaining something like this, what kind of examples would be good and so on

Submitted March 22, 2017 at 02:47PM by Nexum666

Production Ready Microservices In Action

http://ift.tt/2ndbu6c

Submitted March 22, 2017 at 02:16PM by grve25

NodeJS VS AngularJS

http://ift.tt/2nd4XZe

Submitted March 22, 2017 at 01:38PM by SEOMohsin

I've been a Web Developer for 17 Years, and this is what I learned - Daniel Khan

http://ift.tt/2o3QM6v

Submitted March 22, 2017 at 11:58AM by gergelyke

Question regarding the asynchronous nature of nodejs.

Hello, im fairly new to nodejs and learning about the asynchronous nature of node by using coffeescript. in node, every http call made is asynchronous , im making these calls in a for loop of 5, but why do i see the value of counter as 6 inside the call when made.? shouldnt it display value 5 ?------> for i in [1..5] ....... console.log "counter is #{i}" ....... http.get { host: 'www.google.com' }, (res) -> ....... console.log res.statusCode ....... console.log "counter is #{i}" ....... console.log "counter is #{i}" counter is 1 counter is 1 counter is 2 counter is 2 counter is 3 counter is 3 counter is 4 counter is 4 counter is 5 counter is 5 [ undefined, undefined, undefined, undefined, undefined ] coffee> 200 counter is 6 200 counter is 6 200 counter is 6 200 counter is 6 200 counter is 6 undefined

Submitted March 22, 2017 at 08:17AM by russotiquerra

I just don't know how to structure my project. There are so many ways to do things.

It's difficult for me to understand how exactly should I structure my project. Should I have a separate project that runs the client side and another project that runs the server separately ? Or should I just render the the front end with a simple view engine.If I do one thing or the other it won't matter because I always feel like that there is a better way.I know at the end of the day I can do my project however I want, but I want to follow the best practices. But following those best practices seems hard as everyone does it differently.Currently I have two separate projects that runs the server and the client.http://ift.tt/2mqL9mv is this good ? How do I know ? I want to be right now and not wrong a month in to the project and restructure the whole thing.I try to look for 'examples' to follow and I see big projects like Pokemon Showdown, they have it separated too.http://ift.tt/2mSb5Dp also tried to follow another example (an excellent one may I add) but hey, this project is setup differently too.http://ift.tt/2mqDILO is it alright to simply have a view engine like I did for this projecthttps://github.com/HappyZombies/4chan-nodejsI know I am dwelling into more things than just NodeJS, but I just don't know how a project should be structured for it to be 'right'. There are so many ways to do things, and I feel like none of them are...right. Maybe I am just not understanding the big picture.

Submitted March 22, 2017 at 12:07AM by HappyZombies

Build A Support Ticket Application With AdonisJs

http://ift.tt/2nOD1cj

Submitted March 21, 2017 at 11:43PM by romainlanz

Tuesday 21 March 2017

Meet the people who make Node.js: Colin Ihrig

http://ift.tt/2mRXs7z

Submitted March 21, 2017 at 10:46PM by ecares

Any good keystonejs alternatives?

KeystoneJS is awesome but it's nearly impossible to customize it. I want a mongoose admin generator but I can't find anything good.

Submitted March 21, 2017 at 09:54PM by fleaspoon

SFNode Meetup: Creating Electronic Dance Music with JS & Node.js - Walmik Deshpande

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

Submitted March 21, 2017 at 07:46PM by dobkin-1970

A console.log inside express route is not being logged

http://ift.tt/2nOQgtz

Submitted March 21, 2017 at 06:34PM by bobbyrne01

NodeConfAR 2016 - YouTube Playlist

https://www.youtube.com/playlist?list=PLz6xH_GrBpquZgdVzEX4Bix0oxHQlZfwm

Submitted March 21, 2017 at 06:45PM by jcferrans

Build a "Serverless" Slack Bot in 9 Minutes with Node.js and StdLib (x-post r/webdev)

http://ift.tt/2naBtLs

Submitted March 21, 2017 at 07:01PM by J-Kob

Create a Node.js Micro Service for your Mobile App

http://ift.tt/2mMhizX

Submitted March 21, 2017 at 04:19PM by shsh3

Common Mistakes to Avoid When Developing In Node.js

http://ift.tt/2niFle1

Submitted March 21, 2017 at 03:35PM by ereich

Best 60 AI & chatbot conferences you should attend in 2017

http://ift.tt/2o0k2uS

Submitted March 21, 2017 at 02:45PM by sprinter_

Dawson — a serverless framework for Node.js on AWS

https://dawson.sh/

Submitted March 21, 2017 at 11:14AM by mmaksimovic

End-to-End Testing with Nightwatch.js

http://ift.tt/2nvxaeE

Submitted March 21, 2017 at 10:10AM by hfeeri

Frontend Local Setup 6 - Updating Node and NPM on Windows. Subscribe at our Youtube Channel https://www.youtube.com/channel/UCw4cxFG34-cCbG5RdA-7mTw for more video tutorials

https://www.youtube.com/watch?v=1ropX3fg2E8

Submitted March 21, 2017 at 09:25AM by TutorialsDojo

Learn how to design large-scale systems. Prep for the system design interview.

http://ift.tt/2m0lQ5F

Submitted March 21, 2017 at 07:48AM by ratancs

Become-A-Full-Stack-Web-Developer

http://ift.tt/2mUR95g

Submitted March 21, 2017 at 07:51AM by ratancs

⭐️ Companies that don't have a broken hiring process

http://ift.tt/2nm9yJE

Submitted March 21, 2017 at 07:54AM by ratancs

Which stack for a real-time Web application?

Hi,I'm trying to decide which stack of technologies I should use to develop a Web application which dyanimcally shows a google calendar events. I was thinking about "Node + SocketIO + Express" and Bootstrap. Any suggestions or recommendations?thanks in advance!

Submitted March 21, 2017 at 08:36AM by esblab

Compiling .js and .json files together into one minified script

Hello,I was wondering if it was possible that given a few JS files and a JSON file, would it be possible to compile them together server side?E.g. The JS files contain the core logic while a JSON file contains settings specific to one case. And there could multiple JSON files for multiple cases. And I want to make the node server dynamically pick a JSON file and compile it against other JS files and store the result somewhere else to be served.

Submitted March 20, 2017 at 11:38PM by acylus0

Boilerplate for node/express?

Anyone have a simple/basic boilerplate for node with express?

Submitted March 21, 2017 at 12:28AM by emd2013

Monday 20 March 2017

CH4t - BBS themed chat app based in nodejs + express + socket.io

http://ch4t.ga/

Submitted March 20, 2017 at 10:14PM by johnmadison

What microservice framework to use?

Is there a "standard" framework like express or is the community divided? I Googled "nodejs microservice framework" and Seneca is at the top. But is that because of good SEO or is it the most popular?

Submitted March 20, 2017 at 08:52PM by richie_south

Lessons from an Ember-Node app

http://ift.tt/2mMFhQs

Submitted March 20, 2017 at 06:45PM by Matthew_Srtgfr

SeeQL: Real-time SQL profiler [looking for collaborators]

http://ift.tt/2mN1wG0

Submitted March 20, 2017 at 06:08PM by gajus0

Catching value of an async function

I've got this async function:function fetch(cb) { var data setTimeout(() => data = {"hello":"world"}, 1000) return data } That function returns the value after 1 second, I'm looking to console.log the value when it's ready. It's been said that here we should use callbacks, but wtf, I've tried all the ways and I still get undefined..Any solution would be appreciated, but don't add a console.log inside the timeout function..

Submitted March 20, 2017 at 06:31PM by shark1337

Created a super simple Node Twitter CLI Tool - thoughts?

http://ift.tt/2neQBYL

Submitted March 20, 2017 at 04:38PM by bustyLaserCannon

Got an interview on Wednesday, what should I expect?

This weekend was a cool event at my university where 7-8 companies where looking for students that could work for them (internships during the summer, part-time or maybe full who knows ). There was some big names like amazon and some guys that I've never heard of them, but one of them had a banner that looked too good to be true (in a world of PHP, I've never thought this would happen): NodeJS, Express, React, Redux, MongoDB, React-Native and stuffs like that instantly made me get in talk with them. They also had a small conference like the others as well to present what they do ;)They call me to visit them for a discussion about node js, what should I expect them to ask me? Keep in mind that I'm not gonna go full time, I still wanna graduate, but I don't know when I'll get another chance like this, especially with node.js.

Submitted March 20, 2017 at 05:19PM by shark1337

How are async callbacks implemented?

I've seen a lot of examples that uses callbacks for asyn events like reading, dowloading, fetching etc, but I can't figure it out how it's working under the hood..Here's what I've tryed to do, but I can't get it working..function fetch(url, cb) { var data setTimeout(() => { data=`{"hello":"man"}` }, 3000) cb(null, data) } cb = (err, data) => { if (err) return err else console.log(data) }; fetch("http://url.com", cb); As you can see, I'm trying to implement a fake fetch function where the data is delayed. I've been passing a callback, but still got undefined.. Anyway how I could get this working without promises or anything else, only vanilla js?

Submitted March 20, 2017 at 12:01PM by shark1337

Make your Code Cleaner with Decorators

http://ift.tt/2lwFj0A

Submitted March 20, 2017 at 11:13AM by fagnerbrack

šŸ“· Unofficial Instagram Desktop App

http://ift.tt/2bLmmkf

Submitted March 20, 2017 at 08:50AM by ratancs

A CLI tool that automagically adds or recommends the best .gitignore for your project

http://ift.tt/2mO5JM2

Submitted March 20, 2017 at 06:48AM by ratancs

Sunday 19 March 2017

Promise impaired programmer may be this one question away from breaking through.

I've jerry-rigged something like this to work for me in say a Car class (query builder is knex, model is objection):static async createCar(color) { let returner = 'error creating car' await this .query() .insert({color: color}) .then((newCar) => { console.log(`new ${newCar.color} car created`) returner = newCar }) .catch((error) => { console.log(error) returner = returner + ": " + error }) return returner } Then I can call it elsewhere:await Car.createCar('red') // {color: red} But the more I use and understand promises (understanding admittedly lacking), the more I'm seeing that they should really be handled at the end, or at the last call. So I really want my class method here to be called like this:Car.createCar('red') .then( (car) => console.log(car) ) // or whatever I want to do with the car .catch( (error) => console.log(error) ) But I'm having trouble writing the static method that way.Lastly, how come I can generally console.log() a value from within a .then() statement, but I'm not able to return that console.loggable value outside the then() statement? That's a huge one.

Submitted March 19, 2017 at 11:37PM by coderbee

Requiring modules in Node.js: Everything you need to know

http://ift.tt/2nSZpR9

Submitted March 19, 2017 at 06:52PM by quincylarson

I built a boilerplate repo for Node API that uses Koa and Bookshelf. Feedback appreciated

http://ift.tt/2mXz6Kf

Submitted March 19, 2017 at 03:57PM by lorenzopicoli

How to handle File Systems in Node.js

http://ift.tt/2nFYKDe

Submitted March 19, 2017 at 02:28PM by shsh3

D3-Node: Easily generate charts and maps with D3, using Node

http://ift.tt/2mXoQl4

Submitted March 19, 2017 at 02:00PM by bradoyler

What You Should Know About Numbers in ES6 JavaScript

http://ift.tt/2kXCE0x

Submitted March 19, 2017 at 01:39PM by fagnerbrack

Is there a way to protect code?

My products have been resold for a cheaper price quite a bit. I'd like to make an authenticator system where it will first contact a server to check if the user is allowed. I figured users could just change the code to avoid this, is there any way I could actually have something like this work?

Submitted March 19, 2017 at 08:24AM by timgfx

BBS themed node chat app CH4T

http://ift.tt/2mglywx

Submitted March 19, 2017 at 06:32AM by johnmadison

sever - Simple deep cloning in Node.JS

http://ift.tt/2nEAph3

Submitted March 19, 2017 at 04:08AM by Etha_n

Saturday 18 March 2017

User profile management?

I'm talking about user profiles not authentication -- lots of options for auth like passport, Auth0, Stormpath, etc.What does everyone use in their node apps for storing and managing the non-password part of your user profiles? Just standard db queries or is there an easier way?

Submitted March 18, 2017 at 11:02PM by scottsanchez

Windows Dev environment

My Mac just went down and was wondering if anyone is using windows as their main system for nodejs/react development. If so, any tips or programs I should check out to help my workflow.My backup option is Linux, but keen to to try windows if it's viable

Submitted March 18, 2017 at 09:09PM by Phant35

Finding Developers for Open Source Project

So I have been working on an open source alternative of ZenDesk. I have two other members part of it but they aren't as experienced with node.js stack. Anyone know a community where I can post about the project for any developers with extra time who would be interested in helping out?I don't have money to hire any developers since I would be providing the advertising and server setup. The only thing I can offer is a cut in the future profit.So any recommendations on where I can post to find some developers with extra time that be interested?

Submitted March 18, 2017 at 09:00PM by happyElectron

Getting Started with Memory and Performance

http://ift.tt/2mVqZ0W wrote a short little post to share a bunch of stuff I learned about memory and performance in node and v8. I hope someone might find it interesting or helpful.

Submitted March 18, 2017 at 08:10PM by tayo42

Building a Blog with Realm Node.js and Express

http://ift.tt/2lxvE76

Submitted March 18, 2017 at 06:55PM by astigsen

JOB OPENING: Lead Developer - New eSports Web App

Hey guys,My name is John Jessup and I am the CEO of ConcurApp. To give you a little description on our application, Concur is a tool for gamers to communicate with teammates and discuss strategies while also taking advantage of a unique drawing board function that allows players to outline battle plans on any map on any eSports title in real time. Concur’s esports drawing board and chat application can help any team in any esports title prepare for battle ahead of time or on the fly. All major esports titles are supported, whether you are pushing lanes on Summoner’s Rift, defending the bomb sites on Cobblestone, or shooting your way to victory in Call of Duty.We are currently looking to hire a lead developer to complete our web app beta and work on roadmap features. We understand that most of you have school, work and other daily priorities, but as a start-up company with a large amount of traction we need applicants willing to dedicate time and energy.Skills Required: - HTML - CSS - JS - Node - MongoDBIf you are interested in applying, comment below or contact us on any of our social media platforms!Twitter Instagram

Submitted March 18, 2017 at 06:29PM by ConcurApp

Why are remote MongoDB services like MongoLab or Compose popular?

Why are remote hosted MongoDB databases from providers like MongoLab or Compose.io popular, versus a local MongoDB database?My confusion arises because when your application needs to save something to the database (which usually happens quite a bit), it would need to perform a network call to these remote services. That adds a ton of time onto something which should be quick like saving to a DB.This is compared to a local MongoDB instance in your own app. In this scenario, the app does not need to send a network request to save data.So why are these services popular? For something like a chat application, where you need to store each chat message in the DB, that adds up to a lot of network calls and increased latency. Am I missing something? What is the reasoning?

Submitted March 18, 2017 at 05:38PM by 5pitf1r3

detecting high server load using toobusy.js

http://ift.tt/2mGLXQc

Submitted March 18, 2017 at 03:19PM by asafdav2

Question: Intensive processes with Node.js

Hi all, quick question regarding intensive processes: is it considered bad practice to send emails (e.g. forgot password) and do image manipulation (e.g. resize & scale avatar) in my app without offloading them to a job queue? I'm working on an open source app and really don't want to make the requirements too steep by requiring Redis, job queues, workers etc. Also, how do you prefer to handle cron jobs with node? Thanks.

Submitted March 18, 2017 at 03:26PM by niallobrien_83

Simplest portals for selling applications?

I've built an electron application that I would like to sell. I would prefer to avoid the AppStore because reasons. Are there any simple paywall solutions with good payment option? (paypal, bitcoin, credit cards etc.)

Submitted March 18, 2017 at 07:40AM by basiclaser

How to create a NPM package

http://ift.tt/2nC3cmp

Submitted March 18, 2017 at 07:53AM by shsh3

After using multer for file uploads, I cant get data on what checkboxes are checked on the form

As soon as I changed the form to enctype='multipart/form-data' I cant get an array of values for what checkboxes are checked on the form, where I now get a jade message "Cannot read property 'forEach' of undefined". All my checkboxes have name=games where I could do in my index.js req.body.games but that is now undefined.

Submitted March 18, 2017 at 01:40AM by mineralwatersoda

Authenticating users from an Electron app?

Does anyone know how to create a user auth system that will allow users to login from an Electron application?At the moment I have the electron app sending chat messages to a node.js server via socket.io. How can I implement some kind of user system with this setup?As a followup question, Meteor.js has a default user system. Is it possible to authenticate from the electron app against a Meteor.js backend?

Submitted March 18, 2017 at 05:49AM by 5pitf1r3

Friday 17 March 2017

Using future es features in REPL?

I have something like this:import repl from "repl" var replServer = repl.start({ prompt: "> ", }) I've got knex hooked up to it and my models in context and it's great. I can use the models to update the db from the REPL. BUT I can't use say the 'await' keyword. Does anyone know how I might set that up?

Submitted March 17, 2017 at 09:05PM by coderbee

JavaScript file location in Node JS project

Hi guys,I am having a trouble connecting my js file to node js web application. I'm very new to Node JS but i cant connect my app to js file that for example has the onclick action "". Is there a certain way that i should bring in my js files when using handlebars for a web NodeJS app?

Submitted March 17, 2017 at 07:27PM by tht_chico

What does this NPM warning about updating mean and how is it even possible?

Why does the design allow this?npm WARN update-linked node_modules/mongodb needs updating to 2.2.22 from 2.2.22 but we can't, as it's a symlink application-name@0.0.1 /var/www/gamecollection └── monk@3.1.4npm WARN optional Skipping failed optional dependency /chokidar/fsevents: npm WARN notsup Not compatible with your operating system or architecture: fsevents@1.1.1

Submitted March 17, 2017 at 05:22PM by mineralwatersoda

Node / Passport back-end working with Android?

I've followed a simple Scotch.io tutorial to build an authentication site set up using Node.js, Express, and Passport. I can now have users register, sign in, and navigate to a profile site that displays some information about the user, but I was wondering how I can get the same application to work for an Android client. I get confused when I look at the code using Passport like*In a file that defines my routes* app.post('/login', passport.authenticate('local-login', { successRedirect : '/profile', failureRedirect : '/login', failureFlash : true })); I understand how the redirects will work for browser, but I'm not sure how that'll translate when working with an Android client. When the credentials match for a user, what do I respond to the Android client with? Am I using Passport wrong, or should Passport not be used in my case? I've done some research and found that I may need migrate to token generation, which I don't really understand. My questions boil down toShould I be using Passport if I want to serve to web and mobile clients?If I can use Passport, how would one be responding to a mobile request? Will be completely separate from how it currently responds to web requests?If I'm not using Passport, what should I be using instead?

Submitted March 17, 2017 at 03:33PM by QuayShawn

DevTools can now visualise how long things are taking on your Node.js server (database lookups, template rendering). Here's a gif of how to use it

http://ift.tt/2mQxqC4

Submitted March 17, 2017 at 02:33PM by umaar

Developers who know Java and Node: What can you do faster in Node?

To the developers who know Java and Node.Can you give examples of things that you find easier/faster to write with Node?

Submitted March 17, 2017 at 10:15AM by jeffsmith2012

Node.js Weekly Update - 17 March, 2017

http://ift.tt/2mW6Ol9

Submitted March 17, 2017 at 08:56AM by hfeeri

Best module pattern

Ok so which is your best module pattern?i do as follow:/* jshint esversion: 6 */ const someLib = require('foo');(function() {const someFunction = () => { // do something }; module.exports = { someFunction: someFunction }; })();

Submitted March 17, 2017 at 07:16AM by jesusgn90

Thursday 16 March 2017

Awesome Node.js Weekly - Issue 44

http://ift.tt/2mVbXcX

Submitted March 17, 2017 at 12:54AM by stanislavb

what is the different between async/await and async.js

I just came back from C# project, haven't written javascript for a while now. I'm using async.js then found out that there is a built in async/await now. So what is the pros/cons of these two?

Submitted March 17, 2017 at 01:10AM by thestrayed

$beforeInsert()/$beforeUpdate in Objection.js not working in the join table model when one of the joined table model instances creates an instance on the other joined table...

I've got the models Train and Passenger joined by Train_Passenger. Each has within it:$beforeInsert = () => { this.created_at = new Date().toISOString() this.updated_at = new Date().toISOString() } $beforeUpdate = () => { this.updated_at = new Date().toISOString() } These all work in that any of the following will create a new row in the corresponding tables with timestamps as expected:Train .query() .insert({... Passenger .query() .insert({... Train_Passenger .query() .insert({... However, this:someTrainInstance .$relatedQuery('passengers') .insert({... while it will create a passenger in the passengers table with timestamps perfectly, and it will also create the correct record in train_passengers in terms of foreign ids, BUT that record will not be timestamped.Any ideas?

Submitted March 16, 2017 at 11:40PM by coderbee

Raft - I've been working on a Node module for a sort of structured way of defining data sources. I would love any feedback or comments! (x-post /r/javascript)

So here it is: http://ift.tt/2mxXXm8, I wanted a standard way to define data sources that would allow me to write tools (currently raft-cli) that would work for any data sources that confined some certain structure. I am very unsure if this is actually a useful idea or if it's just good as a learning project for myself, but in either case I would love any feedback at all, whether it's about the project idea itself, or the organization of the repo, or the code itself.Thanks!Here's the summary from the README that might provide a bit better summary of the idea.The goal of this project is to provide a structured way of defining data sources, actions that can be performed on those data sources, and options/parameters that can or need to be provided for those actions. The hope is that this structure will allow for tooling (e.g. raft-cli) to be made that can work for any data sources that confine to this structure. Whether or not this is actually useful, or a problem that already has a solution I'm not aware of, I'm not sure.The movitation behind this project was a project I've been working on that requires getting some data from a Google Drive spreadsheet. After I wrote the pieces to get the data, I had to contiously make test scripts to see what the output would be with different parameters. That led me to want to make an interactive command line program that would prompt me for different paramaters and output the results, without having to make and edit a bunch of different junk files. Because I have no will power, I decided to generecize this to work for any "data fetcher" module that conforms to a certain structure, which is what Raft is.

Submitted March 16, 2017 at 11:00PM by weston___

Crawler queue creation tool for paging

http://ift.tt/2neQkoY

Submitted March 16, 2017 at 09:23PM by indatawetrust

How can I view the console without running my web app from command line?

Instead of doing "node app.js" and seeing my web app run and all the requests....is there any other way I can access this console if my app is running via a daemon/forever?

Submitted March 16, 2017 at 08:23PM by mineralwatersoda

A friend is doing front-end/back-end work with Bootstrap and Express/Mongo

A friend is using Bootstrap for the grid, but doing all the flat-design layouts as well and the backend for adding products, storing images, and basic admin panels. Is it low for him to get paid $60,000 (Texas) or should it be more?

Submitted March 16, 2017 at 08:46PM by mineralwatersoda

How do you run your Node.js apps in Docker in production?

I do it like this:1) In docker-compose.yml I run an app via npm scripts:command: npm run start:prod2) In my package.json I just use forever:"start:prod": "NODE_ENV=production forever src/server"Without docker, pm2 looks pretty interesting, but it's not clear for me how to use it with docker. How do you run your Node.js apps in Docker in production?

Submitted March 16, 2017 at 06:40PM by serge-nikitin

Common Async/Await Design Patterns in Node.js

http://ift.tt/2noGhxY

Submitted March 16, 2017 at 06:41PM by code_barbarian

Hello, Certified Modules

http://ift.tt/2nrjul8

Submitted March 16, 2017 at 02:06PM by _bit

Deploying Node.js app to DigitalOcean server: a detailed guide

https://youtu.be/1OU5ngq-WyM?list=PLQlWzK5tU-gDyxC1JTpyC2avvJlt3hrIh

Submitted March 16, 2017 at 09:11AM by insane-architect

Wednesday 15 March 2017

Get $100 daily just rating logos, easy, fast and fun!

http://ift.tt/2mqGP2e

Submitted March 16, 2017 at 01:10AM by LetItDieAddicted

app-context: anybody used this ? any good ?

http://ift.tt/2nH0oDR

Submitted March 16, 2017 at 01:54AM by andy625

Is there any good NodeJS Cms ?

He fellow programmers. I wonder if there are any good configurable nodejs cmses like Wordpress or any other ? I know there is Ghost but it is only for blogging. I found keystone but there are some issues with it. I am looking for something like Cockpit ( https://getcockpit.com ) which I can have any configurable collections.

Submitted March 15, 2017 at 10:57PM by kucukkanat

Can't for the life of me figure our how to retrieve POST json data from html (express)

i've been trying to figure this out for a few days. Nothing I've tried has worked at I'm sort of at a loss. Any help would be really appreciated. Code in question:todoapp/app.js:var express = require('express'); var app = express(); var hPage = require('./routes/index'); var path = require('path'); var fs = require('fs'); var bodyParser = require('body-parser'); var morgan = require("morgan"); app.use(express.static(path.join(__dirname, 'public'))); app.set('view engine', 'pug'); app.set('views', path.join(__dirname, 'views')); app.use(morgan('dev')); app.use(bodyParser.json()); app.use('/', hPage); app.listen(8888, function(){ console.log('server is listening on port 8888.') }); routes/index.js:var express = require('express'); var router = express.Router(); var mysql = require('mysql'); var connection = mysql.createConnection({ host: 'localhost', user: 'root', password: '', database: 'todo' }); connection.connect(function(err){ if(!err){ console.log('DB is connected.'); } else { console.log(err); } }); router.use(function(req, res, next){ console.log(req.method, req.url); next(); }); router.get('/', function(req, res, next){ res.render('index.pug') next(); }); router.post('/data', function(req, res){ if(req.body === undefined){ console.log('nothing was sent.'); res.status(500).send({error: 'baaaah'}) } else{ req.header("content-Type","application/json;charset=UTF-8") console.log(JSON.stringify(req.body.todoTxt)); res.end(); } }); module.exports = router; views/index.pug:doctype html html head title todo link(href='/stylesheets/style.css' rel='stylesheet') body form(method='post' action= '/data' enctype='text/plain') .add button.butt(onclick='handler.addTodo()' name='todoTxt' type='submit') |Add Todo input.entertext(type='text' name='todoTxt') .delete button.deleteTodoButt(onclick='handler.deleteTodo()') |Delete Todo input.deletetodo(type='text' placeholder='Enter todo position') div button.position(onclick='handler.toggleComplete()') |Toggle Complete input.togglecomplete(type='text' placeholder='Enter todo position') button.toggle(onclick='handler.toggleAll()') |Toggle All ul.todos script(src='/javascripts/main.js' type='text/javascript')

Submitted March 15, 2017 at 09:17PM by Chigurhshairdresser

New Relic vs RisingStack Trace - have somebody used one of them with? What are the impressions? Which is better?

I'm trying to compare between New Relic and RisingStack Trace to monitor Node apps but I never used Trace before, and I only used New Relic with Rails apps, do you people have impessions about some of them? Maybe recommend another service that has a free trial too?

Submitted March 15, 2017 at 08:56PM by TalyssonOC

Node.js on App Engine goes GA

http://ift.tt/2n29I8B

Submitted March 15, 2017 at 06:54PM by justinblat

Node.Js Express 4 Application in Visual Studio 2017 and Azure Web Apps

http://ift.tt/2n0gxar

Submitted March 15, 2017 at 05:19PM by aramkoukia

Tutorial with running examples: Property based testing with javascript.

http://ift.tt/2m0wZZ7

Submitted March 15, 2017 at 02:34PM by tonechild

Code Tutorial - QAVideos (1) - Adding User Management to a Node.js app with Angular.js, IBM API Connect, Loopback and Open API Initiative

http://ift.tt/2mJivtJ

Submitted March 15, 2017 at 02:44PM by remkohdev

Roadmap to becoming a developer in 2017

http://ift.tt/2m0vlGI

Submitted March 15, 2017 at 02:28PM by kamranahmed_se

Hello World: Concurrency In Node.js Using The Cluster Module

http://ift.tt/2nlPbIB

Submitted March 15, 2017 at 02:09PM by dobkin-1970

[advice] Node on osx?

I'm a linux-only full-stack dev. There's been a ton of interest from design in what i do, so I'm planning an educational series at the office re: angular, typescript, scss, gulp, webpack and things like that. The obvious step 1: they need node. The less obvious problem: I know nothing of osx.I've been reading a bit on howto, and xcode is clearly a prereq for node on osx. Are there any side-effects to installing xcode? Will it be disruptive to their current environment in any sort of way? Is there anything I should know before I jump into a foreign os on someone else's workstation and install a huge app that i know nothing about?

Submitted March 15, 2017 at 11:39AM by therealkevinard

Contact form with NodeJS, Lambda and SES

http://ift.tt/2n9E617

Submitted March 15, 2017 at 11:27AM by doomhz

Frontend Local Setup 4 - Node and NPM Installation on Windows

https://www.youtube.com/watch?v=GGiADmkjp8k&t=10s

Submitted March 15, 2017 at 09:09AM by TutorialsDojo

Why the Hell Would You Use Node.js

http://ift.tt/2mrVpqj

Submitted March 15, 2017 at 09:45AM by bdavidxyz

What You Should Know About ES6 Maps

http://ift.tt/2m3pa02

Submitted March 15, 2017 at 07:30AM by fagnerbrack

Tuesday 14 March 2017

Web Cache - Everything you need to know

http://ift.tt/2nBr8W8

Submitted March 15, 2017 at 03:14AM by kamranahmed_se

Node.js 7.7.3

http://ift.tt/2mXDevY

Submitted March 14, 2017 at 10:54PM by italoacasas

child_process and color

I'm trying to capture command output (using execa.shell) with color and am having limited success.If I force the command to use color (i.e. --color or similar) color is captured (like mocha). If the command doesn't support a --color option (like nyc) then output isn't colored.execa('command',{stdio: 'inherit'}) works fine. But ... I can't capture the output, it just gets pushed to my screen. I'd like to be able to capture the output.This has to be something about the filehandle or the environment that gets inherited vs what happens with a pipe. setting TERM worked for mocha (as it looks at the term to detect color), but it didn't work for nyc. This tells me that there's something else that needs to be synchronized when using pipe, but I can't for the life of me figure out what it is. Any thoughts?This answer didn't help. (I did get the inherit from it) http://ift.tt/19yk4m1

Submitted March 14, 2017 at 10:37PM by skarfacegc

API call is successfully made but, getting an error in the console

I am attempting to make an API call using the Netflix Roulette API and I've console logged the response to ensure I am retrieving info (which I am) but, I am still getting this error in the console:Failed to load resource: net::ERR_INCOMPLETE_CHUNKED_ENCODINGI have been told this could be cause from a few things:• Anti-virus software• Google chrome browser settings• Ensuring all responses have a response.end()I have eliminated these cause and I am still getting this error. Below is where I make the call:var EventEmitter = require("events").EventEmitter; var https = require("https"); var http = require("http"); var util = require("util"); var unirest = require('unirest'); /** * An EventEmitter to get actor's Netflix info * @param actor * @constructor */ function Actor(actor) { EventEmitter.call(this); actorEmitter = this; var request = unirest.get("http://ift.tt/2n7jc2u" + actor) .header("X-Mashape-Key", "DHmuGLtqcomshyLbBKe5akHeFbN1p1UqyGmjsn7uCNpoDXhBXo") .header("Accept", "application/json") .end(function(response) { var body = ""; if (response.statusCode !== 200) { request.abort(); actorEmitter.emit("error", new Error("There was an error getting titles for " + actor.replace("%20", " ") + ". (" + http.STATUS_CODES[response.statusCode] + ")")); } response.on('data', function(chunk) { body += chunk; actorEmitter.emit("data", chunk); }); response.on("end", function() { if (response.statusCode === 200) { try { var actor = JSON.parse(body); actorEmitter.emit("end", actor); } catch (error) { actorEmitter.emit("error", error); } } }).on("error", function(error) { actorEmitter.emit("error", error); }); }); } util.inherits(Actor, EventEmitter); module.exports = Actor; If you need more reference, here's a link to the repo:Click here for repo

Submitted March 14, 2017 at 09:23PM by lacroix-boi

[Theory] TDD & Sequelize: Is it worth it to verify the schema

I am currently going through a back log of unit tests at this company I work for. Right now I'm the only person on the staff who really has a strong grasp on testing (Specifically TDD/BDD/GDD).What I'm trying to do is build some solid unit tests to make it possible to do future refactoring against.We're using Sequelize; when I look at the part that outlines our schema I feel inclined to verify the column names and associations (foreign keys). While I have written the tests to verify the associations and column names are there; I feel reluctant to check the schema as far as the column types and sizes. I feel this would be 'over testing'.However someone changing a column from string size 255 to 20 could make catching the problem pretty easy.Thoughts?

Submitted March 14, 2017 at 09:46PM by bigorangemachine

How to Place and Receive Phone Calls Using Node.js

https://www.youtube.com/watch?v=5ioNm05PDSE

Submitted March 14, 2017 at 06:54PM by soMuchWindows

Checking req.user with Express.js Passport.js

http://ift.tt/2mUqlmm

Submitted March 14, 2017 at 04:57PM by Cartoslayer

WebSocket-to-TCP proxy/bridge

http://ift.tt/2n6Cipy

Submitted March 14, 2017 at 05:53PM by maxoust

How To Develop An Interactive Command Line Application Using Node.js

http://ift.tt/2mIHWwU

Submitted March 14, 2017 at 03:02PM by johncipponeri

Avoiding circular dependencies with Node require()?

My question is below, but it's also here on StackOverflow if you to want to answer there: http://ift.tt/2mo9STh question:I'm having a problem where I have an Electron app, we'll say contained in files index.html and app.js. app.js is included in index.html with a script tag.Within app.js, I use var ENGINE = require("./myGameEngine/"); which then requires different classes, each in their own file. It looks something like this:var myEngine = myEngine || {}; myEngine.ClassA = require('./src/ClassA.js'); myEngine.ClassB = require('./src/ClassB.js'); myEngine.ClassC = require('./src/ClassC.js'); module.exports = myEngine; Unfortunately, sometimes ClassA, needs to use new myEngine.ClassB(). For example, if ClassA is an entity and has the function ClassA.addComponent() that function might require the use of var component = new myEngine.ClassB().When trying to do this, I run into an error that myEngine is undefined, even though it's the parent that required all these other files. I don't want to require it back in ClassB as that will create a circular dependency, but I need ClassB inside ClassA sometimes.What's most infuriating is that previously, instead of including app.js with script tags and requiring myEngine with require() I simply required both myEngine.js and app.js from the HTML file, and that all worked fine.I could go back to that system but I liked the simplicity of including a single JS file to go with my single HTML file, and doing all the requiring of the game engine inside that JS file, alongside modules from node_modules.Can someone explain to me how what the problem is here and how I can require files within a module, without having to redefine the module in every file?Thank you in advance!Edit: Regarding suggestions to include the classes within other classes, I have created a drawing about why I'd like to avoid that: Can of Worms

Submitted March 14, 2017 at 03:11PM by ianpaschal

AVA, low-config testing for JavaScript

http://ift.tt/2mjJ47D

Submitted March 14, 2017 at 03:12PM by hugo__df

Refactoring by example: Dealing with long conditionals

http://ift.tt/2njSpAs

Submitted March 14, 2017 at 03:13PM by nspragg

Am I doing this REST API correct ? How would you do it

I know there are many different ways of doing things so I am asking if the way I am doing it is okay/the right way to do it.I am using express and sequelize.So I have two controllers folders. the API folder, and the home page folder.In the api folder, I have simple app.get that lead to the link '/api/users' and '/api/users/:id'. The code (roughly) looks like so.app.get('/api/users/', function (req, res) { db.users.findAll().then(function (users) { res.json(users); }); }); app.get('/api/users/:id', function (req, res){ db.users.findById(req.params.id).then(function(user){ if(user === null){ res.status(404).send({error: 'User does not exist.'}); return; } res.json(user); }); }); Pretty neat, so when I go to localhost:4000/api/users I get a list of all the users in json form! Now comes to the client side which is where I am having trouble.There are many ways in which I can approach this so I will provide maybe two ideas I have.The Problem: For an example, I want my home page to display all the users we created in a nice html/css site....How do I go about retrieving this data for the front end/ client side ? This is what I currently have.app.get('/', function (req, res) { db.users.findAll().then(function (users) { res.render('pages/index', {usersObj: users}); }); }); But...I am essentially doing the same thing for the 'api/users' ... no ? Is there a way for me to call the api link instead and take advangate of what I just made?I guess I could just write front end ajax to retrieve the data from the database data from the api url I created (which contains the database data). But what happens if I want to display 5 users instead...surely the 'api/users' can't handle retrieving 5 users as the backend only displays all of them.... I guess I could manipulate the the ajax to cut off and keep only the first 5 array elements from the 'api/users' response.Overall question: What's the best way for the front end / client side to get data from my custom 'api' that I created ? I see a lot of tutorials covering API but they don't seem to go into the client side... should I retrieve the data via the backend ? Or the front end with ajax ? Or am I approaching this the wrong way... thanks !

Submitted March 14, 2017 at 12:15PM by HappyZombies

Writing Secure Node.js Code

http://ift.tt/2mslPuD

Submitted March 14, 2017 at 09:45AM by dobkin-1970

Frontend Local Setup 5 - Node and NPM Installation on MAC. Visit our youtube page for more video tutorials. https://www.youtube.com/channel/UCw4cxFG34-cCbG5RdA-7mTw

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

Submitted March 14, 2017 at 09:13AM by TutorialsDojo

"Light npm" might be bundled in Node.js core

http://ift.tt/2mGa4Re

Submitted March 14, 2017 at 09:08AM by ecares

Any self taught node / full-stack devs in Australia around?

As the title suggests, I'm wondering if there are any Aussie devs out there who might be able to give me some pointers about getting a foot in the door with a junior developer role.Most of the development jobs in my particular city are very much geared towards those with 1-3 years experience, and the few-and-far-between junior dev jobs advertised seem to almost mandate a CS degree. My thinking is that I'd be best off building a project demonstrating proficiency with technologies that are used commercially, so I have been working on a full-stack app using express / react and redux / mocha testing on the backend / mongo / bootstrap / socket.io and so on.I think meetups would be a smart way of getting more insight on the job market but unfortunately they are incredibly infrequent here and don't think there is one for node specifically.If anyone else has been in this position as a self-taught dev trying to get a foot in the door without pre-exisitng contacts, I'd love to hear from you! Cheers.

Submitted March 14, 2017 at 08:55AM by ajc820

How do I retrieve (console.log) POST data in Express?

The farthest I've gotten is retrieving the object (req.body) without the actual text input. I'm getting a 200 status header, but object sent remains undefined. I've used Postman to inspect further, nothing new has popped up though.var express = require('express'); var app = express(); var hPage = require('./routes/index'); var path = require('path'); var fs = require('fs'); var bodyParser = require('body-parser'); app.set('view engine', 'pug'); app.set('views', path.join(__dirname, 'views')) app.use(bodyParser.urlencoded({extended: true})); app.use(bodyParser.json); app.use(express.static(path.join(__dirname, 'public'))); app.use('/', hPage); app.listen(8888, function(){ console.log('server is listening on port 8888.') }); routes/index.js: var express = require('express'); var router = express.Router(); var mysql = require('mysql'); var connection = mysql.createConnection({ host: 'localhost', user: 'root', password: '', database: 'todo' }); connection.connect(function(err){ if(!err){ console.log('DB is connected.'); } else { console.log(err); } }); router.use(function(req, res, next){ console.log(req.method, req.url, req.body.todoTxt); next(); }) router.get('/', function(req, res){ res.render('index.pug') }); router.post('/data', function(req, res){ console.log('post request received.'); console.log(req.body); res.end(); }); module.exports = router; view/index.pug:doctype html html head title todo link(href='/stylesheets/style.css' rel='stylesheet') body form(method='post' action= '/data') .add input.entertext(type='text' name='todoTxt') button.butt(onclick='handler.addTodo()' type='submit') .delete button.deleteTodoButt(onclick='handler.deleteTodo()') |Delete Todo input.deletetodo(type='text' placeholder='Enter todo position') div button.position(onclick='handler.toggleComplete()') |Toggle Complete input.togglecomplete(type='text' placeholder='Enter todo position') button.toggle(onclick='handler.toggleAll()') |Toggle All ul.todos script(src='/javascripts/main.js' type='text/javascript') Any advice would be massively appreciated. Also, any general advice not specific to my question would aslo be really appreciated.

Submitted March 14, 2017 at 05:31AM by Chigurhshairdresser

Zalgo in Node.js

I was learning through the Node.js Design Patterns Chapter, there is a section which explains unleashing zalgo. I have red izs post too, I am not hardcore programmer so i am not able understand what exactly the issue is.http://ift.tt/2n3X6xJ many times i call this function is works as expected, I mean it printed the values of the text file.So what exactly the problem is ?P.S: I am newbie go easy on me :)

Submitted March 14, 2017 at 06:24AM by bboysathish

How to design an architecture for Web And APIs together?

I am building a platform which will have a web frontend and also REST APIs for Mobile clients using Node.JSWhat's the best approach to designing such an architecture?If I create two separate services for web and API, I will end up writing same business logic twice. If I merge both, then I fear it might end up being a mess.Most of the tutorials and articles on the web talk about either web or APIs only but not both together.

Submitted March 14, 2017 at 06:29AM by zeal_kaiser

Monday 13 March 2017

Is Async.js a good tool to use for the foreseeable future?

New to Node, and I just wanted to know from a pros/cons and community standpoint.

Submitted March 14, 2017 at 04:27AM by roboborbobwillrobyou

Whats the best way to password protect my /admin section of my site?

Is there some simple way I can implement authentication for all the pages/sections under /admin for my site?

Submitted March 14, 2017 at 12:24AM by mineralwatersoda

Can't retrieve req.body from POST 200 HTTP header, blank

So I've been trying to figure this out for a while. I receive a 200 HTTP header, but no text. Code in question:todoapp/app.js:var express = require('express'); var app = express(); var hPage = require('./routes/index'); var path = require('path'); var fs = require('fs'); var bodyParser = require('body-parser'); var morgan = require("morgan"); app.use(express.static(path.join(__dirname, 'public'))); app.set('view engine', 'pug'); app.set('views', path.join(__dirname, 'views')); app.use(morgan('dev')); app.use(bodyParser.json()); app.use(bodyParser.urlencoded({extended: true})); app.use('/', hPage); app.listen(8888, function(){ console.log('server is listening on port 8888.') }); views/index.pug:doctype html html head title todo link(href='/stylesheets/style.css' rel='stylesheet') body form(method='post' action= '/data') .add button.butt(onclick='handler.addTodo()' type='submit') |Add Todo input.entertext(type='text' name='todoTxt') .delete button.deleteTodoButt(onclick='handler.deleteTodo()') |Delete Todo input.deletetodo(type='text' placeholder='Enter todo position') div button.position(onclick='handler.toggleComplete()') |Toggle Complete input.togglecomplete(type='text' placeholder='Enter todo position') button.toggle(onclick='handler.toggleAll()') |Toggle All ul.todos script(src='/javascripts/main.js' type='text/javascript') routes/index.js:var express = require('express'); var router = express.Router(); var mysql = require('mysql'); var connection = mysql.createConnection({ host: 'localhost', user: 'root', password: '', database: 'todo' }); connection.connect(function(err){ if(!err){ console.log('DB is connected.'); } else { console.log(err); } }); router.use(function(req, res, next){ console.log(req.method, req.url); next(); }) router.get('/', function(req, res){ res.render('index.pug') }); router.post('/data', function(req, res){ if(!req.body.todoTxt){ console.log('Post received.'); console.log('Todo text is: ' + req.body.todoTxt); res.end(); } else{ console.log('nothing send.'); res.end(); } }); module.exports = router;

Submitted March 14, 2017 at 12:28AM by Chigurhshairdresser

Ask Node: Most underrated node module?

Share a module you think would be used a lot more if other developers knew about it!

Submitted March 13, 2017 at 09:18PM by loftyal

EmpireBot - Discord Empire management bot

https://bot.theegn.com/

Submitted March 13, 2017 at 08:08PM by JerryStewart

Stream large JSON object from database to client example?

Easily bootstrap your NodeJS project with Express, Sequelize and Typescript

http://ift.tt/2mkcF0S

Submitted March 13, 2017 at 06:56PM by maxoust

IBM appmetrics trace question

I am using IBM's appmetrics module for profiling my app, but the "trace" functionality doesn't seem to be working.I have:appmetrics.enable('profiling');appmetrics.enable('trace');appmetrics.enable('requests');but in my event handler:monitor.on('request', function handleRequest(data) {// code and stuff});the request property on data does not have a "stack" property on it.... Has anyone used this package and encountered this problem? There is very little documentation on this property.I believe the problem may be with the trace includeModules config property, but I am not quite sure if or what that should be set to....http://ift.tt/1HWNg0t

Submitted March 13, 2017 at 05:25PM by Charlemagne_III

Streams for Everyone

http://ift.tt/2mEFtDX

Submitted March 13, 2017 at 05:27PM by lamchakchan

Creating almost purely functional endpoints in Express?

I am currently building out a middleman server in Node using Express for an application my company is building. The sole purpose of this server is to take some queries from the client, gather data from our internal microservices, and format the response how the client asked for it.I have came up with a rough outline of an abstraction and made a gist kinda explaining it.My question is, how off am I with this idea and how bad is it going to be later down the road if I do use this abstraction for GET requests?

Submitted March 13, 2017 at 05:53PM by cirsca

How do I wait for the database to be created before testing with Tape?

I've built an API with hapi.js and sequelize (with Postgres), and now I'm creating the unit tests to check if everything is ok. I've created this test to check if GET on '/products' would return with the two products I create when I sync the table. Here is the test:test('Test get all products - GET /products', (t) => { const options = { method: 'GET', url: '/products', }; server.inject(options, (response) => { t.equal(response.statusCode, 200, 'Status Code = 200'); server.stop(t.end); }); }); For now it just checks if the server responds with HTTP code 200, but later I'll add to check if it's an array and if it's length is two. The problem is that the test is starting before the DB is synced, so it tries to access it before I declare the relations on my models. How can I wait to make sure the database was created, before testing?Here is the full code: http://ift.tt/2mjIw0y

Submitted March 13, 2017 at 04:25PM by Luke094

What's the best way to ship a standalone binary file?

I'm using Typescript to develop a Node.js app. I'm very new to this whole area (first time using Javascript) and I'm a bit lost.I don't want my users to have to install Node, Typescript, npm, or anything. I just want to ship a single executable file and have it work on different platforms.What's the best way to go about doing this?Preliminary Googling shows me at least two solutions: nexe and EncloseJS.Do these apply for Typescript apps? What do you guys use for your projects?

Submitted March 13, 2017 at 02:45PM by lookatmetype

Where have I gone wrong here? (querying/schema)

I know I'm missing something.My basic db structure diagrammed is here and my migration reflects that:exports.up = function(knex, Promise) { return Promise.all([ knex.schema.createTableIfNotExists('riders', function(table) { table.increments('id').primary() table.string('email') table.string('password') table.integer('most_ridden_train_id') .references('id') .inTable('trains') }), knex.schema.createTableIfNotExists('trains', function(table){ table.increments('id').primary() table.string('destination') table.integer('passenger_count') .defaultTo(0) }), knex.schema.createTableIfNotExists('train_riders', function(table){ table.increments('id').primary() table.integer('train_id') .references('id') .inTable('train') table.integer('rider_id') .references('id') .inTable('riders') table.timestamps() }) ]) }; exports.down = function(knex, Promise) { return Promise.all([ knex.schema.dropTable('trains'), knex.schema.dropTable('train_riders'), knex.schema.dropTable('riders') ]) }; I've been adding trains and riders and that's been working so for but then came time to update the most_ridden_train_id for the riders now that I've got a few trains, I'm using Objection so I used this:ben // instance of rider .$query() .patchAndFetch({ most_ridden_train_id: 2 }) .then((d) => { console.log("updated rider: ben") }) .catch((er) => { console.log(er) }) // { error: update "riders" set where "riders"."id" = $1 and "riders"."id" = $2 - syntax error at or near "where" //... So that's the error I get there. I know it has something to do with the schema because if I do this, then I don't get an error:ben // instance of rider .$query() .patchAndFetch({ email: "newEmail@gmail.com" }) .then((d) => { console.log("updated rider: ben") }) .catch((er) => { console.log(er) }) // updated rider: ben I bet it's something obvious and I'm just blocked. Thanks for any help!!

Submitted March 13, 2017 at 02:51PM by coderbee

Developing a complete REST API with Loopback

http://ift.tt/2mDhWTw

Submitted March 13, 2017 at 12:53PM by ms-maria-ma

The Complete Node.js Developer Course (2nd Edition)

http://ift.tt/2lSSaMn

Submitted March 13, 2017 at 09:45AM by Helen791

Sunday 12 March 2017

Exploiting Node.js deserialization bug for Remote Code Execution

http://ift.tt/2kqzD5a

Submitted March 13, 2017 at 01:33AM by fagnerbrack

A simple way to use Mongoose with ES6 classes

http://ift.tt/2nk3EFY

Submitted March 13, 2017 at 12:53AM by Midasx

What's the best way to trigger an action in a webpage (Client) when an event takes place in node (Server)?

Hi,I'm trying to create a web page which runs certain tasks when certain things are done in node.js. For example, if I have my backend connecting to an IRC channel and somebody types "!black", I want my back end server to tell the client to change the background colour of the webpage to black, what would be the best way of doing this?

Submitted March 12, 2017 at 10:11PM by 23MPK

Will functions like readFile return a promise eventually?

Promises are a great way to deal with asynchronous calls, and now with async await things are getting even easier, but if the functions don't return a promise, we have to patch them in order to use the new developments of the language. So, will functions like readFile return a promise eventually or will be created counterparts like the sync functions to eliminate the need to convert the function using, for example, bluebird's Promise.promisifyAll?

Submitted March 12, 2017 at 09:52PM by Lakelava

Knex's async queries + Objection.js ORM might be killing me softly.

EDIT: I should note that I'm using postgresSo I submitted another question today before I realized the scope of what's going on here, so this is a higher level question.As I understand the point of object relational mappers, it's to work with objects and have the ORM handled the database to reflect those changes in the background. I'm coming from Rails, so something really simple, like giving a Person named Raymond a Gift of a car (inserting a row correctly into a people table, and into a gifts table, and into a join table like people_gifts), could be done like this:raymond = Person.create({name: "Raymond"}) car = Gift.create({type: car}) raymond.receive(car) // assuming an instance method called receive and the tables/columns etc The Rails ORM in this instance makes it really easy for me to establish relations between tables. In fact I don't have to. I manage relations at the object's instance and class levels and the ORM does the rest.So now I'm learning Node and I see that the way to get your migrations and your query engine and you ORM all set up is Knex + Objection and I do it.But now I want to accomplish the above in Node and the two ways I've seen to do this here are either nested callbacks which feels like hell and then I found the term "callback hell", or use asyncawait or the es7 equivalent which actually ends up being even more complicated because I'm constantly making suspendible functions and suspending them on inner synchronous ones. Either way things get nested and ridiculous but that's not even my issue. My issue is that if you're going to be doing all this, then you're not really working with Models at all really. It defeats the purpose of the ORM. If I can't do anything with my models without arranging them in a convoluted chronological order, things are really not that good.So I MUST be missing something HUGE. What is it? Things can't be this bad.

Submitted March 12, 2017 at 08:58PM by coderbee

Would anyone know where to start with making a CMS with node as a backend?

I can't for the live of me find a decent tutorial or any point of beginning. I can only find these things for PHP, and that's what I'm triyng to move away from lol..

Submitted March 12, 2017 at 09:23PM by TurtleboyYE

Developing a RESTful API With Node and TypeScript

http://ift.tt/2mgjhw4

Submitted March 12, 2017 at 08:08PM by michaelherman

MQTT, Twilio, and Node.js...what am I doing wrong?

I am using MQTT on a Node MCU to publish MQTT messages to MQTT cloud with Node.js running on a Raspberry Pi subscribed to the appropriate MQTT topic. Thinking this may be an issue with the promise I have setup. Code posted here:var previousWashStatus = "OFF"; var washingMachineClient = mqtt.connect(washingMachineUrl, washingMachineOptions); // Subscribe to topic & make DB insertion washingMachineClient.on('connect', function() { washingMachineClient.subscribe('appliances/insideWasher', function() { // when a message arrives, do something with it washingMachineClient.on('message', function(topic, message, packet) { console.log('RECEIVED MQTT(' + topic + '): "' + message + '"'); // Get old status item (determine if delta) var currentWashStatus = message.toString('utf8'); WashingMachine.findLast() .then(function(previousDBWashStatus){ if (previousDBWashStatus.length === 0) { console.log("NO DATA FOUND.") } else { previousWashStatus = previousDBWashStatus[0].status; if (previousWashStatus == "ON" && currentWashStatus == "OFF") { sendTwilioMessage('+(phone number removed for privacy)', "Your wash cycle has completed!"); } if (previousWashStatus == "OFF" && currentWashStatus == "ON") { var washTime = calculateWashTime(); sendTwilioMessage('+(phone number removed for privacy)', "Washer started - est. completion time: " + washTime); } } // Insert to Mongo WashingMachine.create(message).then( console.log("...insertion success"); ); }, function(err){ console.log("ERROR RETRIEVING FROM MONGODB") console.log(err); }); }); }); });function sendTwilioMessage(phoneNumber, message) { twilioClient.messages.create({ body: message, to: phoneNumber, // Text this number from: '+(phone number removed for privacy)' // From a valid Twilio number }, function(err, message) { if(err) { console.error(err.message); } else { console.log("SMS message delivered.") } }); }

Submitted March 12, 2017 at 06:56PM by sensei247

Why is a .then() or .catch required after .query() in Objection.js?

Also if I run a file with a query in it using Node, it never exists. Why is that?

Submitted March 12, 2017 at 05:24PM by coderbee

Writsy - write stream wrapper that supports async initialization and flush function

http://ift.tt/2lQOBX1

Submitted March 12, 2017 at 03:38PM by cshum

HTTPS io.emit

Hello, I made my site using SSL, but I have few node bots that emit data for clients. They emit to http, and this is why client don't see it. Is it able to just tell bot to emit to https, not http, without rebuilding bot, adding SSL certs etc/ I don't need emits in SSL this is why I ask. Thanks!

Submitted March 12, 2017 at 02:28PM by TheSunsetX

Moving tech forward with Gomix, Express, and Google Spreadsheets

http://ift.tt/2jTyxmw

Submitted March 12, 2017 at 12:26PM by dobkin-1970

How I built our Profanity Filter [Blog Post][Open Source][NPM]

http://ift.tt/2niuk9Z

Submitted March 12, 2017 at 12:05PM by vandieUK

Fireloop - Realtime Angular 2 + Loopback framework

http://ift.tt/2nrWQoP

Submitted March 12, 2017 at 08:21AM by 2legited2

Saturday 11 March 2017

Why asynchronous function without callback are deprecated?

No text found

Submitted March 12, 2017 at 02:35AM by Lakelava

npm scripts - tips and tricks video course

http://ift.tt/2kma46l

Submitted March 12, 2017 at 03:25AM by Parasomnopolis

SQLite - How would I pass multiple parameters to SQLite without requesting from the database multiple times?

I basically have an array of usernames in my node.js code. I need to perform some actions for each username. I need to check if the user exists in the database or not. If it doesn't, create it with a value of 5 in my points column. If it does exist, add 5 to it's existing points score.What would be the best way of doing this without speaking to the database many many times to request each object indivudally?Any ideas?

Submitted March 11, 2017 at 08:11PM by 23MPK

How do I use Babel with AWS Beanstalk?

I recently started learning about JavaScript and node, and tried making a simple API using Hapi. I installed Babel and it works fine on my machine, but when I try to run it on Beanstalk it doesn't recognize 'import', so I guess Babel isn't working there. I've followed some tutorials, and this is what I made:.babelrc: { "presets": ["es2015"] } package.json:"scripts": { "test": "echo \"Error: no test specified\" && exit 1", "start": "babel-node bootstrap.js" }, "dependencies": { "babel-core": "^6.23.1", "hapi": "^16.1.0", "joi": "^10.2.2", "pg": "^6.1.3", "pg-hstore": "^2.3.2", "sequelize": "^3.30.2" }, "devDependencies": { "babel-core": "^6.23.1", "babel-preset-env": "^1.2.1", "eslint": "^3.17.1", "eslint-config-airbnb": "^14.1.0", "eslint-config-airbnb-base": "^11.1.1", "eslint-plugin-import": "^2.2.0", "eslint-plugin-jsx-a11y": "^4.0.0", "eslint-plugin-react": "^6.10.0" } bootstrap.js:require( 'babel-core/register' ); require( './src/server'); And the server.js just starts the API, using import. Is there something I'm missing? I don't really know if my dependencies are correct

Submitted March 11, 2017 at 07:46PM by Luke094

npm - Create Spotify playlists based on one artist!

http://ift.tt/2mTOIAV

Submitted March 11, 2017 at 04:22PM by xxbcbud420xx

Password Rules Are Bullshit

http://ift.tt/2mafl0K

Submitted March 11, 2017 at 03:44PM by ratancs

Anyone know of any thermostat libraries in Node?

My Honeywell wireless thermostat served me well for all of one month. Luckily we're out of winter but it's still fairly cool in the UK, so I'd love to build a RPi machine that could effectively manage the temperature while I'm not at home.But it look like most of the NPM packages are just wrapping APIs for Hive.I'm more of a code guy than an electronics guy so I'll have lots to learn about setting up a radio frequency link with my boiler.Hopefully this will help to save money since we can avoid expensive (while still great) solutions like Hive, and any answers we get should help others too.Some links I've found:http://ift.tt/2narLtO

Submitted March 11, 2017 at 03:19PM by jonbaldie

gulp-mocha: Why did it switch from streaming to a cli wrapper?

I've been using gulp-mocha for a while. I stream in my instrumented source with istanbul to get code coverage. Not having to create the intermediate is a good thing imo. Simplifies (at least the mental model) my build system.I recently started playing with react. I was working through how to get babel worked into my build chain when I realized that I needed the compilers: option to gulp-mocha. Turns out the compilers option isn't available in gulp-mocha 3. So I upgrade to gulp-mocha 4. All of my existing coverage breaks. gulp-mocha as of version 4 has switched to a cli wrapper. The compiler flag now works (yay), but I now have to pre-gen the instrumented files afaik (boo).It seems strange that the most recommended gulp plugin for mocha now ignores one of the primary benefits of gulp. I'm tempted to just run builds through npm so I have better control over the command line.

Submitted March 11, 2017 at 01:24PM by skarfacegc

An explanation of how the quality process of nodeJS works

http://ift.tt/2lyH9fL

Submitted March 11, 2017 at 09:31AM by fagnerbrack

Friday 10 March 2017

Something I built with Node. Chat + Dynamic Images + Internet Radio + Rooms + Management + Other Stuff. No need to create an account.

http://hue.merkoba.com/

Submitted March 11, 2017 at 02:37AM by NoYouDidLaugh

How do I retrieve data from a form submit POST?

The farthest I've gotten is retrieving the object (req.body) without the actual text input, IE {todoTxt: ''} Here's my code:todoapp/app.js:var express = require('express'); var app = express(); var hPage = require('./routes/index'); var path = require('path'); var fs = require('fs'); var bodyParser = require('body-parser'); app.set('view engine', 'pug'); app.set('views', path.join(__dirname, 'views')) app.use(bodyParser.urlencoded({extended: true})); app.use(bodyParser.json); app.use(express.static(path.join(__dirname, 'public'))); app.use('/', hPage); app.listen(8888, function(){ console.log('server is listening on port 8888.') }); routes/index.js:var express = require('express'); var router = express.Router(); var mysql = require('mysql'); var connection = mysql.createConnection({ host: 'localhost', user: 'root', password: '', database: 'todo' }); connection.connect(function(err){ if(!err){ console.log('DB is connected.'); } else { console.log(err); } }); router.use(function(req, res, next){ console.log(req.method, req.url, req.body.todoTxt); next(); }) router.get('/', function(req, res){ res.render('index.pug') }); router.post('/', function(req, res){ console.log('post request received.'); console.log(req.body); res.end(); }); module.exports = router; view/index.pug:doctype html html head title todo link(href='/stylesheets/style.css' rel='stylesheet') body form(method='post' action= '/') .add input.entertext(type='text' action='/' name='todoTxt') button.butt(onclick='handler.addTodo()' type='submit') .delete button.deleteTodoButt(onclick='handler.deleteTodo()') |Delete Todo input.deletetodo(type='text' placeholder='Enter todo position') div button.position(onclick='handler.toggleComplete()') |Toggle Complete input.togglecomplete(type='text' placeholder='Enter todo position') button.toggle(onclick='handler.toggleAll()') |Toggle All ul.todos script(src='/javascripts/main.js' type='text/javascript') Any advice would be massively appreciated. Also, any general advice not specific to my question would aslo be really appreciated.

Submitted March 11, 2017 at 01:06AM by Chigurhshairdresser