Thursday 31 May 2018

Trying to open SSH session

I just want to remote to server and open a session so I can manually type commands.Have tried ssh2, ssh2shell, node-suppose. Hit dad ends on each of them. Does anyone have any recommendations on the best way to do this?note: the above options only seem to be working when you want to run commands automatically. I want to interact with the shell.

Submitted May 31, 2018 at 05:38PM by AugmentedCryptoWeed

Memory leak

Hi guys,I seem to have a memory leak and I don't know how to find out where it is originating from. I tried using the Chrome inspector timeline but that is showing tiny increases (less than ~1kb). However, it seems like my app's memory usage is growing at ~2-3 MB every couple of seconds.Any recommendations?

Submitted May 31, 2018 at 04:46PM by MediocreAstronaut

NPM vs. Yarn - What is Your Preference?

I've been developing with NodeJS for about a 2 years now and have been using NPM mostly, however, I have done some online tutorials to learn Yarn which doesn't seem that much different to me. It seems a little faster but everyone is saying the latest versions of NPM are just as good and just a tad slower. I like React and I know Facebook supports both open source communities so which is better for using React with NodeJS? NPM or Yarn?

Submitted May 31, 2018 at 03:37PM by RamesesLabs

8 Key Takeaways from the Node.js Survey of 1,600 Engineers (2018)

https://ift.tt/2L9QBC1

Submitted May 31, 2018 at 03:48PM by andreapapp

Question about reversal of `error` and `result` in node-mysql and Promise API.

I have an insert query promise that looks like this:const insert = (query, values) => new Promise((resolve, reject) => connect(config) .then(connection => connection.query(query, values, (error, result) => { if (error) { reject(error); } else { resolve(result); } })) ); But in order to call it, I do this:app.post('/users', (request, response) => { connection.insert('INSERT INTO users SET ?', request.body).then( (result, error) => { if (error) { console.log(error); } response.send(`User added to database: ${result.insertId}`); } ); }); Notice (error, result) => vs (result, error) =>.Does anyone know why this would be?Full code for reference.Thanks!

Submitted May 31, 2018 at 03:52PM by floppydiskette

Announcing Acquit 1.0.0: Generate Docs from Mocha Tests

https://ift.tt/2L9LDFd

Submitted May 31, 2018 at 04:10PM by code_barbarian

HTML parser for Node.js and browser

Hi!Here is my case-study pet project — HTML parser which has straightforward API, separate tokenizer and tree-constructor modules and supports streaming. Take a look if you have some parsing-related use-case https://ift.tt/2C3jQCG

Submitted May 31, 2018 at 03:03PM by nik-garmash

Node callback fires only once.

