Wednesday 31 October 2018

Why is adding a package to the root package.json for in a yarn workspace bad?

I have struggled to find an answer, i just see people constantly say "its bad" with no real reason for why it is bad.Basically my question is like so, we have a bunch of common modules that all packages require (e.g. chai/mocha/typescript). So why is it a bad idea to add it to the root package.json for this library?From my understanding of how hoisting works, they will just end up bubbling up to the top anyways. So wouldn't it be better to globally lock the version of the library across all packages?

Submitted November 01, 2018 at 06:22AM by frankimthetank

Useful utilities for working with teams?

Hey guys,​so I was wondering what sort of utilities people use in their projects when working in teams. I'm currently in the middle of setting up some CI/CD systems for a few projects (all Node) and I've so far looked at and considering:HuskyGoogle ts-styleCommitlintAnyone got any other suggestions? Thanks!

Submitted November 01, 2018 at 05:04AM by acylus0

10 Reasons that Make Node.js a Top Choice for Web Application Development

https://ift.tt/2n6qEMF

Submitted November 01, 2018 at 05:22AM by mydevskills

express post data is empty

using body-parse as found in tutorials

Submitted October 31, 2018 at 10:06PM by Walf9

The next-gen math library written in Node.js - add-two-numbers

https://ift.tt/2CUV6Q8

Submitted October 31, 2018 at 08:25PM by SentialX

Cannot create a database locally on mac

ETH wallet generation

Hi guys, I would really appreciate a second opinion on the following ETH wallet implementation on client-side https://ift.tt/2RlHNvK in advance.

Submitted October 31, 2018 at 04:54PM by doomhz

If I need to spread an increasing large amount of tasks over a few servers, should I spin up a bunch of VPSes and add keep adding more? Or is there like a cloud scaling service Amazon offers or something?

I need to do a bunch of HTTP requests and then a bunch of processing of the resulting data. It gets quite intensive, to the point that I can't reliably do it on one server anymore, so I created two more Linode VPS in addition to the main one to spread the work load over.The work is basically the main server sends a bunch of commands to the other servers to do, which includes an HTTP request and what to do with the results, then the other servers perform the fetches, manipulate the data then store it in a central database.This is working now but the work load is increasing and I'll need to spin up another VPS soon, and the configuration is kind of annoying.Is there a better way to do this? An automated way to create more servers as needed that isn't super hard to understand? Creating new VPSes is easy just time consuming.

Submitted October 31, 2018 at 02:41PM by canucktesladude

Upload a file using Express - Nodejs ... check it out ...

https://ift.tt/2AEqTDc

Submitted October 31, 2018 at 02:13PM by net-raft

AWS Lambda Programming Language Comparison

https://ift.tt/2qlYT12

Submitted October 31, 2018 at 12:20PM by nshapira

Tuesday 30 October 2018

[HELP] How to check if an email is already registered in KOA with TypeORM?

This is my attempt:​``` export async function crmSaveAction(context: Context) {const crmRepository = getManager().getRepository(CrmEntity);context.body = context.request.body; const { email } = context.body.email; const data = context.request.body;const contactToBeSaved = await crmRepository.findOne({ where: { email }, })console.log(>>> Body here: ${context.body}); console.log(>>> Email here: ${email}); console.log(>>> Params here: ${context.params});if (contactToBeSaved) { context.body = Email already registered! }const newContact = await crmRepository.create(context.request.body);await crmRepository.save(newContact);console.log(newContact);context.body = newContact;} ```​In console:​>>> Body here: [object Object]>>> Email here: undefined>>> Params here: [object Object]​But it does nothing and duplicated emails are registered. Please help.Full code's here: https://ift.tt/2RrTtxi

Submitted October 31, 2018 at 04:59AM by xzenuu

NPM package wrapper for OpenAPI Generator available

This package https://ift.tt/2SvemZD will wrap the *.jar binary from https://ift.tt/2jT806l into an NPM package to make the usage in NPM/Node.js® projects much more easier.

Submitted October 31, 2018 at 01:08AM by harmowatch

Awesome Node.js Security resources

https://ift.tt/2qkfpi9

Submitted October 30, 2018 at 10:02PM by ecares

Nodejs, express and mongo api with chat

Hello guys, im working on an api that returns a list of ads for pet adoption, i can add new ad and return a list of ads, theres a lot of work to do, like auth with jwt and etc. I want to create a chat where the users can chat about the adoption, i saw that i can use websockets, can you give me some tips about it? Dont know how to put all of it togetherThanks.

Submitted October 30, 2018 at 06:39PM by Dantharo

loadtime - Measure how long it takes to load an npm module in node

https://ift.tt/2zd8dIR

Submitted October 30, 2018 at 06:57PM by dankalen

Tutorial - Create a hapi.js webhook to receive a SMS when someone submitts your Typeform

https://ift.tt/2OgCsUA

Submitted October 30, 2018 at 07:07PM by panthera_services

Problems with npm pack and npm install on CI server

I have a mono-repo with one main project, and a few supporting libraries that are separate packages. For the build process, we build the dependent projects then create tarballs with npm pack. Then, in package.json, we reference these tarballs like so:"library-one": "../library-one/library-one-0.2.1.tgz" This works great locally, the main application builds and runs like we'd expect. In this case, "locally" means on a MacBook Pro laptop.We also have a Drone CI server, and here is where I'm running into problems. The dependent projects build and pack fine, but when npm install is run in the main application, it blows up:Unhandled rejection Error: Integrity check failed: Wanted: sha512-rawpC6gbisQra9xbfsqxto/qfplJV2PzH0l5rFqT4E2PH60y7D1gmTXMzUVRaU6AyXzDtBY5gNYxgbA7pecx9g== Found: sha512-LvdlBy/rJnXZPcRc3f/ED2Spfq8vzw4LtZVNYHyWYt51jJGJMge2Yam6xaf/cqEkHqeOIR/k6RFSSdta6TM0cQ== Checking package-lock.json, I can see that the failed integrity checks are for the two dependent projects. I can't for the life of me figure out why the tarball would have a different sha512 on a Linux Drone server vs. a macOS laptop.Anyone ever run into something like this before?In case you're wondering why I am using npm pack: We are currently using yarn, and in package.json we refer to the dependent projects just by their directories, e.g.:"library-one": "../library-one/dist" When running npm install, yarn copies the ../library-one/dist folder into node_modules and everything works great.Trying to switch to use npm instead caused an issue. With npm, the relative path causes a symbolic link to be created instead of copying the directory. Which would normally be fine. Except, the main application is an Angular 6 app. For some reason I still can't figure out, when the dependent projects are symlinked, the Angular build fails horribly. That's a whole other issue.So the only solution I could find was to use npm pack to package the dependent projects up into tarballs, so that npm install would extract them into node_modules, effectively creating a copy of the directory.Edit: I should mention that I made sure I am using the exact same version of node and npm on my laptop that I am on the Drone CI server.

Submitted October 30, 2018 at 07:34PM by thinksInCode

Slonik (v7) A Node.js PostgreSQL client with strict types, detail logging and assertions.

https://ift.tt/2AB3oeg

Submitted October 30, 2018 at 05:18PM by gajus0

Using exec curl to retrieve a comic or a web search

