Monday 30 September 2019

What is your view on nest js framework?

I work as Angular and PHP developer. I try to learn node js with express. I think it's only a middle ware framework. Scene I aware of typescript, I choose nest js. I cool and easy. I don't need to learn new things. It makes it life easier for me. So framework you prefer and why. Is nest js is a good choice?

Submitted October 01, 2019 at 05:30AM by maximumfate

Hashing Passwords

Are there any companies that provide password hashing services and are they affordable?

Submitted October 01, 2019 at 03:06AM by RoyalsRule

REST or Socket for Browser Based Game?

Hello everyone,I'm currently trying to build a smalll browser based MMO and need some advice. Let me preface this by saying I'm a frontend guy, and not too experienced with backend & security.Currently what I have is a React frontend & Express/Mongo REST server for the API. I'm using a JWT token to authorize API calls.I'm concerned that having endpoints that the users can potentially exploit might cause problems in the future.I don't know what best practice is but do you think having a socket connection rather than a REST API would be a more secure solution?

Submitted October 01, 2019 at 03:44AM by ObviouslyNotANinja

What is needed to deploy a fullstack app?

( Posted on another subreddit but posting here to get more responses)I'm new to this stuff. I know frontend quite well (HTML, CSS, JS), and know how to deploy it to static severs (GitHub Pages, for instance). It's very straightforward.What's confusing me though is being able to deploy a full-stack app (basically, one with front end and back end. Like say a project that has React on the front end and Node/Express on the backend). I tried deploying one to Heroku, but it seems like I have to deploy both parts separately? (i.e. deploy the back end and front end as sepereate entities/projects/apps and then link them together somehow). I don't get how the process works. It's much more difficult than basic front end.Do you guys get what I'm asking now? Basically, what is the list of steps needed for deploying a full-stack application?

Submitted October 01, 2019 at 03:58AM by GreenMess0

Certainty-js: Automated CACert.pem Management for Node.js Software

https://github.com/paragonie/certainty-js

Submitted October 01, 2019 at 01:34AM by sarciszewski

What are the best practices to work with https/certificates in a project? Should I commit the certificate to the repository? Should I use the production certicate in my development environment?

I never really worked using https, recently I got to work in a project that requires https intead of http. It was quite easy to convert the http setup to https, but I have some doubts about how to handle certificates. From what I saw, the other developers from another project put the certificates inside a folder and commited it to the repository and used it in the development and production evironments.I don't think this is the best practice in this case, so I put the certificates in the gitignore and tryed to set up an self-signed certificate using openssl to work in development environment. The only thing that doesn't seem to work is that chrome browser complains about this certificate and I have to setup postman to accept it.What advice would you give me?

Submitted October 01, 2019 at 01:44AM by eliseu_videira

Build and Deploy a Realtime Chat Application - Socket.io, Node.js, and React.js

Hello everyone, I won't rattle on too much, everything is in the title. I created a YouTube video about building a real-time chat application, if you're interested, feel free to take a look. Here's the link - https://youtu.be/ZwFA3YMfkoc.Any feedback and/or critique is welcomed and appreciated! :)

Submitted September 30, 2019 at 06:12PM by HolidayInternet

Any project ideas we can collaborate on?

Hello, are there any ideas we can collaborate on? Profitable and NonProfitable too

Submitted September 30, 2019 at 06:31PM by xxxxsomeguyxxxx

Help publishing soap endpoint protected by basic auth