I'm using Azure service bus to send messages across containers in my K8s setup. Implementation of service that receives message is done in Node.js.From the doc page, here is the code I'm using to receive the messages.serviceBusService.receiveQueueMessage('feedback', function(error, receivedMessage) {if (!error) {// Message received and deletedconsole.log(receivedMessage);//..}});Everything works as expected for the first time but the messages are not received for the second time. It works as expected when the code snippet is kept inside the `setInterval` block. Which seems not the intended way of doing this.Any ideas what could be wrong?

Submitted May 31, 2018 at 12:53PM by ash1729

StdLib, the Node.js serverless API Platform, announces $2M in funding from Stripe and a new Online Code Editor!

https://ift.tt/2xt2EZ7

Submitted May 31, 2018 at 08:51AM by JanethL

Wednesday 30 May 2018

Express 101 - an introduction for beginners

https://ift.tt/2krnmz9

Submitted May 30, 2018 at 04:09PM by flaviocopes

Resources to learn unit testing

Hiyaaa!! I wanna learn about unit testing with mocha and chai, and so far I've managed to learn some simple testing stuff, but I feel I wanna go to a more advanced level. Is there any resource, site... you would recommend for the task? Most of the ones I find are about testing simple functions and some CRUD or REST stuff...

Submitted May 30, 2018 at 03:20PM by NodeNoodle

I'm looking for online resources to learn Node

Any suggestions on where to get started would be appreciated!

Submitted May 30, 2018 at 02:37PM by FPV_Racing

Book about design patterns

I would like to read a good book about different design patterns in Nodejs. Any suggestions?

Submitted May 30, 2018 at 01:15PM by kr1stofferk

Socket Timout Connection

I'm using socket.io for a chatting system, I observed behavior of socket that it expires after avg 25-30 seconds and initialize a new request to generate socket. When a new socket generated for the same client doest the older socket connection get killed or it also remain alive ?

Submitted May 30, 2018 at 09:45AM by ovaix_

Sharing AES-256 encrypted data between Node.js and Python 3

https://ift.tt/2IWwFpE

Submitted May 30, 2018 at 09:50AM by kiarash-irandoust

Js developers ending to package any simple codes

In JavaScript community, We're watching a flow which makes newbie developers lazy. I think packaging any simple code to a util module is not very appropriate, actually, they'll not struggle with depth of js.for example in hoek package we have merge function which this functionality could afford just by using Object.assign js function.

Submitted May 30, 2018 at 08:18AM by msudgh

To Yarn and Back (to npm) Again

https://ift.tt/2LFHSIT

Submitted May 30, 2018 at 06:25AM by tknew

Tuesday 29 May 2018

Dynamically modify an "extra" js file and make functions exportable without a restart?

How to write to a js file and immediately make a method exportable without restarting server?Im trying to make a user input CRON mechanism. So user can input on frontend whatever CRON schedule they want to complete task.In node what Im doing is1) writing the CRON task to a local file (so I have a permanent record of it in case of server issue) 2) writing using node-cronso my cronTaks.js file looks a little likeconst task_123abc = cron.schedule('*/10 * * * * *', () => { console.log('hey Robbie'); }, false); Im having difficulty being able to use node-crons methods .start(), .stop(), .destroy().My first attempt was to simply add task_123abc.start() on my cron job .js file and "requiring it". Only when I try to edit the file and replace .start with .stop() and re-require, my cron job continues.How can I start off with an empty js file, append to it a method (in this case a cron), immediately make that new method exported so the main function can call .start() or .stop() on it?Any tips/advice/suggestions?

Submitted May 29, 2018 at 05:22PM by itsmoirob

timeof: Measure the execution time of any command

https://ift.tt/2shjNA4

Submitted May 29, 2018 at 03:33PM by here-for-karma

How to wait for array.map(/*make a db request*/) to finish before moving on?

I'm using the 'mssql' module, and I need to run multiple prepared statements based on some data I gathered earlier in my app.I'm trying to do something like this:Promise.all(tables.map(table => { doSQLStatements(table) }); closeDbConnections() function doSQLStatements(table) { return new Promise((resolve,reject) => { table.Keys.map(key => { let req = sql.PreparedStatement(/*stuff*/) req.prepare(/*stuff*/) .then(() => { req.execute(/*stuff*/) }) .then(results => { /**do stuff to results**/ console.log(results); }) .catch(err => {console.log(err)}); }) console.log("**get here only after all results processed**"); }) } And I'd like to wait for the /**do stuff to results**/ of each iteration of arr.map() to finish. Unfortunately, console.log("get here only after all results processed") for each table is being called before console.log(results) for any keys.The console ends up like:**get here only after all results processed** **get here only after all results processed** **get here only after all results processed** results for table1 key1 results for table1 key2 results for table3 key1 results for table3 key2 results for table2 key1 results for table2 key2 When it should be:results for table1 key1 results for table1 key2 **get here only after all results processed** results for table3 key1 results for table3 key2 **get here only after all results processed** results for table2 key1 results for table2 key2 **get here only after all results processed** Is there some way to force it to go through arr.map() synchronously then finish the function?

Submitted May 29, 2018 at 04:21PM by I_HAVE_THAT_FETISH

need guidance advancing an open source security project to scan office files.

I was working on this project: https://ift.tt/2J0QRml ran into an obstacle I need guidance on please.I can look into a office file using this library: https://ift.tt/2LChGi6 it gives me buffers for the files inside the office file format. But now I need to parse those files inside. The owner of the CFB library told me they are compressed in a MS format: https://ift.tt/2xkOLMB says is described here: https://ift.tt/2IUiyRL Im having a tough time figuring out how to apply that in node.thanks.

Submitted May 29, 2018 at 04:21PM by AnthongRedbeard

My code confuses me so much :(

Hi, i am a beginner in node and i wanted to build a cube timer as my first project. Everything worked perfectly until I started doing some calculations on the server. Because of node being asynchronous my code doesn't work and i have totally no idea how to fix it :( Someone told me that i have to use a promise, but i don't really know how to apply it in my case.function sumOfSeconds(fun){ Time.find({}, function(err, data){ if(err) throw err; sumOfSolves = []; for(var i = 0; i < data.length; i++){ sum = data[i].min * 60 + data[i].sec; sumOfSolves.push(sum); } fun(); }) } function best(){ var best = Math.min(...sumOfSolves); var position = sumOfSolves.indexOf(best); Time.find({}, function(err, data){ if(err) throw err; if(data.length === 0){ var bestTime = '-'; }else{ var bestTime = data[position].time; } return bestTime; }) } module.exports = function(app){ app.get('/', function(req, res){ var bestTime = sumOfSeconds(best); Time.find({}, function(err, data){ if(err) throw err; res.render('index', {times: data, bestSolve: bestTime}); }) }); As you probably see in the above the problem is when i request '/' because res.render runs before i have var bestTime defined. How can i approach it? Please take the fact that I am not very advanced in js into consideration. Thanks for your help!!!

Submitted May 29, 2018 at 01:23PM by everek123

Monday 28 May 2018

Need Help with 'mssql' Module

It's my first time working with anything Javascript related.I have a DB table formatted as such:KeyID | TableID | ColumnName | ColumnValue | ColumnType which is a sort of pivoted info table for storing a backup (baseline) of data from other tables.In my node app, I havean array of tables to be baselined (var tables = [])an array of keyIDs to use (table[i].Keys = []an array of the expected columns from destination table (table[i].Columns = [])I was trying to keep it simple, planning on just going table-by-table, running one keyId at a time on each table.async function(table) =>{ for(key in table.Keys){ p1.prepare(SELECT * FROM dbo.BackUpTable WHERE TableName = @tableName AND KeyId = @keyId) .then(() => { await p1.execute(tableName:table,keyId:key) .then(() => { then await formatting the record into an object array like:/* [ {ColName: 'blahblah', ColVal: 'blahblahval', ColType:'type'}, {ColName: 'blahblah2', ColVal:'blahblah2val', ColType:'type'} . . . ] */ Then await inserting into the destination tableawait p2.prepare("INSERT INTO @destTable (@cols) VALUES (@vals)") await p2.execute(/*stuff*/) })//end the execute.then() statement })//end the prepare.then() statement }//end for loop }//end function but this is clearly a bad way to do it, because I'm getting lost in all the nested "async await" to make it not run all 4000 key requests asynchronously or end up moving ahead before getting all the data formatted or whatever.I'm stuck thinking slowly and synchronously. How should I approach this problem instead?

Submitted May 28, 2018 at 08:40PM by I_HAVE_THAT_FETISH

Music player

I would like to make something like spotify and be able to have the server automatically detect a file and make it available for the user to listen to. Also maybe a user system for the user to make playlists as well

Submitted May 28, 2018 at 08:00PM by CanuckianGamer

Firebase Cloud Messaging with Node.js: Handling tokens and notifications

https://ift.tt/2sfw2MC

Submitted May 28, 2018 at 08:08PM by nulless

What makes programmer "senior programmer"?

I am working as full-stack developer since 2014 in small software house (3 programmers in the team, I have the biggest experience - almost 5 years, including my previous job). However, I am not satisfied with current projects, so I started to think about move to another company. I just need to change my work environment. Though I am working in NodeJS (Meteor mostly, but we have done some microservices in pure Node) and PHP (shitty WordPress or - rarely - Laravel), I am curious if I deserve for senior developer position. What makes programmer "senior programmer"? Is it only experience, soft skills, ability to understand client and his needs? What knowledge I need to have to be considered as "senior" (specially in Node)?

Submitted May 28, 2018 at 06:09PM by tomciozdwola

How to test my api?

Hello guys,I am a JavaScript developer and by now I am pretty confident in my NodeJs skills. I would like to get into testing my apis now. Simple questions: What is the way to go now regarding testing?I see that TDD is pretty popular and I assume most people use mocha/chai for their tests - are there any in depths guides discussing how people build around their tests?Thanks in advance

Submitted May 28, 2018 at 03:50PM by roconf

Make function synchronous

Hi, I have been working on a simple cube timer app using node. The problem is that when i run best(), Math.min returns infinity because it runs before the execution of sumOfSeconds ends and therefore i get an empty array. Is there a way to solve this problem? Thanks in advance!var sumOfSolves = []; //crete an array of total seconds in each time - used for Ao5, Ao12, best and worst function sumOfSeconds(){ Time.find({}, function(err, data){ if(err) throw err; sumOfSolves = []; for(var i = 0; i < data.length; i++){ sum = data[i].min * 60 + data[i].sec; sumOfSolves.push(sum); } }) } function best(){ sumOfSeconds(); //ERROR function is async that is why it doesnt work var best = Math.min(...sumOfSolves); var position = sumOfSolves.indexOf(best); Time.find({}, function(err, data){ if(err) throw err; var bestTime = data[position]; console.log(sumOfSolves) }) } best();

Submitted May 28, 2018 at 02:40PM by everek123

How to fix the EADDRINUSE error?

I'm running a nodejs Express app on a linux server and once in a while the app runs into the Error: listen EADDRINUSE :: 3000. I searched for the answer and all I got was to kill the process, but I can't keep doing that forever. Does anyone know a way to fix this problem for good?

Submitted May 28, 2018 at 03:00PM by hsm4ever13

Free handbook on Progressive Web Applications

https://ift.tt/2L1siWR

Submitted May 28, 2018 at 01:29PM by tpiros

Mongoose get ith document

Hi, is there a way to get the document on a certain position using mongoose? Thanks!

Submitted May 28, 2018 at 11:45AM by everek123

Commentary on working on a standalone desktop app in NodeJS (Karaoke Mugen)

Hello r/nodeIt's been almost a year since I've started writing this little piece of open source software with a few friends and contributors, and at the dawn of our 2.2 release, I thought it might be a good idea to talk about it here and see what I learned during development. I also realize most apps written in NodeJS are made for the web and are intended to be deployed to servers : as you'll see, Karaoke Mugen is a standalone, client/desktop app, and some usual choices need to be reconsidered when making decisions on which technologies to use.That's why i thought it'd be an interesting post. To be honest I wanted to promote the project first, but thought providing technical details and justifying some choices made would make for a far more interesting read for r/nodeI knew nothing about NodeJS a year ago, and learned with this project, sometimes the hard way (callbacks are evil.) However, it allowed me to get a good idea of what I can and can't do with NodeJS, about CI/CD, RESTful APIs, file format validations, QRCode generation, or even static site generators and JSON.What is it ?Website: https://ift.tt/2siwjys repository: https://ift.tt/2JcGcba https://ift.tt/2sidWcQ sum up what the app does : it's a karaoke session manager. You're with some friends or with a crowd, you start up the app, it starts up mpv (http://mpv.io) and a webserver using Express to allow your guests to add suggestions to the playlist or search for songs to add. It uses SQLite3 for its backend database (since it's a standalone app) and we started writing the admin backoffice in React (the main frontend is handcrafted JS with a few libraries thrown in). The guests use their own devices to access the server (they must be on the same wifi network) and the admin can control the player and playlists from a specific admin panel.It uses a karaoke database another team of our own maintain (https://ift.tt/2kwc78R) but people can use their own karaoke files (as long as they use the same format we decided on)What was interesting during this first year of development was getting back on track with most modern ways of coding and working on a project. For the background I'm mostly a sysadmin with some dev knowledge, but over the years, I lost touch with what was happening in the dev world. NodeJS and this project allowed me to catch up.So why NodeJS ?We had a few constraints : the app had to be standalone and multi-platform. It needed to be as simple as possible and self-contained so users only had to double-click on an executable to launch the app.We achieved the standalone part thanks to pkg (https://ift.tt/2pJcVLV) and found out NodeJS had a pretty extensive ecosystem of modules we could use, either for database or for parsing ASS files (subtitles) or manipulating mpv. Using those was a breeze and we had a prototype running in a few weeks.From there, we started working on the web interface and adding other quality of life features.The code was rewritten between 2.0 and 2.1 from using nested promises with lots of then/catch to using async/await, which greatly simplified everything. We also started writing less monolithic code and spread functions more accross smaller JS files. It took us about 1 month to rewrite everything using more recent ECMAScript standards.In retrospect, what was really nice with NodeJS was that we coudl get something working very quickly and with good enough results for a prototype. Development started in early June, and our first real public release, 2.0, landed in early novemberWhy SQLite3A note on databases : I heard a lot of questions on why we used SQLite instead of anything else. SQLite is, as its name says "lite" and we were a bit frustrated with some performance issues when 20+ users tried to add songs or update the database at once. Clearly SQLite is not made to handle many concurrent users, but with some optimizations left and right, we managed to mitigate most of the slowdowns. Someone is working on a benchmark using Gatling and so far, the app starts sweating heavily at around 150 users simultaneously, which would be a very rare case (getting 150 people in a room to sing karaoke is pretty difficult :p)However, we couldn't afford to use another database like postgres or mongo. We needed to embed the database and its engine within the app. This was the simplest way to achieve that.Dependencies and the node_modules bloatI guess everyone is facing sooner or later a time when they look at the node_modules directory size and gasp in horror.When bundling your app like we do with pkg, remember that you can use --production with Yarn to only install production dependencies only and not the dev ones like eslint or babel, which tend to take a lot of space.Something else I did was looking at each module's size and looked at our yarn.lock to quickly check which dependency used it. By only takign intoa ccount modules bigger than 300-400Kb I quickly eliminated stuff I didn't need. One good example was express-validator, or lodash which take a lot of space. I only used a handful of functions from lodash and thus only added those as dependencies, not the whole package. Getting rid of momentJS also allowed to save space : I rewrote by hand the only function we used from it.Working with some module authors also proved to be helpful. I notified the node-mpv (https://ift.tt/2kuKk8A) author that it was using an older version of cuid, which had a big (2Mb) memory footprint. Upgrading it saved lots more space.Last but not least, I used modclean (https://ift.tt/2GXmmeY) with its safe setting to get rid of all non important files in the node_module directory prior to packaging.All in all, I saved up like 40 Mb of space (the .exe file went from 150 to 100-110 Mb in size)What's next ?We still have a lot of work on the app. It's considered stable and when you take a look at the issues left there aren't many new features we'd need to implement.However, we received some requests, notably to have stats uploaded to a central server, to know which songs are most popular, etc. There is also an issue about making the app work online, without any wifi network. If you've played games like Jackbox Party Pack before you'll have an idea of what I'm talking about : the app connects to an online server which proxifies requests from users (connected to the online server) back to the app running to control its player.We'd also like to rewrite the user frontend part in React too.These are complex issues and we're still trying to decide on how to tackle them.ConclusionNodeJS has been a fun experience for this little project, and it's not over yet. If you have questions about the app, about some choices we made, I'll try to answer all questions :) I probably didn't think of everything when writing this post.If you want to contribute, that'd be awesome! As I said above with have some challenges awaiting us, or we could need help refactoring stuff or cleaning up the code. Any help is welcome.

Submitted May 28, 2018 at 10:53AM by AxelTerizaki

App.delete doesn't work

Hi, i am so confused - shouldnt this work?App.delete('/clear', function(req, res){some code})$.ajax({ type: delete, url: '/clear' success: some codeWhenever I run the app i get an error, but when I change both routes to '/' everything works perfectly. Thanks in advance :)

Submitted May 28, 2018 at 09:45AM by everek123

how to iterate over JSON obj or array to render it on ejs

https://ift.tt/2sl3kd4

Submitted May 28, 2018 at 09:49AM by tapu_buoy

1 Question about making requests on a url to find new submissions?

Hi, this might be the wrong place to ask but I'm very new to anything related to this. I'm trying to figure out how I could find new submissions on a specific url/page. For example, I would have a script running on a specific news site page (that lists new articles when they're posted) and every time a new article is posted, it would notify me(?) or just spot it(?). Is this possible and is this the right place to ask? If yes, where would I start about learning how to do this?Thanks a lot

Submitted May 28, 2018 at 09:51AM by smarterthanyou7

Download a free handbook on Progressive Web Applications

https://ift.tt/2J7AVSm

Submitted May 28, 2018 at 09:51AM by tpiros

Struggling With Digital Transformation ? How To Get Back On Track.

We provide a range of exciting and innovative web services to take your business to the next level.Some of the services are,- Web development- Web scraping- Data mining- Data extraction- Mobile application development- Web design- Branding- Social Marketing- Algorithm Writing- Problem solving- ConsultingWe are building bridges in web technology in order connect the client's goal to reality.Lets get your project started !Visit Us - https://ift.tt/2GyCS56 Us - [sales@devrolabs.com](mailto:sales@devrolabs.com)

Submitted May 28, 2018 at 10:25AM by kesarawimal

How to build a referral system with node?

I have a website and I want to include a referral program to it.User-a for example will have a unique referral link and if another user bought a product on my website through this link, user-a gets its commission.I just wonder how can I implement this by nodejs, and what's the technique to develop such a feature.Thank you :)

Submitted May 28, 2018 at 10:33AM by _Shadymohammed

Sunday 27 May 2018

The complete guide: Creating an HTTPs server with Node.js and Express

https://ift.tt/2IN0Qzf

Submitted May 27, 2018 at 07:03PM by nulless

WorkerConf: First alpine Backend Conf on NodeJS, Rust, Cloud and Infrastructure w/ intl. Speakers

https://www.worker.sh/

Submitted May 27, 2018 at 03:14PM by joekleber

Get exchange rates in real time.

https://ift.tt/2KV4io4

Submitted May 27, 2018 at 02:20PM by b_curious

A todo list viewer npm package. Feel free to contribute and make a pull request!

https://ift.tt/2INOBT5

Submitted May 27, 2018 at 01:26PM by JakeGore

OCR in node js

Can anyone recommend a good OCR package for node js?It's for a little project that I'm messing with in my spare time so I'm not looking for something super fancy

Submitted May 27, 2018 at 12:21PM by zero-nothing

WebSockets and HTTP/RESTful API on one server?

Hey,I want the following/have the following scenario: I'm about to build an application (MERN stack) consiting of a RESTful API which is provided by node.js, a database (mongo) which stores data POSTed to the RESTful API and a react application, which can retrieve data from the database via the REST API.The data I want to store are most likely system information/technical details like storage (empty space etc.), services (stopped/running), files in form of binary data etc. The data gets provided by different remote clients (keep in mind, there will be multiple remote clients, but only one web client). Remote clients in this case are basically other systems.I'm looking for a way to store the data on the server. I thought about the following concept: my node.js server would not only provide the REST API but also allow websockets to connect to it. Why Websockets? Because I need the server to be able to request from the client at any time(which is what websockets are for, http only provides communication from the client to the server). For the remote clients I wrote an application in JAVA, which is able to connect to my node.js server via a socket and response to requests from the server. This works great so far.To sum it up: currently a user can login to the web client (react app) and access the REST api provided by my node.js server to GET data from the database. Works perfectly.At this moment however only the server can request data from any remote client via a socket. The ultimate goal would be to somehow give the user using the web client an option to execute/trigger this request, so the user can request up to date information from any remote client (the data get's stored by the node.js server, which uses the provided REST api itself by using the request lib).Where would I implement this function/method though? How about creating another route for my REST API which exeactly does this, e.g.(just basic examples to keep it simple):https://localhost:3000/clients/client0/request?type=servicehttps://localhost:3000/clients/client0/request?type=filehttps://localhost:3000/clients/client0/request?type=storageBehind this kind of route the server would execute a request towards the specified remote client(in this case client0) via a socket. The remote client would respond to the request. The server would process the response by calling the provided REST api routes to POST data and store it tot he database. The up to date data could now be retrieved via GET from the web client. The entire process would enable the user to request up to date data from any remote client. Which http method should I choose for this kind of route though?Is there anything wrong with this approach? Any bad ideas? Any other options? I would be happy to hear your thoughts about this and I hope I explained my issue sufficiently.

Submitted May 27, 2018 at 10:53AM by Fasyx

How does node know which app.delete relates to a certain ajax request?

Hi, I am a beginner in node and I was just wondering how node js knows which app.delete corresponds to which ajax request. Suppose on my website I have two buttons one deletes only one item and the other one deletes all items. Then on my server I have two app.delete one deletes one item from the database and the other one deletes all items. How does node know that when I click the button to delete all items, that it is supposed to perform the task under the app.delete which deletes all items. Thanks in advance :)

Submitted May 27, 2018 at 08:35AM by everek123

Saturday 26 May 2018

Managing changing content of a js website

Hi all, I built a nodejs + react website but i do not know what design/module i should add to my website for easier content management. Kindly advice on which keyword i should google for .. tried “CMS” but it doesnt seem to be the answers that i am looking for

Submitted May 27, 2018 at 04:08AM by pjunjie

metaproperties - Associate data with any object without modifying it in any way. Implemented using WeakMaps.

https://ift.tt/2r1kHPG

Submitted May 27, 2018 at 04:23AM by kizerkizer

App.post vs app.delete

Hi, I am beginner and I know what app.get, app.post, and app.delete do but I was just wondering what is the difference between app.delete and app.post. They seem to work in the same way: data is received from the client and according to it some actions are taken. If in app.post I would pass the position of the element that I want to delete and then add some middleware to delete it, it would work in the same way as app.delete. Am I right? What is the difference? Thanks for any answers :)

Submitted May 26, 2018 at 01:51PM by everek123

What would be a good express middleware for handling Bearer tokens 'Not' generated or validated by your express app.

So here is my situation. Im trying to build a proxy express app that sits in front of a webservice where I work.This webeservice has an endpoint for getting a Bearer Token and an endpoint for validating a Bear Token.I can easily get these tokens in my proxy service and use them for further requests.Problem is it just looks really messy. A validate token promise wrapped in a token exists promise wrapped in a build header function for every request.I was wondering if there is some MiddleWare that already exists that accepts this Bearer token and automatically stuffs it into headers for further requests?I took a look at a few Passport strategies but I didnt find something that looked like what I want.Edit: Im new at this

Submitted May 26, 2018 at 11:31AM by dubbeat

Building a micro service for authentication and authorisation of multiple clients.

Newbie NodeJs dev here.Find the link for source hereI was having same problem while developing personal applications, right now I am reading stuffs and trying to write a solution which can scale well.Right now the system uses JWT and the secret is shared between the service and clients.I would like someone to have a quick look and let me know if I am moving in the right direction.It would be great if someone could collaborate with me.Thanks,

Submitted May 26, 2018 at 08:48AM by b_curious

Emailing in Node question: why use mailgun, mailchimp, etc. instead of just using an SMTP server locally?

Like the title says, it seems like most learning resources where you build an app that sends user-confirmation emails, password-reset emails, etc. have you using a 3rd party emailer.I checked the pricing for these to see what happens when I go over my "free tier" limit, because of course, my app will be the next Facebook, and they're all pretty expensive.It makes me wonder why not just use an SMTP server locally? Can't you do that (I'm a beginner and legit don't know)? I assume you'd have to pair with some queue of some kind also.

Submitted May 26, 2018 at 06:27AM by Early_Significance

Friday 25 May 2018

Relying on express

Hi, I was just wondering if relying on express is a bad habit? Pretty much everything I do uses it and I don't really know how to do certain things without it. Thanks for your opinions:)

Submitted May 25, 2018 at 01:54PM by everek123

Is Node.js killing PHP?

https://ift.tt/2IOmUda

Submitted May 25, 2018 at 02:02PM by SweetRaccoon

Question about making requests on a url to find new submissions?

Hi, this might be the wrong place to ask but I'm very new to anything related to this. I'm trying to figure out how I could find new submissions on a specific url/page. For example, I would have a script running on a twitter account and everytime that specific twitter account tweets, it would notify me(?) or just spot it(?). Is this possible and is this the right place to ask? If yes, where would I start about learning how to do this?Thanks a lot

Submitted May 25, 2018 at 10:56AM by smarterthanyou7

Monitor and Analyse API

Hey node newbie here,so I have multiple restful API's running on different ports on localhost. Is it possible to monitor or listen to the req/res head & body on a specific port`?More specifically I want to see and write the traffic on specific endpoints to a db and build my own little Analytics-Page for that (just like web analytics e.g. Google Analytics).I've been browsing for Tutorials etc. for a while now, but I seem to be searching for the wrong things. Could you kindly point me in the right direction?

Submitted May 25, 2018 at 11:03AM by DTR9000

The Day A Bug Was Fixed Only Because The CEO Called In

https://ift.tt/2IKlzzV

Submitted May 25, 2018 at 10:28AM by fagnerbrack

npm install removes itself and some packages

Hello, i am just beginning with NodeJS and i encouraged a problem. Everytime when i try to install a package using npm it just removes itself and some packages. Here is example log when i tried to install discord.js:PS G:\NodeJS> npm install discord.js npm WARN saveError ENOENT: no such file or directory, open 'G:\NodeJS\package.json' npm notice created a lockfile as package-lock.json. You should commit this file. npm WARN enoent ENOENT: no such file or directory, open 'G:\NodeJS\package.json' npm WARN discord.js@11.3.2 requires a peer of bufferutil@^3.0.3 but none is installed. You must install peer dependencies yourself. npm WARN discord.js@11.3.2 requires a peer of erlpack@discordapp/erlpack but none is installed. You must install peer dependencies yourself. npm WARN discord.js@11.3.2 requires a peer of node-opus@^0.2.7 but none is installed. You must install peer dependencies yourself. npm WARN discord.js@11.3.2 requires a peer of opusscript@^0.0.6 but none is installed. You must install peer dependencies yourself. npm WARN discord.js@11.3.2 requires a peer of sodium@^2.0.3 but none is installed. You must install peer dependencies yourself. npm WARN discord.js@11.3.2 requires a peer of libsodium-wrappers@^0.7.3 but none is installed. You must install peer dependencies yourself. npm WARN discord.js@11.3.2 requires a peer of uws@^9.14.0 but none is installed. You must install peer dependencies yourself. npm WARN NodeJS No description npm WARN NodeJS No repository field. npm WARN NodeJS No README data npm WARN NodeJS No license field. + discord.js@11.3.2 added 1 package and removed 476 packages in 6.274s PS G:\NodeJS> npm install module.js:549 throw err; ^ Error: Cannot find module 'G:\NodeJS\node_modules\npm\bin\npm-cli.js' at Function.Module._resolveFilename (module.js:547:15) at Function.Module._load (module.js:474:25) at Function.Module.runMain (module.js:693:10) at startup (bootstrap_node.js:191:16) at bootstrap_node.js:612:3 module.js:549 throw err; ^ Error: Cannot find module 'G:\NodeJS\node_modules\npm\bin\npm-cli.js' at Function.Module._resolveFilename (module.js:547:15) at Function.Module._load (module.js:474:25) at Function.Module.runMain (module.js:693:10) at startup (bootstrap_node.js:191:16) at bootstrap_node.js:612:3 PS G:\NodeJS>

Submitted May 25, 2018 at 10:39AM by Fearcore4K

Infinite looping while POST /users/login

https://ift.tt/2LqHz4u

Submitted May 25, 2018 at 06:08AM by tapu_buoy

Send data from client to server

Hi, I am new to node and I get the basics, but when it comes to building my own project I am very confused. On the front end I have a paragraph and I would like to send the text content of it to the server when a button is clicked. How can I do it? Thanks for any answers :)

Submitted May 25, 2018 at 06:45AM by everek123

Thursday 24 May 2018

Is node.js falling behind again?

Hi all,I need to vent some frustration. Do you guys remember io.js? and why it was created? Exactly! it was created cause they felt that nodejs was not doing a good job at staying current. Now, in frontend js, es6 modules are getting more and more common place, if you can life without IE support, that is. And since Node is based on V8, and Chrome uses V8, and supports ES6 Modules since version 61 then why is it not supported yet in Node? Its already there! Aren't they just over complicating things to try to mix ES6 and Common.js modules? why not keep 2 seperate module loaders for a while, and show a deprication warning when using a common.js module? and why have a special file extention for ES6 modules at all?! It all just seems wierd...*shigh* Well, thanks for reading my rant and feel free to give me your 2 cents, maybe my head is not bolted on straight today

Submitted May 24, 2018 at 05:37PM by Cyb3rWaste

From an image to string in an axios request

So I need to pass an image(and text) from a react component to an api.I have this code in my react api:export const addProject = (name, imgs) => {var imgsArray = [];Object.keys(imgs).map(x => imgsArray.push(imgs[x]));console.log(imgsArray); //Will print(with 3 files passed): (3) [File(179582), File(32123), File(122404)]var formData = new FormData();formData.append("name", name);formData.append("images", imgsArray);return axios.post('/api/addProject',formData,{ headers: {'Content-Type': 'multipart/form-data' }});}So far we have an image object and have passed it in a formData object via a post request to the node js api.This calls the function below(removed most of the code as it's irrelevant to my problem:router.post('/addProject', upload.array('file'), (req, res) => {console.log(typeof req.body.images); //Will print out stringconsole.log(req.body.images); //Will print(with 3 files passed): [object File],[object File],[object File]});So I'm passing the file through but it's been converted to a string. I've spent ages trying to fix this to no avail.Thanks for any help!

Submitted May 24, 2018 at 06:24PM by thelynched

Scalable Node.js with Kubernetes and Google Kubernetes Engine

https://ift.tt/2GMFAEb

Submitted May 24, 2018 at 06:34PM by _bit

Server to Server authentication + scaling

Working on building an API gateway and one (probably multiple) of my microservices that it connects to requires authentication (token-based).Is it feasible to store this token in-memory or is there a better storage mechanism that isn't browser-based? Because the end user client should not have cookies that is passed to the API gateway that is then passed to the data source/microservice... the end user shouldn't be aware of or care where that data is coming from as long as it's returned from their request to the API gateway's endpoint.What I'm concerned about is clustered environments where each instance of the API gateway application ends up with a (different?) token. Is that... acceptable?Am I overthinking it because there will be a refresh policy in place for the token's also that happens seamlessly to the end user, so it would be a similar case of getting a token when there isn't one already or if it's expired.tl;dr best way to handle authentication/store tokens in a clustered or scaled environment when the node (Express) is the client (server-to-server)?

Submitted May 24, 2018 at 06:37PM by jsdotjs

Build a Node.js command-line chat application with Chatkit

https://ift.tt/2s9SAhU

Submitted May 24, 2018 at 05:54PM by bookercodes

Node.js (JavaScript) performance tips

https://ift.tt/2LtftWb

Submitted May 24, 2018 at 03:17PM by hobozilla

parsind - A simple route handler binder for express-like routers!

https://ift.tt/2KR9gm0

Submitted May 24, 2018 at 01:29PM by cognetio

List Processing with map, filter, and reduce

https://ift.tt/2qnQ0nq

Submitted May 24, 2018 at 12:01PM by fagnerbrack

Bad Request in all requests in one computer

Hey guys,I've been working on a Node API. When I run the API on my desktop all my requests work, however, when I run the same API in another computer I always get bad request. Any ideas what could be causing this?

Submitted May 24, 2018 at 10:23AM by calves07

App.use vs app.get

Hi, what is the difference between those 2. I am new and I don't really get that whole middleware concept. Thanks in advance :)

Submitted May 24, 2018 at 10:14AM by everek123

Wednesday 23 May 2018

Will node require more 'programming'

Hi, I started learning node a few days ago mostly because I wanted to start creating ful stack apps rather than just front ends (I started by learning javascript). I watched a bunch of tutorials and learned some basics. Right now node for me is just basically memorizing methods and the syntax, and I was just wondering is that what node is all about (I am new to backend, so this might as well refer to backend overall). Will node ever become this 'real' programming (Where I have to figure out how to actually solve the provlem) or will it always be just memorization? Thanks in advance:)

Submitted May 23, 2018 at 07:55PM by everek123

Help Packaging a NodeJS App for Windows

https://ift.tt/2s6LM4C

Submitted May 23, 2018 at 05:20PM by LTD-Dev

Best form sanitization npm?

Hi all,I'm working on a pretty basic site for a small business. The owner wants a small contact form so that customers can reach out for information via the website. Of course I am going to sanitize those user inputs, but I am not looking to do anything crazy. I found node-sanitize, but I was wondering if there might be a more widely used form sanitization npm. It can be express middleware like node-sanitize, but I don't mind wrapping an npm in middleware to make it work with express.

Submitted May 23, 2018 at 04:30PM by maximusprime2328

User Friendly Database Interaction on a Public Site?

Hello I am setting up hosting on an app I developed for my first time. I am using express, ejs, and mongoDB as my database. I am building this for a friend that is less savvy with command line and am wondering what is a safe way I can give them access to a database in a user friendly way with out creating a view on the public site that can get attacked.

Submitted May 23, 2018 at 04:01PM by koy5

Why is this throwing a type error?

So I have an api call from react that is throwing the error:TypeError: Converting circular structure to JSONSo I have this code in the react file:handleSubmit = (event) =>{event.preventDefault();//Get the valueslet name = event.target.name.value;let importance = event.target.importance.value;let desc = event.target.desc.value;let img = event.target.img.value;let video = event.target.video.value;let url = event.target.url.value;let formats = [];let types = [];{Object.keys(this.state.formatsList).map(item => {if(document.getElementById(item).checked){formats.push(document.getElementById(item));}})}{Object.keys(this.state.typesList).map(item => {if(document.getElementById(item).checked){formats.push(document.getElementById(item));}})}api.addProject(name, importance, desc, img, video, url, formats, types).then(console.log(name+" has been added.")).catch(console.error);}Then this in the react api file:export const addProject = (name, importance, desc, imgs, video, url, formats, types) => {return axios.post('api/addProject', {name: name,importance: importance,description: desc,images: imgs,video: video,url: url,formats: formats,types: types})}Then this in the site apirouter.post('/addProject', (req, res) => {const name= req.body.name;const importance= req.body.importance;const description= req.body.desc;const images= req.body.img;const video= req.body.video;const url= req.body.url;const formats= req.body.formats;const types= req.body.types;// validation ...mdb.collection('projects').insertOne({ name: name, importance: importance, description: description, images: images, video: video, url: url, formats: formats,types: types}).catch(error => {console.error(error);res.status(404).send('Bad Request');});});I'm totally lost on this, thanks for any help!

Submitted May 23, 2018 at 03:24PM by thelynched

ByteArray.js just had it's biggest update! Come check out the best binary library for JS!

https://ift.tt/2IQhLAd

Submitted May 23, 2018 at 02:05PM by Zaseth

[Question] Right way of passing consistent data from DB to user without repeatedly querying

Database stores some data about the user which almost never change. Well sometimes information might change if the user wants to edit his name for example.Data information is about each user's name, username and his company data.The first two are being shown to his navigation bar all the time, like ``User_1 is logged in`` his company profile data when he needs to create an invoice.My current way is to fetch user data through middleware using `router.use` so the extracted information is always available for rendering through all routes/views, for example:My current way is to fetch user data through middleware using router.use so they are always available for rendering through all routes/views, for example:.router.use(function(req, res ,next) { // this block of code is called in every route req.getConnection(function(err,conn){ uid = req.user.id; if(err){ console.log(err); return next("Mysql error, check your query"); } var query = conn.query('SELECT * FROM user_profile WHERE uid = ? ', uid, function(err,rows){ if(err){ console.log(err); return next(err, uid, "Mysql error, check your query"); } userData = rows; return next(); }); }); }) .I understand that this is not an optimal way of passing user profile data to every route/view since it makes new DB queries every time the user navigates through the application.What would be a better way of having this data available without repeating the same query in each route yet having them re-fetched once when user changes a portion of this data, like his fullname ?

Submitted May 23, 2018 at 01:23PM by King_Cadmos

[Question] Right way of passing consistent data from DB to user without repeatedly quering

Database stores some data about the user which almost never change. Well sometimes they do if the user wants it.Data like his name, username and his company data.The first two are being shown to his navigation bar all the time, like "User_1 is logged in", his company data when he needs to create an invoice.My current way is to fetch user data through middleware using router.use so they are always available for rendering through all routes/views, for example:.router.use(function(req, res ,next) { // this block of code is called in every route req.getConnection(function(err,conn){ uid = req.user.id; if(err){ console.log(err); return next("Mysql error, check your query"); } var query = conn.query('SELECT * FROM user_profile WHERE uid = ? ', uid, function(err,rows){ if(err){ console.log(err); return next(err, uid, "Mysql error, check your query"); } userData = rows; return next(); }); }); }) .I understand that this is not an optimal way of achieving user profile data to every route/view since it make DB queries every time the user navigates through the application.What would be a better way of having them available without repeating the same query in each route yet have them re-fetched when user changes a portion of this data, like his name ?

Submitted May 23, 2018 at 01:03PM by King_Cadmos

Domains post-mortem

https://ift.tt/2FgUG5L

Submitted May 23, 2018 at 01:08PM by ecares

Can I POST URL encoded data instead of object?

This is form data I feed request lib with: https://ift.tt/2KM7Rgo I feed him with this instead somehow? https://ift.tt/2LnK87i have a very big payload on another site and I don't wanna copy and paste it and format it myself

Submitted May 23, 2018 at 12:21PM by carrycopter

looking for discord bots?

Is there any good opensource bots for discrod. I need to write my own, and want to see some examples.

Submitted May 23, 2018 at 11:18AM by comalex

Tuesday 22 May 2018

ByteArray.js now has a high performance method 🎉🎉🎉

https://ift.tt/2IQhLAd

Submitted May 22, 2018 at 07:30PM by Zaseth

Node child_process.exec Displays Special Characters as Question Marks

I'm running a test using Node's child_process.exec to execute an echo statement with special characters in it.const {exec} = require('child_process'); try { exec("echo téstér", function(err, stdout, stderr) { console.log(stdout) }); } catch(e){ console.log(e.message) } When running this on my Linux machine, I get the téstér value I was expecting. When I run it on my Windows machine I get back t?st?r.Am I missing something when I call the exec function to have my special characters appear?

Submitted May 22, 2018 at 07:36PM by -Captain--Hindsight

Multi-threading coming (soon) to Node via Workers!

https://ift.tt/2GBeeRj

Submitted May 22, 2018 at 05:30PM by TheCommentAppraiser

Adding a custom block cipher to Node JS

I have a modified version of openssl with a custom TLS cipher that I am testing. How would I use it in Node JS?I have pointed the modified version of openssl to Node JS using the LD_LIBRARY_PATH.I have tried specifying the custom TLS cipher using the --tls-cipher-list option to no avail. However I can list it from the openssl ciphers command.

Submitted May 22, 2018 at 03:36PM by llamoure

Getting started with hapijs, Objection ORM, and the hapi pal toolchain

https://ift.tt/2KIG28O

Submitted May 22, 2018 at 01:55PM by devinivy

The 7 Biggest Lessons I’ve Learned By Building A Twitter Bot With Nodejs🐤🤖

https://ift.tt/2LbyxYU

Submitted May 22, 2018 at 10:55AM by tomastrajan

dana - simple database migration tool

https://ift.tt/2IE6zU1

Submitted May 22, 2018 at 09:06AM by cognetio

Installing Node.js Tutorial: Using snaps on Linux

https://ift.tt/2KJyLW5

Submitted May 22, 2018 at 08:34AM by harlampi

Monday 21 May 2018

What's the best way to manage TLS certificates? (self-signed in dev versus LetsEncrypt in prod)

I have an open source project for an https server. I use LetsEncrypt in production for certification management, but for local development I threw together some self-signed certs.I am currently using:if (path_to_lets_encrypt_certs_exists) use('/absolute/path'); else use('../local/certs'); I figure I shouldn't host the local certs to Github (self-signed). I'm not sure why, it just feels wrong, but I suppose there's nothing dangerous about it? I added the local cert path to .gitignore.I'm not sure I am handling this correctly though.This project currently requires no build process. I just node it.js to run it in dev or prod.

Submitted May 21, 2018 at 08:08PM by throw_at_work_away

[Help] How to pass node flag to global npm package

I'm running a global npm package via CLI that is running out of memory, but I can't figure out how to pass the --max-old-space-size flag to it. All examples I could find use the node command, and just adding it after gives me an unknown option error. Is there a way to do this?

Submitted May 21, 2018 at 08:10PM by ouralarmclock

How to setup a powerful API with Nodejs, GraphQL, MongoDB, Hapi and Swagger

https://ift.tt/2rWUjb4

Submitted May 21, 2018 at 06:29PM by thickoat

How would develop a SAAS that handle user account, payment, invoice, queue system?

Hello, I've developed a website that handle payment in the past. And it was very archaic. First, you think it's faster to code the thing yourself but then things get more and more complicated as you fix bugs, add features, add exceptions...I learned the lesson! So now I switch my mindset to use as many reliable nodejs module as possible + use recommended practice in term of architecture/code.If today you add to make a SAAS that:- user can register (receive email confirmation + password forgotten...)- subscription with several pricing plan- generate and manage invoice for customer- manage people that doesn't pay in time- queue system for many maintenance task- admin panel to manage user, payment, and invoiceWe can say it's the minimum typical SAAS app. How would you do it? How would you architecture the whole system (frontend and backend and admin panel)? Would you use cloud service to handle part of the business (for example invoice generation, queue system...) ?Thanks

Submitted May 21, 2018 at 06:07PM by pauldupont34

ByteArray.js is Now supporting AMF3 👍

https://ift.tt/2IQhLAd

Submitted May 21, 2018 at 03:16PM by Zaseth

Discussing NodeJs Enterprise Apps that scale. (InfoQ, pay pal)

https://ift.tt/2EQ091o

Submitted May 21, 2018 at 02:43PM by TheOneRavenous

How to host a NodeJS app MYSELF?

Hello,I have created two real node Apps and i need to host them MYSELF on my OWN pc.The tech used in the apps are: NodeJS(version 9.5.0), Express, MySQL. (Windows 10)Google doesn't really point me anywhere about hosting my own nodeJS app and a general search on how to host your own website points me to xampp but apparently it's only for PHP.The website will barely have any visitors and the visitors that do open it up, they will stay for 5 minutes max, so I am not too concerned about security.How do I accomplish this? What is the software I am looking for? Keep in mind that I need to host 2 websites at the same time.Thank you for your time.(The apps are personal projects and the people opening the site will be potential employers)

Submitted May 21, 2018 at 12:09PM by khazha88

Node.js with front-end

Hi, this might be a very obvious question, but I started learning node yesterday and I am really confused. I developed the front end of a Rubik's cube timer (it measures time and then adds it to an array, and performs some simple calculations). Suppose I would like to publish (put it on the internet so anyone can access it) this cube timer, do i need to use node in some way? If i would like to add those times to a database would I have to rewrite the whole cube timer in node or could I just somehow link it with the backend? Thanks in advance :)

Submitted May 21, 2018 at 09:58AM by everek123

Where to place Custom Error classes in Node js project?

Hi,In your experience, where would you place CustomError class definition files in a nodejs project structure? What's the best practice here?Thanks for sharing!!

Submitted May 21, 2018 at 09:37AM by raccoonranger73

Is a self-created function an asynchronous code in Node?

It is known that Node provides some API that run asynchronously for I/O or CPU-intensive tasks, such as fs.readFile function. However, if I self-create a function and then run it with a callback pattern, is it asynchronous (non-blocking)?Consider this function:function addNumber(number, fn) { //Add 1 to 'number' ten times then return the number for (let i = 0; i < 10; i++) { number += 1; } fn(number); } If I then call the function:addNumber(100, function (number) { console.log(number); }); Is this an asynchronous code in Node.js? That is, does the function still runs in the event loop while blocking other operations? I am wondering because this function follows the usual "callback" pattern whenever we want to run asynchronous code.

Submitted May 21, 2018 at 09:39AM by VickNicks

Sunday 20 May 2018

Push Notifications Using Node.js & Service Worker

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

Submitted May 20, 2018 at 09:46PM by katerina-ser60

ByteArray for Javascript with fully working AMF0 library

https://ift.tt/2IQhLAd

Submitted May 20, 2018 at 04:13PM by Zaseth

Seamlessly call functions on other systems with the help of ES6 Proxy

https://ift.tt/2rVitmd

Submitted May 20, 2018 at 03:40PM by lindell92

I heard about MVC Model View Controller a while back but didn't got what it is until when I started to build an app in Node. Here let me share what is a "View" is in MVC

https://ift.tt/2rQJabJ

Submitted May 20, 2018 at 02:35PM by tamalweb

Abusing Proxies for DSLs

https://ift.tt/2qhmbpx

Submitted May 20, 2018 at 01:51PM by fagnerbrack

Best learning resources

Hi, I am completely new to node and even backend. I started learning js about 1.5 months ago and now i decided that I want to learn some backend development. What are the best learning resources? Where to start? Thanks in advance :)

Submitted May 20, 2018 at 11:22AM by everek123

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

https://ift.tt/2rYSA43

Submitted May 20, 2018 at 11:34AM by Rajnishro

Saturday 19 May 2018

Node + Express + MongoDB(Mongoose) + ES6 Tutorial

As the title says, I have been trying to find a tutorial for these Technologies, it seems like l mostly find a lot of tutorials for the first three, but the last one never makes it in. If anyone knows of a complete tutorial on all three it would be really helpful. Thanks.

Submitted May 19, 2018 at 09:58PM by BateJay

hyper-stylesheet: Adds support for an external hyper terminal stylesheet

https://ift.tt/2x1LgL0

Submitted May 19, 2018 at 08:21PM by here-for-karma

Using node 6, one of the node_modules is not compatible and breaks everything, posible solutions?

Hi guys I've been trying to solve this for too long already, I have Express on a Google cloud function so it uses node 6 and can't be upgraded, on of the modules the app have requires node 8, How could this be solved?With babel? taking the module folder and moving it into my project and transpile it there? I've been looking a lot online but can't find what I really need.

Submitted May 19, 2018 at 03:57PM by virality444

ByteArray in Javascript + full AMF0 module

https://ift.tt/2IQhLAd

Submitted May 19, 2018 at 02:25PM by Zaseth

"TypeError: The header content contains invalid characters" and some other stuff.

Hello,I'm working on a discord bot, made with Node.JS.I got the following error :https://ift.tt/2rUMvpj tried to search on the internet, etc, I can't find a clue of what I need to do.Here's my code :My server : https://ift.tt/2kbfAJR function file : https://ift.tt/2rR2J2K ideas ?Thanks for your help.

Submitted May 19, 2018 at 02:03PM by themistik

[Error NodeJS MySQL] conn.end() is not functioning (cannot enqueue after invoking quit)

For a reason that I am struggling to find out, I cannot apply conn.end() after my queries in any route.I am starting to think that in some point the involvement of Passport.js configuration causes it because before the query I give conn.state and it seems that there is already an open connection.Error (events.js is not a file I work on, I guess is a standard node_modules factory file)`events.js:183 throw er; // Unhandled 'error' event ^ Error: Cannot enqueue Quit after invoking quit. .Route file on which I try to apply conn.end()var express = require('express'); var router = express.Router(); var dashboard = express.Router(); dashboard.use(function(req, res, next) { console.log(req.method, req.url); next(); }); var dashboard = router.route('/'); dashboard.get(function(req,res,next){ req.getConnection(function(err,conn){ console.log(conn.state, conn.ThreadId) // authenticated, xxxx if (err) return next("Cannot Connect"); var query = conn.query('SELECT SUM(total_price) AS transactions_total FROM transactions WHERE date_created = CURDATE()', function(err,rows){ if(err){ console.log(err); return next("MySQL error, check your query"); } res.render('dashboard', {data:rows}); conn.end(); // causes the described error }); // conn.end(); even tried here }); }); dashboard.all(function(req,res,next){ console.log("route for dashboard executed"); console.log(req.params); next(); }); module.exports = router; .app.jsvar express = require('express'), path = require('path'), bodyParser = require('body-parser'), app = express(), expressValidator = require('express-validator'), session = require('express-session'), passport = require('passport'), flash = require('connect-flash'), passportConfig = require('./config/passport'), dbConfig = require('./config/db'); // skipping code about static files, bodyparser, expressValidator, session, passport passportConfig(passport) /*MySQL connection*/ var connection = require('express-myconnection'), mysql = require('mysql'); app.use( connection(mysql, dbConfig, 'request') ); var dashboard = require('./routes/dashboard.js'); // in this route I apply conn.end() var router = require('./routes/rates.js'); // skipping app.post/app.get code for /login & /logout & isLoggedIn middleware app.use('/', router); app.use('/', dashboard); // issue on that app.get('/', function(req, res) { res.render('./dashboard.ejs'); //issue on that }); module.exports = app; .db config filemodule.exports = { host : 'localhost', user : 'root', password : '', database : 'mydb', debug : false } .Passport.js configurationPastebin link

Submitted May 19, 2018 at 12:45PM by King_Cadmos

Beginner here, does NodeJS not come with a default server to run your app?

As title.. I'm pretty confused. When I learned Ruby on Rails, to run my app, I would type the command 'rails server', which would run the app on the Puma web server locally. But a lot of tutorials on NodeJS focus on creating your own web server, and after viewing this guy's video (https://www.youtube.com/watch?v=U8XF6AFGqlc), he mentions that you have to create your own server on Node (around the 16:52) mark. I guess all this is making me more confused about Node, as it pertains to web app development.

Submitted May 19, 2018 at 10:11AM by y3ll0wmamba

A different way of passing parameters in JavaScript

https://ift.tt/2ItaiI2

Submitted May 19, 2018 at 09:37AM by gergefil

How a RegEx can bring your Node.js service down

https://ift.tt/2rTDCMT

Submitted May 19, 2018 at 08:28AM by lirantal

Friday 18 May 2018

Help! Started learning node + express and not sure what the next steps are!

Hey all,Im a junior developer and I've stared learning the MERN stack(MongoDB, Express, React and Node). I have 2 months to learn this stack to the point where I know what im doing and can build with it at a basic level.When I say I have 2 months to learn this, I mean I can dedicate everyday to this full time without anything else getting in the way.The problem I'm having is finding a solid learning path and when to move from one framework to the next??I've worked my way through a few node + express tutorial builds, teamtreehouse courses and reading about MERN and its going quite well, but how do i know when I've learned enough to add in react and mongo?What do i need to know about node and express to get a basic app for learning started? Is it just a case of being able to set up a server, add routing, hook in a DB and add some other things for a basic app?Would it be a good idea to just keep reading and building by following tutorials until I feel comfortable then try and set this up on my own?What is everything a basic app would need with node + express, that a beginner to the stack should be learning?Sorry about all the questions, this has just been stressing me out because i just want to be able to build beautiful kick-ass apps already and im feeling lost going from one place of learning to the next.All help and suggestions are totally appreciated!Thank you in advance!

Submitted May 18, 2018 at 07:31PM by thenewdev1

Can someone explain this node module for tf2 and steam?

I don't know if I'm asking this in the correct subreddit but I'm having a hard time understanding this module: https://ift.tt/2rRkUGd. If this is not the correct subreddit to ask, could you direct me to the right place either on reddit or elsewhere?I'm interested in making a tf2 trade bot that can trade while ingame. This node module allows the bot to do that using something called a Game Coordinator. It uses protobuf to communicate it seems. I can't find any documentation on the tf2 Game Coordinator. Could someone link me to some documentation or explain how it works? The reason why I don't just use the library linked above is because I want to do it in python instead of node. I don't need all of the features from the node module also.Edit: coordinator

Submitted May 18, 2018 at 05:01PM by benscar1

Can someone explain the difference between Escaped & Unescaped String Interpolation? I'm using pug.

Hi all, have looked around and was unable to find much material on the specific differences between unescaped and escaped string interpolation. Thanks in advance.

Submitted May 18, 2018 at 02:01PM by CaptainFitzgerald

Looking for a team building a trading bot in NodeJS

Hi,We are looking for some extra support on our team creating a trading bot (Crypto).The Trading Bot solution is at the moment in a private project. We are working on it with 3 members but all in our spare time. Current status is that we can go live with the tool within a few weeks and have a large backlog we have to focus on.If you like to join our team (don't matter if you don't know anything about trading, we do. We have example strategies and more complex stuff like machine learning models for our phases so just ping me for more information).Looking forward to the updates or questions :)

Submitted May 18, 2018 at 01:20PM by micasa001

10 Best Node.js Frameworks in 2018

https://ift.tt/2Kxesve

Submitted May 18, 2018 at 12:36PM by eugeniyak

Senior Backend Node Developers, London. Up to £100k

Hi guys,I'm Kai and I'm the Head of Talent at Endian. We're a software development agency based in London. I'm doing some of the technical hiring for a client of ours. Have a look at the advert below...I’m on the hunt for permanent Backend Node Developers in London at a Senior level. Endian is working with an exciting product development company focused in the blockchain space. Startup through to corporate, the clients you’ll work for vary from e-payments, aviation, and social impact. You’ll be joining a strong team who are building decentralised applications and you’ll be tackling some very interesting challenges such as identity management, transaction anonymity, and data security. I’d love to hear about what you’re doing at the moment, where you would like to take your career and how you’d like to achieve these goals. I can tell you a little more about the company, the job, and culture of the business. Get in touch on LinkedIn or via email - [kai@endian.io](mailto:kai@endian.io) Salaries up to £100k

Submitted May 18, 2018 at 12:47PM by kaiendian

How to access an SQL Database from an Azure Function and Nodejs

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

Submitted May 18, 2018 at 11:59AM by fboucheros

André Staltz: Reactive Progamming is no longer niche 🙌

https://ift.tt/2rWOMkT

Submitted May 18, 2018 at 09:20AM by FrontendNation

Express JS + React JS

Dear Gurus ,I'm about to depart into a journey for builidng a web apps that need to have a live feed to always show user what has been going on behind the scene , and all are money / payment related.May i seek the opinion of gurus where , whcih approach will be better ? I have in mind that i would like to use Express as an backend API and then front end React JSI still not clear about this but i do have a questions. Should these 2 be separated into 2 droplet ( Digital Ocean ) or should thhese 2 locate under same server?Thanks

Submitted May 18, 2018 at 07:34AM by jsangularjs

Thursday 17 May 2018

I didn't know Node JS has been around since the 70's

https://ift.tt/2IQdtZE

Submitted May 17, 2018 at 07:29PM by samofny

How exactly to use socket.io for my purpose?

So i don't have much knowledge regarding socket.io. I have a users collection and a posts collection. The posts collection has a reference to _id from the users collection. My requirement is that once the user logs into a webpage, he must be only shown his posts (being updated live) using socket.io. Eg. user A after loggin in should see user A's post's. user B after loggin in should see user B's posts and so on. Now i've looked in to rooms in socket.io and was wondering how to go about this? How should i associate each user's socket with his _id so that he can only see his posts.Thanks

Submitted May 17, 2018 at 07:30PM by mclovin4009

The Future of Native Modules in Node.js

https://ift.tt/2GtaQYy

Submitted May 17, 2018 at 05:17PM by ms-maria-ma

How do I handle this error?

My app uses an encrypted key as a query string. But since query string cannot parse special characters, I have to encode them usingencodeURIComponent() When the url with the query string is accessed, it sends the query string back to the server, decodes it before it is decrypted. If I manually alter the query string to some malformed URI, I get an error.Error: Malformed UTF-8 data at Object.stringify (D:\Projects\healme\node_modules\crypto-js\core.js:478:24) at WordArray.init.toString (D:\Projects\healme\node_modules\crypto-js\core.js:215:38) at D:\Projects\healme\routers\routes.js:29:37 at Layer.handle [as handle_request] (D:\Projects\healme\node_modules\express\lib\router\layer.js:95:5) at next (D:\Projects\healme\node_modules\express\lib\router\route.js:137:13) at Route.dispatch (D:\Projects\healme\node_modules\express\lib\router\route.js:112:3) at Layer.handle [as handle_request] (D:\Projects\healme\node_modules\express\lib\router\layer.js:95:5) at D:\Projects\healme\node_modules\express\lib\router\index.js:281:22 at Function.process_params (D:\Projects\healme\node_modules\express\lib\router\index.js:335:12) at next (D:\Projects\healme\node_modules\express\lib\router\index.js:275:10) What can I do so that if an invalid query string/URI is entered into the browser, I show a custom page saying an error has occurred?I try to use a try and catch block but it doesn't seem to work.try { decodeURIComponent(req.query.key); catch (e) { resp.redirect('/error.html'); }

Submitted May 17, 2018 at 06:06PM by eggtart_prince

Can someone explain why this decrypt works?

using the library crypto-js, I encrypt the string 'goat'.The encrypted sting is something like thiskhsfg935j+353klhddg98= Decrypting using the same secret key, I get 'goat'. If I delete the = and decrypt it using the same secret key, I get 'goat'. Deleting anything more than the =, it does not decrypt. Does the = character not playing any role in terms of decrypting?

Submitted May 17, 2018 at 06:13PM by eggtart_prince

Understanding How Node.js Release Lines Work

https://ift.tt/2rOr4Gf

Submitted May 17, 2018 at 04:26PM by _bit

CarMax Pricing Tool - Full-Stack JS App built w/Node + React

https://ift.tt/2wLfAcm

Submitted May 17, 2018 at 04:37PM by FullSlack

Security Talk at PayPal: Least Privilege Made Easy

https://ift.tt/2IoYg2o

Submitted May 17, 2018 at 05:12PM by nucleocide

After 5 years and $3M, here's everything we've learned from building Ghost

https://ift.tt/2jYyEeg

Submitted May 17, 2018 at 03:01PM by spmaster007

Question about nodeJS and concurential acess.

Hello. I've developped a messenger bot from scratch to advise buyers of a company. I've made a file storage system with FS so when I have to store sthing like the product they want, I write it in a file in the server.Here comes my question :If I call a function, which open the file "client123" and write into this file "{Product_type : x, product_number : y...}"If I want to iterate on the object to create a new object(like a string with all the attributes values)Can I do : for(let keys in client123") Or will I have to do (for keys123.comptor in client123")I mean I don't get if my variable which have been declared in a promise.then() are independant?thanks

Submitted May 17, 2018 at 02:23PM by aloisnoob39

What's New in Mongoose 5.1: Map Support

https://ift.tt/2k2ViCa

Submitted May 17, 2018 at 02:49PM by code_barbarian

Loopback models with custom mixins for computed properties

https://ift.tt/2IlKrBI

Submitted May 17, 2018 at 01:40PM by clementwalter

Creating a chat with Node.js from the scratch

https://ift.tt/2Kto5ej

Submitted May 17, 2018 at 12:52PM by kiarash-irandoust

What happened to Ayo.js?

Whatever happened to the social justice warrior version of node? The only information I can find about it is on the GitHub site.

Submitted May 17, 2018 at 10:12AM by baffybonk

How do I set up a test server with mocha?

// test/login.jsvar app = require('../index'); var http = require('http'); var Browser = require('zombie'); describe('login', function() { before(function() { this.server = http.createServer(app).listen(3000); this.browser = new Browser({ site: 'http://localhost:3000' }); }); before(function(done) { this.browser.visit('/', done); }); it('should see should username', function() { assert.ok(this.browser.success); assert.equal(this.browser.text('#username'), 'user101'); }); after(function(done) { this.server.close(done); }); }); I get a listener should be a function error.

Submitted May 17, 2018 at 06:24AM by eggtart_prince

NodeJS deployment

I've recently gotten myself a server, which is running IIS 8 and I've installed IISNode, but for some reason either express servers or Vue websites is not running, and the error is very similar to, when .NET is not enabled on a .NET website.So how do I deploy on a Windows Server?

Submitted May 17, 2018 at 07:45AM by ToppeR144p

How to read values from excel and create bulk insert query using sequelize with node js

The below code is the single insert codeinsertData: function (sqlQry, dataJson) { var deferred = new Q.defer(); sequelize.query(sqlQry, { raw: true, replacements: dataJson, type: sequelize.QueryTypes.CREATE }) .then(function (result) { deferred.resolve(result); }, function (err) { deferred.reject(err); }).catch(function (err) { var reslog = { "status": "Error", "message": err + "" } deferred.reject(reslog); }); return deferred.promise; }, i want to insert multiple data in mysql with sequelize.

Submitted May 17, 2018 at 08:17AM by ElumalaiKutty

Wednesday 16 May 2018

yesn‘t

https://ift.tt/2k0zM0N

Submitted May 16, 2018 at 08:31PM by dschwammerl

Constraints based cron-like scheduler... Opinion on my new lib?

https://ift.tt/2k1EoUh

Submitted May 16, 2018 at 06:48PM by nemanjan00

A quick tutorial on passing data from a server to handlebars views

https://ift.tt/2wNdn03

Submitted May 16, 2018 at 02:57PM by prashantmvikram

“Configue” config library now supports Shortstop protocols

https://ift.tt/2wNju4v

Submitted May 16, 2018 at 03:06PM by AdrieanKhisbe

Constrain GraphQL inputs with directives

https://ift.tt/2ILYiAJ

Submitted May 16, 2018 at 03:49PM by confuserr

Path Traversal vulnerability in all versions of koa-body

https://ift.tt/2KrZl62

Submitted May 16, 2018 at 02:22PM by Katana__

Programming a news site from scratch using Node.js - Free Udemy Courses - DiscUdemy

https://ift.tt/2wOV6zG

Submitted May 16, 2018 at 02:24PM by udemyfreebies

Node.js 10.0.0: Everyone’s Favorite Got Even Better

https://ift.tt/2IneDZ9

Submitted May 16, 2018 at 01:37PM by Slavos17

How long should this tech task take for a junior?

Hi everyone,I'm looking to hire a very junior developer and I have set a tech task which i think is really basic.https://ift.tt/2IpiuoN long do you think this task should take. Its basically just implementing missing code.Thanks

Submitted May 16, 2018 at 01:18PM by jaylensoeur

SSO Help

Hello I am newer programmer going through a school and also learning extra stuff by my self. I was wondering if there was some easier documentation on SSO login creation as i am trying to create a React/node/express app that uses a OAuth 2.0 log in structure. The information is already predefined and i was unable to find a passport dependency to make it a little easier. Any help is appreciated thank you!

Submitted May 16, 2018 at 05:58AM by rburger27

Tuesday 15 May 2018

Help with websockets in node.js app

I have a functioning node.js app using websocket however during periods of high traffic the app crashes. Is there a way to better handle the incoming data with a buffer as opposed to a rate limiter ? Don't want to lose the incoming data if it's at all possible.Cross posting from another node sub.Cheers for the help

Submitted May 15, 2018 at 07:43PM by phillwilk

Check out the first church-based JS conference

https://amsterdamjs.com

Submitted May 15, 2018 at 07:47PM by FrontendNation

jiractl: A command-line tool for managing Jira (written in Node.js)

https://ift.tt/2KpvUl4

Submitted May 15, 2018 at 08:13PM by gorgerson

Upload Multiple Files in Directory to Google Cloud Bucket w/ Node

Hi all,Apologies if this is the wrong place to post thisI have a small project where I have a script that produces multiple reports (html,json files), once the reports are in a directory I'd like to upload those files at once to a google storage bucket. What's the best way to iterate through the contents of the directory and upload each file in one go? These files will be very small (~10mb dir total) so size isn't really a concern. Below is some sample code I was using to upload 1 individual file.Thanks in advance, I'm no java or node pro but I can usually frankenstein something together. I've seen lots of examples around the internet but they usually only pertain to one individual file.```java //gcp upload jsvar fs = require('fs');// Imports the Google Cloud client library const storage = require('@google-cloud/storage');var gcs = storage({ projectId: 'my-project', keyFilename: './my-key.json' });var bucket = gcs.bucket('fake_test_bucket');bucket.upload('./summary.json', function(err, file) { if (!err) { console.log("file is now in the bucket") } }); ```

Submitted May 15, 2018 at 08:18PM by krispey

What if JavaScript wins? – Anil Dash – Medium

https://ift.tt/2rJovX0

Submitted May 15, 2018 at 07:26PM by kapv89

Odd Traffic

So, I have a website I'm hosting on Amazon's EC2. The web site is written using Node.js and ejs views. This website is pretty much my resume, doesn't submit any forms or anything like that.I set up a logger to monitor traffic and I've realized that about twice per hour I get a visit to my homepage from an IP located in a foreign country.I realize that these are bots scanning different IP ranges trying to exploit different weaknesses but since my website doesn't deal with any user data and doesn't submit any forms is it still at risk?Here's the log after one night: https://ift.tt/2k0xsHh

Submitted May 15, 2018 at 06:16PM by UncleHoodie

Install packages in subfolders

I'm creating an api and i always use a single npm install in the parent folder and importing from there to the subfolders, it is good to install packages in subfolders? I mean having another node_modules, package.json in that subfolder.

Submitted May 15, 2018 at 02:57PM by gonzarodriguezt

Start – Functional tasks runner for Node.js

https://ift.tt/2wDw7PA

Submitted May 15, 2018 at 03:49PM by dpswt

Express.js Node.js & MongoDB - Free Udemy Courses - DiscUdemy

https://ift.tt/2rLo8ub

Submitted May 15, 2018 at 05:05PM by udemyfreebies

Passport.js Am I missing something?

So I've tried to implement Passport.JS and the docs are useless and it seems the only desirable feature it has is the ability to implement multiple different strategies. But beyond that it doesn't seem to make basic authentication any easier and is limited to nly handling authentication.Besides having multiple strategies available, am I missing something with it?

Submitted May 15, 2018 at 03:53PM by _--__--__--___-_____

API Gateway pattern

Anyone have any examples of implementing an API gateway (or backend for frontend) that I could check out? Not specifically AWS API Gateway, but rather how to architect a home-grown API gateway to other microservices in Node? I'm having trouble getting started.Nice to haves:Handling authenticationData transformation/aggregationI know how to do authentication and data massaging, I just don't know where to put it or how to structure it within my API gateway tier.Using Express.js

Submitted May 15, 2018 at 01:28PM by jsdotjs

Can we do something about the loads of trash article promotions that flood this sub?

They’re getting really annoying. Thanks!

Submitted May 15, 2018 at 12:55PM by OzziePeck

error connect ECONNREFUSED websocket

Im trying to build p2p server in node.js using ws package but after running $HTTP_PORT=3002 P2P_PORT=5002 PEERS=ws://localhost:5004 npm run dev i get an error :Listening on p2p port 5002 Listening on port 3002 events.js:165 throw er; // Unhandled 'error' event ^ Error: connect ECONNREFUSED 127.0.0.1:5004 at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1174:14) Emitted 'error' event at: at WebSocket.finalize (/home/ris/Desktop/gj- chain/node_modules/ws/lib/websocket.js:190:41) at ClientRequest._req.on (/home/ris/Desktop/gj- chain/node_modules/ws/lib/websocket.js:639:10) at ClientRequest.emit (events.js:180:13) at Socket.socketErrorListener (_http_client.js:395:9) at Socket.emit (events.js:180:13) at emitErrorNT (internal/streams/destroy.js:64:8) at process._tickCallback (internal/process/next_tick.js:178:19) [nodemon] app crashed - waiting for file changes before starting... I tried reinstalling dependencies,change ports, kill processes on all ports(3002,5002,5004) but it didnt work. I believe there is some dependancy mess, im using ubuntu 16.04 node 9.11 / npm 5.6.0 version.

Submitted May 15, 2018 at 11:34AM by z3xt4r

Need help understanding and converting synchronous dependant MySQL query code

Hello, this is my second Node project. I am using Node, Express, MySQL.What I am doing is, I have an array of names of users that have posted something, I then loop over those names and for each of them I do a connection.query to get their posts and I store those into an array(after that I do some other data manipulation to it, but that's not the important part)The problem is: my code tries to do that data manipulation before it even receives the data from the connection.query!I google-d around and it seems async await is the thing I need, problem is, the examples given are quite different from my situation and I can't really find code that fits my situation. // namesOfPeopleImFollowing is the array with the names namesOfPeopleImFollowing.forEach(function(ele){ connection.query(`SELECT * FROM user${ele}posts`, function(error,resultOfThis){ if(error){ console.log("Error found" + error) } else { allPostsWithUsername.push([{username:ele},resultOfThis]) } }) }) console.log(JSON.stringify(allPostsWithUsername)) // This is EMPTY, it mustn't be empty. So, how do I convert that into something which will work properly?(Incase you need the entire code, here it is: https://ift.tt/2jXQvSf though I forgot to uncomment the code)Thank you for your time.

Submitted May 15, 2018 at 10:59AM by khazha88

Is there a documentation generator that follows my project structure instead of forcing theirs? I’m creating an express.js API

AFAIK stuff like swagger want you to follow their way of thinking about a project structure, screw that, I came to node.js from ruby on rails to avoid that kind of shit.

Submitted May 15, 2018 at 11:16AM by zticky

Async & Recursive Function

Hey Folks!I guess i need your help now.Im writing a Script which goes through a order-file to determine a Folder structure to convert md files to a single pdf fileThese Files are in seperated FoldersFor Example/Guidelines/Guidelines/Javascript/Guidelines/C#etc.in all these Folders is a order File and markdown files which needs to converted into a single pdf file (In the Right Order of course...)My Problem right now is, the recursive function is written but it looks like - i cant get the right order because readline seems to put an whole array to my array and not line by linewhich results in a wrong order because folders get added first and in the end the subfolders...not /Folder and then /Folder/Subfolder but Folder, Folder, Folder... and then /Folder/Subfolder etc(Hope everybody understands what im trying to tell :D English isnt my native language)If someone could give me any hint, or want to see any code - feel free to ask :DEdit:CodePen: https://ift.tt/2rHLIIV CreatePDFFiles { constructor() { this.files = []; this.createFileArray(this); } async createFileArray(self) { await self._recursiveReadOrder(self); setTimeout(() => { self._createPDFFile(self.files); }, 5000); } async _recursiveReadOrder(self, orderFile = '.order', folder = '.') { let orderList = self._getOrderList(orderFile); await self._readOrderList(self, orderList, async (self, line) => { const newFolder = `${folder}/${line}`; const markdown = `${newFolder}.md`; self.files.push(markdown); if (self._isFolder(newFolder)) { orderFile = `${newFolder}/.order`; await self._recursiveReadOrder(self, orderFile, newFolder); } }); } _getOrderList(orderPath) { return readline.createInterface({ input: fs.createReadStream(orderPath) }); } async _readOrderList(self, list, callback) { await list.on('line', (line) => { callback(self, line); }); } _isFolder(folder) { return fs.existsSync(folder); } _removeDuplicates(fileArray) { return fileArray.filter((elem, pos) => { return fileArray.indexOf(elem) == pos; }); } _createPDFFile(files) { setTimeout(() => { const pdfname = files[0].replace('.md', '.pdf').replace('./', ''); markdownpdf().concat.from(files).to(`pdf/${pdfname}`, () => { console.log(pdfname, 'created'); }); }, 5000); } }

Submitted May 15, 2018 at 10:15AM by ToxicalToast

Static code analysis tools: code climate, sonar and others

Hey, I'm considering to use some code analysis tool in my project like code climate, sonar or any other. Did you try it and can share thoughts? does it provide enough value on top of ESLint?

Submitted May 15, 2018 at 10:34AM by yonatannn

Build a Daily Snapshot Service in 5 Minutes With StdLib and Node.js

https://ift.tt/2wDULzH

Submitted May 15, 2018 at 09:09AM by JanethL

ESLint custom rules and config for Node.JS

Hey, what ESLint configuration you use? any additional rules, config? airbnb? semi-standard? Mostly looking for things like 'eslint-plugin-mocha' that lint for Node-specific issues

Submitted May 15, 2018 at 07:24AM by yonatannn

Monday 14 May 2018

We’ve watched Google I/O webdev talks and chose the best ones, here’s the list!

https://ift.tt/2Ij92ac

Submitted May 14, 2018 at 09:24PM by ab-azure

AWS Lambda Internals — Part 2: Going Deeper

https://ift.tt/2jTgISa

Submitted May 14, 2018 at 08:04PM by ranrib

Basic questions regarding token authentification (restful API, JWT)

Axyos in 2018

Hey guys, so, to put it short, any specific reason to use Axyos instead of Request-promise in 2018? Axyos looks very popular so i'm tryng to understand if im missing out by not using it. Request-promise looks so simple and powerful to me.

Submitted May 14, 2018 at 07:12PM by Pelopida92

Which JavaScript open source projects had the biggest impact this year? 🤔

https://ift.tt/2IDNZPb

Submitted May 14, 2018 at 05:37PM by FrontendNation

Is this a terrible implementation?

Hi there!So I'm making my first own project with Node js for a while and I wanted to know if how I'm doing it is ok or a crime against nature. I'm loading lot's of different react components and they all fire off requests as you can see in the screen shot bellow?https://ift.tt/2KX4ZOy this OK or am I better off using one big request and manipulating the page after with getElementById e.c.t.?Thanks, Ed.

Submitted May 14, 2018 at 03:23PM by thelynched

New To Node

Hi Everyone,I have decided to move from Django to Node, anyone got a good place to start. Maybe some tutorials or something I can follow to get started with?Thanks.

Submitted May 14, 2018 at 04:20PM by Nadnerb93

Node.js Tutorial For Absolute Beginners - Free Udemy Courses - DiscUdemy

https://ift.tt/2IhMfaV

Submitted May 14, 2018 at 04:31PM by udemyfreebies

I released shortcutd, a daemon that launchs commands when pressing keys combinations. Works without graphical env. Support keyboard hotplug

https://ift.tt/2rzFn1n

Submitted May 14, 2018 at 03:36PM by tiben_

100% Native Mac App to evaluate Nodejs code snippets from menubar!

https://ift.tt/2KYvymI

Submitted May 14, 2018 at 01:51PM by vsaravind007

Cannot set a cookie through express on Heroku

I have a react app and a nodejs server running both on the same heroku account under different subdomains;server.herokuapp.com reactapp.herokuapp.com I post username and password data to nodejs server through axios in react app.axios.post(`${server.url}/login`, {email, password}, {withCredentials: true}) In the nodejs server, I use express along with cors middleware.const origin = 'https://ift.tt/2wGqKiz' let app = express(); app.use(cors({credentials: true, origin: origin})); Nodejs server gets the data from the client (reactapp) and sends it to another remote server. The response from the remote server is a sessionid that I have to use to create a cookie with.loginOptions = {...some information for the remote server} app.post("/login", (req, res) => { request(loginOptions, (error, response, body) => loginCallback(res,error, response, body)) }) const loginCallback = (res, error, response, body) => { cookieData = setCookie.parse(response.caseless.dict['set-cookie'][0]); const {name, value} = cookieData[0]; res.cookie(name, value).send('CookieSet') } This just works fine on localhost.However, on Heroku, I cannot set the cookie. I get the sessionid and everything from the remote server in accordance with the username and password but setting the cookie is the problem.

Submitted May 14, 2018 at 02:20PM by eligloys

Classcat is a JavaScript function for conditionally concatenating CSS classes (smaller & faster than the popular alternative).

https://ift.tt/2KXaltc

Submitted May 14, 2018 at 01:33PM by JorgeBucaran

How to pipe curl into tar with node spawn

Hi guys,Im currently trying to write some function which will recive some http link and download that .tgz archive with curl and pipe it to tar which will process it. For now i have this codeconst { spawn } = require('child_process') const curl = spawn('curl', ['-s', 'some_http_link','--output','-']); // pipe pachage to stdout of curl process const tar = spawn('tar', ['-xz', '-O', 'folder/some_json_object']); // spawn tar process which should unpack curl and output data to stdout curl.stdout.pipe(tar.stdin); // pipe curl stdout to tar stdin console.log(tar.stdout); // print data (i guess) This returns some errors pastebin link hereAny ideas of how to resolve this?Bottom line, i dont want to start process with exec, i want to avoid shell. I know i can do shell one liner withcurl -s link | tar -xz -O thing_i_need.json and it will print content of thing_i_need.json to stdout, but want to avoid it. Thanks!

Submitted May 14, 2018 at 11:36AM by p3numbra_3

Fat binaries or containers for distribution?

I am thinking through distribution options for an application I'm working on. It uses SQLite in its default configuration, with the option to use PostGreSQL. This article argues that Docker is a band-aid for older scripting languages (PHP, Ruby, Python) that rely on OS kernel services for concurrency ("threads drool, processes rule!"), and that the future belongs to languages designed to compile to no-dependency binaries for distribution (Go, Rust, even Java as with version 9, the runtime can be bundled with the app).I've been thinking about how Electron handles its bundling, including a Node runtime and Chromium in the distribution package. The downsides for Electron (very heavy apps) don't apply as much to my n-tier web application. I am thinking of distributing it as a stand-alone binary, with the Node runtime included, and other external software bundled (SQLite, Solr, and Git).Is anyone else doing something like that, or have an opinion on it?

Submitted May 14, 2018 at 11:56AM by calligraphic-io

Node.js Tutorial For Absolute Beginners

Hi Guys This Udemy Course Free Today For limited time. I hope you like it.It is a great course[100 % OFF] 😀★😀 Hurry [100 % OFF]Node.js Tutorial For Absolute Beginners✅ Learn nodejs with V8, Express, core JavaScript concepts, and more.➡️ What Will I Learn? ✔️Create an Awesome websites and web applicationshttps://deal5star.com/node-js-tutorial-for-absolute-beginners-2/

Submitted May 14, 2018 at 12:46PM by EdwardSchmitt21

Full guide to developing REST API’s with AWS API Gateway and AWS Lambda using Node.js

https://ift.tt/2Ko4XhP

Submitted May 14, 2018 at 01:07PM by 4DaftPanda

Need help with querystrings and Mongoose

Hi! Anyone have any general advice for handling querystrings like this?/calculatePrice?id[0]=123&qty[0]=1&id[1]=xxxx&qty[1]=3` I’m having difficulty creating a query object to work with Mongoose.

Submitted May 14, 2018 at 10:18AM by akynde

How To Hire The Best Node.js Developer?

https://ift.tt/2IzWvyC

Submitted May 14, 2018 at 09:58AM by SweetRaccoon

express + mssql // question about the streaming logic in general. I can't find a lot of material about it neither any good examples

Hi guys, as the title implies, I'm building a restful api with node, express, mssql and tedious. I was looking into the streaming method and I've found there's not a lot of documentation or information about it out there.I just don't necessarily understand the logic behind it/how to use this in the end application.My personal use is with power BI to get data from the streaming endpoint and have some live/continuously updating tiles.Is there any good documentation on the concept out there? even if just for express itself which better explains how the streaming can be used.

Submitted May 14, 2018 at 08:57AM by rickydbz

Sunday 13 May 2018

index.js automatically found. Is there a list of file names Node automatically finds?

I accidentally wrote out a command on my compy without pointing directly to node /folder/index.js and just wrote node /folder/ and voila, it still ran the right script. Is there a list of file names that node automatically finds, or is index primarily it?

Submitted May 13, 2018 at 10:58PM by ms_nitrogen

Alternatives to Cheerio for webscraping?

I don't want to use jQuery syntax to select DOM elements. Is there anything else available which sticks to ordinary JavaScript syntax?EDIT: Found jsdom, which is just what I'm looking for.

Submitted May 13, 2018 at 09:43PM by koenigsforst

Using Skaffold and LocalStack to Develop Cloud Applications Locally

https://ift.tt/2KgDOxi

Submitted May 13, 2018 at 06:59PM by gorgerson

Set up server, localhost not recognizing javascript/css files

Hey everyone! Started digging through node yesterday because I wanted to work with an API for this small web app I want to make. I can get the API data fine through node and understand using sockets to transport that data, but I am having issues now when I run my index.html through localhost:8080, my issues through the console are:Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://localhost:8080/style.css".Uncaught SyntaxError: Unexpected token < jquery.csv.js:1Uncaught SyntaxError: Unexpected token < client.js:1The client.js is where I have all of my jquery/js and jquery.csv.js is a library Im using to easily parse csv files (which is what I need for this project).Does anyone have any idea what's going? I've been working on this project all weekend and have searched stackoverflow endlessly. All of these files are within the same directory. This is how I set the external file links in my html:I have also tried appending http://localhost:8080/ to the front of the scripts/css but that hasn't worked as well. Please help this noob get over this hurdle lol, any help would definitely be appreciated.For reference, my server file's code: https://ift.tt/2IBi2XU

Submitted May 13, 2018 at 05:35PM by enebeme_

Nest 5: The official release 🚀 Node.js in 2018

https://ift.tt/2KljcUD

Submitted May 13, 2018 at 02:37PM by mysliwik

Need projects to collaborate

Hi,I have been learning node for the past two months and learned all the basics and did some basic projects. I want to work on some medium to large projects. I don't have a project idea but I would like to contribute to other projects. I have 2 years experience as java developer and now started node also. Please anyone having node project in development, I am happy to help.Thanks

Submitted May 13, 2018 at 02:43PM by pragmaticpi

Handling forms & data WITHOUT frameworks - nodejs

Good afternoon from back here, folks! I'm kind of stuck on this thing here. I've been searching for a long time for something pretty basic, and I haven't found a single result that helps me. Uh... I don't know if this or r/learnprogramming is the better place to post this, so I'm posting it in both.Basically, I want to handle forms using the default modules, without installing new frameworks. I started learning nodejs about sometime ago, and I decided to 'learn by doing', you know - create a message-board-ish thing - and ran into the first obstacle: forms. I don't know express, and every single tutorial for form handling I look at keeps using express.app.get.post or whatever.So if someone has a tutorial or a helpful handful of words or something, it'll help loads. Right now, I have a server listening for GET request that serves a form, but doesn't do anything with it. Please? I desperately need to know how to handle form data witohut frameworks.I have this idea of splitting the url with request.url.split("&"), but that only works for GET, and doesn't tell me how to send the ofrm data to my server. Please help, guys? Thanks thanks thanks so much!

Submitted May 13, 2018 at 01:05PM by OrochimarusCthulhu

Which is the faster map(), Lodash or ES6?

https://ift.tt/2GblK55

Submitted May 13, 2018 at 09:02AM by bananajsjs

Saturday 12 May 2018

Should I be using Koa over express?

I've only ever used express and I am quite familiar with it but nowadays I see articles popping up about Koa alot.Has most of the community transitioned to Koa ? Does Koa have a large ecosystem yet?Where does Koa stand altogether is what I'm asking actually.

Submitted May 12, 2018 at 10:43PM by TG__

Need help with using my .ENV file (Mocha / Selenium/ Node)

I have been trying to set up and use my .env file forever now and I'm just wasting time. Would someone here be willing to walk me through setting it up? I've seen every webpage regarding it (please, no need to link to online how-to's, I've read them a few times over) and I still can't get it to work properly. I'm a noob and am doing my best to learn but am at a stopping point until I get some direction. Any help would be great - please DM me and I'll share my repo. A million thanks and happy day to you all.

Submitted May 12, 2018 at 09:42PM by Whatsamattahere

Need help with my "YouTube like app"

Hi guys. I need a help with my NodeJS project. I'm making a little like youtube app for educational purposes.On front-end I use: VueJS + Vuetify + Vuex (for states)On back-end I use: NodeJS + Express + PostgresSQL DB (Sequelize for query handling)also some little features like Webpack, bodyparser, morgan, etc. (but it doesn't matter now)The main questions now related for my video model. I created some Video model with fields: author, title, views, likes, dislikes, description, uploadDate...How should I do the video files storing to be able to divide access to videos on private/public (the same like on YouTube)?How can I pass videos to front-end and play them on the GET /watch?video-id=some_id ? (also I wanna load it by parts like on YouTube: 5-20 seconds downloaded and video starts to play)I'm a noob in full-stack web-dev so sorry for my maybe stupid questions for NodeJS. Thank you

Submitted May 12, 2018 at 09:54PM by moonkeeep

Need help to write mocha test

I built a small module which performs buffering, and once the whole data is received from the server, it emits a message to the client. The code:const EventEmitter = require('events').EventEmitter; class LDJClient extends EventEmitter { constructor(stream) { super(); if (!stream) throw new Error('"stream" can not be null'); let buffer = ""; stream.on('data', data => { buffer += data; let boundary = buffer.indexOf('\n'); while(boundary !== -1) { const input = buffer.substring(0, boundary); buffer = buffer.substring(boundary + 1); try { this.emit('message', JSON.parse(input)); } catch(e) { this.emit('message', { type: e.name, message: e.message }) } boundary = buffer.indexOf('\n'); } }); } static connect(stream) { return new LDJClient(stream); } } module.exports = LDJClient; And the client which exported this module looks like:const netClient = require('net').connect({ port: 6000 });; const ldgClient = require('./lib/ldj-client.js').connect(netClient); ldgClient.on('message', message => { if (message.type === 'watching') { console.log(`Now watching: ${message.file}`); } else if (message.type === 'changed') { const date = new Date(message.timestamp); console.log(`File changed: ${date}`); } else { console.log(`Unrecognized message type: ${message.type}`); } }); I am writing test and improving the code LDJClient as author asked in his book. I need some help to implement the below 2 cases to augment the LDJClient class.What happens if the last data event completes a JSON message, but without the trailing newline?Write a case where the stream object sends a data event containing JSON but no newline, followed by a close event. A real Stream instance will emit a close event when going offline—update LDJClient to listen for close and process the remainder of the buffer.My test looks like so far:const assert = require('assert'); const EventEmitter = require('events').EventEmitter; const LDJClient = require('../lib/ldj-client.js'); describe('LDJClient', () => { let stream = null; let client = null; beforeEach(() => { stream = new EventEmitter(); client = new LDJClient(stream); }); it('should emit a message event from a single data event', done => { client.on('message', message => { assert.deepEqual(message, {foo: 'bar'}); done(); }); stream.emit('data', '{"foo":"bar"}\n'); }); it('should emit a message event from split data events', done => { client.on('message', message => { assert.deepEqual(message, {foo: 'bar'}); done(); }); stream.emit('data', '{"foo":'); process.nextTick(() => stream.emit('data', '"bar"}\n')); }); it('should finish within 50 mili-seconds', done => { setTimeout(done, 40); }).timeout(50); it('should throw error when null is passed to the constructor', done => { stream = null; assert.throws( () => { new LDJClient(stream) }, { name: 'Error', message: '"stream" can not be null' } ); done(); }); it('should emit error message when incoming data is not properly formatted json string', done => { client.on('message', message => { assert.deepEqual(message, { type: 'SyntaxError', message: 'Unexpected end of JSON input' }); done(); }); stream.emit('data', '{"foo":"bar}\n') }); it('should throw error when received data is not JSON', done => { client.on('message', message => { assert.equal('SyntaxError', message.type); done(); }); stream.emit('data', '\n'); }); }); Can anyone help me to solve this?

Submitted May 12, 2018 at 12:02PM by arup_r

Passwords hashing done the right way

https://ift.tt/2KT5BVs

Submitted May 12, 2018 at 08:19AM by indeyets

Friday 11 May 2018

Nodejs Race condition handling in Ecommerce Website.

Suppose there are two users A and B making a purchase in a E commerce website at a time.A sees the product quantity is more than 1, so in order to lock the product quantity ( temporarily reduct the product quantity to zero) He makes a call to mysql module and this results in waiting for a callback function !!During this time B sees the product quantity as 1,he too locks the product and the entire product quantity changes to -1;How to handle this case in Nodejs ? So that Only A completes the transaction sychronously and B gets a message that product is out of stock.

Submitted May 11, 2018 at 10:43PM by a_naidu

Can i use global variables to store data?

I'm new at Node Js and i was wondering if is it correct to use a global variable to store some users data? i have a function that returns user information from a database so i decided to create a variable where stores users previously requested. Is that right or is a sin as a programmer?

Submitted May 11, 2018 at 11:11PM by silvaF

Newbie question: REST API scaling

Hello fellow programmers,I'm new to NodeJS and am trying to figure out if Node is a good choice for my project.My current plan is to use:MySQL DBNode REST API(s?)ReactJS frontendAs I've been researching across the web about Node and how it compares to Ruby/Python/PHP, it seems that a possible pain point is that Node could have slower performance at scale? Since it only allows a single operation to happen at a time while other incoming requests wait in a queue, if I understand correctly.The system needs to be able to handle roughly 10,000 daily users, and a key objective is fast response times.Is Node a good choice for this? Some of the common advantages seem to be ease of programming since it's JS, but that isn't important to me since I have plenty of time to make this, and am language-agnostic in terms of personal preference.Thanks for reading this :) have a great Friday night and I look forward to hearing your expert opinions!

Submitted May 12, 2018 at 12:39AM by WildBattery

Do you eat Domino's pizza? I have written a script that wins Domino's games to get you the biggest discount [UK]

// get-voucher.js const fetch = require('xfetch').default; const CookieJar = require('xfetch').CookieJar; (async () => { /** * Get the highest prize from Domino's Wild West Wondershot. * * @see https://ift.tt/2jRhfEg */ const jar = new CookieJar(); await fetch('https://ift.tt/2GbEVMk', { jar }); const prizes = await fetch('https://ift.tt/2jOK8Rj', { jar, responseType: 'json', headers: { referer: 'https://ift.tt/2GbEVMk' } }); console.log('prizes', prizes); const code = prizes[prizes.length - 1].unique; await fetch('https://ift.tt/2G9lKT8' + code, { jar, headers: { referer: 'https://ift.tt/2GbEVMk' } }); const response = await fetch('https://ift.tt/2KTK3Ik', { jar, headers: { referer: 'https://ift.tt/2G5kxfH' } }); const start = '
'; console.log('Voucher: ' + response.slice(response.indexOf(start) + start.length).match(/[A-Z][^<]+/)[0]); })(); To run it you need to install xfetch, i.e. npm install xfetch && node get-voucher.js.Gives you 35% off Dominos pizza.I have been using it for a long time... decided that for my own personal health's sake it is better if I share it and Domino's discontinues it. :-)

Submitted May 11, 2018 at 11:18PM by gajus0

Confused about function output ...

When I do the below I get the needed list of clusters ...var ecs = new AWS.ECS({'region':'us-east-2'}); var params = {}; var results = ecs.listClusters(params,function(err,data){ console.log(data); }); When I do the below ...I get a whole dump of info that has nothing to do with the data ...var ecs = new AWS.ECS({'region':'us-east-2'}); var params = {}; var results = ecs.listClusters(params,function(err,data){ return data; }); I'm totally confused ...

Submitted May 11, 2018 at 08:17PM by sethrei

Piped buffer disappears when program terminates; is this a known bug?

I have described the issue in the following Stack Overflow question, https://ift.tt/2G8ayGv short, if you execute:node --eval "let index = 0; let output = ''; while (index < 1000000) { output += ' ' + (index++); } console.log(output); throw new Error('test');" | cat The program's last output is 12773 when the expected output is 999999.Execute it without pipe and you will get the full output.Where does the buffer disappear?

Submitted May 11, 2018 at 07:28PM by gajus0

Favorite Node.js framework poll for web server development (school project)

https://ift.tt/2jQ6j9R

Submitted May 11, 2018 at 06:02PM by nejcn001

FIX protocol and Node.js?

Hello guys, has anyone been working with FIX protocol and Node.js? I cannot seem to find the proper library to connect to a certain FIX server. I tried this one - https://ift.tt/2KUMSsT but it just won't compile. There's already an open issue for a month about it, but nothing is happening on fixing it. I also tried https://ift.tt/1ZaZuhe - but just couldn't send Logon message ...I'v never done anything related to FIX before, so maybe I'm just doing something wrong ...

Submitted May 11, 2018 at 03:27PM by sessionspade