Hello, I am learning node.js, and I am writing a program and I am stuck. I need to create a proxy server that has three basic functions, retrieve a comic from dilbert.com, retrieve a websearch page from duckduckgo.com, and a private file server. I have the server set up and got the file server running, but I am supposed to use exec and call the curl function to be able to download the comic or the web search. I have no clue how exec curl works with servers, so what would be the best way to get the .gif file from the comics and the text from the webpages, onto my server using response.write() or end()? (using the http://dilbert.com for the current comic or https://ift.tt/2RnJAAq for specific date, and then https://ift.tt/2PACFac, where the specific dates and search terms are specified by the inputed url)

Submitted October 30, 2018 at 05:05PM by TGoldie44

Best practices TDD for RESTful API

I am currently in the process of developing an API for a blog server using NodeJS. For this project I will be using the following stack:NodeJS 10 LTSTypescriptPostgreSQLRestify or ExpressKnexJSI've got the whole plan worked out, except one thing, writing tests.For this project I would like to use the TDD approach, but I can't really find the best practices for this.It should be possible to run the tests using a separate database locally (not the local dev DB), and run the tests using GitLab CI within Docker.The NodeJS app will serve only as the middleman for reading posts, authors etc. using a public API endpoint, and as a protective layer to protect the protected API endpoint (for placing new posts, deleting them, etc)My question is: what would be the best and cleanest approach for this? And what kind of tests should be written?Thanks in advance.

Submitted October 30, 2018 at 05:10PM by lucianonooijen

webrtc signal solution with primus

https://ift.tt/2Jps0cV

Submitted October 30, 2018 at 04:21PM by indatawetrust

Question about async/await

Node v10.13.0 (LTS)

https://ift.tt/2zniG4H

Submitted October 30, 2018 at 10:51AM by dwaxe

Monitor large files efficiently (REST API)

Hey,I'm working on a project, which consists of the following components:- Backend(node.js)- Frontend(react.js)Furthermore I'm about to write a REST API in C#(.NET Core), which will be distributed among a few clients. The REST API should monitor a few system properties: windows services, disk space, currently running processes, RAM etc. and send back the data to the requester. The requester in most case will be the backend, which accesses the REST API endpoints and stores the responses in an POSTGRESQL database.To simplify this: Accessing the frontend and requesting current system information about a specific system (a system in this case is just a Windows Server, which I want to monitor), should result in the frontend communicateing with the backend, to request up to date system information from the systems REST API. The backend proceeds the requests by making requests to the specific systems REST API. The response gets stored by the backend, as well as proceeded to the frontend.So far everything works fine. Now I want to monitor files, e.g. logs, on any system. The challenge I'm facing is how to approach this. I want the REST API to be as slick and small as possible, leaving as less as possible footprints on any system. Given this, monitoring, or just filtering for reg. expressions, via the REST API(on the systemside/clientside) and sending back the results doesn't seem efficient to me, since it can put a lot of stress on the system. On the other hand, I could simply create a REST API endpoint to transfer the file via a decoded stream, encode it on the backend and filter the file on the server. This seems reasonable to me.However I have files which can be up to 400 MB. Any recommendations how I should deal with them?This is my first bigger project, feel free to correct me on my ideas and thoughts. Please! :)

Submitted October 30, 2018 at 09:04AM by Fasyx

A mail system that sends at different times, for different users?

Has anyone built anything like this? I'm looking at 20 to 50 users that each have their own settings for when they want to receive our daily email. Do you run a cronjob every hour to check who needs sending? Or what's a good way to think about this?

Submitted October 30, 2018 at 06:06AM by vospit

How to expose a class via custom module?

Is it just:class myWhatever { ... } exports.myWhatever = myWhatever; ?EDIT: Figured it out. The answer is yes. Make sure you use the module.class in the instantiation, e.g. :var wev = require('mywhatever'); var whatever = new wev.myWhatever();

Submitted October 30, 2018 at 06:09AM by poor-toy-soul-doll

Generate Stripe Coupons via Slack Commands using Node.js and Code on Standard Library

https://ift.tt/2PBPbGt

Submitted October 30, 2018 at 06:56AM by LibProgrammer

Monday 29 October 2018

Params are a little weird

I am using the modules express and pug and i am trying to create a form from one HTML page to another, but when I do submit my form the URL is all weird and it doesn't form the URL properly.My node get is something like this: app.get('http://name/:summoner') buy my form makes the URL like this '(http://name/?summoner=vi) so it never reaches the code. What am I doing wrong?Thanks

Submitted October 30, 2018 at 04:44AM by ultramegaman479

Any good books, tutorials, articles, or anything else to read/watch that you guys can recommend me to improve my tests?

I started my first job as a developer 3 months ago, I’m just part time rn as I’m finishing school in December but the developers I work with write tests for our projects and I kind of understand the tests they write but I don’t have a great understanding of how to start writing tests for my code, they use mocha, and I’ve seen YouTube videos so I know how to use mocha for testing but I’m not sure how to use it to test my stuff.

Submitted October 30, 2018 at 02:40AM by Cgnrivera

Integration testing: how to achieve both reasonable performance and clean design?

I'm Testing some casual microservice with some business logic and also database, have unit tests but this questions is focused on the integration/component testing that involves DB: how do you manage the DB state to achieve both reasonable performance and simple design? Should I fully isolate each test case, reset the entire DB before starting each test and set the state within the test (e.g. fill records) - I may reach a clean design as each test is autonomous but the performance is really bad. On the other hand, if my tests share the same DB state then they become tightly coupled and steps on its other toes. How would you mitigate this? any related tips/best practices are appreciated

Submitted October 29, 2018 at 10:31PM by poothebear0

How can I pass data from the frontend to the server?

Context: using Pug, making a Peer Review thing for school.When a student begins to take a review, we pass pug the questions and the assignment ID and they fill in the answers and send them back. I've got the first part down, but two things:How does the frontend track the assignment ID? Should I make it part of the submission URL or something? ie POST /assignment/:id/submit when the review is doneWhat's the best way to pass answers back? I feel like form-url-encoded is an odd choice for something like a review with free response questions. JSON would be nice, but how do I get the front end to send it all back as JSON? My first instinct is to have a submit action script that just gets references to each input field and constructs a JSON object and sends it back. Seems tedious, is there a better way?

Submitted October 29, 2018 at 09:52PM by ThePantsThief

Forever... 🤣

https://ift.tt/2DbJJUQ

Submitted October 29, 2018 at 07:15PM by EvilPencil

Some weird guys neds the help in mongodb thread.

Don't mind me, just troll scountin'.https://ift.tt/2Dc3A6l

Submitted October 29, 2018 at 04:13PM by _woj_

Integrate NextJs and Nestjs into a fullstack app

I made a package that allows for you to integrate server side rendering via Next into a Nest application. This is the first public package I have ever made and would appreciate any feedback, especially around documentation.- Github- NPM​At a high level, I created a module for Nest that allows for you to bind the Next app which then overrides the default `@Render` decorator to allow for rendering of react pages.

Submitted October 29, 2018 at 03:07PM by kyle787

I'm not sure I understand migrations in KnexJS.

So I created a migration with knex migrate:make create_tables, and whenever I update my DB structure, I do:knex migrate:rollback knex migrate:latest Which makes me lose whatever values were in the table, but that's fine. I can just seed a few dummy rows in there no problem.Should I keep everything in one migration file? Should I make a migration file every time I want to add a table, or tweak a table?I'm working on a 6-month long project, and I'm in the beginning stages now, so I'm always editing the DB structure little by little.

Submitted October 29, 2018 at 02:12PM by v_95

My Journey to Achieving DevOps Bliss, Without Useless AWS certifications

https://ift.tt/2zcOYza

Submitted October 29, 2018 at 02:15PM by patrickleet

Update only specific field in mongodb

Hello,I am trying to update a specific field of an item in Mongodb. I am working with mongoose and have a Schema for the specific item.My patch command looks like the following: Item.update({_id: id}, { $set: {"name": req.body.name, "amount": req.body.amount, "done": req.body.done, "description": req.body.description, "unit": req.body.unit }}) After Updating for example amount with the following POST{ "done": true } All other fields not specified in the POST-Json Body getting "null"{ "_id" : ObjectId("5bd70548053851675db312c9"), "done" : true, "name" : null, "amount" : null, "description" : null, "unit" : null } What am I doing wrong? I thought the $set param would make this possible.

Submitted October 29, 2018 at 01:10PM by Sp1xx

Pennywise – Application to open anything in a floating window

https://ift.tt/2JmjCdP

Submitted October 29, 2018 at 09:50AM by kamranahmed_se

Importing an external JavaScript library from a URL in a node.js server

Hey guys, I'm currently developing a REST-API using node.js, which needs two external JS-scripts from a URL for the application logic / algorithm, both in the format of .min.js. Until now I have found 2/3 potential solutions with their own problems:​By using 'http.get' in the script to import them, but it didn't work since it seems the command will import the .min.js in an HTML-format. => Error: , 'SyntaxError: Unexpected token <'By manually saving both .min.js files locally and importing them to the node.js script using imports() function from node-import, but it also didn't work. => Error: 'ReferenceError: window is not defined'Again, saving the files locally, and importing them by using var js1 = require('example.min.js'); and running them by using eval(js1); , which also didn't work, I suppose since they're minified JS. => Error: e is not a constructorIs there anything else I haven't tried, or perhaps is there any workaround to make one of the solutions I've found work?Thanks!EDIT: I'm using LoopBack framework for the REST API.

Submitted October 29, 2018 at 09:54AM by xypherifyion

Handling Like Button in NodeJS

I'm planning to build a like/upvote button in my chat app, that has to be real time so I thought I'd do it with socket.io, and I just wanted to know if I have to persist the who liked what data in my database and also show the number of likes on the post, should I do it with two different queries, is there a good article / tutorial on best practice of making a like button.

Submitted October 29, 2018 at 10:13AM by waybovetherest

Noob on testing, what should I test for?

I've read a bunch of stuff and watched a bunch of videos and everyone says talks about writing your (failing) test first, before making one line of code. Then write your unit to make the test succeed. Ok good. But what should I test for?All the examples that I saw do something like this. Suppose I need a function that sums 2 numbers.First thing we should write the failing test. Something like this:var res = sum(2,3);expect(res).to.equal(5);Then write the function:function sum(x, y) {return x + y;}Now the test would succeed. But is this enough? Is that it?Shouldn't I test, for example, for wrong argument types? What if someone passes 2 strings instead of 2 numbers to the function? What about arrays? Or Objects? Should I test for that case (and expect an error or something like that)? Where and when do you stop?

Submitted October 29, 2018 at 09:08AM by honestserpent

Sunday 28 October 2018

Physics Engine with Node

I have decided on offloading computation heavy part of my game to C++. Main reasons are speed and more resources when it comes to physics engines.I need recommendations moving forward. Should I use addons to use it? Or should I have them communicate via sockets? Sockets most likely be easier, but slower. Is that assumption correct? Any keywords to search or tutorials to read would be appreciated!

Submitted October 29, 2018 at 05:35AM by MakihikiMalahini-who

Web and API on seperate routes

I am working on an open source project. It will eventually have a JSON API that will interact with an android mobile app. Should i have say the login code for the web site, and the JSON API for the mobile client on separate routes?Example:module.exports = function(app) { app.get('/', function(request, response) { ... }); app.post('/', function(request, response) { ... }); } andmodule.exports = function(app) { app.get('api/', function(request, response) { ... }); app.post('api/', function(request, response) { ... }); } I heard there were security issues with using body parser like so:app.use(bodyParser.urlencoded({ extended: false })) // parse application/json app.use(bodyParser.json()) and instead you should use this:// create application/json parser var jsonParser = bodyParser.json() // create application/x-www-form-urlencoded parser var urlencodedParser = bodyParser.urlencoded({ extended: false }) // POST /login gets urlencoded bodies app.post('/login', urlencodedParser, function (req, res) { ... }) Any advice would be appreciated.

Submitted October 29, 2018 at 12:02AM by Ookma-Kyi

CRON Jobs with variable timezones?

I'm building a platform which should run a cron job every morning at 8. But since I have users from different timezones, how can I implement that it doesn't run directly but checks if it needs to run.Should I make a sort of cronjob that runs every minute and check who needs to have his mails sent? The issue is I'm on heroku so that will make my app go out of idle every minute, how does one handle a situation like this?

Submitted October 29, 2018 at 12:14AM by vospit

When do you know you/someone is a good node developer?

What characteristics/knowledge of things do you consider makes a person a good node developer?

Submitted October 28, 2018 at 07:14PM by maxhooligan

A chat forum for Datascrtucures, algorthims, and leetcode problems.

https://ift.tt/2CKEomn

Submitted October 28, 2018 at 06:33PM by Hossmen

How to correctly test API (Mocha and Chai)

Hello, I want to test my rest API. This is actually how I am doing it but I'm not sure this is good:// Test the /register endpoint describe("Users - Post /register", () => { let res: any = {} // will stock the response of the /register request before(() => DatabaseUtils.dropDatabase()) // This function drop the database to have a clear database before the test before(() => { return chai.request(app) .post("http://localhost:3000/api/users/register") .send({ email: "email", password: "password" }) .then(response => res = response) }) // List of `it` blocks testing the response describe("In the response", () => { it("The response should be an object", () => { expect(res).to.be.an("object") }) it("The body (res.body) should have property data", () => { expect(res.body).to.have.property("data") }) // And a lot of other it blocks... }) // List of `it` blocks testing the database describe("In the database", () => { let user: User before(() => DatabaseUtils.dropDatabase()) // Drop the database before(() => DatabaseUtils.createUser()) // Create a new user in the database before(() => { return UserModel.findOne({ email: "email" }) .then((u: User) => user = u.toJSON()) }) it("The user should be added", () => { expect(user).to.exist }) it("The user should be an object", () => { expect(user).to.be.an("object") }) it("The user should have a name", () => { expect(user).to.contain.property("name") }) // And a lot of other it blocks... }) First question, is it good to do like this? Or is it better/necessary to repeat the request in each it block?​Second question, a lot of it blocks will be repeated for each endpoint, is it possible to create them in other file? In a function or something? Because I tried this:// Updated code to use the function // Function to host the common tests for each endpoint function commonResponseTest(res: any) { it("The response should be an object", () => { expect(res).to.be.an("object") }) // And a lot more... } let res: any = {} before(() => DatabaseUtils.dropDatabase()) before(() => { return chai.request(app) .post("http://localhost:3000/api/users/register") .send({ email: "email", password: "password" }) .then(response => res = response) }) // Updated list of `it` blocks testing the response using the function for common tests describe("In the response", () => { commonResponseTest(res) // And a lot of other it blocks for the specific tests... }) But in this case, res is undefined inside the function. So I don't know, maybe is it not possible?

Submitted October 28, 2018 at 05:30PM by GreenMonkeyBoy

passing parameter to function?

i try to pass parameter to function below but it shows an error i dont know why it occurs<-----code example---->var x=123;var att = document.createAttribute("onclick");att.value = "fun(x)";var btn = document.createElement("BUTTON");var t = document.createTextNode(result[l].name);btn.setAttributeNode(att);btn.appendChild(t);function fun(result){console.log(result);}

Submitted October 28, 2018 at 12:20PM by mohamedimy

The Code You Write Should Only Suck Less Than The One Before

https://ift.tt/2PSviri

Submitted October 28, 2018 at 12:14PM by fagnerbrack

Should I make a separate application for admin panel or is hosting 1 bundled app better?

I am making an application using the MERN stack and I need an admin panel that would be accessed under https://ift.tt/2JjB6HN. Is making 2 different applications a better solution for scalability and perhaps a superior one if I want to change the admin part of the application or shall I make one large application that gets split up to admin and client parts?There are no methods or components that need to be reused in any part of the app. I only access the same database and that is it.

Submitted October 28, 2018 at 10:21AM by Just42s

Saturday 27 October 2018

Backtesting quantitative strategies in JavaScript

I've started work on a new API for backtesting trading strategies in JavaScript and TypeScript.Grademark builds on my years of experience in testing quantitative trading strategies: r/https://ift.tt/2EL21hm only just started, but already it has a bunch of features, can test a simple trading strategy and has more features a planned. I'm looking for feedback from anyone interested in this kind of thing, so please take a look. Please check out this first example of a simple trading strategy: r/https://ift.tt/2D6ZHPT tuned for blog post and videos coming in the next few weeks.https://ift.tt/2EXsSGK

Submitted October 28, 2018 at 01:11AM by ashleydavis75

Big React hook collection

https://ift.tt/2OUtscW

Submitted October 27, 2018 at 11:39PM by hexadecimalfreak

AI TicTacToe. Which JS Machine Learning libraries do you know?

https://ift.tt/2OUov48

Submitted October 28, 2018 at 12:15AM by GiacomoFava

Best kafka package for Nodejs in cloud?

What node package do you use to subscribe Kafka publishers in the cloud environment?

Submitted October 27, 2018 at 08:40PM by irspaul

Static files not served from one of my "auth" route

Hi,I am doing something wrong using static file in node where I store custom css and asset.js data.I reference to them in app.js like soapp.use(express.static(path.join(__dirname, 'public')));In my public folder I have two subfolders for css and .js. I am using ejs template engine and reference them like this​If I go directly to my route and render the map view it work just fine (http://localhost:4321/map). The issue is when I try to render it from my auth route it is not referencing to the files properly. I am not sure what rookie mistake I might be doing?http://localhost:4321/auth/css/mystyle.css net::ERR_ABORTED 404 (Not Found)http://localhost:4321/auth/customjs/asset.js net::ERR_ABORTED 404 (Not Found)function allowAccess(req, res, next) {queries.getUserById(req.signedCookies.user_id).then(user => {if(user.id == req.signedCookies.user_id && user.admin == true) {next();} else {res.render('../views/pages/map')}})}​Any help is much appreciated

Submitted October 27, 2018 at 03:08PM by geoholic

Integration Testing + Server Setup using Jest

I have an express/node server written in es6 and I am trying to setup my integration tests using jest. In order to do so, I need to spin up the server.I looked into setupFiles but it runs for every file which is kind of slow. I looked into setupGlobal but jest won't transpile ES6 code.Is there a canonical solution to this problem?

Submitted October 27, 2018 at 02:50PM by adamthompson922

Standalone TOR/onion client?

Hi! I'm building a web crawling/scraping NodeJS app (a kind of a search engine), and one of the requirements is to support both regular and .onion TOR URLs and make GET requests to them. Unfortunately, all solutions I've found require a separate TOR proxy service running to access onion websites.Is there a library that provides a standalone TOR client? I would very much like to use it instead of dealing with a separate service, because the latter complicates deployment significantly, and the app is meant to be deployed anywhere with a single command.Thanks!UPD: I've thought about Docker, but the bundle size really concerns me, I'm trying to make the app small and quickly downloadable.

Submitted October 27, 2018 at 12:47PM by smthamazing

What's the best architecture for handling 100K concurrent connections?

Hi guys,I am aware of clusters and tricks like –nouse-idle-notification, but I cannot seem to find a recent tutorial on the best tuning options for Nodejs 11 so far.What is the best architecture (I am aware that stateless is a must) for handling such concurrency level? Additionally, I would like to structure my app in the microservices form preferable on something like kubernetes, I am in clinking more onto the CQRS + ES pattern. I am not sure on the libraries choice either (whether to use Kafka or gRPC).Thank you in advance

Submitted October 27, 2018 at 11:01AM by k_rx1337

Do you use Node with MySQL Group Replication?

Hi allAs the title says, do you use Node with MySQL Group Replication?I'm wondering what's the best way to go about this - something like this? https://ift.tt/2EMED2N concern is I usually connect to MySQL like this:var con = mysql.createConnection({ host: MYSQL_SERVER_IP, So what happens if that server goes down? How can I automatically start writing/reading/etc. from one of the other servers?Thanks for your advice.

Submitted October 27, 2018 at 08:14AM by stiofan_io

Friday 26 October 2018

Authentication for Facebook Page

I'm building a webapp with NestJS, where users can login with their Facebook account and give access to their Facebook page to post via my webapp.Which authentication I should be using, Passport or Auth0?Please enlighten me.

Submitted October 27, 2018 at 07:10AM by xzenuu

Saving textarea to database

How do I store text including newlines to database and display the exact formatting of the text back on my website? I am using EJS.When I enter a sentence that spans multiple lines and store in the database (MS SQL) and display it on my .ejs , the line breaks are gone

Submitted October 27, 2018 at 07:31AM by RevolutionaryRow0

Need some advice & direction! I asked almost the same question on another sub and was told this was a much better place to ask.

I have only ever done a full out desktop application in Java, using OOD, in class. The structure went something like: a few classes for Objects, a few classes to do logic, a few classes as Controllers for the screens, and an Application class that bundled it all up and had the application running.I do understand OOD works differently in javascript, but I am wondering whether the structure of an application works out the same.I see that in Electron (or even Node.js), there is a main.js and that sets up the process. If I wanted to go about a small project using OOD, should I do something similar to what I did in my Java classes, or is this not the practical way to do it? Every beginner tutorial seems to mash up the Main.JS file with all sorts of logic code that in class, we were told to take out and put in separate files, and then import as needed.Thanks!!!!

Submitted October 27, 2018 at 04:30AM by tdot456

How to deploy a Node/Express application so it’s only accessible to users on my company’s network?

I built an application for my company but they have a strict policy against cloud hosting and the site can ONLY be accessible to users on the local network.How can I deploy the application so only users on the local network can access it? It would be nice if I could use a domain name but if I can only use an IP address that’s ok too. Do I need to setup an intranet?Also, if remote users login via a VPN to get on the network would they be able to access the site?Any tips to point me in the right direction would be greatly appreciated!!!

Submitted October 27, 2018 at 05:46AM by Eatsleeptren

Feedback on starter node web app

I have some experience building web apps, although not in Node.js. I tried to pick and choose what seemed to me the best modules in order to be able to build web apps/graphql APIs. I was wondering if you guys could give me some feedback or advice on what I could improve or have forgotten.Sample projectThanks!

Submitted October 26, 2018 at 10:52PM by edevil

Separating logic from Express routes for easier testing

https://ift.tt/2xT87FB

Submitted October 26, 2018 at 10:15PM by fagnerbrack

⛅ CLI for fetching weather forecast using openweathermap api

https://ift.tt/2SmaUAA

Submitted October 26, 2018 at 09:36PM by xxczaki

Mongoose: use UpdateMany instead of InsertMany?

This seems like it should be a very simple process, and probably is, but I can't seem to find the best way implement this.I need the ability to upload an array of "Product" objects to mLab with Mongoose. First I will loop through the uploaded items to validate them, then I need to insert/update them. Here is how I'm inserting them now.Sample Products:[{"sku": "bar32","name": "Test 1","owner": "5bcd137a7cc407380d5a0802"},{"sku": "foo64","name": "Test 2","owner": "5bcd2d669637b63f06e32f9b"}]​Validate and upload:let accepted = [];products.forEach(function(product) {if (validate(product)) accepted.push(product);});Product.insertMany(accepted, function(err, docs) {...});​This works great, but the next time a product list is given I need to be able to insert any new products, update any products that already exist (if SKU exists) and were uploaded again, and don't touch any products that exist in DB but weren't uploaded again.I was hoping I could actually just replace my originalProduct.insertMany(accepted, function(err, docs)with:Product.updateMany({upsert: true}, accepted, function(err, docs)This way on the first upload none would exist so they would just be upserted, then on subsequent uploads I could hit the same function and it would update any that exist and upsert the rest. However this did not seem to work. It may be my syntax that's incorrect but I couldn't find any examples doing it this way. Most examples use BulkWrite but this seems like something UpdateMany should be able to handle.Any advice?

Submitted October 26, 2018 at 07:13PM by Wishwatch

Effective Docker HealthChecks For Node.js – Patrick Lee Scott – Medium

https://ift.tt/2ELZ8fY

Submitted October 26, 2018 at 05:53PM by patrickleet

AWS Lambda Serverless Monitoring - Public Live Demo Environment • r/aws

https://ift.tt/2O6JcEz

Submitted October 26, 2018 at 03:23PM by nshapira

Configuring a CI/CD Pipeline for Serverless • r/serverless

https://ift.tt/2z0VjNO

Submitted October 26, 2018 at 03:37PM by nshapira

npm install does not appear to be reading package-lock.json

node version: 8.12.0npm version: 6.4.1Here are my steps for testing:​Create new empty directory.Change directory into new directory.Run "npm init" and answer all the questions.Run "npm init cors --save" (This installs fine and updates package.json and package-lock.json as expected.Delete the node_modules directory.Delete the package.json. Do not delete package-lock.jsonRun "npm install"This complained that package.json is missing and does not install the cors module specified in the package-lock.jsonAm I misunderstanding this or am I missing a flag?

Submitted October 26, 2018 at 03:05PM by webb_world

Add ads on NodeJS web app

Hi everyone,i built a nodeJs app currently hosted on heroku.This app will probably be used by +/-50 users daily (uni related app).Is there a way to monetised it ? (only by adding non intrusive ads).I think I need another host, am I right ?Which one ?Thanks

Submitted October 26, 2018 at 02:23PM by SwiiZe

3 JavaScript Performance Mistakes You Should Stop Doing

https://ift.tt/2JfuQB5

Submitted October 26, 2018 at 10:25AM by pimterry

Best methods/checklist to make a nodejs app robust, autostart, monitored and scalable?

just discovered pm2 while working through this example.https://ift.tt/2EKW8k1 surprised at the quality of tools available. Now I'm wondering what best practices and other tools/checklists I should be using.at moment I'm just demo testing a few simple apps, it's a different game when it comes to production load stability. Dev ops hasn't been my emphasis but now I'm wondering what steps are next.

Submitted October 26, 2018 at 10:03AM by AspiringGuru

Node video tutorials

I need recommendations from this great community for a series of video tutorials or a course (paid or free) to really understand how Node works and all the details behind this technology. I have a good background and wrote couple of apps using node and express.

Submitted October 26, 2018 at 09:24AM by agk22

How can I mask/remove ip from backend with Nodemailer?

I'm using Cloudflare as a proxy to prevent DDoS attacks. This means that having my actual server's IP exposed would render it useless leaving me much more vulnerable to attacks. Right now I'm using nodemailer to send emails via gmail. Though I see that my server's IP is displayed clear as day in the recipients email headers. How can I prevent nodemailer from giving out my server's IP address?

Submitted October 26, 2018 at 09:37AM by 2JJ1

Writing koa/nuxt applications

https://ift.tt/2ECrM31

Submitted October 26, 2018 at 09:00AM by kiarash-irandoust

Recommended package for sending emails?

I'd like to have my backend send emails for password reset requests and such. What would you recommend using?It must not expose my server's IP address.

Submitted October 26, 2018 at 08:05AM by 2JJ1

Which technologies shall I use for Video Stream Project

Hi there.We have got a large project for stream videos like vimeo for our customers. we have to use the Node for it. which technologies shall I use for this project? MERN Stack or something else. Thanks.

Submitted October 26, 2018 at 08:06AM by dsalahi

Thursday 25 October 2018

Starting with nodeJS, information about modules.

HiI shifted from a Flask server with REST api on it to a nodeJS server.I am trying to implement a scheduled mailer in my backend nodeJS server hosted on digital ocean droplet.I found some modules like mailgun and nodemailer .What are the factors to consider before choosing modules in nodeJS.Any good resources for information on modules.

Submitted October 26, 2018 at 06:37AM by Mugiwara_Luffy

Biggest downside to learning Node with as little framework/middleware as possible?

Hello there. I'm pretty new to Node and to programming in general. As I'm learning and making my own things, I am finding that I most enjoy learning about / working with node/js as-is, without any frameworks etc. What I'd like to ask a crowd of more experienced node/js people is, what is the biggest downside to taking this approach with node/js in general? Will I find an obstacle somewhere in the course of learning at this level that would be very difficult to overcome? I'd love to keep building from the low-level stuff if possible, but I'd rather not waste my time just to find out about a well-known reason that's a bad idea months down the road. Open to any and all feedback on this topic in general as well! Cheers.

Submitted October 25, 2018 at 11:18PM by Mattb150

Failure API Question

This is sort of theoretical for a project I’m working on.If for some reason your API crashes or errors out, is it feasible to create a bash script or something to restart the server? I know you can set up a sort of server director (forgetting the terminology right now) to check if the first server is up and such, but is there a way to automate restarting the server?

Submitted October 25, 2018 at 11:15PM by imanuglyperson

Creating and Reading QR Codes with Node.js

https://ift.tt/2PSyFi8

Submitted October 25, 2018 at 10:34PM by code_barbarian

Learn serverless Node.js. (5x10min videos)

https://ift.tt/2PUKBQa

Submitted October 25, 2018 at 10:58PM by Angelius750

Team structure in the age of microservices

https://ift.tt/2OMDgpt

Submitted October 25, 2018 at 10:07PM by efunction

Using Jest to test Node app - web interface?

I've recently taken to using Jest to test our Node applications. We follow a strict CICD process where we have a Dev, QA, Stage, and Prod build cycle. I'm trying to figure out a way to introduce these tests to our staging environment post-deployment. We are completely locked out of the instance after deployment, so there's no SSH'ing in or anything to run a test from the command line.Ideally I would like developers to be able to run individual tests with a click of a button, and maybe some sort of configurable parameter field so that we could run a test with manual input as well.I did some searching for a web interface and all I could find is Majestic. I'd like to find at least one or two more to compare features, but it seems this is a niche request. Any ideas?

Submitted October 25, 2018 at 09:32PM by cipp

IoC or similar in Node

I know this comes up a lot, but hear me out.I'm playing with a new project in node, and to start off I'm doing healthchecks. (It's a nice way to test all parts of the system can interact, and proves deployment and automated tests work)I've got a handler for this already, and it works fine. But I want to have a reasonable coverage from the checks. In particular:Local system health (memory, disk space, etc)PostgresRedisGoogle API - if configuredOthers in the futureNow, writing code to test all of these is relatively easy. And writing a handler that iterates over them all is easy. But it's the wiring them up I get stuck on.The ways that come to mind are:Handler imports all of the checks and depends on them directly. This is a testing nightmare.Handler is somehow constructed by providing the list of checks. How?I can obviously achieve the second option by having a function somewhere that wires everything up, but then that function depends on everything. And that's horrible.So, what do people normally do to achieve this?

Submitted October 25, 2018 at 09:04PM by sazzer

Help web scraping Facebook Ad Archive

I'm trying to get the data on this webpage https://ift.tt/2O1LZib but can't seem to get it with web scraping. I've tried using request-promise cheerio puppeteer and phantomjs but none of them return the correct HTML. I know its a react page so you have to run the javascript first but even so, I cant get the table results. Does facebook have an anti-scraping defense or are you able to get the correct HTML back?

Submitted October 25, 2018 at 09:08PM by qpal123

What do I need to know to 'know' node?

I've just had a recruitment consultant ring up about a job offer. On the phone he asked what my experience of node was and if I could give him some examples.I've used node daily, I can set up API's, build an express server, but I've got no idea if this is what he was looking for? Is there anything else I should learn for node incase this question comes up again?

Submitted October 25, 2018 at 08:09PM by dtwoo

URL(s) to ZIP

I'm trying to make a website where you can grab multiple URLs and then download them all. I have the URLs sorted to just image types like png, jpg, and gif. Is there a way to take all the URLs that are grabbed and put them into one zip file then downland that zip file?

Submitted October 25, 2018 at 07:25PM by MyNaMeHuLk

The Best way for learning professional Node

I'm PHP developer with 4 years professional experiences. I worked with Travel Agency and build complex CMS and CRM from scratch I developed by Laravel.I'm going to learn node with Mosh course and Udemy(The complete Node.js Developer Course).I'm going to learn MERN Stack (MongoDB, Express, React, Node) and scalable APIs with GraphQL, Docker, AWS such as EC2 and S3.Is it a good plan?

Submitted October 25, 2018 at 07:31PM by dsalahi

Small Focused Modules

https://ift.tt/2ShCChO

Submitted October 25, 2018 at 07:39PM by sindresorhus

Building a project from the ground up...

Anyone on here (London based) interested in building a project from the ground up?You’d be joining the team as our Node expert, helping build progressive web apps.The abbreviated tech stack is Node, Angular, JavaScript and AWS.You will get access to an annual training budget, remote working, a gadget budget, 25 days annual leave and a lots of other perks.Please drop me a message if you’d like to find out more...!

Submitted October 25, 2018 at 05:09PM by flythecopter

Promises in chunks

Hi, i'm struggling into finding a nice way to execute an array of promises in chunks.Suppose I have an array with 1000 urls and each url needs to be sent to a service. Now, I don't want to send them all at once but in chunks of 100​what would be the best way to do this?

Submitted October 25, 2018 at 05:02PM by thrider

How to add title to array of objects returned with express find()?

Sorry I'm new to node and what I know so far is just built using a tutorial for referenceapi.get('/', (req, res) => { let city = req.query.city; People.find({ city: city }, (err, people) => { if (err) { res.send(err); } res.json(people); }); }); this returns the objects as:{ name: "example", id: "123123123" }, { name: "example", id: "123123123" } But I would like them to be nested as objects of another group called People. How would I accomplish that?

Submitted October 25, 2018 at 04:46PM by SumTingWong59

NodeJS as a gateway in a web application

I'm looking for any examples of a web application using front-end framework (Angular preferable) and Node.JS as a gateway to the REST API something similar to the diagram belowhttps://i.redd.it/phfhiupllcu11.png

Submitted October 25, 2018 at 04:14PM by Major-Lag

Upload and Move a file using NODEJS ... check it out ...

https://ift.tt/2RhOkb7

Submitted October 25, 2018 at 03:23PM by net-raft

Using Amazon DynamoDB Database With AWS Lambda In Nodejs

https://ift.tt/2Aresuj

Submitted October 25, 2018 at 02:34PM by blockchain_tech

Why node.js has to be restart for changes to be applied?

Hi, I'm a bit confusing about how node.js handle javascript.Both Chrome and Node.js use V8, in Chrome, I can open dev tool, edit the source code, save, and then continue running with all changes applied, but why in Node.js, I have to restart the server to apply changes I made to the source code? I heard V8 engine uses JIT compiler, thus, it should be able to edit the source code, the JIT compiler only reads text it needs directly from the source code to compile to machine code during runtime, right?How a Javascript source code is compiled and interpreted? For instance I have a file named index.js like this:​function a(b) { console.log(b); }; a(10): when I runnode index.js can you tell how the compile and interpret steps happen?The source code being compiled and interpreted right when in met the function a declaration or until it met the function call a(10) ? If we don't have the a(10), is there anything being compiled?

Submitted October 25, 2018 at 02:58PM by jiendang

Buffer.toString() not the same with the original sent data

I am doing a Foto with the webcam and then converting the canvas to a .jpg image. Then I am sending the converted to base64 image to the server and use data.toString() for the conversion back to base 64.I am using the npm package base64ToImage for converting the foto back and saving it. The problem is with the conversion back to base64. The error invalid base64 string is shown.I compared the base64 from client with the one from server and they do not match. Why? So i cant covert the image back.Please help, I am at the end of my patience, as I know the solution has to be easy.As the data has more than 600k caract, I'm only posting a part of it:-this is from the client: data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAoAAAAHgCAYAAAA10dzkAAAgAElEQVR4XsS9Wa9kWXodts8QcW9mdlV3cWiyW2yqJXEAKMjwk/XiBz/4zc/+PfaTAVsjRYlNtmXSBvyTDD8IoFqUaEqsrq4xM++9EWcw1vSdHVHVgABxiEYjK/PGjThnn72/vfb61re+4Z/+43+0j+PQHk5zG4ahXa7PbVu3tre1bevatmVv4zi26fTQrtdru+6tTfPUpnFo+763cbu0bd/bNKwNr+104ucsy9a2bWvreOH7tmFr4zS2aT/xfePyin+2febPh3njX6/bkz63DXrfPvLz8OKfw8Kfz+uV13WaR17Xu/XU1mVty9O5Leva9v3c5tPcv-this is from the server: imgBase64=data%3Aimage%2Fpng%3Bbase64%2CiVBORw0KGgoAAAANSUhEUgAAAoAAAAHgCAYAAAA10dzkAAAgAElEQVR4Xpy9aZMkS3Ic6HFlVfebAZe%2FmSL8sisQEjtczIFjcA24Xyj8aSQx012VGceKXuae%2BRoQyiYE0vO6qzIzItzN1dTU1Kb%2F63d%2Fd23b1t4ej3acR7uuo03T1M71bMs8t2XZ2nVd7XxMDa%2B5nfxzuk7%2B%2FdI%2B2rou%2FB3896O9t8f%2BaB%2FX2uZlbtNjbsEdit: Im trying to format it like code, but I dont know how to make it work

Submitted October 25, 2018 at 01:57PM by Coreeze

TAKE ME TO THE RIVER by KALEIDA (Official Audio)

https://www.youtube.com/attribution_link?a=0spA68lqzro&u=%2Fwatch%3Fv%3DKaW4pv-1YDA%26feature%3Dshare

Submitted October 25, 2018 at 10:21AM by kapv89

npm start-script not wirking

Hey, i just created a third start script for my node application. While I can start my application with "npm start" or "npm test" my third start script "npm docker" is not working.If I start the app with "NODE_ENV=docker nodemon server.js" in console, it is working as expected.Did I miss sth?`"scripts": {"test": "NODE_ENV=test nodemon server.js", "start": "nodemon server.js", "docker": "NODE_ENV=docker nodemon server.js" }, `

Submitted October 25, 2018 at 10:42AM by Sp1xx

NodeJs Authentication via Google using PassportJs

https://ift.tt/2qbXPNg

Submitted October 25, 2018 at 11:13AM by blockchain_tech

Wednesday 24 October 2018

What are the benefits of using a Microservices architecture?

Hey guys, I am learning about microservices.Microservices architecture offers the most desirable way of designing and implementing various enterprise applications. As a developer, you can use the approach in leveraging APIs.In this medium article are presented 5 major benefits:https://ift.tt/2PnyMoL can be aligned with several technologiesAdded agilityEfficiency in developmentScalability in costsEasy maintenanceWhat other benefits do you know? And when you should not use this type of architecture?

Submitted October 25, 2018 at 07:24AM by jsdojo99

A write up for Node + Javascript Interactive 2018 Conference

https://ift.tt/2SeAxDp

Submitted October 25, 2018 at 04:35AM by anasbladz

Help serving files from the backend to a frontend request

Find a tech job in Southeast Florida, the easy way!

Hey everyone!A little backstory… I moved down to south Florida about 3 years ago from the midwest. For about 2 years, I could not for the life of me find a job that I was actually interested in working for, until I got lucky through a friend of a friend.No matter how hard I searched on LinkedIn, Indeed, Glassdoor, Monster or any of the other super-massive job listing sites, nothing panned out. Having been through the experience of struggling to find a job in tech for a couple years, I decided to create a curated list of tech jobs or jobs with tech companies in the south Florida area (Palm Beach, Broward and Miami/Dade counties).It’s free to use, it skips all of the BS that you would get digging through any of the main job hunting sites, and its laid out in an easy, simple fashion. If you are an employer and looking for candidates for roles that you’re hiring for, posting a job listing is totally free. I will periodically go through and audit job listings to avoid spammy listings ending up on this site.For the most part I believe this site could really help connect solid employees with companies that they would actually enjoy working for, and that would be a good fit for both employee and company.Please check it out when you get the chance at https://ift.tt/2qhJqPX!

Submitted October 25, 2018 at 03:22AM by jazehoots

Examples of well written API's?

When building something from a tutorial it's always nice to see a well structured, good practice coded example as well. Do you know any examples of such repositories?

Submitted October 25, 2018 at 03:25AM by vospit

Unhandled rejection Error: Can't set headers after they are sent [help]

I can't figure out where the issue lies...Based on my research of what this error means, It seems like somewhere I am either sending a request twice or sending a response twice. I don't see anywhere this is happening...file1.js export const wrapper = (req, res, next) => { async function getValue(user) { await getExpiration(user).then(response => { if (response.condition) { return res.status(401).json() } }) } getValue(user) } ...file2.js export const getExpiration = async user => { return new Promise((resolve, reject) => { getOrgInfo(user.org_id) .then(res => { return resolve(res) }).catch(err => reject(err)) }).catch(err => console.log(err)) } } ...file3.js // this is a function that talks to my database and returns a promise export const getOrgInfo = (org_id) => { return kx('orgs').select('Expiration').where({'id': org_id}) }

Submitted October 25, 2018 at 01:22AM by chrismellor08

Best practice to schedule node functions?

I am automating email notifications in a Nodejs backend. Anyone have experience with this? Is node-scheduler the best option?

Submitted October 25, 2018 at 12:56AM by elmagico94

Hiding MySQL server credentials in Electron.

How is this possible?

Submitted October 24, 2018 at 10:07PM by myope-uk

Master Node JS, build REST APIs with Node.js, GraphQL APIs, add Authentication, use MongoDB, SQL & much more!

https://ift.tt/2EGxwsP

Submitted October 24, 2018 at 07:14PM by sarthakdav101

mongodb $match aggregate question

db.text.find().pretty(){"_id" : ObjectId("5bd09e2d0a952713a3601122"),"email" : "jeffrey@gmail.com","passwordData" : [{"webpage" : "nba","username" : "username","password" : "password","email" : "email"},{"webpage" : "mlb","username" : "username","password" : "password","email" : "email"},{"webpage" : "nfl","username" : "username","password" : "password","email" : "email"}]}​hello all, I have this document in my local mongo database but I am trying to get only one of those objects by using this codedb.text.aggregate({$unwind: "$passwordData"},{$match: {“email”: "[jeffrey@gmail.com](mailto:jeffreyyourman@gmail.com)”, “passwordData.webpage”: “nba”}});I am getting an error that says "SyntaxError: illegal character @(shell):1:55"​Expected output{"webpage" : "nba","username" : "username","password" : "password","email" : "email"}​If anybody has any idea what is going on can you please give me some insight? Thanks in advance!​​

Submitted October 24, 2018 at 05:40PM by jyourman24

Building a complete Authentication and Authorization library for NodeJS

I recently used PassportJS for a project; I think there is a huge gap. There are a ton of things that you still have to implement yourself, and in the case of authentication and authorization amateur coding could be dangerous.Auth0 is a good service, but I am looking for something more on self-hostes side, like a library to directly use in the code, just like PassportJS. I want to implement all the features of Auth0 in an opensource library.I can't find what I am looking for, so I am building one. Would absolutely love to know your views on this problem. Also, it would be awesome if you could share how you implement user management, authentication, and authorization in your apps!Keep Rocking \m/

Submitted October 24, 2018 at 05:55PM by supersarkar

Streams For the Win: A Performance Comparison of NodeJS Methods for Reading Large Datasets (Pt 2)

https://ift.tt/2EQSghI

Submitted October 24, 2018 at 02:57PM by kiarash-irandoust

Does anyone use nodejs with typescript on the backend on production?

Heard a lot about typescript and used it with angular. Seems like very helpful in catching issues during compile time. Does anyone use it for backend nodejs server in production? Any things to take care of or give special attention?I am planning to use it in one of our projects but new to this setup so wanted to know if it is fine?

Submitted October 24, 2018 at 01:14PM by myth007

Observer, Observable and Subscription

https://youtu.be/1XFxycO2uYQ

Submitted October 24, 2018 at 09:48AM by Rahul_001

Server to Server communication in NodeJS

https://ift.tt/2O2zZgo

Submitted October 24, 2018 at 07:46AM by blockchain_tech

Tuesday 23 October 2018

What do you use to generate API doc pages?

Hi all, what is everyone using to generate API documentation for your REST-y services? I’ve seen that Swagger is pretty popular in the Java world, wondering if there’s anything that stands out in the Node world?Bonus points would be something that has Typescript integration, where it can show Typescript types for the request/response data.Thanks!

Submitted October 24, 2018 at 01:49AM by 50653

Need help with sequelize query

I am trying to execute this querySELECT name, avg(distance) as distanceAvg FROM table_name group by name; I am able to execute the query without the avg() aggregate as :Model.findAll({ attributes: ['name','distance'], group: 'name', raw: true }) but adding an aggregate function gives me error that my endpoint doesn't exist.This is my code for that: Model.findAll({ attributes:['name', [sequelize.fn('AVG', sequelize.col('distance')), 'distanceAvg']] , group: 'name', raw: true }) Any help is welcome :)

Submitted October 23, 2018 at 11:59PM by CromulentEntity

Is there a guide somewhere that teaches the reasons to use all the different kinds of http requests, like get, post, and queries?

No text found

Submitted October 24, 2018 at 12:26AM by smiles_low

Is node 10 production ready?

No text found

Submitted October 23, 2018 at 10:22PM by bch8

secure-env and cross-env

Hi, if I use secure-env on .env my cross-env doesn't work anymore(if I try cross-env=test on a npm script while my .env has env=development, it remains on development). Does anyone know how to use both?

Submitted October 23, 2018 at 09:52PM by drbt97

Looking for tips from someone with knowledge of password hashing, Node and C#

So, I have a dated system I have acquired. It was built with webforms, SQLServer etc. I can connect and query with knex, but I'm looking to build an express API using the same DB, without forcing everyone to change their passwords. I don't have a background in C#. I realize that SHA1 is not really the way to go, but is there a way to re-create this C# in Node using something like Crypto, or am I barking up the wrong tree in my thinking? Any guidance would be appreciated.​ private string EncodePassword(string pass, string salt) { //make an array byte[] numArray; //Gets an encoding for the UTF-16 format using the little endian byte order. byte[] bytes = System.Text.Encoding.Unicode.GetBytes(pass); //Converts the specified string, which encodes binary data as base-64 digits, to an equivalent 8-bit unsigned integer array. byte[] numArray1 = Convert.FromBase64String(salt); byte[] numArray2 = new byte[(int)numArray1.Length + (int)bytes.Length]; Buffer.BlockCopy(numArray1, 0, numArray2, 0, (int)numArray1.Length); Buffer.BlockCopy(bytes, 0, numArray2, (int)numArray1.Length, (int)bytes.Length); //Creates an instance of the default implementation of SHA1. System.Security.Cryptography.HashAlgorithm hashAlgorithm = System.Security.Cryptography.SHA1.Create(); //Computes the hash value for the input data. numArray = hashAlgorithm.ComputeHash(numArray2); //Converts the value of an array of 8-bit unsigned integers to its equivalent string representation that is encoded with base-64 digits. return Convert.ToBase64String(numArray); } ​

Submitted October 23, 2018 at 08:58PM by comma84

What kind of server do I need for signalhub?

So, I'm trying to make this as short as I can: I'm trying to rebuild the p2p chat browser program front this video: https://ift.tt/2R86EDf At about 28:00 he starts talking about the signalserver, and that he has running already one on his computer. The github description of signalhub says that I should use the command line api, but I couldn't figure out what this is. My problem is that the browser always returns "Uncaught (in promise) TypeError: Failed to fetch localhost:9000/v1/test-app-demo/cjnm5ahhz0000a1ik1evlsutf:1 GET http://localhost:9000/v1/test-app-demo/cjnm5ahhz0000a1ik1evlsutf net::ERR_FAILED", although a I got a "signalhub listening on port 9000" (through json). I read something about a node server has to be used, but I got know idea how to do this.https://ift.tt/2q5ud42 The code I am using for this, of course in browser browserified.Edit: Grammar, sry not a native speaker ^

Submitted October 23, 2018 at 09:13PM by jannjul

Object and arrays don't update properly

In a project I'm working on called Sherwood Architecture is having an issue (https://ift.tt/2EG536e) where the arrays and objects aren't updating properly when I try to change them inside of a function being called from setInteral. Why is this happening and how do I fix it?

Submitted October 23, 2018 at 08:31PM by SpaceboyRoss

Node v11.0.0

https://ift.tt/2R9dMiL

Submitted October 23, 2018 at 08:34PM by injektilo

Request URL with multiple query parameters

I have a lot of values I want to pass to my backend server when I am doing a get request. E.g. I can add multiple values like http://<>?maxAge=25&minAge=45&maxHeight=135&minHeight=180&.... and so on. The url keeps in growing as i add the parameters. Is there any easier way to do this?

Submitted October 23, 2018 at 07:29PM by stopcharla

Learn Angular 7 | Episode 1 of 5

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

Submitted October 23, 2018 at 08:15PM by AngularActivity

Array initialized in parent function is not updated when pushed to in function?

I have something like the code below where I initialize an array in a "parent" function, then inside a "child" function I push a value to the array. But the array in the parent is not updated?And even inside the function I gather the value should be [1] but it is 1. Confused!​Any idea what is going on?​Thanks​const server = https.createServer(options, (req, res) => {let ids = []function addId() {ids.push(1)console.log(ids) //1, not [ 1 ] )}console.log(ids) // []})

Submitted October 23, 2018 at 06:20PM by snicksn

I'm new to node world, built a restful API to learn the fundamentals, please feel free to give feedbacks !

https://ift.tt/2q6etht

Submitted October 23, 2018 at 06:25PM by thebapho

Do any popular mobile rpg games use node? Will my idea work okay with node?

Do any popular mobile rpg games use node? Will my idea work okay with node?I am currently working on a single player puzzle game and in around 6 months hope to start a mobile rpg with mostly asynchronous multiplayer mechanics. I have zero experience in multiplayer so during that 6 months I hope to reach a point where I am capable of making the game I want to make. Before starting my game I spent time learning javascript / react / redux which is why I am thinking about node and mongodb. I also did a tiny bit of Udemy's The Complete Node.js Developer Course 2nd Edition and really enjoyed its teaching style.The features I want my game to have are below.Arena - An active player chooses to fight in the arena. A database request is made to get the stats of an enemy player. Then the computer fights an active player using the data of the enemy player pretty much like a monster. Most mobile gacha games have this exact system.High Score - Just random data like highest level.World Bosses - Although everyone fights the boss at the same time you don't actually see other players. What you see is the same as you would when in a single player monster fight except you also see the world boss's hit points dropping even when you aren't attacking it. So in the fight the only multiplayer mechanic is how the boss's HP is shared between all players attacking it and how your loot is based on your damage ranking compared to the other players.

Submitted October 23, 2018 at 05:23PM by DuskyPixel

Node newb question regarding the traditional callback approach with http clients

I've been programming for years but only recently with node.js. I'm happily async/await where I can and I've recently been working on a project which requires an http client.I've been wondering about this, with Python, for example it's extremely easy to write http clients using the Requests module and I've written a lot of code which does this:Request an http resource (GET, POST, whatever).Block and receive the response.Store the response (or part of it) in a variable.Do stuff the the response data.However, I can't wrap my head around doing that above with callbacks. How could I effectively issue an http request, wait for the response and then proceed?How do I the same with Promises? The way that Node does async feels a bit foreign to me at this point. I know I'm missing something obvious. See my other post for an example of me doing the above with async/await - how could that code be rewritten with callbacks or Promises?https://ift.tt/2CANZw3 in advance!

Submitted October 23, 2018 at 03:53PM by tech_tuna

NodeJS Web Development Company India | NodeJS Development Services | CMARIX

https://ift.tt/2yV8ZKf

Submitted October 23, 2018 at 02:15PM by Alenaacmarix

Deploying a Node App to Google Cloud with Kubernetes

https://ift.tt/2PmzUcs

Submitted October 23, 2018 at 02:20PM by michaelherman

Build an Uptime Monitor in Minutes with Slack, Standard Library and Node.js

https://ift.tt/2ScfNMG

Submitted October 23, 2018 at 08:05AM by notoriaga

Monday 22 October 2018

Help for a newbie

hi, I've made the decision to try and switch over to node js from being a traditional php/asp/j2EE developer, but I'm feeling a little overwhelmed by the number of different tutorials and focus points.​my end goal is to do research on nodejs ecommerce systems and how easy replication and configurations would be, but of course i need to learn to crawl first.​i've been drudging through a few basic tutorials - i've set up an nginx ssl server that grabs a "hello world" nodejs api on port 3000, and serves it on https, and i'm quite happy with that progress.​the problem comes after that - there are so many platforms to choose from, i've selected sails to learn but i find it simply overwhelming. the tutorials are pretty much 'quickstarts' that ask u to perform x command, but don't really explain what it is they're trying to do.​can anyone point me in the right direction, or maybe share your experience of learning node?

Submitted October 23, 2018 at 05:19AM by mookanana

Problem with async/await and http client requests

Data wrangling with Nodejs

I have a web application written in Python using Flask to provide some basic "Data Analysis" to the company I work at. I picked Pandas for the work because I can manipulate data in memory, without having to call the database everytime an user changes an input. But now, I'm in a new project and they requested me a similar application, and I want to do it in Nodejs as it seems to be faster than Flask in terms of request handling. I've been searching for some library like Pandas, but none of them seems to be a "mature" library. I can just switch back to Python, but now I would like to know how people manage data in webapps without querying the database all the time. Could you guys gimme some advice?

Submitted October 23, 2018 at 01:50AM by Krogiar

Learn Angular 7 | Full Project for Beginners

https://www.youtube.com/watch?v=QvpQE-5tcKU

Submitted October 23, 2018 at 01:05AM by AngularActivity

How can I install nodejs for all users on Ubuntu server not only the root user?

I’ve searched a lot but couldn’t find a solution that worked most of them were pretty outdated too. I‘m running Ubuntu server 16.04 and I need all my users to be able to use node and global NPM packages.

Submitted October 22, 2018 at 08:44PM by AlexanderHorl

🤠 A simple Chuck Norris Jokes CLI.

https://ift.tt/2qdh4X3

Submitted October 22, 2018 at 06:58PM by leonardomso

What's the best practice for storing e vironment variables in a node project?

*environment variablesCurrently we have a .conf file being referenced by the java portion of the project.

Submitted October 22, 2018 at 07:34PM by DHarry

Applying filters based on distance

Given a list of people in a json file with certain details and their location(latitude and longitude). I would like to obtain people in certain radius along with filters on other fields. What is the best way to approach this problem? do we need to use a db?

Submitted October 22, 2018 at 06:47PM by stopcharla

Help with multiple requests using Tedious

Currently I am using Tedious to connect to MSSQL database. I create a request and store the information needed in an object. I have that all working. Now I need a follow request for each item in my object that has a value greater than 0 in one of the fields. This request will return one or more items that I then want to update my object with.I know I cannot make more than one request at a time to a connection.Do I need more than one connection to do this?If I only need one connection, then is there an event I listen for to fire the second request? "requestCompleted" does not seem to work and "done" does not seem to fire.I am using Node.js 8.12, Tedious, and Express.The code below is a rough work in progress, nowhere near production. I am just confused how to make a second request.​var Connection = require('tedious').Connection; var Request = require('tedious').Request; var config = { userName: 'redacted', password: 'redacted', server: 'redacted', options: {encrypt: true, database: 'redacted', useColumnNames: true, 'rowCollectionOnRequestCompletion': true} }; var connection = new Connection(config); connection.on('connect', function(err) { // If no error, then good to go... }); var cors = require('cors') var express = require('express'); var app = express(); app.use(cors()); app.get('/', function (req, res) { var testData = {}; // Build request request = new Request("SELECT aColumnID,tTabName,tGroupName,tDisplayName,tblColumnMain.tBaseTable,tDBColumnName, tblObject.tName, tblCustomField.nConstraintID FROM tblColumnMain INNER JOIN tblCustomField ON tblColumnMain.aColumnID = tblCustomField.nColumnID INNER JOIN tblFieldGroup ON tblCustomField.nGroupID = tblFieldGroup.aGroupID INNER JOIN tblTab ON tblFieldGroup.nTabID = tblTab.aTabID INNER JOIN tblObject ON tblTab.nObjectType = tblObject.aObjectType ORDER BY tTabName, tGroupName, tDisplayName", function(err, rowCount) { if (err) { console.log(err); } else { console.log(rowCount + ' rows'); } }); // For each row of data request.on('row', function(columns) { const id = columns.aColumnID.value; testData[id] = {}; for (var col in columns) { testData[id][col] = columns[col].value; } }); request.on('requestCompleted', function () { res.setHeader('content-type', 'application/json'); for (var row in testData) { if (testData[row].nConstraintID > 0) { console.log('Fetching Constraint Values'); requestContraints = new Request("SELECT tblColumnMain.tBasetable, tblColumnMain.tDBColumnName, tblColumnMain.tDisplayName, tblCustomField.nConstraintID, tblEnum.nIndex, tblEnum.tDisplayName FROM tblColumnMain JOIN tblCustomField ON tblColumnMain.aColumnId = tblCustomField.nColumnId JOIN tblFieldGroup ON tblCustomField.nGroupId = tblFieldGroup.aGroupId JOIN tblTab tblTab ON tblTab.aTabId = tblFieldGroup.nTabId JOIN tblObject ON tblObject.aObjectType = tblTab.nObjectType JOIN tblEnum ON tblCustomField.nConstraintID = tblEnum.nConstraintIDWHERE tblColumnMain.aColumnID=" + testData[row].aColumnID, function(err) { if (err) { console.log(err); } }); requestContraints.on('row', function(columnsConstraints) { for (var colContraints in columnsConstraints) { testData[id][nConstraintID] += columnsConstraints["tDisplpayName"].value; } }); connection.execSql(requestContraints); } } res.json(testData); }); // Execute statment connection.execSql(request); }); var server = app.listen(5000, function () { console.log('Server is running..'); });

Submitted October 22, 2018 at 05:53PM by webb_world

Passing variables to node.js

Not sure how to phrase this, so I'll just write it out the best I can.I have an html page, with a label that has some items, say names of fruit. If I double click on Orange, for example, I can pass that to a javascript function, no problem.However since node is serverside, how would I do the same thing in order that I can access something from a database, or use the variable to Do something on the server?Or would it go HTML to Javascript to Node?

Submitted October 22, 2018 at 02:24PM by orksaredorks

create sql table by passing variable

hi guys i want to create a table in sql by passing the variable like below<---------------->var table = mysql.format("create table ?(un VARCHAR(255))",v);con.query(table,function (err, result) {if (err) throw err;console.log('table created');​});but it not works anybody help me with this problem

Submitted October 22, 2018 at 12:59PM by mohamedimy

why is my site slow? bundle size is small?

this is the website https://bound2.appit comes in with a decent score on pingdom. And the page size is just 1.1MB. But the "wait" phase is nearly 15 seconds. I don't think this is to do with my use of canvas.Perhaps an old version of webpack / node config problem?This is a link to my github => https://ift.tt/2q7bZPD project is really simple, so webpack / server.js files are possibly the ones. I'm using old webpack.Massive thanks.

Submitted October 22, 2018 at 10:20AM by harrydry

keywordsextract - Command line tool extract keywords from any web page

https://ift.tt/2CVcXat

Submitted October 22, 2018 at 09:42AM by vladocar

6 Main Reasons Why Node.js Has Become a Standard Technology for Enterprise-Level Organizations

https://ift.tt/2PEQnW7

Submitted October 22, 2018 at 09:32AM by stanislavb

Does anyone know why my code sends [Function anonymous]?

app.post('/test', (request, response) => {response.send('foo');});if I send a request to /test, I receive this:[Function anonymous]​

Submitted October 22, 2018 at 07:43AM by smiles_low

Sunday 21 October 2018

Why Is NodeJS More Crucial For Your Business Than You Think

https://ift.tt/2CWXUNm

Submitted October 22, 2018 at 07:31AM by blockchain_tech

Learn the smart, efficient way to test any JavaScript application

https://ift.tt/2A6MyDT

Submitted October 22, 2018 at 07:04AM by fagnerbrack

[question] iconv-lite not decoding everything properly, even though I'm using proper decoding

Hi, I'm using this piece of code to download a webpage (using request library) and decode everything (using iconv-lite library). The loader function is for finding some elements from the body of the website, then returning them as a JavaScript object.request.get({url: url, encoding: null}, function(error, response, body) { // if webpage exists, process it, otherwise throw 'not found' error if (response.statusCode === 200) { body = iconv.decode(body, "iso-8859-1"); const $ = cheerio.load(body); async function show() { var data = await loader.getDay($, date, html_tags, thumbs, res, image_thumbnail_size); res.send(JSON.stringify(data)); } show(); } else { res.status(404); res.send(JSON.stringify({"error":"No content for this date."})) } }); The pages are encoded in ISO-8859-1 format, and the content is looking normal, there are no bad chars. When I wasn't using iconv-lite, some characters, eg. ü, were looking like this: �. Now, when I'm using the library like in the code provided above, most of the chars are looking good, but some, eg. š are an empty box, even though they're displayed without any problems on the website. I'm sure it's not cheerio's issue, because when I printed the output using res.send(body); or res.send(JSON.stringify({"body":body}));, the empty box character was still present there. Is there a way to fix that?EDIT: I copied the empty box character to Google, and it has changed to š, maybe that's important

Submitted October 22, 2018 at 06:39AM by hamstersztyk

Recommend fully working projects/repositories built using the MERN stack.

I believe that part of learning coding is knowing how to read code. Please help me find large working open source projects/websites that are built using MERN stack. Thanks!

Submitted October 22, 2018 at 06:34AM by Demado

[ADVICE] Any Loopback4 Reviews?

Anyone using Loopback4?Now I'm looking at NestJS and Loopback4, which would be better for APIs?

Submitted October 22, 2018 at 04:42AM by xzenuu

How can I reduce the yarn installation memory footprint?

I'm trying to run a Node app with only 192 MB RAM without a swap file (VPS running on OpenVZ), but can't pass the installation process, it is simply killed when I try to run $ yarn. Is there a way to reduce the memory footprint needed for the installation process?

Submitted October 21, 2018 at 10:29PM by rraallvv

CLI for checking Github status

https://ift.tt/2Jbt6bV

Submitted October 21, 2018 at 08:38PM by xxczaki

Why should your Node.js application not handle log routing?

https://ift.tt/2NzeWpB

Submitted October 21, 2018 at 07:19PM by ccleary00

What should I keep in mind before flushing pm2 logs?

https://ift.tt/2S8VLCm

Submitted October 21, 2018 at 06:21PM by sioa

Sails.js learning resources

Hello,could you recommend me some learning resources on sails.js ?I was thinking about the book Sails.js in Action, but I it is already one year old, so I am afraid that stuff in there will be obsolete and it will not prepare me for newest version which is out right now. I need to learn it for my job so any advice would be highly appreciated.Thanks

Submitted October 21, 2018 at 05:10PM by Zovi343

Can anyone please share feedback on nest.js node framework?

So going for a pet project and looking to build backend. My previous node experience consists on building few api's for automation via rocket chat integration and some mingling with hubot. That's using express js.However, now I'm having a pet project, it's rather simple LMS system with some quizes and content. Going to use React for my frontend, but could use some more sophisticated backend. However, while I could use Symfony (php framework), I want to continue to develop my skills in javascript and potentially typescript. So I stumbled upon NestJS, which looks like fully fledged web framework when compared to less extensive tools like Express which I've previousy had used. Nest uses Express at it's core though.Documentation seems solid and it seems reasonably popular. However I'm a bit skeptical about dependency injection pattern being used in javascript, given that it's not class based OOP language, it feels more like a dragged in hack. But perhaps that's how typescript is done the correct way too?So please, help me out. Anyone who have experience in Nest JS or have a good eye for technologies used in typescript or even have extensive experience in Angular 2+ (nest is based on same patterns) is very welcome.Thank you!​

Submitted October 21, 2018 at 02:48PM by wherediditrun

Could anyone share feedback on nest.js framework?

DISCLAIMER: Sorry, dublicate, I've received 500 after creating first post. : lhttps://https://ift.tt/2NUDNR7

Submitted October 21, 2018 at 02:58PM by wherediditrun

Detect Internet Bot using NODEJS ... check it out ...

https://ift.tt/2EC3J4j

Submitted October 21, 2018 at 03:05PM by net-raft

Best practices with production timers?

Hi there,I'm looking to schedule a task to run every 60 seconds or so to clear up cached data in Redis.I've been thinking using a simple setInterval, but that feels like a "code smell" that would be hard to debug, update, etc.Any recommendations, things to consider, etc?

Submitted October 21, 2018 at 02:05PM by natanavra

Looping Inquirer.js Prompts

I tried to create a loop for inquirer.js for a command line application, where if certain conditions are satisfied, the application will loop to the start again. There is a second inquirer prompt where looping will be done according to the satisfied statement.inquirer .prompt(question1) .then(answers => { if (//condition satisfied){ //loop back to prompt question1. } inquirer .prompt(question2) .then(answers => { if (//condition satisfied){ //loop back to prompt question1. } else { //loop back to prompt question2. } }); }); For the first inquirer function, if the condition is met, I would like to loop back so the function is start over again. If condition is not met, then question2 will be asked by the next function.If the condition is met in this second function, I would again like to start over to the first function again. However, if it's not met ('else' statement), then I would like to ask the question2 again by looping back to the second function.The entire application will keep these looping operations until the user quits the program. However, I am having trouble implementing these looping action.

Submitted October 21, 2018 at 02:05PM by VickNicks

Fast, tiny Markdown to MDAST parser

https://ift.tt/2J7ZP1O

Submitted October 21, 2018 at 01:02PM by hexadecimalfreak

Developing a service with an RDBMS

I'm trying to find some advice/suggestions/best practices/etc on developing a Node service that depends on an RDBMS (specifically Postgres), in order to allow efficient development, quicker feedback loops, and easier ways to get started on a new machine - including an absolutely clean CI system. (Each build is in an empty container, and can run multiple concurrently so no shared dependencies)What I don't want is for developers to need to run and manage the database software themselves. That's a waste of time and energy.Additionally I want some way that automated tests that need a real database - basically the full stack tests and the DAO level tests - can be run easily by both developers and CI with the minimal of setup.Basically I'm wanting some way to run the software for development and automated test purposes such the the database is started and schema is bootstrapped automatically, and then all shut down afterwards.I assume such a thing is possible, but I'm struggling to see how. (Even a brief look at Docker seems to show that a lot of the modules haven't been updated in ages - things like grunt-dock or grunt-docker-spawn...)Cheers

Submitted October 21, 2018 at 11:18AM by sazzer

Saturday 20 October 2018

Sequencing asynchronous function calls in a foreach loop

I recently created web scraper for a local real estate investor that scrapes addresses from a single website that displays information about all counties in my state. This real estate investor needs addresses from multiple counties, so the scraper was built to take one argument - the county - so it can scrape everything for that county.The idea was to create an array of counties that I could pass to a foreach loop, calling the scraper as a function. Here's a sample:const ws = require("webScraper");​const counties = ["county1", "county2", "county3"];​counties.forEach(county => {ws.scrapePage(county);})​The information being scraped gets inserted into a CSV file, but I noticed that the counties are all out of order because scrapePage() function runs multiple times in parallel. I'd like it to wait until the one county is finished before passing in the next county. Does anyone know how to accomplish this?​***Additional Information***The site I'm scraping is built with React, so I needed a headless browser (nightmare.js) to navigate the site. That said, the webScraper module that holds the scrapePage() function uses promises. I just need to make sure that this forEach runs the scrapePage() function sequentially so I don't over-hit the server. How do I make the forEach finish the entire scrapePage() function for the first element in the counties array before calling the scrapePage() function again with the next element from the array?​

Submitted October 21, 2018 at 06:36AM by androidengel

Recommended me nodejs book (latest and updated)

No text found

Submitted October 21, 2018 at 03:07AM by redline97

Ok im new drop a link to how to use connect-flash | express-messages | PassportJs | Or just simpler solution plz getting depressed xD

No text found

Submitted October 21, 2018 at 12:35AM by marciusx1

Looking for socket.io developer tools / gui client

Yo reddit, I have node.js socket.io server and I want to test it somehow without creating my own client. is there any software to debug socket.io?

Submitted October 20, 2018 at 11:22PM by F1nya

Minimal & Modern boilerplate for building apps with React & styled-components

https://ift.tt/2S37Qcl

Submitted October 20, 2018 at 11:39PM by xxczaki

Multiple json objects

I'm not sure how to word this so please bear with me.So let's say I have these 2 json files:1.json{ "example": [ { "fruitId": "101", "fruitColor": "Red" }, { "fruitId": "102", "fruitColor": "Yellow" } ] } 2.json{ "fruits": [ { "fruitId": "101", "fruitName": "Apple" }, { "fruitId": "102", "fruitName": "Banana" } ] } How would I replace the fruitId in 1.json with the fruitName from 2.json? So this is how I want 1.json to look:{ "example": [ { "fruitId": "Apple", "fruitColor": "Red" }, { "fruitId": "Banana", "fruitColor": "Yellow" } ] }

Submitted October 20, 2018 at 10:39PM by IcyHeartWarmSmile

Requesting help with MEAN Stack setup/deployment

I am a MEAN stack beginner trying to get an arbitrary application up and running on a Digital Ocean droplet running Ubuntu 16.04 LTS. I do not actually have an application yet, so that can be as minimal as a 'Hello World'. I want to be able to see and interact with the application in a remote browser (I can't run a browser from where I'm hosting the application), and begin to understand the toolchain, directory structures, and get past the ops tasks involved in setting up an application.I have tried to use a number of MEAN stack guides online, but most of them have some major issues or don't seem to work in my use case. I'm not a total beginner to Linux and I've been experimenting and Googling and reading StackOverflow pages all day and I just can't seem to get everything to work together and am encountering a lot of issues especially with file permissions and don't really understand how to get Node serving in such a way that I can actually see an application in the browser. It seems so much easier to serve content using apache or nginx but I guess that's just because I have experience there.What configuration and commands do I need to run to actually minimally serving something? And how can I be sure that's serving in such a way I can see it from a remote browser (not on localhost)?If anyone would be willing to point me to a good guide or get on discord or something and help me, it'd be greatly appreciated.

Submitted October 20, 2018 at 11:04PM by cbslinger

Performance benefits of using classes?

I see a lot of code using classes for their controllers, DAL, etc.Is there a performance boost to creating classes and instantiating them where you need them opposed to making a bunch of functions that you export and import individually?class UserController { doSomething() { } doSomethingElse() { } } vsexport function doSomething() { } export function doSomethingElse() { }

Submitted October 20, 2018 at 09:33PM by jsscrub

Are crash courses good?

Im a hs student with little time to study web dev but i wanna learn a lot about coding. Are crash courses efective? What is the best way to learn node? I already know front end and am familiar with js.

Submitted October 20, 2018 at 08:31PM by DarthBaiter23

Is there an NPM package that can map ES module dependencies?

I have a Node.js codebase that uses ES modules.I want to be able to see what files include a specific file, e.g./foo.js import './bar.js'; /bar.js // I want to know which files in the project depend on this file. In the above example, if the subject file is bar.js, I want to know that /foo.js is depending on this file.I am assuming that ES modules permit static dependency inspection. Therefore, it should be possible to map all relationship between files.

Submitted October 20, 2018 at 07:42PM by gajus0

New data in mongodb: update directly or with one admin user account?

I'm building a simple Express app that stores content in a MongoDB database and displays it to anyone - no user account required to view.I want the creation of new content (new documents in the database) to be something only I can do. What would the advantages and disadvantages be of doing that either:A. by setting up user authentication for a single admin account and then pages with forms to post data to the DB that only I could accessB. accessing the database directly from my server somehow and adding or removing content that wayEdit: or is there some other way to do this?

Submitted October 20, 2018 at 04:05PM by veryfloppydisk

Upgrading to Babel 7

I am trying to upgrade my Vue.js project that uses Node.js server (with websocket, etc.) from using Babel 6 to Babel 7. I have downloaded the following NPM packages:- @babel/node - @babel/preset-env - @babel/core - @babel/cli And here is my current npm script: ./node_modules/.bin/nodemon --exec babel-node server.js --presets @babel/preset-envYet. When I run that, I get:➜ ~/vueproj/game git:(feat/items-overhaul) ✗ ./node_modules/.bin/nodemon --exec babel-node server.js --presets @babel/preset-env [nodemon] 1.18.4 [nodemon] to restart at any time, enter `rs` [nodemon] watching: *.* [nodemon] starting `babel-node server.js --presets @babel/preset-env` /Users/dan/vueproj/game/node_modules/@babel/runtime/helpers/builtin/es6/interopRequireDefault.js:1 (function (exports, require, module, __filename, __dirname) { export default function _interopRequireDefault(obj) { ^^^^^^ SyntaxError: Unexpected token export I could not find out how to use the CLI as the documentation for that was not good.

Submitted October 20, 2018 at 11:41AM by Ardougne1

Library to detect whether a image has been photoshoped?

I found an example solution online https://ift.tt/oeqKnb but unluckily it has been discontinued. Now I am looking for a nodejs library to make a similar function. Input is a bitmap image (a photo made by camera) and the out put can be a number, indicating how likely it is being modified and how much. Thanks!

Submitted October 20, 2018 at 10:15AM by guoyunhe

Friday 19 October 2018

Serving static files only to authenticated users

I have node/express app running behind an nginx proxy, all working perfectly, using nginx to server static files (e.g. all .css, .js, and .jpg ...)I would like to restrict access to some of these static files (particularity .jpg's) to only authenticated users in my node (using passport).What is the best way the achieve this whilst also maximizing the performance of nginx. X-Sendfile-Type X-Accel-Redirect seem to be the best thing I can find on the topic, but not entirley sure how to incorporate these into serving .js/.css/.jpg staticsthanks

Submitted October 20, 2018 at 01:06AM by hydroperox

Server-side rendering with nginx?

As far as I can tell, nginx is usually set up to try and serve static files in some directory based on whatever file extensions are specified in the configuration file. If I have a node server whose responsibility is generating HTML strings to be served back to the client, does this server need to write the HTML into a directory in order for NGINX to see it? Or can I simply pass this response back to nginx, which can send it back to the client, without having to write the file anywhere (which seems wasteful I/O-wise)?Basically my question is: how do I pass the server-rendered HTML to nginx so that nginx can serve it to the client? It looks like a proxy_pass is what I need in my nginx config file? If anyone has experience doing this I'd be interested to hear about it.

Submitted October 19, 2018 at 09:46PM by ConfuciusBateman

How to know when a node server is going to start rejecting traffic due to server load/traffic load?

Hi allI have a number of small node servers running behind a load balancer. The job of each small node server is to accept the request, copy its payload, and put the payload into a queue. A HTTP 200 is then returned.Each of the node servers is a $5 digital ocean droplet.This is all working fine, but I am sort of guessing when I need to add more servers to handle the load.So let's say the amount of traffic received doubles.1) Is there an easy way to know if the servers are struggling and dropping / rejecting traffic?2) Is there a way to be notified when the servers are reaching a critical point (e.g. "if the traffic increases by 5% more I'm going to have to start rejecting requests").Thanks for your help.

Submitted October 19, 2018 at 06:41PM by stiofan_io

Practice Project Recommendations

Hi, i recently learnt nodeJS and i have made a few apps/apis for practice like cms api, twitter poster, giphy api etc and a few more. I want to practice more by making some production level applications. If you have any suggestions. Please post.

Submitted October 19, 2018 at 05:13PM by Annoncat

Vue.js Authentication System with Node.js Backend

https://ift.tt/2AjpQbF

Submitted October 19, 2018 at 04:37PM by joshkale_

Do I have to hardcode urls?

Basically, I want to do some hrefs here and there and I was wondering if it was possible to reference the route instead of hardcoding the whole url. I did it with Django so I was assuming it would be there too but I can't find anything.​I want to do this:

Using NodeMailer with Node JS Webpage

Hey everyone :)​I'm relatively new to js and I'm trying to learn by making a backend for a website. I currently have everything up and running through gulp and I am trying to add an email contact form using nodemailer.I've created a file called email.js which is stored with the rest of my js files and is then brought in with in my 'index.html' file, the form in the html uses the following header,
. When I submit the form however, it simply gives me an error of 'Cannot POST /contact'.How would you guys advise I try and fix this? Thanks for all help.​The code for the 'email.js' is as follows:const nodemailer = require('nodemailer'); const express = require('express'); const bodyParser = require('body-parser'); const app = express(); app.use(bodyParser.urlencoded({extended: true})); // POST route from contact form app.post('/contact', function (req, res) { let mailOpts, smtpTrans; smtpTrans = nodemailer.createTransport({ host: 'smtp.gmail.com', port: 465, secure: true, auth: { user: 'email', pass: 'psw' } }); mailOpts = { from: req.body.name + ' <' + req.body.email + '>', to: 'email', subject: 'New message from contact form', text: `${req.body.name} (${req.body.email}) says: ${req.body.message}` }; smtpTrans.sendMail(mailOpts, function (error, response) { if (error) { res.render('contact-failure'); } else { res.render('contact-success'); } }); });

Submitted October 19, 2018 at 01:49PM by magicthrowaway10199

Getopts: A High-Performance Node CLI Options Parser

https://ift.tt/2rs7Rdy

Submitted October 19, 2018 at 01:13PM by JorgeBucaran

Building a Node.js standard library for microservices

https://ift.tt/2OykIch

Submitted October 19, 2018 at 11:49AM by theninj4

Having some problems writing to a database

So I've sort of got through my first problem (getting a column error), but am now getting null in all fields of my database when the write happens. Here's a chunk of what I've got (I left out some of the variable declarations, they're all similar to what you see here)var gameSession = gameDetails[5] var gameType = gameDetails[6] var otherInfo = mySQL.escape(gameDetails[7]) || "No info" var sql = 'INSERT INTO gameinfo VALUES (`GameName`, `system`, `days`, `timeRange`, `gameSession`, `gameType`, `otherInfo`);' connection.query(sql, function(err, result){ if(err) throw err; console.log("1 record inserted"); }); Now, I've never played with databases before, but in trying to get this to work and reading documentation, it seems like this insert is supposed to take the variables, and make that that variables position, the contents of that variable. However, if I change one of the names of my variables, say 'GameName' to just 'Name' in the code, but not the DB i get an errorError: ER_BAD_FIELD_ERROR: Unknown column 'Name' in 'field list' Which looks to me like either 1) I'm supposed to have my database columns with the same name as my variables (which I thought was a bad practice, as it made attacks easier) or 2) I'm completely misunderstanding, something.

Submitted October 19, 2018 at 11:38AM by akuthia

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

https://ift.tt/2PGU79F

Submitted October 19, 2018 at 11:30AM by Rajnishro

Issue with Oauth2 Google scope

Thursday 18 October 2018

Loopback question: I keep getting a 401 status error when I try to use a custom method.

I've taken over a react-native project that uses Loopback. The previous developer created a Model called "account". In it there are a bunch of custom methods that he created. They all work properly. However, when I created my own method called "deleteSingleHearingTest". It is never reached. I keep getting a 401 status error message. Inside the account.json file I've updated the ACL object to include this: { "accessType": "EXECUTE", "principalType": "ROLE", "principalId": "authenticated", "permission": "ALLOW", "property": "deleteSingleHearingTest" } Is there any other place I need to make sure I give an authenticated user permission?

Submitted October 19, 2018 at 03:39AM by jjssjj71

Connect-Mongo (session store for Express and Connect) looking for maintainers

https://ift.tt/2cRpkrj

Submitted October 19, 2018 at 04:28AM by mod-victim

Hey guys i just build a NodeJs and MongoDb starter kit. If you guys have any suggestion please let me know. I'm kind of new to web development just doing this for a year

if any of you guys want to contribute or have any suggestion please refer to my Github repositoryyou can also read the full article here https://ift.tt/2IXTsOo

Submitted October 19, 2018 at 03:32AM by thakursachin467

could you please help me with a problem

https://ift.tt/2CPFEFu

Submitted October 18, 2018 at 09:10PM by clarke12342003

Setting up Nodejs Backend for a React App – Crowdbotics – Medium

https://ift.tt/2PHk9cP

Submitted October 18, 2018 at 07:33PM by simplicius_

This course was designed to be interactive, with more than 80 challenges along the way to get you writing code and solving problems on your own. This will give you the real-world skills and experience needed to write GraphQL applications once you’re done with the class.

https://ift.tt/2OA1LpS

Submitted October 18, 2018 at 07:47PM by prdniminakuro

Require googleapis in private helper lib... good idea? bad idea?

My team and I are working on building various microservices between all of our business applications, and are about 1.5 years into our serverless journey. We are reaching out to various systems repeatedly(G-Suite, Workday, NetSuite, Zendesk, Etc), so we decided to create a common lib to store our helper functions, breaking each system into a separate class to allow us to tree shake what we need when we need it.The lib is starting to get large and the open topics on the table are:Is the way we've structured the common lib good practice? or should we be breaking this up into smaller lib modules per system?Each of these classes uses a large lib (ex. aws-sdk, googleapis, etc.) and in efforts to keep the common-lib small, we are passing in the clients from these large libs into the common lib constructor. Is this good practice?If we were to break up the common lib anyways, should we still be passing in the clients to keep those modules small?Using NodeJS 8.10Thanks in advance!

Submitted October 18, 2018 at 06:34PM by b1ackha7

Basics of Node REPL ( Read Evaluate Print Loop)

you can use experiment node commands in node command line which is called REPL(Read Evaluate Print Loop). Its kind of cool thing to try if you want to just bored of coding. :)you can explore more herehttps://github.com/IsAmrish/bootstrap/blob/master/nodejs/README.md

Submitted October 18, 2018 at 05:33PM by isamrish

Good Jest examples for testing an API?

Hi, I want to get more in the habit of writing tests for my applications.​I've looked at a lot of tutorials on medium, and youtube and found some good examples of how to use Jest, (and also their documentation was really helpful and well written), but I still can't find good examples of how to write tests for real applications. Most of the tests I've found were pretty simple, and small files where everything is in 1 file which makes it easy to test.​However, I'd like to see examples of projects that use jest for testing an API where the API actually makes a call to a database or something.​I've looked through github repos of google and facebook, and I've found some examples of how they test their code, but not all examples use jest, and not all examples involve testing API calls.​So I was wondering if anyone could show me some examples of repos that use jest to test code that relies on other dependencies/APIs.

Submitted October 18, 2018 at 04:04PM by ns_helloworld

How To Build A Money Data Type In JavaScript And Avoid The Floating Point Trap

https://ift.tt/2QLQFL9

Submitted October 18, 2018 at 08:08AM by fagnerbrack

Text Yourself the NASA Picture of the Day with Standard Library and Node.js

https://ift.tt/2QYiHD7

Submitted October 18, 2018 at 08:01AM by LibProgrammer

Wednesday 17 October 2018

Naming Convention

I don't know is this right thing to post here. But, I was reading someone's code yesterday and I found that he wrote the file name as user.controller.js. So, I am wondering why it is user[dot]controller[dot]js instead of user_controller.js? is there any special naming rule for Node and express based application?

Submitted October 18, 2018 at 06:23AM by tech3ad

I'm looking to be a node backend dev. What should I have on my portfolio in terms of projects?

Obviously the CRUD+Auth Rest API should be there but what else is relevant?

Submitted October 18, 2018 at 05:33AM by dexterleng

Upgrading from Webpack 1 to 4 - Anyone Got Good Resources/Tutorials?

Hey all, like the title says, I'm upgrading some old Webpack code. Hoping someone might have some links to where I can find helpful tutorials on each step.​Thanks in advance, guys.​​

Submitted October 18, 2018 at 05:34AM by urban-developer

Query MQTT?

I have a process question as I am starting to go cross eyed on this. I have a MERN app and a IOT enabled device that publishes a heartbeat message back to a device specific MQTT channel. I want to show in my Node UI whether a device is online or offline based on this heartbeat message. How would one do this?Option 1 - Create a socket.io / MQTT Subscription to the Device channel in the UI, for each heartbeat update the status to online. If I get a Offline payload, turn it to offline. The issue is I will not always get an offline unless they shut down the IOT device gracefully. Alternatives?Option 2: Add a lastknown timestamp for my Device. Force the IOT device to call a API bypassing MQTT all together (which I am using for everything else) which updates the lastknown timestamp associated to the device.. This method seems the most concrete but it's not using MQTT which is already in place and working fine.Option 3: Add a lastknown timestamp for my Device model then build a background service that will constantly monitor a MQTT subscription and on each heartbeat update the lastknown timestamp. For the UI, if the timestamp is within a minute of now then mark the device as online otherwise mark it as offline.

Submitted October 18, 2018 at 01:01AM by fender21

Beginner Troubleshooting Question: Console.log Outputs on Heroku?

I am trying to debug my first deployed node app currently. It is on Heroku. I am having trouble finding where my console.logs go. I have tried a lot of variations of the heroku logs command (--tail --app etc.) and I am starting to think the logs are someone else. Google and stack overflow have not been big helps so perhaps someone here can help?Where do my console.log statements output?

Submitted October 17, 2018 at 09:16PM by Marshawn_Washington

Build an Electron App with Angular 7

https://www.youtube.com/watch?v=RV868-R4F2Y

Submitted October 17, 2018 at 10:07PM by AngularActivity

JADE PUG - Its roles and uses in NodeJS application development?

https://ift.tt/2CkHGMZ

Submitted October 17, 2018 at 08:22PM by aishks14

function to query multiple Mongodb collections

So i'm new to nodejs/mongo but i'm trying to figure out a way I can query multiple collections and return the results of each of the querys into one variable. Is this possible?​function getblacklistdata(datasets, start, end) { MongoClient.connect('mongodb://localhost:27017/', { useNewUrlParser: true }, function (err, client) { if (err) throw err; var db = client.db('blacklist'); var rdata = []; for (var i = 0; i < datasets.length; i++) { db.collection(dataset[i]).aggregate( { "$match": { "ipaddr" : { "$gte" : start, "$lte" : end } } }, { "$group" : { "_id":"$ip_str", "lists_count":{ "$sum":1 }, "blacklists": { "$addToSet": '$list' } } }, { "$project": { "ip":"$ip_str", "lists_count":"$lists_count", "blacklists":"$blacklists" } } ).toArray( function( err, data ) { if ( err ) throw err; // append data to rdata array here } ); }; }); //return rdata for the function at the end } ​

Submitted October 17, 2018 at 09:01PM by PaymentRequired402

How to programmatically load an iframe in node?

I am very new to node (only know frontend javascript), but I am trying to load a page for one second, and then parse the contents of that page, then output them. Is this even possible with node?

Submitted October 17, 2018 at 09:04PM by iainmoncrief

Learn ExpressJS (NodeJS) by building a random number Generator

https://ift.tt/2PDKl8f

Submitted October 17, 2018 at 08:57PM by caprica-six-bsg

Creating a logger in Node.js from scratch

https://ift.tt/2CP3IbG

Submitted October 17, 2018 at 07:03PM by efunction

[Help] Why doesn't this work?

to make things short, this is my code on a small project:const environment= process.env.NODE_ENV console.log(environment) //development console.log([environment]) // [ 'development' ] console.log(process.env.NODE_ENV) //development const stage = require('./config')[environment] console.log(stage) //undefined my config file is just an object: module.exports = { development: { port: process.env.PORT || 3000 } } NODE_ENV is set to development when i start the server.why is stage still undefined? environment is correctly set as development, and if i just useconst stage = require('./config').development everything works as it should.so why my stage const keep showing as undefined when i use NODE_ENV?thanks!

Submitted October 17, 2018 at 08:07PM by ImtheDr

How and why I built A nodeJs-MongoDb Starter kit

Now this problem is quite common with all the developers. Whenever we start a new project we have to repeat the same steps again and again of downloading the dependencies and requiring all the dependencies into our project. We repeat this process again and again in every project and sometimes it becomes hectic and we forget certain steps and then we have to debug the entire app to see where we made the mistake where we form to import something or installing certain dependencies into our application. Now you see the problem. It might not be happening with you now but at a certain point in our development phase we will face this problem.Every time we start a new project, we’re overwhelmed at the selection of build tools, testing frameworks, component libraries and more. Best solution? A starter kitif any of you guys want to contribute or have any suggestion please refer to my Github repository

Submitted October 17, 2018 at 06:31PM by thakursachin467