I'll preface this with the disclaimmer that I am historically more of an infrastructure person, now in a position that I need to build several web services. Due to business requirements, I am trying to create what should be a very simple service using node-soap, exposing a soap endpoint protected by basic auth. I have followed the documentation to create a basic soap endpoint, which is working with a very basic wsdl, and I have followed the documentation for securing a Node service using basic auth.​My problum is that Node is protecting everything except the /wsdl context with basic auth, but when I get into the soap.listen event basic auth is ignored and all unauthenticated requests are processed. I suspect I am missing something very basic, so anything you can point me to is appreciated. Searches and documentation seem primarily focused on calling a soap endpoint with basic auth and there don't seem to be any good examples of actually publishing such a service using Node.​My server functions​var server = http.createServer(function(request,response) {var credentials = auth(request);console.log('Checking credentials');if (!credentials || !check(credentials.name, credentials.pass)) {response.statusCode = 401response.setHeader('WWW-Authenticate', 'Basic realm="example"')response.end('Access denied')}response.end('404: Not Found: ' + request.url);});function check(name, pass) {var valid = true//Simple method to prevent short-circut and use timing-safe comparevalid = compare(name, 'john') && validvalid = compare(pass, 'secret') && validreturn valid}server.listen(8000);soap.listen(server, '/wsdl', WorkOrderService, xml, function(){var authorized = check('user','pass');soap.authorizeConnection = function() {return false;};console.log('server initialized');});​I've tried placing the check call into the soap.listener, and tried both false and true for the soap.authorizeConnection. As mentioned, I'm new to both SOAP and Node, so please do not be shy about pointing out the basics.

Submitted September 30, 2019 at 05:36PM by infra2dev

Need some help with getting value out of .save() function with Mongoose

Hey,I have written the following code:module.exports = (parent, args, context, info) => { let mutationReturn; mongoose.connect(config.MONGO_DB_URL) var db = mongoose.connection db.on('error', console.error.bind(console, 'connection error:')); db.once('open', () => { console.log('Connection successful!') const Race = mongoose.model('Race', RaceSchema, 'RaceStore') const clientRace = new Race(args.race) clientRace.save().then(race => { mutationReturn = { id: race._id, name: race.name, naturalAttributes: race.naturalAttributes, skill: race.skill } }) }) return mutationReturn } The variable mutationReturn is always undefined. I'm not amazing with Promises, could I have some help getting this to work, please?

Submitted September 30, 2019 at 03:49PM by K9_Morphed

Senior Devs: Looking for feedback on basic password hashing strategy

I'm implementing basic password hashing/validation using Node/Express/Bookshelf/Postgres. crypto module for encryption. I'd appreciate critique/feedback // protocol.config.js const protocols = { 'v1': { keylen: 64, digest: 'sha512', iterations: 100000, encoding: 'hex', salt: { size: 128, encoding: 'base64' }, }, } // UserModel.js class User extends bookshelf.Model { get password(){ return this.attributes.password; } get salt(){ return this.attributes.salt; } get protocol(){ return 'v1' } static async generateSalt(config){ const buf = await randomBytes(config.size); return buf.toString(config.encoding); } static async encrypt(string, salt, config){ const derivedKey = await pbkdf2(string, salt, config.iterations, config.keylen, config.digest); return derivedKey.toString(config.encoding); } static async save({ password, ...data }){ const salt = await User.generateSalt(protocols[this.protocol].salt); const hash = await User.encrypt(password, salt, protocols[this.protocol]); const hashSaltProtocol = String.prototype.concat.call(hash, '$', salt, '$', this.protocol); return this.forge({ ...data, password: hashSaltProtocol }).save(); } async comparePassword(string){ const [password, salt, protocol] = this.password.split('$'); const hash = await User.encrypt(string, salt, protocols[protocol]); return crypto.timingSafeEqual( Buffer.from(password, protocols[protocol].encoding), Buffer.from(hash, protocols[protocol].encoding) ); } } High level explanation:Save all password protocols in external file.Set current password protocol on the model.Password is hashed using current protocol.Random salt is generated using current protocol.Password, salt and version are saved together in password field in User table. ie "passwordhash$salt$version"When user submits a password for validation, the saved password is retrieved from table and split.Submitted password is encrypted using salt and version of the saved password.Password and submitted password are compared using timingSafeEqual instead of naive comparison (i.e. "===");The big idea is that I want a flexible solution for bumping password hashing protocols without impacting passwords hashed from previous versions or storing that data in the table.

Submitted September 30, 2019 at 02:56PM by brodega

Three Different Ways to Create Objects in JavaScript

https://medium.com/better-programming/three-different-ways-to-create-objects-in-javascript-d3595d693296

Submitted September 30, 2019 at 01:53PM by noharashutosh

Where can I learn about production ready, proper architecture best practices for nodejs servers?

Any good resources? I am finding lots of beginner tutorials, but I need something more advanced!

Submitted September 30, 2019 at 01:53PM by christophanderson12

Node packaging using gulp

I am faced with a situation where I need to install all dev dependencies in a project as global dependencies. It it possible to do something like that in node?

Submitted September 30, 2019 at 01:53PM by praveenfun2

Auto article creator

I know how to take information from form but i need now to take this information and create an article with pug and nodejs

Submitted September 30, 2019 at 01:55PM by Nikas_GreenFetus

Preferred Package Manager in 2019?

It's been almost 2 years since using node seriously but am about to jump back in. What's the package manager of choice these days - npm or yarn? Yarn introduced the lock file, but npm added similar (the same?) functionality shortly after.What are you using these days?

Submitted September 30, 2019 at 01:41PM by intertubeluber

Full Stack Unsplash Image Gallery App with React and Node and CSS Grid

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

Submitted September 30, 2019 at 12:52PM by coderchrome123456

Releasing ascii-themes, a Node.js CLI to Generate VSCode Themed ASCII Art

https://medium.com/@lakatos/releasing-ascii-themes-a-node-js-cli-interface-to-generate-vscode-themed-ascii-art-8ac516ad5f21

Submitted September 30, 2019 at 12:36PM by panthera_services

Host a Node Js App

Can i host a node js app on a shared mutual plan ?

Submitted September 30, 2019 at 10:02AM by TheGreelax

Sunday 29 September 2019

Is fs.Promises API still experimental?

I'm on Node v10.16.0, the current LTS version is v10.16.13. I keep getting warnings saying that fs.Promise is experimental since my current project uses fs.Promises. Should I completely switch from fs.Promises and just use the regular fs API? I'm worried that if people install my module there will be incompatibility issues since I'm thinking some people might be using older versions of Node.

Submitted September 30, 2019 at 07:52AM by ansonplusc

Controller that creates bank transaction with some rules

Hello, guys! I need to create a simulation of a bank transaction with a few specific rules.For example, if the type of the payment is done with a debit card, it must be charged a fee of 3.2%.For now I could not set up the rules in the controller yet. Could someone help me out? Here is how my current controller looks like:javascript async store(req, res) { const { type_transaction } = req.body; if (type_transaction === 'debit') { let { value } = req.body; return value += 32; // random value just to test if it'll be saved in the db } const transaction = await Transaction.create(req.body); return res.json(transaction); }With the method above, I'm able to change the value, but I'm not able to save the changed value to the DB. Like the image below:https://user-images.githubusercontent.com/16469917/65846188-54e9c100-e313-11e9-8fb5-6f0173dd514d.pngThis is how the Transaction Model looks like now:```javascript class Transaction extends Model { static init(sequelize) { super.init( { value: Sequelize.INTEGER, description: Sequelize.STRING, type_transaction: Sequelize.STRING, installments: Sequelize.INTEGER, }, { sequelize, }, );return this; // ... CONTINUES ``` Could anyone help me to solve this problem?

Submitted September 30, 2019 at 03:47AM by brainiac__

Resumable file uploader.

https://youtu.be/R70yli6bSy4

Submitted September 30, 2019 at 04:14AM by subrat_msr

Best file/code structure for Node + Mysql?

What is the best project structure for Mysql on node? I want to be able to make queries in different files/routes. How should the database connection file look like, and what is the best way to reuse that connection ( pool?) in other files? Could someone help me out, or at least redirect me to an open source project that would make a great example.

Submitted September 29, 2019 at 08:50PM by amza10

My Machine learning (NEAT) algorithm library

here is my library implementing the neat ( Neuroevolution of augmenting topologies) algorithmany contributions feedback or pull requests are welcomehttps://www.npmjs.com/package/neat_net-jshttps://github.com/ExtensionShoe/NEAT-JS

Submitted September 29, 2019 at 08:12PM by Extension_Shoe

Hanlde JWT expiration and re-trigger unauthorized axios call using vue js and axios with node as backend

Hi there, i am building an API which uses JWT to maintain authentication for the user but i m having trouble to maintain the JWT token as most of the time ehat is happening is that i have JWT valid for 15 min and if user triggers a call to server that needs a valid JWT it fails and server returns 401 / 403 unauthorized status then i dont know how to handle that expiration time and re-trigger the call after re-authenticating the user.I am using vue-cli and axios for frontend and node js, express and jsonwebtoken for backend. ANY helpp.So almost struggle for the authentication part for evey api is create as i have no idea how to handle expiration time along with re-trigger the unauthorized call again without user having to click it again

Submitted September 29, 2019 at 07:38PM by kgoel085

Having trouble with Mongoose/Promises

I'm fairly new to Mongoose and the idea of promises, so I've been having some trouble with creating this API.\ var deserialized = (JSON.parse(tournament.content)); //console.log(deserialized[0]['team']); Robot.find().then(robot => { for (var i = 0; i < robot.length; i++) { Wheel.findOne({ type: robot[i].wheel }).then(wheel => { if (!wheel) { const wheel = new Wheel({ type: robot[i].wheel, total: total += deserialized[i]['score'], teams: 1, average: total }); wheel.save(); } else { wheel.teams++; wheel.total += deserialized[i]['score']; wheel.save(); } Wheel.find().then(wheel => { Robot.find({ wheel: wheel[0].type }).then(finalRobot => { for (var k = 0; k < finalRobot.length; k++) { for (var j = 0; j < deserialized.length; j++) { if (deserialized[j]['team'] == finalRobot[i].team) { deserialized[j]['score'] *= 1.1; console.log(deserialized[j]['score']); } console.log(deserialized[j]['team']); console.log(finalRobot[i].team); } } }) .catch(err => console.error(err)) }) }) } }) When I run this in my app, I keep getting this error: TypeError: Cannot read property 'team' of undefined, which I presume is because it's trying to access data that hasn't been returned yet. How would I chain these promises together in order to prevent that from happening?​Thanks!

Submitted September 29, 2019 at 03:15PM by dayofboredom

How to Learn Software Design and Architecture [Roadmap]

https://khalilstemmler.com/software-design-roadmap

Submitted September 29, 2019 at 03:24PM by stemmlerjs

Project Ideas for MERN

Any project ideas to make with MERN? (Mongo, Express, React, Node)

Submitted September 29, 2019 at 02:41PM by xxxxsomeguyxxxx

Cant install npm

Hey.When i try to install npm via sudo apt i get this error:tarting pkgProblemResolver with broken count: 1 Starting 2 pkgProblemResolver with broken count: 1 Investigating (0) php7.2-dev:amd64 < 7.2.19-0ubuntu0.18.04.2 @ii mK Ib > Broken php7.2-dev:amd64 Avhenger av on libssl-dev:amd64 < 1.1.1-1ubuntu2.1~18.04.4 @ii mR > Considering libssl-dev:amd64 0 as a solution to php7.2-dev:amd64 1 Added libssl-dev:amd64 to the remove list Fixing php7.2-dev:amd64 via keep of libssl-dev:amd64 Investigating (0) libssl1.0-dev:amd64 < none -> 1.0.2n-1ubuntu5.3 @un uN Ib > Broken libssl1.0-dev:amd64 Er i konflikt med on libssl-dev:amd64 < 1.1.1-1ubuntu2.1~18.04.4 @ii mK Ib > Considering libssl-dev:amd64 0 as a solution to libssl1.0-dev:amd64 0 Holding Back libssl1.0-dev:amd64 rather than change libssl-dev:amd64 Investigating (0) nodejs-dev:amd64 < none -> 8.10.0~dfsg-2ubuntu0.4 @un uN Ib > Broken nodejs-dev:amd64 Avhenger av on libssl1.0-dev:amd64 < none | 1.0.2n-1ubuntu5.3 @un uH > (>= 1.0.2) Considering libssl1.0-dev:amd64 0 as a solution to nodejs-dev:amd64 -1 Holding Back nodejs-dev:amd64 rather than change libssl1.0-dev:amd64 Investigating (0) node-gyp:amd64 < none -> 3.6.2-1ubuntu1 @un uN Ib > Broken node-gyp:amd64 Avhenger av on nodejs-dev:amd64 < none | 8.10.0~dfsg-2ubuntu0.4 @un uH > Considering nodejs-dev:amd64 -1 as a solution to node-gyp:amd64 -1 Holding Back node-gyp:amd64 rather than change nodejs-dev:amd64 Investigating (1) npm:amd64 < none -> 3.5.2-0ubuntu4 @un puN Ib > Broken npm:amd64 Avhenger av on node-gyp:amd64 < none | 3.6.2-1ubuntu1 @un uH > (>= 0.10.9) Considering node-gyp:amd64 -1 as a solution to npm:amd64 9998 Re-Instated libssl1.0-dev:amd64 Re-Instated nodejs-dev:amd64 Re-Instated node-gyp:amd64 Investigating (1) libssl1.0-dev:amd64 < none -> 1.0.2n-1ubuntu5.3 @un uN Ib > Broken libssl1.0-dev:amd64 Er i konflikt med on libssl-dev:amd64 < 1.1.1-1ubuntu2.1~18.04.4 @ii mK Ib > Considering libssl-dev:amd64 0 as a solution to libssl1.0-dev:amd64 0 Holding Back libssl1.0-dev:amd64 rather than change libssl-dev:amd64 Investigating (1) nodejs-dev:amd64 < none -> 8.10.0~dfsg-2ubuntu0.4 @un uN Ib > Broken nodejs-dev:amd64 Avhenger av on libssl1.0-dev:amd64 < none | 1.0.2n-1ubuntu5.3 @un uH > (>= 1.0.2) Considering libssl1.0-dev:amd64 0 as a solution to nodejs-dev:amd64 -1 Holding Back nodejs-dev:amd64 rather than change libssl1.0-dev:amd64 Investigating (1) node-gyp:amd64 < none -> 3.6.2-1ubuntu1 @un uN Ib > Broken node-gyp:amd64 Avhenger av on nodejs-dev:amd64 < none | 8.10.0~dfsg-2ubuntu0.4 @un uH > Considering nodejs-dev:amd64 -1 as a solution to node-gyp:amd64 -1 Holding Back node-gyp:amd64 rather than change nodejs-dev:amd64 Investigating (2) npm:amd64 < none -> 3.5.2-0ubuntu4 @un puN Ib > Broken npm:amd64 Avhenger av on node-gyp:amd64 < none | 3.6.2-1ubuntu1 @un uH > (>= 0.10.9) Considering node-gyp:amd64 -1 as a solution to npm:amd64 9998 Done Noen pakker ble ikke installeres. Dette kan bety at du har bedt om en umulig tilstand eller, hvis du bruker den ustabile utgaven av Debian, at visse kjernepakker ennÃ¥ ikke er laget eller flyttet ut av «Incoming» for distribusjonen. Følgende informasjon kan være til hjelp med Ã¥ løse problemet: The following packages have unmet dependencies. npm : Avhenger av: node-gyp (>= 0.10.9) men skal ikke installeres E: Klarer ikke Ã¥ rette problemene, noen ødelagte pakker er holdt tilbake.

Submitted September 29, 2019 at 12:20PM by Norsk_Viking

Display Progress bar with NodeJs

I have created a post to display the progress bar during file download. I guess it will help the newbies to know more about the Node Js.​https://webomnizz.com/download-a-file-with-progressbar-using-node-js/

Submitted September 29, 2019 at 12:02PM by jogeshpi06

PWA Manga Reader in React/Node.js | Setting up MongoDB with Mongoose | Part 2 | Pair Programming

https://www.youtube.com/watch?v=2gV_pzRwB0w

Submitted September 29, 2019 at 11:32AM by singsong43

Catage: A CLI tool to capture screenshots of your code with execution result

https://github.com/thatisuday/catage

Submitted September 29, 2019 at 11:36AM by thatisuday

What are Some Projects Ideas Built Using Socket.IO?

No text found

Submitted September 29, 2019 at 09:37AM by noodleLinux

I created a cli tool that lets you create quick and simple scaffolds for Discord bots

Hi,A few days ago it occurred to me that I was getting tired of re-writing my bot templates over and over again.I felt like this could help some beginners out with having a proper structure and keeping it organized, instead of having all of their files jumbled up together. The angular cli inspired me. I also tried to see if there were any cli tools that did this, I wasn't able to find any from Google but hopefully there's room for another one if there exists one already.As of right now only discord.js projects work and you need a Node version that supports fs promises but I will change that soon because I understand some people may have older versions, and fs.promises is still experimental i think.GitHub: https://github.com/ansonfoong/djs-cli-toolNPM: https://www.npmjs.com/package/discordjs-cliYou can create either a plain discord.js project, or one with the commando framework. You can also generate commands and events, and it will build a basic template for you. Currently still trying to find other potential bugs and also working on other features to support more arguments. But if anyone here is interested in checking out the source code and giving me advice I would appreciate it.

Submitted September 29, 2019 at 09:52AM by ansonplusc

I want to work for free!!

I’m looking for opensource projects that are in need of contributors. As a senior Java developer exploring other languages, I’m looking for experience with JavaScript/Node.So if you know of any friendly communities, please let me know ;)TypeScript projects are also very welcome.. #staticTypingRules

Submitted September 29, 2019 at 10:18AM by RevertCommit

Loopback v4 vs NestJS

Hi r/node,I've been comparing between Loopback v4 and NestJS as an opinionated API framework. At the surface, they both seem to have feature parity (albeit Loopback v4 is lacking certain features due to the complete rewrite from v3).SimiliaritiesTypescript-firstOOP DI & IoCOpenAPI-compatibleGraphQL-compatiblePassportJS-compatible authenticationInterceptorsConnectors for popular databasesCLI-generated codeExpressJS and Hapi aren't listed as they are not really comparable as they work on a lower layer.Is there any reason why to choose one over the other?

Submitted September 29, 2019 at 08:02AM by seryup

Saturday 28 September 2019

Creating virtual audio input and output devices

Is there any way to create virtual speaker and microphone on a machine using Node.js? I'm just looking to add a virtual media device that can be used by webapps through MediaDevices Web API

Submitted September 29, 2019 at 07:36AM by AnxiousBottle

Best practices when using React (hooks), Socket.io and Express for my app (NOT a chatroom app)?

I'm building an app that is NOT an online chatroom with Socket.io.Now It's just basically a JSON file that has to be in sync with all connected clients, everyone can edit the file and broadcast it to others. The file is stored locally and is re-written each time it's updated.How the hell do I initialise a connected client with the current file (both if the server goes down and up, and when clients join for the first time)Also what is the best way to keep track of socket.connected within my context provider?I'm sorry if this is poorly written but I have literally read every single article online and the doc's like a hundred times and I'm always ending up with some weird code that doesn't work.

Submitted September 29, 2019 at 04:02AM by Crispy_Kleina

API calls and HTTP Status codes

https://medium.com/@JSantaCL/api-calls-and-http-status-codes-e0240f78f585?source=friends_link&sk=9535b29c53fe5b588a1eb4b2c53febe7

Submitted September 28, 2019 at 10:13PM by congolomera

Can someone help with a project for iOS? Please dm me

No text found

Submitted September 28, 2019 at 07:53PM by goldy412

NodeJS: Encryption/Decryption.

Is NodeJS crypto module secure enough for production use, or you would rather use other external modules like bcrypt or cryptoJS? Other suggestions are welcome.

Submitted September 28, 2019 at 05:18PM by haykerman

Is installing nodejs on a 32 bit linux machine possible

Hello, I need to install nodejs on a lubuntu laptop (32 bit)I know that node doesn't support 32 bit machines, but is it still possible to install it?Thanks

Submitted September 28, 2019 at 03:44PM by jati1115

What's a good http mocking library?

I have been using nock so far, but want to look at alternatives. The project I work on has a lot of API chatter and using nock has become tedious. So how do you all mock API responses and what libraries do you use?

Submitted September 28, 2019 at 01:31PM by johndoepbabu

Code Faster with Visual Studio Code Snippet Generator

https://youtu.be/J8EYFZotFzk

Submitted September 28, 2019 at 01:06PM by coderchrome123456

I made a chrome and firefox extension that shows the total number of nested dependencies for an npm package

https://github.com/bibo5088/npm-nested-dep

Submitted September 28, 2019 at 10:59AM by bibo5088

I created a ORM using Redis, suitable for microservices

Here is the library, please enjoy:https://www.npmjs.com/package/ts-redis-ormFeatures highlight:Simple class structure using typescript decorator. (Very similar to type-orm)Using native JS value types (Number, String, Boolean, Date, Array, Object).Atomic. All redis logics are written in Lua to protect data integrity.Schema validation and database reSync.Support multiple index keys and unique keys.Built-in entity timestamps (createdAt, updatedAt, deletedAt) .Soft delete.Aggregate functions (count, sum, min, max, average).You do not need to initialize a connection before using the entity. It's all done internally.Import / Export DB into file.Good Performance. You can create around 10, 000 entities in 1 second for 1 CPU process. Query is also extremely effective with proper indexing settings.

Submitted September 28, 2019 at 10:39AM by plk83

Building a Production - Ready Node.js App with TypeScript and Docker - Cloudnweb

https://cloudnweb.dev/2019/09/building-a-production-ready-node-js-app-with-typescript-and-docker/

Submitted September 28, 2019 at 09:00AM by GaneshMani

Friday 27 September 2019

GitHub - tensult/medium-to-wordpress-migration: Script to export medium blogs to wordpress rss xml format

https://github.com/tensult/medium-to-wordpress-migration

Submitted September 28, 2019 at 06:19AM by tensult

XSRF and Node (2019)

Hi all!Unless I am mistaken, the `csurf` npm package is basically an implementation of an Encryption Based Token.Which means that the secret used to generate the token should be kept server side.Since one usually generates this token and secret when a session is created, it makes sense to store the secret in the session store, along with other values. So far, so good - I hope.Thing is, I decided to get rid of session stores, due to many considerations, and have decided to use a JWT based session mechanism, persisted in a cookie (Secure,HttpOnly,SameSite + Supported Browser Filtration).This means that the XSRF secret will be stored in the Session JWT token as well, which contradicts the whole purpose of a secret. The question is, does doing so expose an attack vector? (and I mean an actual one, not a wild theoretical scenario).Are there any alternatives to this package which are actively maintained?P.S: my first ever post on reddit, so sorry if I did / said something wrong.Thanks :)

Submitted September 28, 2019 at 06:38AM by eyalperry

readFileSync over readFile?

Hi guys, I'm learning node and I read on here that readFileSync should never be used in production. Apparently it should always be readFile. Can someone explain to me why that is?

Submitted September 27, 2019 at 06:18PM by 1qon1q

Would have more sense to post it here, what do you guys think?

https://www.reddit.com/r/programming/comments/d90n0w/is_there_a_better_way_to_deal_with_dates_details/?utm_medium=android_app&utm_source=share

Submitted September 27, 2019 at 04:14PM by leonath

React Todo CRUD App in 30 Minutes

https://youtu.be/0IYFrR8y8Os

Submitted September 27, 2019 at 04:41PM by coderchrome123456

When I run NPM install, do I install the Dev Dependencies, or JUST the dependencies?

Title. This is a really dumb situation that I'm in that I need to ask this question, but oh well.

Submitted September 27, 2019 at 03:39PM by reacteclipse

The Easiest Way to Query Postgres in Node.js

https://medium.com/@forbeslindesay/the-easiest-way-to-query-postgres-in-node-js-56765997919c?sk=1dc6a3df017a893d742776835ad2cd2f

Submitted September 27, 2019 at 03:58PM by ForbesLindesay

There has to be an easier way to do what I'm trying to do..

So I'm working on an automation project for work, and powershell (Invoke-WebRequest) wasn't cutting it due to lots of security settings on our internal sites.so I switched over to Puppeteer for the browser automation piece - very new to JS and puppeteer, pretty much learning as I go.Have most of the script completed and working, and it does work as is, but I'm thinking there is a way to make it easier.It really just logs into our site, clicks a few buttons, and then fills in the form to create a new user, which includes some text boxes and a few dropdowns.They coded these websites in kind of a shitty way, and on this user creation page, I can't get any clicks to actually work because Puppeteer doesn't like the selectors of any of the fields.got around this by just tabbing through the different fields and then typing the info.the issue then is the dropdowns.a few of these dropdowns have 50-100 different options and any one of them could potentially be used.so right now, it works, but it includes a shitload of these:await page.keyboard.press('ArrowDown'); We're talking 1000 lines just for one dropdown.I'm thinking there has to be an easier way to simulate a ton of these in a row.I don't want my script to actually list 75 of these lines when I want to arrow down to a specific item in the dropdown.I have another script that uses {clickCount: #} to simulate repeated clicks, but I can't find anything similar that works for presses.anyone have any ideas?

Submitted September 27, 2019 at 03:04PM by GreekNord

Confused about BrowserView Electron.js

Remember .filter(), .map() and .reduce()

The following 10 minutes video covers fully how filter map and reduce works.https://youtu.be/EzB6Pk66XW8https://i.redd.it/gxcpdm3zp4p31.png

Submitted September 27, 2019 at 01:21PM by arboshiki

Run a NodeJS HTTP Express Server on Multiple CPU Cores

https://coderrocketfuel.com/article/run-a-node-js-http-express-js-server-on-multiple-cpu-cores

Submitted September 27, 2019 at 11:42AM by jkkill

Sequelize Query Question

Is there any way to get the value of a column while inside the where object? I have a min and max column and I don’t want a $gt or $lt comparison to the variable I am checking, but against the actual contents on the column. Essentially a range between the min and max column values.

Submitted September 27, 2019 at 11:57AM by FreeLunch2020

How do I turn video into images?

I want to take a video and turn it into images for data processing, but I haven't the faintest where to begin looking and most searches are of turning images into videos. I'd appreciate any help with this, thanks.

Submitted September 27, 2019 at 10:57AM by sinithw

I made HideJS for the times I wanted to demonstrate a web app without revealing any source code.

The site is HideJS, hosted as a Heroku app with NodeJS + Puppeteer backend. You just enter a URL (to your website or web app), click the button, and it encrypts it for you to share. Others take the encrypted string and submit it in the same box. The encryption part is (maybe obviously) so they can't just visit the direct URL instead and see your source code.If you're patient for maybe 5 seconds (?) an interactive stream of the site will be established. The experience should be exactly the same as visiting the actual site, except without sound and with a low framerate. And of course, the complete inability to see any source code. It turns any web app or site into a blackbox.Try visiting this link to see it in action: (can you guess what it is?)https://hidejs.herokuapp.com/4dd42e87e0c8644f185a8d345e35c5c0ba54bbbd5195072c646a375de3a1fedcDON'T click the blue button when you visit the link! Just let it load =)I've only tried it on Chrome on a Windows x64 Laptop. Try selecting text, copying it with CTRL + C and pasting it into a form with CTRL + V. Or watching YouTube videos (without sound, sadly).Maybe this is mundane stuff to everyone who's had to use Puppeteer for their dayjob. But to me, it feels kind of magical. What do you think?It works with Canvas so you can actually play games through it (I confirmed this), but for some reason WebGL doesn't render. I do intend to fix that.I know Browserless.IO does something similar to this but it's focused on debugging and headless automation, not for blackboxing demos of web apps.To be honest I did not do a TON of research into seeing if there already existed something like this for this purpose, but what searching I did do didn't yield anything. If you do know of something like this please share!Thanks for reading.EDIT: By the way I am struggling to find a way to simulate mouse wheel events. I can't even get them to work in regular Chrome. If someone could help me out with that I'd be very grateful, I tried all the solutions on stackoverflow but none of them have worked. So I'm simulating up and down arrow keys on Puppeteer as a replacement.

Submitted September 27, 2019 at 11:16AM by MelerEcckmanLawler

Nodejs and firebase issue

how to use firebase cloud messaging in react (node js) without using Firebase Admin SDK?

Submitted September 27, 2019 at 10:37AM by Edge_Coleman

Thursday 26 September 2019

NodeJS: How to get URL?

I want localhost:3000, localhost:3000/blahblah, and localhost:3000/anythingatall to all open index.html like localhost:3000 does. But I also want to get the full URL path to store it in a variable.How?What do I put after this?app.use(express.static(path.join(__dirname, ''))) server.listen(port, () => { console.log(`Server running on port ${port}.`) })

Submitted September 27, 2019 at 07:15AM by MelerEcckmanLawler

which package do i use to store express sessions in mysql latest server?

from beginner in mysql and nodejs, i was trying to work with sessions in my express server using "express-mysql-session" store which returns "client doesnot support authentication protocol requested by server; consider upgrading MySql client" for normal database queries i am using "@mysql/xdevapi" which package do i use to store express sessions in mysql latest server?do i need to downgrade mysql to authenticate using old "native_password"?

Submitted September 27, 2019 at 05:27AM by AwalMukesh

Making a CLI tool and publishing it to NPM registry

Hello,I'm trying to publish my CLI tool to NPM registry so other people can use it. It should work like how any CLI program works where when I type the command, the program will run. I set my command to "djs" and when I run it on my system after doing "npm link" it works fine. However, on other systems it doesn't seem to work. My friend installed my package by doing npm install discordjs-cli and it said "djs" command not found when he tried to use it. I've spent some time googling stuff yesterday and could only find articles to people building a CLI tool, but not deploying it for others to use. Anyone know how I can set it up so others can use it without having to configure anything? This is the repository for my project: https://github.com/ansonfoong/djs-cli-tool

Submitted September 27, 2019 at 03:15AM by ansonplusc

50 Days of Building an AI/SaaS Startup in 5 Minutes (Strategy, Tools, & Results)

https://youtu.be/D2kiDcsAFts

Submitted September 27, 2019 at 02:22AM by voidupdate

Researching development tool workflows (paid interview)

I’m working on building a local development tool and I’d like to talk with a few people to learn about their development process. If you're interested, please take a few minutes to tell me about yourself. You would be paid for your time.

Submitted September 27, 2019 at 02:28AM by kevinklin

I built module for working with JSON. It's working but alpha. How useful is it? Should I continue?

I feel like a lot of JS applications rely on JSON.parse / JSON.stringifyBut then one day they grow up a little and run into JSON that is bigger than they initially allowed for. Whether one huge JSON that is too big to even fit in memory, or just JSON that's big enough that for not blocking you just don't want to process it synchronously.So, I built a drop-in replacement from JSON that works asynchronously. Just change JSON.parse(string) to await JSLOB.parse(stringOrStream) and the same for stringify/streamifyIt stores the key value pairs in any level compliant DB, which you can pass in, whether you want it to be in-memory, on-disk, or clustered.So loading/serializing is working fine, as well as asynchronously accessing properties on the resulting object (see README for examples)But, there's just a ton of other functionality to built, like asynchronous setting, iterating keys, etc. Not to mention code clean up.I'm trying to figure out whether this is worth working on further. Would this be valuable to someone? I imagine it should be, both in data engineering use cases, as well as simply having your webserver not block while it tries to parse a large JSON sent by a user (without having to tediously rewrite your code to stream)Here's the project: https://www.npmjs.com/package/jslobThoughts? Feedback?

Submitted September 27, 2019 at 02:32AM by Why_Is_The_RSS_Gone

How to manage a log system in a node.js application using Winston

https://www.datadoghq.com/blog/node-logging-best-practices/

Submitted September 27, 2019 at 01:34AM by antonio-martin

I have one doubt about what http status code should I return in my nodejs api if a request tries to find an user, but its not found in the database.

Hi, today I was writing an test code for my api, there's a route '/confirm-user', that tries to find the username send in the body of the request and returns its userId if one is found.But I started writing the case where the user was not found, because the username was not in the database, so I tested for a response status of 404, not found. The test passed and I proceed to the next. It was then that I noticed that I didn't even set my /confirm-user to the app, so the 404 I got was an generic 404 that returns everytime a wrong request is sent.That let me to think that maybe the correct response was 200, signaling that the request was on a right endpoint, with an message in the body of the response warning the the user was not found in the database. Is this the right approuch in this situation? Is there a best practice guideline for what should be the correct status code response?

Submitted September 27, 2019 at 12:20AM by eliseu_videira

Is there a package available that provides a dashboard and API for managing Client Software Updates?

Is there any such thing available as an npm package? I want to manage a large number of clients which will query a central API. The server would decide whether that client needs an updated version of the software. If so, it would respond with JSON containing a URL to download the new version.On the server there could be a dashboard to manage rolling updates, delayed upates, version rollbacks, pinning a certain client to a specific version, etc.I tried googling for such a thing but maybe I'm not using the correct search terms.

Submitted September 27, 2019 at 12:53AM by Syndeton

NodeJS Amazon AWS Submit Feed Problem

Single or Separate Domain Model

I'm curious about developers who use TypeORM and more or less follow the clean architecture.Do you use a separate domain model, a plain ol typescript model AND the TypeORM model or do you just use one model for infrastructure AND domain?My opinion is that the TypeORM (or even sequelize for that matter) model classes are infrastructure level concerns, not domain layer concerns.

Submitted September 26, 2019 at 11:34PM by stemmlerjs

Decoupling Logic with Domain Events [Guide] - Domain-Driven Design w/ TypeScript

https://khalilstemmler.com/articles/typescript-domain-driven-design/chain-business-logic-domain-events/

Submitted September 26, 2019 at 11:39PM by stemmlerjs

What is the best module to parse a huge Mongo query into an XLSX file ?

I'm using ExpressJs , MongoDB and the latest stable NodeJs release , I'm trying to find a way convert the data obtained from a huge query in Mongo, to XSLX and send the file to the client.The query returns about 48, 000 documentsBased on your experience what is the best approach , or plugin to use in this situations ?

Submitted September 26, 2019 at 08:24PM by sherlockholmes1930

Help catching up after a year hiatus?

I spent 4 years working in JavaScript. Most of my time was spent on the back end, but I had some frontend responsibility (React). After a year off, I need to get back to work.Could anyone share with me some resources for catching up with the ecosystem so I can feel comfortable interviewing around?I would appreciate any suggestions!

Submitted September 26, 2019 at 08:46PM by tawntea

Build a Command-Line Progress Bar in Node.JS

https://blog.bitsrc.io/build-a-command-line-progress-bar-in-node-js-5702a3525a49

Submitted September 26, 2019 at 03:22PM by JSislife

simplewebrtc webrtc-adapter cannot install

Hello!I'm trying to install simplewebrtc but for some reason webrtc-adapter cannot install. Any ideas how to fix this?I hit this on command line: npm install simplewebrtc.. and my output is this:npm WARN simplewebrtc@3.0.2 requires a peer of webrtc-adapter@^6.0.0 but none is installed. You must install peer dependencies yourself. npm WARN localmedia@4.0.2 requires a peer of webrtc-adapter@^3.1.6 but none is installed. You must install peer dependencies yourself. npm WARN attachmediastream@2.1.0 requires a peer of webrtc-adapter@^4.0.0 but none is installed. You must install peer dependencies yourself. npm WARN getscreenmedia@4.1.1 requires a peer of webrtc-adapter@^4.0.0 but none is installed. You must install peer dependencies yourself.

Submitted September 26, 2019 at 03:34PM by penukki

I can’t get Instascan to work

I’m making a web application with React that is meant to be accessible from IOS Safari, and I need to scam QR codes for it; however, Instascan doesn’t work. It gives different errors on different devices. Even on a computer it doesn’t work.

Submitted September 26, 2019 at 03:59PM by _AirMike_

Which backend framwork in 2019/2020

I've been using Express.js for years but a friend of mine recently told me he switched to Hapi a year ago and is really happy with it.In the Hapi docs, all exemples in the Express vs Hapi section lead to the conclusion that Hapi is more verbose. On top of that, it seems wayyy slower that other framworks.This made me wonder about available frameworks in the field though, what about Hapi, Feather, Sails, Restify and others? I mainly use Node for to build REST backend, but I'd be interrested in any feedback.Anyone who can speak about his experience? Made a succesful/terrible switch?

Submitted September 26, 2019 at 04:11PM by Buzut

Recommendation for SQL ORM

Hello,I am coming from Python/Flask background. There I used SQLAlchemy, which is mature and proven as an SQL ORM. But for Node, is there anything that can be compared with SQLAlchemy? I know about Sequlize, but heard that it generates complex SQL.So those who are constantly working with Node JS, please suggest some good SQL ORMs. Currently, I work with Node only when I am permitted to work with NoSQL databases (because NoSQL/Mongo suits better with Javascript). But when I have to use SQL (which is in most cases), I try to avoid Node because of ORM. Please note that I haven't used any Node ORM before.

Submitted September 26, 2019 at 02:06PM by muhib21

Package for Environment Variables

Hi folksI am working on a node project, and I have came across a need. I want to have any npm package, that I can use to handle different environment variables. But, the catch is - I want to update this variables in runtime (from a web browser). After updating these variables, I can restart the server and new environment values should be used. In short, I want an easy web page (browser based solution) to update my environment variables dynamically.Is there any available solution for this? Any package or do I need to build it on my own?Thanks in advance! :)

Submitted September 26, 2019 at 11:29AM by KUCAK

Stop using package-lock.json or yarn.lock

https://medium.com/@gajus/stop-using-package-lock-json-or-yarn-lock-909035e94328?sk=657ad1d34d58401b6641fd235bb4f580

Submitted September 26, 2019 at 10:11AM by gajus0

LoGOUT API IN NODEJS

How to make logout API in nodejs using JWT Token?

Submitted September 26, 2019 at 09:30AM by Ritikjain97

OpenAPI (Swagger) specifications that write your tests for you (sort of)

https://medium.com/p/82276a491c68

Submitted September 26, 2019 at 09:55AM by Fewthp

Best Visual Studio Code Extensions for React Applications

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

Submitted September 26, 2019 at 07:52AM by coderchrome123456

Wednesday 25 September 2019

Puppeteer and file chooser

Using puppeteer I’m trying to upload a file to a website. I’m using file chooser and I read the documentation. But it never seems to work.

Submitted September 26, 2019 at 05:11AM by PoopStickss

How to make a Login Form in HTML and CSS

https://youtu.be/gmqd3Pl5bHk

Submitted September 26, 2019 at 04:42AM by coderchrome123456

Introduction to Node & Express

https://www.youtube.com/watch?v=81Mx1Rh_UGo

Submitted September 26, 2019 at 02:43AM by PerryR9

Node v12.11.0 (Current)

https://nodejs.org/en/blog/release/v12.11.0/

Submitted September 26, 2019 at 01:24AM by dwaxe

Anime CLI

i built a node cli to find basic info on anime by inputting the title, i used axios for the api request and the jikan apiyou can install it via npm, its name is @zieme/anime-spy.check it out and see if its any good, feedback will be awesome

Submitted September 25, 2019 at 08:58PM by FormerBrick

Obviously we all appreciate Nodejs, but when should you NOT use Nodejs?

There's a ridiculous amount of things you can use Node for, but that doesn't always mean that you should.What do you think Node's main weaknesses are and how do those end up impacting production environments?

Submitted September 25, 2019 at 05:05PM by g3t0nmyl3v3l

Verify Phone Numbers with Node-RED

https://www.nexmo.com/blog/2019/09/25/verify-phone-numbers-with-node-red-dr

Submitted September 25, 2019 at 03:02PM by juliabiro

ES6 vs ES5

Does ES6 has better performance compared to its ES5 transpiled part?

Submitted September 25, 2019 at 03:10PM by praveenfun2

Top Node JS Frameworks for Web Application Development

https://www.decipherzone.com/blog-detail/Top-Node-Js-Frameworks-for-Web-Application-Development

Submitted September 25, 2019 at 01:46PM by Techtrends2019

JavaScript is Facing A Fork: The Language and The Machine

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

Submitted September 25, 2019 at 12:37PM by fagnerbrack

Best Visual Studio Code Themes While Coding in 2019

https://www.youtube.com/watch?v=_W-sIjsaFV0

Submitted September 25, 2019 at 12:07PM by coderchrome123456

6 Ways to Make HTTP Requests with Node.js

https://coderrocketfuel.com/article/6-ways-to-make-http-requests-with-node-js?fbclid=IwAR0uxu8Mjc6u3Lz9r5P8G03hC4b0ALopMZtmtFlcXEhaooYBxZxHk-kq9qc

Submitted September 25, 2019 at 10:46AM by mominriyadh

Express & Passport.js - How do I authenticate from an external server?

Hi all, I can't seem to find an answer to this after searching everywhere. I currently have a REST server for my API and I would like to authenticate a user and somehow persist the session on the frontend, but I cannot seem to do that with any of the Passport strategies.REST server (localhost:5000) - Node/Express/PassportFrontend Server (localhost:3000) - ReactI'm using an async post request from React, but how would I return a 'session' and store it on the frontend? The concept eludes meThanks in advance

Submitted September 25, 2019 at 11:04AM by ObviouslyNotANinja

Best IMAP client module?

Hello,we are using the "imap" module https://www.npmjs.com/package/imap — not too bad, but last commit was in 2016. Development seems to be on hold, pull requests do not get merged.Does anybody know an alternative?Thanks a lot.

Submitted September 25, 2019 at 08:23AM by chattypaul

How to Build a Slack App to Keep a Slack Channel Topic Locked with Node.js on Standard Library

https://medium.com/@brimm_reaper/how-to-build-a-slack-app-to-keep-a-slack-channel-topic-locked-with-airtable-and-standard-library-dddea4b9ca03

Submitted September 25, 2019 at 08:01AM by kev_cuddy

Tuesday 24 September 2019

Anyone uses a specific tool or package for managing fixtures?

In Node, there is no defined standard for fixture management like in Ruby on Rails or Django. How do you manage fixtures when writing tests?

Submitted September 25, 2019 at 06:41AM by faboulaws

Setting up a website, I have some questions...

So I've been doing some research on setting up websites in Node.js and it seems that Express is a pretty good one to use, it even has that express-generate command that sets up a basic project to start from.Now, I'm no stranger to frontend web development. I know my way around HTML/JS/CSS and part of what draws me to Node is that I already know Javascript.I ran `express-generate` and use hbs as the templating engine since it's very close to HTML and it makes a lot of sense to me, and I also set it to use SASS instead of CSS. It runs, it's all good and all, but my research has only opened up more questions.It seems like there is always a "You should use ___!" around every corner. I plan on having a database connection on my site, and I know MySQL. So I look at getting that on there, and after installing mysql apparently there is a faster and better mysql 2 I should use. Not only that, but I should use something like Knex to build the database queries. In fact, I should use an ORM so I should use something like Sequelize but recently people said Objection is way better than Sequelize and to use that instead. Even so, this article says I shouldn't use an ORM. After looking into this, I found out that the default hbs that express comes with has a vulnerability, and that I should instead use something like express-hbs, or better yet, express-handlebars, for my templating engine. I also want to get Bootstrap working in my site, so I could use a CDN or as some people suggest I should use `npm install bootstrap` but while I'm at it apparently webpack is another one to use to put resources together, but in order for some of it to compile together I should add Gulp to the mix? What about Babel, Browserify, jspm, Grunt, Yeoman, or Slush? This is confusing borderline intimidating...I spent a week adding things, reading things, trying things, resetting my project, going back and testing things, and comparing things. I'm currently using express, express-handlebars, and objection (ORM) with mysql2.Before I go any further in reading and considering extra stuff, I figured there's no harm in reaching out and asking for help r/node please help me out.First off, are there any packages that I should know about that I had not already mentioned? I'm somewhat new to this, so please just assume I know very little.Secondly, I feel like there are many rabbit holes that I could hall in and I don't know what paths I should be taking. I'm scared that if I ignore these extra packages and options I will regret them down the road, but I'm also scared that they're absolutely not mandatory and adding them to my project will just make things harder and will end up being a fat a waste of time. Could you please give me advice on this?EDIT: I did some reading and found this fun read and now I can relate to all the confusion.

Submitted September 25, 2019 at 06:19AM by stevenr4

AngularJS Http Get Service to Fetch JSON Data Example

https://youtu.be/_kWNC9K06_w

Submitted September 25, 2019 at 06:23AM by coderchrome123456

[Help] Creating 1st Party vs 3rd Party Access REST API?

Hello,So I'm working on building my own Full Stack Web App. Let's call it "SocialFora". I have a simple Vue client/Node backend setup. Now, based on this info, my Vue client is the 1st party application because it's internal to, let's say "my business". Meaning if users want to login, they go to the site /login. etc. Now, let's say my users want to build their own 3rd party applications to access their stuff. That means I would need to give them access to my "API".In that case, does this "API" that my users are building for the same API that my 1st party vue client is accessing? or is it a separate project API specifically for handling 3rd party access?If the 1st party and 3rd party are indeed accessing the same API backend, then I'm guessing both 1st party and 3rd party applications are using different forms of OAuth2 access methods? (Assuming Password for 1st party, Auth Code for 3rd party).I've searched the web on this topic, but there's nothing that talks about both parties.Your wisdom is very much appreciated! :)Thanks.

Submitted September 25, 2019 at 03:15AM by nathangonz17

Command queing for ASCII based protocol over TCP socket

Hi,I'm trying to write some configuration software for a device. The device is configured via a serial interface with an ascii based protocol. Command messages are simple strings ending in a carraige return. When a valid command message is received, the device responds with "OK".To interface with the device I've got an RS232 to IP converter, which my node.js app connects to with a TCP socket.I've been able to succesfully send commands with socket.write(command), and parsing the output of the device to get a variable "deviceoutput" with value "OK" works ok as well.The issue I'm having is that I want to send multiple commands to my node.js app, queue them, send the first one but wait to send the next until the "OK" message from the device has been returned.Creating the queue seems simple enough by doing:function Queue() {this.data = [];}Queue.prototype.add = function(record) {this.data.unshift(record);};Queue.prototype.remove = function() {this.data.pop();};Queue.prototype.first = function() {return this.data[0];};Queue.prototype.last = function() {return this.data[this.data.length - 1];};Queue.prototype.size = function() {return this.data.length;};const commandQueue = new Queue();​Has anybody tried something similar in the past?

Submitted September 25, 2019 at 12:54AM by D0tfile

What is API in this example?

Quick question if I have an express GET request to the DB to get some info and then use axios.get in react to display that info, is there an API there and what would it be?

Submitted September 25, 2019 at 01:38AM by Drexx_B

What to do next?

Hey friends.I’m going all in on Node and React while trying to land my first full time developer job, and I want to challenge myself with something new using Node.I’ve done a lot with it already, but right now I’m creating a chat and video sharing app using web sockets. Once this is done, I’m not sure what to go learn and work on afterwards. I’ve built a few full stack CRUD applications with authentication at this point and just don’t know where to go next.A list of things I feel comfortable doing with Node:-Basic web server to host files and applications -API creation and management (Express)-Interacting with both SQL and noSQL databases (Sequelize, mysql2, Mongoose)-A really simple command line RPG game using inquirer-Interacting with Firebase using Firebase tools and SDK-Interacting with the file system to change and overwrite some txt files-User authentication with JWT and sessions, mostly using passport and some oauth providers-Currently playing with websocketsAny guidance or reading you can give me would be really helpful - I really like Node’s architecture and the fact that it’s easy to hop between front end work (React) and back end since they both use JS; and I’d like to keep going. Thanks a ton.

Submitted September 24, 2019 at 10:12PM by darkwingduckman

(Help) Next JS build failed on shared hosting. Error: spawn ENOMEM

When I run "npm run build" on my shared hosting server it throws an error: spawn ENOMEMIt runs fine on my localhost and was running fine on the hosting server for a couple of weeks until yesterday.I also asked on StackOverflow and there are more details there...https://stackoverflow.com/questions/58087173/next-js-build-failed-on-shared-hosting-error-spawn-enomem​If anyone have an idea of what's wrong and how to fix it that'd be great.

Submitted September 24, 2019 at 09:01PM by leojoey82

Adding an Application Icon to a Node CLI App

Hello! I've looked online to find any information about this and I only get results for applications using a web framework like Express or React so I decided to ask here.How would I give my command line application a new icon? When I build the application ('npm run build') I get a default node icon and I was wondering if I could change this.Thanks :)

Submitted September 24, 2019 at 06:54PM by shaneajm

Does DDD Belong on the Frontend? - Domain-Driven Design w/ TypeScript

https://khalilstemmler.com/articles/typescript-domain-driven-design/ddd-frontend/

Submitted September 24, 2019 at 07:53PM by stemmlerjs

A new library for http requests

Hey everyone.Recently I needed to create a "more readable way" to make HTTP requests for my company, and I really liked the final result. So, I decided to extract this idea to a new npm module. Here's the link:https://www.npmjs.com/package/httpclient.jsFor those who like the idea, feel free to send a PR :)

Submitted September 24, 2019 at 07:38PM by bsmayer_

What's the best way to schema a Trello like app with mongoose?

Leaving aside the multiple users, just single user - his boards - lists - cards in lists. What would the best way to model / schema this one to many relationships?

Submitted September 24, 2019 at 04:50PM by imdefsomebody

GraphQL Editor 2.0 - draw your GraphQL schema - new Release with Search !

https://github.com/graphql-editor/graphql-editor

Submitted September 24, 2019 at 03:34PM by ArturCzemiel

AdminBro - A modern Admin Panel for Node JS

Check out my new Blog: https://www.inkoop.io/blog/adminbro-a-modern-admin-panel-for-node-js/

Submitted September 24, 2019 at 03:12PM by jitendra_nirnejak

NodeJS install failed on remote linux server

I am using Putty, I extracted and renamed nodejs but after installing with as below it none of the commands will work, node and node -version are unrecognised.mkdir ~/bincp nodejs/bin/node ~/bincd ~/bin ln -s ../nodejs/lib/node_modules/npm/bin/npm-cli.js npmHow can I fix this?I wanted to install node so I could install and write angular apps which worked fine on Windows but my server runs on Linux. I am running on a user shell.

Submitted September 24, 2019 at 12:39PM by 0amethyst

Design patterns in microservices

In the broadest sense, design patterns in microservices refer to various solutions to challenges the microservices-based architecture poses. If you want to refresh your knowledge of design patterns, try this article, including introduction to Direct, API Gateway, Backend For Frontend patterns.

Submitted September 24, 2019 at 01:18PM by placek3000

Hey guys can anyone help me with this. I’m trying to connect to my atlas, but can’t. any help, would be appreciated. My db is in the test database

https://i.redd.it/otrfmpknbio31.jpg

Submitted September 24, 2019 at 10:01AM by en85

How we can Achieve Auto Typing in Visual Studio Code??

I have a video to make simulating the typing

Submitted September 24, 2019 at 09:28AM by coderchrome123456

Thoughts on Nestjs?

https://nestjs.com/

Submitted September 24, 2019 at 08:30AM by skay-

Making a backend with an encrypted database?

So I'm interested in making an app where I want some of the data in the db (probably mysql) to be encrypted. I don't really know much about security and encryption stuff, but this app will be for personal use only so it's a good learning opportunity and not a big deal if I get something wrong. I guess this is more of a general backend question, but I do want to do it in nodejs.I also don't want the users to have to enter two passwords to use the app (once to log in and once to access their data).Do you guys have any articles or libraries that help handle this sort of stuff? My layman's theory is that there would be some sort of encryption key, which is generated from the user's password. When the user logs in, we generate the key and store it to localstorage. That way the plain text password isn't stored anywhere, and nothing is stored on the server that could be used to see the data. Then, with every request, we send the key along, so the server can return plain text data (or encrypt data that's being submitted).There's probably a billion security holes in that strategy, but I'm ready to learn! :P

Submitted September 24, 2019 at 07:44AM by Nodeboi

Monday 23 September 2019

Deploy Angular 8 Application to Firebase Cloud Hosting

https://i.redd.it/f3g00bp4dho31.jpg

Submitted September 24, 2019 at 06:47AM by jsonworld

Should I use JWT or sessions for authentication with a templated front end (EJS)?

My current setup is Node, Express, Mongo DB, and jsonwebtoken for authentication. I have authentication working fine through the REST API (for mobile application use). The problem: the front end is not a SPA, it is rendered using a templating engine (EJS).​My current train of thought is to also use JWT for the EJS front end and send the JWT through the header. Is this bad practice? Should I use sessions for the EJS portion and JWT for the mobile app portion?

Submitted September 24, 2019 at 01:50AM by fishingBakersfield

Is it worth it to use docker for dev environment?

I've been setting up the project to integrate docker into my production deploy but I've seen different opinions regarding development environment.Is it an overkill? what are your thoughts.

Submitted September 24, 2019 at 12:01AM by robotzuelo

Why pnpm won't install any package?

Hey community. I can't install any packages with pnpm, the command exits with error but no message shows up in the prompt. I installed nvm on macOS Mojave via homebrew, then installed node 8.0.0 via nvm and pnpm via npm. Does anyone know what could be the problem, or how to check the pnpm logs after it fails installing the packages with pnpm install?

Submitted September 23, 2019 at 11:17PM by rraallvv

Any good cpanels for node

I’m looking for either a good free control panel or a good node host for 5$ or less per month. I’ve heard of virtualmin but I’m not sure if it supports nodejs.

Submitted September 23, 2019 at 11:04PM by gmdxrillex

Compile typescript on NPM package install

Hey, im looking for a a best way of handling shared code in my company in typescript. Previously we used symbolic links to make the folders appear inside the project but I came up with a better solution to leverage NPM local file references which still create symbolic links but in the node modules folder and with the nom install command.I achieved this by changing the post install script to npm prune (seems to download modules without causing recursion), rm -rf dist (remove the build directory) and tsc (to compile).This has been working moderately well until today when i was nesting a shared package inside another shared package which didnt work. Any advice on a better solution that doesnt involve storing build artifacts or publishing private code to the npm repo.tl;dr is there a better way to do ‘npm prune && rm -rf dist/ && tsc’?

Submitted September 23, 2019 at 09:12PM by NikZM

What is considered best practices for running Next.js + Express (or whatever back-end) on the same server?

I've heard that its a good idea to have a clear separation between back-end logic and front end logic, and that extra care should be taken with running Next on the same server as your back-end as not to risk allowing to much back-end/DB exposure via your front-end app.What is the ideal solution for this? Containers...?

Submitted September 23, 2019 at 09:12PM by Zarathustra420

Javascript Promise Example

https://youtu.be/Wi7Ihj34TKo

Submitted September 23, 2019 at 06:25PM by coderchrome123456

How should I go about making modern APIs?

With UI intensive requirements I've decided to use graphql, but I'm not sure if I should create a traditional rest api first and layer a graphql server over it or build a standalone graphql server, also what would be the pros and cons of these approaches?Edit :- Let's Say I'm going for a microservice based approach, which are independent REST services, does that change anything?

Submitted September 23, 2019 at 06:11PM by Prateeeek

Using MEVN stack, got a specific question about image upload with Multer. PLZ...

I have a rather specific question about Multer. I'm using the MEVN stack and managed to upload images to my server with Multer using a specific model with just one field for the image that looks like this:const image = new Image({file: req.file.path,});That worked fine. Before sending the image from my frontend, I converted it to a FormData object. So I did this:await axios.post(urlImage, formData);All good, easy peasy. However, I am trying to save an image in the following way with a 'person' model:const person = new Person({personData: {image: req.body.personData.file.path,basicInformation: req.body.personData.basicInformation,profile: req.body.personData.profile,experience: req.body.personData.experience,education: req.body.personData.education,skills: req.body.personData.skills,hobbies: req.body.personData.hobbies}});On the frontend with Vuejs I'm sending a Person object, that contains an image field that holds the formData and the rest of the fields are arrays of objects. Normally with Multer, the image is accessible with req.file.path as I did in the first example*.* But as you can see the FormData objects lives in req.body in the Person object*,* effectively making it (as far as I know) undefined with Multer. Whatever I try, the 'req.file'  is always undefined because of it. Is there no possible way to achieve this with Multer? I've got multiple posts on stackoverflow with zero answers. Am I stupid or something?

Submitted September 23, 2019 at 04:52PM by Mertakus

Just finished learning GraphQL. Need some reviews.

I made a GraphQL server boilerplate as a tutorial: https://github.com/winsaw/apollo-serverI need some reviews from you guys. Please throw me some feedback.

Submitted September 23, 2019 at 05:03PM by hxi837

Brad Traversy | Full Node.js Deployment - NGINX, SSL With Lets Encrypt

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

Submitted September 23, 2019 at 05:19PM by sword-of-fire

Unix Management

Necessity to use CLI is appeared increasingly during any project development. Inevitably, an automation process has to be designed.IntroductionAny ordinary project requires documentation. We have a pair kinds of documentation during development, TypeDoc & JSDoc. The finish variant of our documentation is a HTML files directory, generated with documentation tool. You know, it would be great for me as a developer to run documentation on a third-party server. Third-party server is nothing less than good old Docker) container. Running of Docker container is nothing more than Unix Management system through Command-line interface, CLI.What do we face at every step of project documentation management? Documentation generation tools, CLI. No matter how little is said both mentioned directions provide the enormous range of informatics tools and methodologies. Let’s not dwell on methodologies today, but let’s try to dive into Command-line Interface.CLISo what is the CLI and what does automation have to do with it? CLI is represented the text interface between human and Unix system where the instructions are provided with commands, text strings. The command is represented the command name and its ?parameters. Typing of Unix commands is absent, but the common approach is governed.So, let's consider the process of creating project documentation. Our project consists of JavaScript & TypeScript code. We can automate the process of code documentation generation with JSDoc & TypeDoc. We can use next commands to generate documentation:TypeDoc: typedoc --out .docs/ts/html --readme ./docs/README.md ./srcJSDoc: jsdoc ./ -d ./.docs/js/html -R ./docs/README.mdCurrent action automation is supported with npm-scripts.Generated documentation is no more than HTML files set. Let’s create out separate server to run documentation, as mentioned above. To run server we can use default tools: Docker, Docker Compose.Separate server to run documentationDocker Compose files:docker-compose.ymldocs.docker-compose.ymlNode.js CLI utilities are used to build the initial step in automating the process of creating a documentation server.ConclusionSo, it’s clear how it works. The one problem of development is visible. Our actions are represented any development tools, but CLI is represented the text information only. As a developer, I would be pleased to work not with textual information, but with variables, objects, classes, etc. It’s worth nothing that the server creation is represented commands dendritic hierarchy. Let’s try to figure out the two points above.Ok. Let’s stop for a while.

Submitted September 23, 2019 at 04:26PM by rmhehey

MEAN Stack (Angular 8) Tutorial: Build a Simple Blog CMS

https://www.djamware.com/post/5d88cb43e7939eec17dc4c89/mean-stack-angular-8-tutorial-build-a-simple-blog-cms#.XYjW5m9YifY.reddit

Submitted September 23, 2019 at 03:30PM by didinj

How to set cors http only cookie not in firefox and chrome both?

Currently I am running front-end app on local machine and the express app is behind nginx on a remote dev server. In express app cors (whitelisting)** is enabled (different config for dev and prod) with **credentials set to true. Front end is in angular(8).some posts on internet says that browsers don't allow setting localhost as domain of http-only cookie set via remote. Although firefox do show response cookie but it does not set it in browser.Also tried google-chrome with web-security disabled but it didn't workedconst cookie=process.env.NODE_ENV==='production'?{ httpOnly: true, maxAge: 3600000, overwrite: true, domain: req.get('origin') }:{ httpOnly: true, maxAge: 3600000, overwrite: true, domain: ".localhost" // also tried domain:localhost // and left out domain key // as per other stackoverflow posts }; res.cookie('cookieName', await generateToken(data),cookie); is it related to nginx or something else and if not on front-end running on local-machine will it work properly if I use req.get('origin') i.e. in production mode where the request will come from original some-website.com

Submitted September 23, 2019 at 02:07PM by u_d_b

Drag and Drop Image Uploader in jQuery

https://youtu.be/cBZ8ZFrSzig

Submitted September 23, 2019 at 02:26PM by coderchrome123456

PDF.js Tutorial | Rendering a Simple PDF File in Javascript

https://youtu.be/2K39CECdWhc

Submitted September 23, 2019 at 10:08AM by coderchrome123456

How to get notification whern CRON fails.

We at our company using node-cron to run cron jobs for task like daily backups, data manipulation for different teams, sometimes some-cron job fails and we only get to know in the morning.I want to know how can we get a notification via email , or message. so the issue can be resolved earlier.

Submitted September 23, 2019 at 09:56AM by sanketsingh1995

Sunday 22 September 2019

Linking Vue.js and Express behind a Nginx reverse proxy

I'm very new to the node world and I am slightly struggling to get my vue.js frontend to communicate with my express backend. Locally I can do it no problem, but I am stuck trying to do it on my server.Nginx is serving as a reverse proxy, my current config has www.x.com/upload traffic sent to the express server and all other traffic sent to the vue server. I am using dropzone to upload the files.All data is sent when I upload according to the network tool in chrome, but the file doesn't appear in the express server and dropzone never shows 'upload success' like it would when run locally. I'm not really sure what's wrong, data is being sent to the right location, and I don't know why express wouldn't handle it properly. It must be a config issue since everything runs locally but I am a bit lost. Any help would be very much appreciated.My current express index.js is simplyconst express = require('express'); const multer = require('multer'); const cors = require('cors'); const app = express(); app.use(cors()); const upload = multer({ dest:'./uploads/' }) app.post('/upload',upload.single('file'), (req, res) => { res.json({file:req.file}); }); app.listen(3000,()=> console.log("Running on localhost:3000")); Thanks!

Submitted September 23, 2019 at 12:00AM by Macscroge

Live Stream Server (RTMP)

I am looking to create a web app that makes live streaming user friendly for church's as I've pulled out plenty of hair trying to learn how to do so for my church. I'm looking to make essentially a rtmp ingest server that handles streaming to Facebook, YouTube, etc. similar to restream.io.I've seen some ideas thrown around using node and ffmpeg with spawning child processes. I have a little experience with docker as well. Not sure if that helps with performance.Please feel free to share resources/ideas. Extremely eager to learn! Also interested in production optimization (never single handedly sent an app to production). Thanks so much!

Submitted September 23, 2019 at 12:03AM by BredHacker

Should I learn Express, Koa, or Hapi? Will documentation for one work for the rest?

I'm familiar with Node.Js because I built a serverless web application using AWS Lambda functions. I'm no expert, but I can use Node and NPM. I also have experience with JS. I want to learn a new framework to build totally new projects from the ground up.​Express has a huge community and every tutorial or package I find online seems to be geared towards Express. It makes me feel less intimidated knowing that there's a huge amount of resources that I can fall back on.Koa seems to be marketed as a strictly 'better' version of Express. Its biggest drawback is that it has a smaller community.Hapi seems to be recommended a lot around here. I read the guiding principles of how Hapi was designed and I love them. They have an emphasis on readability, but no "magic" happening behind the scenes (unlike Ruby). They've also got an emphasis on security.​Are tutorials and packages that I find for express going to work the same on Koa or Hapi? Will the authentication process be the same? Which one of these should I choose to learn.

Submitted September 22, 2019 at 09:22PM by Byte11

Correct way of creating a realtime application with Cassandra

Right now I have a ec2 instance running Cassandra and a simple websocket server. Is there anything I am missing and I would like to know if this is the correct way to make a "real time" chat application?Client connects to websocket, inserts a message, the message is stored into database, and the message is then sent to users if the record to the database is successful.const cassandra = require('cassandra-driver'); const client = new cassandra.Client({ contactPoints: ['127.0.0.1'], localDataCenter: 'datacenter1' }); const WebSocket = require('ws'); const wss = new WebSocket.Server({ port: 3000 }); wss.on('connection', function connection(ws) { ws.on('message', function incoming(message) { //Insert message into Cassandra DB client.connect() .then(function () { return client.execute('SELECT * FROM test_keyspace.users'); }) .then(function (result) { const row = result.rows; console.log('Obtained row: ', row); response.status(200).json(result.rows); //Send message to other users if record in db is successful }) .catch(function (err) { console.error('There was an error when connecting', err); return client.shutdown().then(() => { throw err; }); }); }); //Then send messages to users connected to the websocket in chatroom ws.on('close', function(){ console.log("I lost a client"); }); });

Submitted September 22, 2019 at 07:51PM by sscarcano

Node v12.4.0 - can't resolve 'net' or 'tls'

I am using @google/maps which uses https-proxy-agent. When I attempt to use @google/maps, I get the following errors: -ERROR in ./node_modules/https-proxy-agent/index.jsModule not found: Error: Can't resolve 'net' in '/var/www/node_modules/https-proxy-agent'@ ./node_modules/https-proxy-agent/index.js 5:10-24@ ./node_modules/@google/maps/lib/internal/make-url-request.js@ ./node_modules/@google/maps/lib/internal/make-api-call.js@ ./node_modules/@google/maps/lib/index.js​ERROR in ./node_modules/https-proxy-agent/index.jsModule not found: Error: Can't resolve 'tls' in '/var/www/node_modules/https-proxy-agent'@ ./node_modules/https-proxy-agent/index.js 6:10-24@ ./node_modules/@google/maps/lib/internal/make-url-request.js@ ./node_modules/@google/maps/lib/internal/make-api-call.js@ ./node_modules/@google/maps/lib/index.jsThese are called from https-poxy-agent: -var net = require('net');var tls = require('tls');Now, it is my understanding that these modules are intrinsic to nodeJs. So the question is obvious... why aren't these being found? Is there something wrong with my node version or have I somehow failed to install it correctly? Thanks.

Submitted September 22, 2019 at 08:11PM by U4-EA

Different behavior for running npm start and running script directly

So this is the scripts in my package.json "scripts": { "test": "echo \"Error: no test specified\" && exit 1", "start": "hoodie" }, It works perfectly using npm start, howerver it throws an error when I just run hoodie. Why is that? Thank you!

Submitted September 22, 2019 at 08:12PM by hoodie123uji

How to make Node.js as much secure as java(back-end)?

I have been working on node.js for 1 and a half year now. But there is always one question in my mind that I always get to hear, "Node.js is not as much secure as java". Although, we can use oops concept in javascript and make the variables parsed to strictly typed variables. So, what should be done to make Node.js as much secure as it can be?

Submitted September 22, 2019 at 07:30PM by procastinator_10

Angular Material Simple Login Form And Registration Form

https://w3hubs.com/angular-material-simple-login-form-and-registration-form/

Submitted September 22, 2019 at 06:53PM by dan_martine

Lock for a reservation service.

I don’t know if this is the right place for the question, but I’m working on system to place reservation for a spot. I’m using an angular frontend with a node backend and Firebase Firestore DB.What I want to achieve is that when you want to reserve a spot. You get n minutes to complete the reservation. When n minutes has passed the spot is given free again. My question is where to store and implement the mechanism to give the spot free again? I don’t want to keep track of it (only) in the frontend. Is a redis instance with a key and expiration time the way to go? Or is that overkill?

Submitted September 22, 2019 at 06:56PM by Stefa93

Need for Collaborators for new Project (CLI project)

I have explained about the goal here https://github.com/buildtip/create-web-app/issues/56Please Give feedback and ping me if you want to join this project to bring it life.

Submitted September 22, 2019 at 06:01PM by r00t_aXXess

Build a WhatsApp bot in 10 minutes using Node.js and Twilio

https://medium.com/the-andela-way/build-a-whatsapp-bot-in-10-minutes-using-node-js-and-twilio-9869b443bf5e

Submitted September 22, 2019 at 05:50PM by pmz

jsPDF Tutorial | Create PDF Filled Form in Javascript

https://youtu.be/wpQKocbW_7M

Submitted September 22, 2019 at 04:12PM by coderchrome123456

Thinking about Recursion: How to Recursively Traverse JSON Objects and the Filesystem

https://qvault.io/2019/09/22/thinking-about-recursion-how-to-recursively-traverse-json-objects-and-the-filesystem/

Submitted September 22, 2019 at 03:03PM by kvothe1956

Javascript Alert Boxes

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

Submitted September 22, 2019 at 12:50PM by coderchrome123456

Deploying NestJS app to Aws Elastic Beanstalk

Hey guys ,I'm a bit frustrated with the deployment of NestJS app that i built with the help of a Udemy Course .I'm unable to deploy it on Elastic Beanstalk.Can someone help me with it ?There is nothing big or complex about the app it's just a task management app using postgres as DBSharing my github repo below:https://github.com/CruelEngine/nestjs-task-managementThe course that i followed is :https://www.udemy.com/nestjs-zero-to-hero/The problem is that the instance always goes to degraded state . I've changed the scripts, modified even the dependencies and dev dependencies . But it's always the same ☹️Thanks,

Submitted September 22, 2019 at 12:16PM by CruelEngine

Javascript Image Upload

https://youtu.be/xqIVrjKhfaU

Submitted September 22, 2019 at 09:08AM by coderchrome123456

Saturday 21 September 2019

How to connect Firebase with Angular 8 Application from scratch

For all the developers who have been searching for a robust platform for building mobile and web application faster, you can think about Firebase. The Firebase is a Backend-as-a-Service that offers the developers a wide spectrum of tools and services to develop high-quality apps at a much faster pace.Today, I am going to create a sample application to show how we can connect Firebase with Angular 8 Application. Follow below link to read more: https://jsonworld.com/demo/how-to-connect-firebase-with-angular-8-application

Submitted September 22, 2019 at 06:06AM by jsonworld

Web Development Tutorials

Guys, I have started creating some amazing web development videos, currently working on Data Structures Videos using JavaScript. I am also planning to create videos on one of the topics below :Vue.jsAngular.jsAngular 8BlockchainNode.js **MongoDBReact.jsand any other web technology you want.And also feel free to comment down below, which series would you like to watch so that I can create the best content for that to the best of my abilities.Please feel free to have a look. And if the videos suit your style and you are able to derive good knowledge out of that ,please subscribe.Here is the link to the channel :https://www.youtube.com/channel/UCWWRLPeMNMeDhpfE7R6qCyw

Submitted September 22, 2019 at 04:45AM by prateek951

Can I store a function in a database?

Im making something that needs to run code at certain times but I also need to be able to cancel it. Im using node-schedule to do it but I'm not able to cancel it if the variable used when making it is not still there. I tried storing the variable in my MongoDB Database but when I try to run the cancel function it says it's not a function. Does anyone know a way that I could fix this problem?

Submitted September 22, 2019 at 05:36AM by MuricaIsHere

Passport vs JWT?

What are your opinions on both?

Submitted September 21, 2019 at 09:24PM by gaurav219

Can any one help me with this Redis script?

I have a redis script that, in production, is run as a cron job. I did some edits, and am trying to test it before I send it back to my boss. I'm pretty sure the code is all correct, but the script doesn't seem to be working.Essentially, I am using redis to track server calls, and every so often these redis logs get saved to our Mongo database. When they are saved to Mongo, two things happen. 1) I loop through all redis keys and save them to Mongo. then I add a field to the redis file with a key of 'backUp' and a value of 'true' 2) I again loop through all the redis keys, and if there is a key of 'backUp' with a value of 'true' I delete that key.Because I am just trying to test this script without the whole app running, I've added a single redis document with 'client.hmset'. I've also added some log statements, and at the bottom I added some code that lets me run the file as a script.Here is the code:const db = require('../mongodb') const analyticsRepo = require('../app/repos/analytics') const ObjectID = require('mongodb').ObjectID let Binary = require('mongodb').Binary const redis = require('redis') const client = redis.createClient({ port: 6379 }) let start exports.start = start = function (cb) { console.log('start ()') client.hmset(['newHASH', 'route', 'routeValue', 'ipAddress', 'ipAddressValue'], function (err, res) { if (err) { console.log(err) } console.log(res) client.keys('*', function (err, keys) { // gets all hashes in redis db, returns them as 'keys' if (err) { console.log(err) } console.log('keys: ' + keys) for (let i = 0, len = keys.length; i < len; i++) { // loop through all keys client.hgetall(keys[i], function (err, results) { // gets all key/value pairs from keys[i], returns them as 'results' if (err) { console.log(err) } /* --inserts the object to be stored in Mongo db using the key/value pairs from 'results'-- */ const newLog = { route: results.route, ipAddress: Binary(results.ipAddress), // converts string to binary userId: new ObjectID(results.userId), // converts string to Mongo ObjectID timestamp: Date.parse(results.timestamp) // converts string to unix timestamp } analyticsRepo.create(newLog, function (err, insert) { if (err) { console.log(err) } }) // add backup field to keys[i] after saved to Mongo client.hset([keys[i], 'backup', 'true'], (err, backup) => { if (err) { console.log(err) } }) }) } }) // 2nd iteration of all hashes in redis client.keys('*', function (err, keys) { // gets all hashes in redis db, returns them as 'keys' if (err) { console.log(err) } for (let i = 0, len = keys.length; i < len; i++) { // delete the hash from redis client.hget([keys[i], 'backup'], (err, backupField) => { if (err) { console.log(err) } if (backupField === 'true') { client.del(keys[i], (err, success) => { if (err) { console.log(err) } console.log('record deleted') }) } }) } }) }) cb() } const redisToMongo = async function () { await db.init(function (err, results) { if (err) { console.error(err) return process.exit(1) } else { console.log('program begin') start(() => { process.exit() }) } }) } let args = process.argv[1] if (args === 'LOCAL PATH') { redisToMongo().then(() => { console.log('program run') }) } When I call the `redisToMongo` function at the bottom, I have a log statement that logs 'program run'. This log works correctly. Similarly, within the `redisToMongo` function I have a log statement that logs 'program begin'. This log works correctly. Similarly the first line of the `start` function, which has all the "real" code. has a log statement that logs 'star t()'. This log works, but nothing else seems to work. My client.hmset call should either log an error or success statement but neither on happens.Presumable if this were working, the redis document would be created, and then saved to my MongoDB, but this doesn't happen. And just to be sure, I tried calling a 'bad' redis command like 'hset123()'. This threw an error just like it should.How is it possible that I'm getting no errors, no log statements, and no successful additions to my database? Can someone please help me out here? Like I said, I'm pretty confident that the actual redis code is correct; I think I just don't know how to get this script to run or something...

Submitted September 21, 2019 at 08:02PM by Briyo2289

Am i the only one who keeps forgetting to export my local modules?

Like i literally do this every time, i just jump on to require it

Submitted September 21, 2019 at 08:26PM by HistoricalDust

Stubborn - A testing tool to mock HTTP server responses

https://github.com/ybonnefond/stubborn

Submitted September 21, 2019 at 07:32PM by bambou713705

Need some advice and feedback: generating charts from data and then integrating them into emails

I'd like to know how to add nice and smooth charts in the emails my application send to my clients. Don't know how to implement it exactly but I'm sure it'll make these weekly emails appealing. Has somebody already done that?My Node application uses Sengrid services to send emails and I already have a Cloudinary account for pictures storage. Is it possible to generate a full SVG or Base64 image to direct integration in emails? Should I generate pictures with a backend worker/script in Python or JS, push them in the cloud through the Cloudinary API and add a simple link in my emails? Is it easy/possible/desirable to use an online API which provides "chart a a service" and integrate magic links in emails?I'd like some advices from people who already did it successfully because I know how HTML/CSS and images/links security for emails is a pain in the ass.PS : maybe https://www.image-charts.com/ ?

Submitted September 21, 2019 at 10:43AM by Karl-Hambourg

Text Shadow 3D Effects

https://csspoints.com/css-text-shadow-3d-effects/

Submitted September 21, 2019 at 11:42AM by masgbox

Best practice for MERN deployment

Greetings all,Currently I have a website that is two separate domains, one for the ExpressJs/Mongo backend, and a React/Next/Express for dynamic routes frontend. Is this a common situation?Also, is docker a best practice as well? In my case, since the front end and back end are on separate domains, how would a docker-compose file control that? Is Docker the best practice or a MERN application deployment? I do like it for development.Right now I have just deployed my application without Docker, and it works fine. I'm really just looking for the best way to deploy a mern, or any node app for that matter. Specifically speaking, Docker and Frontend/backend separation.

Submitted September 21, 2019 at 08:47AM by lakerskill

Friday 20 September 2019

What would you suggest as in final quarter of 2019 to use Typescript or Javascript(without Babel) for a Node.js/express backend to use?

A Js dev by choice but not a fan-boy. Well awared of oops (regular and js based prototypal ) concepts and developement practices . I know basics of typescript ( worked alongside Angular devs and done oops heavy courses in Java, C#, etc in college) will brush up in 2-3 days.If I go with typescript this will be my first node(backend) project in it. My main focus is on maintainability of source code and scalability.I have basic or you can say superficial knowledge about Sql. Probabily going with Mysql/MariaDb ( gone through the pain of everything NoSQL :) )Last but not least project has a tight initial time line and possibly their will be no transitioning time from POC/MVP to market ready (actual concept is already build using CakePhp and in bad condition, both backend & frontend, not marketable enough and misses key feautures e.g. it is a static site with bunch of forms and admin portal). But it will be a long-term project.These days I am seeing lots of "Typescript is not Javascript" posts over internet and various pain points that Ts devs face when Ts have inconsistent behaviour after transpilation.So have to make a quick call. What would you suggest? And if you advice me to go with TS can you suggest some articles and tutorials to scaffold a backend project in Ts.

Submitted September 21, 2019 at 07:11AM by aakhri_paasta

What web server should you use with node?

A little back story, I’m a SysAdmin and have a decent understanding of how to use traditional web servers (IIS, Apache). I took a work sponsored bootcamp on full stack development (with Node) and it was interesting. My work, now wants me to rebuild one of our internal sites, cool! In class we used Express on our local machines. We never really discussed what we should use (or how) for a production app? Is Express acceptable, are there better options? What do you use for process monitoring? To complicate things I’m look at hosting in AWS. (deciding between using Beanstalk or trying to setup EC2/RDS)

Submitted September 20, 2019 at 11:57PM by MikeKnowsThings

How would I protect my Node server (BFF)

So I have an Angular app that makes http requests to my node server. The Angular app is just a collection of 4 forms the user has to fill in. And then the data for each form is sent to an endpoint on the node server.Since Angular runs in the browser how would I stop people from just inspecting the http requests and making the API calls directly to the Node server (through postman or whatever)?

Submitted September 20, 2019 at 08:12PM by I-Am-Programmer

NPM CEO Bryan Bogensberger Resigned

https://www.prnewswire.com/news-releases/npm-inc-announces-leadership-change-300922517.html?tc=eml_cleartime

Submitted September 20, 2019 at 08:07PM by runvnc

Does Node natively limit the size of data in the body of requests?

It is very simple to set up an api in node where you can accept various different requests, like POST or PUT requests where the user can send information in the body in the request.So I was wondering if node can natively limit the size of the data or if there are libraries/middlewares that can handle this in express or other api frameworks.An example would if I set up a POST endpoint where a user can create a Person with different properties like name, age and so on. So if the user decides to send multiple gigabytes worth of data in the request, how would one stop node from trying to load all of it in memory and crash the application due to node using up all the available memory.I know there are libraries to validate request bodies like Joi where you can for example specify the max amount of characters in a string but this can only be done after node handles the incoming request and saves all the data.

Submitted September 20, 2019 at 07:10PM by Royar1

A cheap database solution for node app

Hi,I am creating a node app and deploying it on opeNode. opeNode is very cheap and being a student I like cheap things but my application requires a database. Is there any way I can host the database at cheap rates like opeNode. I was looking through some npm modules which use JSON as database. Is that a safe option or is there any other option?

Submitted September 20, 2019 at 06:37PM by GhostFoxGod

Socket.io Hosting?

I'm a bit of a noob when it comes to Socket.io and Ionic 4, so I decided to practice a bit. I made an app that sends a command through a socket.io server to change the background color of the application. So like I can open the application on two different tabs, press the button on one tab and see the screen go from light to dark or dark to light on both screens simultaneously. I want to be able to build my the app to my phone so that I can tap the button on my phone and see the background color of the application on my browser change, but I can't seem to host the server so that both devices can communicate with the server. I spend the last two days trying to understand how to do this. I googled and youtube and all the tutorials I saw was either on using socket.io with localhost or using socket.io to host a website on platforms like heroku but the tutorials don't quite fit what I want to do... I apologize if I'm just stupid but this is really frustrating me. Can someone please help me? My code can be found at https://github.com/Wolfman13/HeartLight-Client and https://github.com/Wolfman13/HeartLight-Server

Submitted September 20, 2019 at 04:58PM by ChaoticAlchemist

Building a Super-Robust HTTP API with Isomorphic TypeScript

https://jamesmonger.com/2019/09/10/super-robust-api-with-isomorphic-typescript.html

Submitted September 20, 2019 at 02:30PM by jkmonger

16 COMPANIES WHICH APPS WERE WRITTEN USING NODE.JS | Software Brothers Blog

https://medium.com/@softwarebrothers/16-companies-which-apps-were-written-using-node-js-7903dac3726a

Submitted September 20, 2019 at 01:09PM by SoftwareBrothers

Handling requests on Express server

I have a simple Express API service with a few endpoints. The APIs are used by the frontend to read/write data from Elasticsearch (ES). The said endpoints are described below.1. /api/storeCities # parses a CSV and writes 100,000 documents to the cities index in ES 2. /api/fetchCities # fetches 100,000 documents from the cities index in ES 3. /api/fetchStates # fetches 100,000 documents from the states index in ES 4. /api/fetchCountries # fetches 100,000 documents from the countries index in ESQ1. For all the fetch endpoints above, I have no problem/latency fetching data into the UI. Since node supports 1000s of concurrent requests, there shouldn't be any problem multiple users calling the same API (?).Q2a. Whenever someone calls the /api/storeCities endpoint, node parses a CSV file and writes data to ES. However during this process, all other endpoints stop responding and there's huge lag from all the fetch endpoints. Since node is non-blocking, why is the WRITE operation affecting the READ ones? Is this a problem on the ES front?Q2b. I am also using the node Cluster module so there are multiple instances of my Express app. However, the lag still persists when someone calls the /api/storeCities endpoint. It seems like node is blocking all the READ calls from ES until the WRITE call is finished.I am unable to pinpoint where the problem is, node or ES?

Submitted September 20, 2019 at 01:11PM by vanillacap

I built an app to keep track of my followers in all my accounts with VueJs + ExpressJs + MySql

Hi everyone.For the last 3 weeks, I’ve been working on the following project. The thing is I own several accounts for my projects (Instagram, Twitter, MailChimp, GitHub, etc). So it was really hard to keep track of how my audience was growing (or not) in any of them.So I decided to build my own solution. I create a very simple app, that sends directly to your inbox a report showing the followers (subscribers, etc) you have in your accounts. Also, it saves the historical data, so it shows how much your audience has grown.For the tech lovers (I would love to answer any technical questions if you have any):Backend: ExpressJS (Node),FE: Vuejs off course + Bulma + BuefyBD: Mysql DB + Sequelize JSQueues: BullOther tools: Nodemailer, vue-analyticsAPIs integrated: YouTube, Twitter, MailChimp, Convertkit, Instagram and GitHub.I posted about it first in /r/vuejs and some interesting questions came up:Why I choose Bulma instead of Vuetify?Sincerely I recommend both, I think that Bulma is prettier/attractive than Vuetify, but Vuetify is more powerful and flexible than Bulma. So, I would say if your project will need complex pages, with a lot of components I would recommend Vuetify, but if your project is more focused on a clean and visually beautiful UI I would go for Bulma.Which was the hardest API work with?YouTube API was pretty easy to integrate using the googleapis (https://github.com/googleapis/google-api-nodejs-client).Twitter was a bit tedious, because you have to submit for a dev account first to get permissions to use it, and you have to fill a lot of questions and stuff, but then is easy using https://github.com/desmondmorris/node-twitter.But the worst was Instagram, I ended up using a workaround to get the followers from a search GET query that returns a JSON, but I'm not actually using the API.Why did I choose to send the report by email instead display them in a dashboard?I choose an email report because I don’t want another app to remember. I prefer to receive a scheduled report that I could check (daily or weekly) when I read my emails. Easy and simple. I tell you, is really exciting to check your emails and see that you have received a new report, willing to see if your audience is growing. As I really enjoyed the result, I decided to release it to the world. Is FREE, but I added a premium plan, to see if I can make some money with it haha.The app is https://trackmyaudience.xyz, let me know what do you think, any feedback is appreciated.TL;DRI own several accounts for my projects so it was really hard to keep track of how my audience was growing (or not). I built https://trackmyaudience.xyz, a very simple app, that sends directly to your inbox a report showing the number of followers (subscribers, etc) you have in your accounts

Submitted September 20, 2019 at 02:04PM by ngranja19

Concurrency in Node.js

One of my colleagues has written an article about concurrency in Node.js. He mentioned its general idea and pointed out some traps that may come with it. You can check it out on the blog. What do you think about it?

Submitted September 20, 2019 at 01:09PM by placek3000

Node.js now available in Haiku

https://www.haiku-os.org/blog/return0e/2019-09-19_nodejs_now_available_in_haiku/

Submitted September 20, 2019 at 10:25AM by brucebaird

Sands of Time: modifies the system time for different processes whenever you want

https://github.com/Tap30/sands-of-time

Submitted September 20, 2019 at 10:08AM by rajabzz

Build a WhatsApp bot in 10 minutes using Node.js and Twilio

https://medium.com/the-andela-way/build-a-whatsapp-bot-in-10-minutes-using-node-js-and-twilio-9869b443bf5e

Submitted September 20, 2019 at 08:26AM by tsicnarf

Thursday 19 September 2019

Giving Command Line Application a GUI

Hello! First time poster and also not very experienced with Node but I have an application that is basically a game queue system.After a certain amount of people join the queue it sends every user a message on the CLI that a match was found and gives the user an IP address to connect to. I was wondering if there are ways to port this to a GUI so users can click a button and when the match is found it displays the text that would usually appear on the CLI on a GUI instead.I’ve found UGUI as a potential solution but I was wondering if anyone experienced in doing this has a better solution or thinks that UGUI would work for what i’m trying to do. (Also sorry for formatting i’m on mobile)Thanks!

Submitted September 20, 2019 at 03:02AM by shaneajm

Looking for node posgresql tutorial

Hi anyone here could point me to a good full tutorial for node and posgresql? Free or paid are welcome. Thanks!

Submitted September 20, 2019 at 03:49AM by tsicnarf

Download file retrieved from AWS via NodJs over Angular?

User clicks on link, in Angular link has a bound function that sends a get request to NodeJS, I can see that NodJs gets the file/buffer stuff, and now I've been stuck on how to send file to user. Here is the current logic: app.get('/api/file', (req, res) => { let params = { 'Bucket': awsFun.createBucketName(req), 'Key': req.query.fileName } s3.getObject(params, (err, data) => { if (err) console.log(err, err.stack); else res.status(200).send(data); }); });

Submitted September 19, 2019 at 10:32PM by sinithw

How I scale Firebase (by migrating to graphQL)? And speed up my development by 10x

https://medium.com/@clapie.florent/how-i-scale-firebase-by-migrating-to-graphql-and-speed-up-my-development-by-10x-200b4a3068a0?source=friends_link&sk=cf4a748bfa93d061ad84fd194d5e87bb

Submitted September 19, 2019 at 09:44PM by kiarash-irandoust

Create and Deploy a Next.js and FaunaDB-Powered Node.js App with ZEIT Now

https://zeit.co/guides/deploying-nextjs-nodejs-and-faunadb-with-zeit-now

Submitted September 19, 2019 at 09:07PM by --d-a-n--

Pacman 404

I requested the site via browser it gives a result. But when I request through nodejs request() it provides Pacman error like administration blocking what is the solution?

Submitted September 19, 2019 at 07:30PM by mohamedimy

[Noob question] Is it possible to query the master process from a worker process without using event emitters while using using cluster?

My nodejs project structure looks like this:Master{Very_Big_Cache}Workers{TCP server that might need to query data from the cache}​Is there any way to query the data (in an elegant way) from the master process without using event emitters so I can query it on a sync way or await it?

Submitted September 19, 2019 at 05:17PM by Kran6a

What do you use to control access to your API resources ?

Giving a logged in user access to only the resources s.he owns seems like a common use case on paper.In reality, I couldn't find that many examples and tutorials. I've found many libraries to handle this, but they all have a different approach, so I'm wondering: what do you use to control access to your API resources ?Examples of such libraries:accesscontrolcancancaslconnect-rolesexpress-authorizationmustbe permissionacl node-authorizationcasbinexpress-aclabacrbac...

Submitted September 19, 2019 at 04:15PM by F00Barfly

Methods to deploy your node.js app to glitch.com

https://blog.maddevs.io/web-app-deploy-to-glitch-com-b43470c32a2f

Submitted September 19, 2019 at 02:19PM by darikanur

Moving beyond console.log() — 8 Console Methods for Debugging

https://medium.com/gitconnected/moving-beyond-console-log-8-console-methods-you-should-use-when-debugging-javascript-and-node-25f6ac840ada?source=friends_link&sk=62597805243671cb9b96e54b052fde58

Submitted September 19, 2019 at 01:55PM by CodeTutorials

Methods to deploy your node.js app to glitch.com

https://blog.maddevs.io/web-app-deploy-to-glitch-com-b43470c32a2f

Submitted September 19, 2019 at 11:23AM by darikanur

Is there a way to run npm scripts with forever.json?

I am trying to use forever as it's shown in the documentation. I created a json file and added something like this[ { // App1 "uid": "app1", "script": "index.js", "sourceDir": "/home/myuser/app1" } ] And it works, I run it like so:forever start /home/myuser/app/forever/development.jsonBut, projects created through create-react-app don't have an entry point but they have npm start. So is there a way to run npm start in the above setup?In the terminal I could do this: forever start -c "npm start" /home/myuser/app1 but it be supper hand to be able to add all my apps into a json file (the first example).Is there a way to do it?

Submitted September 19, 2019 at 09:40AM by gate18

Build an App to Send SMS Surveys with Twilio + Airtable on Standard Library

https://medium.com/@brimm_reaper/build-an-app-to-send-sms-surveys-with-twilio-airtable-on-standard-library-ef5be1cd4f0b

Submitted September 19, 2019 at 08:02AM by J-Kob

Wednesday 18 September 2019

How to connect Nodejs with PostgreSQL

There are many databases available today which is used as per the requirement of the application, And as a web developer requirement may come to work on an application using PostgreSQL database. So the first thing comes in our mind that how the databases will be connected and basic queries with it. For the task pg package of NPM will be used. So here, In the below sample application, I will import a CSV file into the PostgreSQL database. Find more: https://jsonworld.com/demo/how-to-connect-nodejs-with-postgresql

Submitted September 19, 2019 at 04:20AM by jsonworld

How to handle time based events in Node/TypeScript.

Suppose, in my application, I want to have a user purchase a product. When they do so, a Shipping API goes out and creates a label and a WebHook is registered for when the API marks that the package is delivered. Within the next 72 hours, I want the user to rate their item, and if they don't, send a push notification reminding them to when those 72 hours have passed.What is the best way to handle that kind of "eventing" in Node?Thank you.

Submitted September 19, 2019 at 12:04AM by JamieCorkhill