Wednesday 31 July 2019

[userscript] Move node.js API guide table of contents to a sidebar

One thing that annoys me about node.js API documentation is that the table of contents is in the top, so when clicking a method I have to go back to the top to scan for alternative methods.With this userscript, the table of contents is moved into a sidebar so it is easy to scan for methods.```csscolumn1.interior {margin-left: 540px; }toc {position: fixed; overflow-y: scroll; overflow-x: hidden; top: 15px; bottom: 0; width: 340px; margin-left: -350px; padding-left: 20px; padding-right: 10px; font-size: 13px; }toc h2 {display: none; }toc ul {margin-left: 1rem; }toc ul li {margin-bottom: 0.5rem; }apicontent {padding-top: 0; } ```

Submitted August 01, 2019 at 05:34AM by char101

Would app.use( ) create a bottleneck

So let's say each API does some check for authorization and checks if your req.body does not have any null values. Instead of writing these explicitly in each API, if I write it in app.use( ), would it create a choke point?Would each request wait here till the previous one does not move along? I guess the app.use ( ) should not "await" right? It should only operate on callbacks or on then( )

Submitted August 01, 2019 at 06:18AM by kjroger94

Sending response status and json result in Headers Error

I posted my question on stack overflow but so far I haven't gotten a response. I'm trying to return a response of status and json if user didn't provide requirements to sign up return res.sendStatus(400).json({ errors: errors.array() });.I get an Error Can't set headers after they are sent to the client.If I remove one of chaining methods, then the response works normally. return res.json({ errors: errors.array() }); But I would like to include both.​Source code.const express = require('express'); const { check, validationResult } = require('express-validator'); const connectDB = require('./config/db'); const app = express(); // Connect to Database connectDB(); // Init Middleware app.use(express.json({ extended: false })); app.get('/', (req, res, next) => { res.send('API Runnning...'); }); // Define Routes app.use( '/api/users', [ check('name', 'Name is required') .not() .isEmpty(), check('email', 'Please include a valid email').isEmail(), check('password', 'Please enter a password at least 5 characters').isLength( { min: 5 } ), ], (req, res) => { const errors = validationResult(req); if (!errors.isEmpty()) { console.log(errors); return res.sendStatus(400).json({ errors: errors.array() }); } const { name, email } = req.body; res.send('User route'); } ); const PORT = process.env.PORT || 5000; app.listen(PORT, () => { console.log(`server listening on port ${PORT}`); });

Submitted August 01, 2019 at 01:41AM by Calligringer

[JOB] Walmart Labs is looking for React/NodeJS Developers for their Open Source Team

Nodejs runtime books

I am not a newbie to Node js, I had an experience with it a couple of years ago, some REST API/Mongo/WebSockets staff. And right now I am moving from Python/Django to Typescript/Nodejs backend stack. And I am looking for some books with detailed explanation of how node js runtime really works. I know there are a plenty of node js books, but most of them are focused more on the practical usage of this platform: http server, working with database and etc. But I am more interested in the platform implementation details and how I can tweak runtime to accomplish my goals. Does anybody aware of such books, which can satisfy my needs?

Submitted July 31, 2019 at 11:31PM by ceoro9

An Introduction to Domain-Driven Design - DDD w/ TypeScript

https://khalilstemmler.com/articles/domain-driven-design-intro/

Submitted July 31, 2019 at 09:38PM by stemmlerjs

Node v10.16.1 (LTS)

https://nodejs.org/en/blog/release/v10.16.1/

Submitted July 31, 2019 at 09:47PM by dwaxe

how do i store a product with multiple prices depending on the size?

im building an online store using express,mongo, and mongoose.For example i have shampoo bottles in different sizes where the price changes based on the size.350ml = $25700ml = $481400ml = $902800ml = $170Each productId and price will change but the sizes will always be the same.Then from my page the user will be able to use a dropdown to select the size then update the price and when they click add to cart ill need to add that productid with the size and price.​I think this problem has more to do with how im saving my product schema but im pretty new to this and having trouble finding info on mongoose.​thanks

Submitted July 31, 2019 at 10:08PM by canadiandime

Scraping websites in order to search for keywords - JavaScript Web Scraping Guy

https://javascriptwebscrapingguy.com/jordan-scrapes-websites-for-keywords/

Submitted July 31, 2019 at 10:51PM by Aarmora

[SUGGESTION] Frameworks needed ...

Hello,I want to create an application "platform independent" that shares the same code base. The app basically will crawl a specific website and extract data points. What are frameworks on top of node that I could use to achieve this ?Thanks

Submitted July 31, 2019 at 08:30PM by CURVX

Can I authorize JWT cookies in NestJS?

Hello, I am currently writing a backend server using NestJS. I have a JWT passport strategy that I use with AuthGuard to validate the JWTs. I was wondering if it is possible to extract the cookie containing my JWT token and pass it into jwtFromRequest in the super() method in my JwtStrategy class that extends PassportStrategy. Currently it is using ExtractJwt.fromAuthHeaderAsBearerToken() to get the tokens from the headers. Sorry for a noobish question. I did not know how to better phrase this.The current logic:1. User signs in -> server signs payload and returns it in a res.cookie()2. User requests the server -> server will check the JWT in client's cookies and use passport-jwt to check the validity

Submitted July 31, 2019 at 08:49PM by recycled_bin

Slack App Node.js template you can deploy + link to Slack instantly from GitHub, no config required

https://github.com/stdlib-examples/project-slack-ping

Submitted July 31, 2019 at 05:59PM by J-Kob

Is it possible to use GraphQL and Instagram authentication together?

^ basically the title.I am trying to create an app where users will register using their instagram accounts, and also I want to use graphql, how do I secure some of the routes and also how do i retrieve data from instagram's api?

Submitted July 31, 2019 at 04:48PM by warchild4l

How to create and run cron jobs in Node

https://werick.codes/articles/how-to-create-and-run-cron-jobs-in-node

Submitted July 31, 2019 at 03:46PM by tesh254

Help me understand the behaviour.

​CodeIf I run this block of code and send a post request including a file with request from any http client, I see 'Got a chunk' couple of times and at the end 'Got all data' in console. I expected it like this. I was happy!Then I notice, if I try to upload a large file I don't see anything in the console until the whole file is uploaded to server. Why do I think like that? Well, when I hit the send button in http client, it takes a lot of time to complete the request. When the request gets completed I see all the logs in my console.What I expected: I expected that file will be send in a chunk so I will start seeing logs almost immediately after sending the request because server will receive a small chunk and trigger the 'data' event.What am I missing here? What do I have to do to achieve the expected behaviour?​Thanks in advance.

Submitted July 31, 2019 at 02:46PM by mrdijkstra

Simple package.json style IOC container for Node

I created an IOC container designed with simplicity and familiarity to package.json in mind. This was created to be the simplest possible way of mapping modules to their respective dependencies. Feedback on what people think of the dependency declaration-style as well as design decisions (such as auto-instantiation instead of the common factory-pattern), as well possible contenders that do the same (thus rendering it redundant) would be much appreciated. If anybody would like to comment on the technical implementation that would also be great (such as the subscriber-based dependency resolution). I think the performance could probably be increased by the use of certain log-n tree structures (instead of iterating as much as is currently done), or possibly priority queue for faster leaf-finding.Here is the package: https://www.npmjs.com/package/nano-container

Submitted July 31, 2019 at 01:54PM by booleantoggle

Sources

What are some of the best sources to learn node for a beginner?

Submitted July 31, 2019 at 11:20AM by rishikcr7

Visual GraphQL tutorial for beginners

https://app.graphqleditor.com/?category=tutorial&visibleMenu=code

Submitted July 31, 2019 at 12:50PM by rob_mat

Array issue on MongoDB $in query operator

Hello guys,Pretty new to Node.js and MongoDB, I have an issue with the $in query operator. You have to give it an array, but when I get it from my URL it's not working. Find my code below:// GET /profiles?gender=man:woman router.get('/profiles',auth, async (req, res) => { if(req.query.gender){ const parts = req.query.gender.split(':') parts.forEach(function(element){ console.log(typeof element) console.log(element) }) console.log(Array.isArray(parts)) } // parts = ['man', 'woman'] try { const profiles = await Profile.find({ gender: { $in: parts } }) res.send(profiles) } catch (e) { res.status(500).send() } }) With this code I get the 500 error but everything looks fine in my console:string woman string man true But when I uncomment my variable "parts" and populate it manually with 'man' and 'woman' it works and i get my header status response 200 with the datas.Do you know what's wrong with my code ?

Submitted July 31, 2019 at 11:18AM by Jrm_car

Need help to resolve Promises

I need to unwrap single value from promise but it ended with error " Promises must be handled appropriately"Promise.resolve(getTokens).then((val)=>{ return admin.messaging().sendToDevice(val,payload) })

Submitted July 31, 2019 at 09:04AM by the_vjack

Tuesday 30 July 2019

OpenGL bindings for Node

I know this probably isn't a reasonable question but it's worth a shot. I know languages like Python have capabilities to create windows and draw on them, but can it be done with Node with bindings? I don't want any Electron-based solutions or anything like that, I want a pure Node/C++ binding implemention that allows drawing onto a native window. I know OpenGL is basically a "framework" that is available in most languages like C++ and C, but since C++ files can be compiled and binded with Node, why hasn't someone made something that I can use in Node? This question probably sounds pretty stupid but I'm honestly curious why it hasn't been done before.

Submitted July 31, 2019 at 06:24AM by PassTheMayo12

Anyways to create a Discord bot that transfers ownership?

I recently saw someone who supposedly got a bot added to their server that later somehow made a certain user owner, who then deleted the server. I have no idea how that happened, but would like to know if it’s possible to somehow code a Discord bot that makes select user owner n removes it from original owner.

Submitted July 31, 2019 at 06:03AM by parordice

Error Handling PUG template

I’m building my first Node application using Express and Pug and I’ve been looking for an interesting page to display errors for invalid routes and such. I haven’t been able to find any Pug templates like this and I was hoping a Pug template resource existed. Thank you!

Submitted July 31, 2019 at 03:09AM by collegebender

Guys, i'm currently working with ejs templating and i'm doing a todo list from a course and have some things which i can't understand

https://imgur.com/a/gmesVcgI can't understand the thing with the dynamicText. It has a value in the app.js as "Work List" but in the course the instructor has write <%= dynamicText %> and in when i go console log it gives me just Work it doesn't give me Work List. This is the right solution but i need an explanation. I would appreciate that a lot guys, thanks in advance!

Submitted July 31, 2019 at 12:39AM by anevskii

How do I show a Map/dictionary data in nodemailer

I am using nodemailer module, and under the Html: html message goes here, I can do a string interpolation, but how would I display/render contents in a map or dictionary without specifically specifying each key.I have this as a map, sometimes it can be three pairs, I want the key and value to be rendered{Name: man, age:40}

Submitted July 30, 2019 at 11:24PM by lanrayx2

iGaming blockchain project is looking for validators

https://twitter.com/daocasino/status/1156190170657492993

Submitted July 30, 2019 at 08:41PM by WasteTraffic

Authentication APIs using Node

Hi, Have anybody desgned authentication and authorisation APIs using Nodejs?

Submitted July 30, 2019 at 08:51PM by boilerweb

How to use http.createServer with async/await?

I want to make a very simple server using Node's built in http module rather than express or koa or something else. How can I use async/await with this rather than having to use callbacks?

Submitted July 30, 2019 at 08:01PM by nowboarding

Advice regarding web hosting service for SSR React.js SPA

Hi folks, I'm a frontend developer and sometimes I like to mess around with Node.js, I have this project for a relatively simple server-side-rendered spa built with React.js, I have worked with simple backend Node.js code before but mainly just for fun, I've never actually deployed a Node.js application on the web, so I'm not so sure how I should go about it, I've heard there's a few types of web hosting services available: Shared Hosting, VPS Hosting, Dedicated server hosting, Cloud hosting, Managed hosting and Colocation, but I really have no idea what kind of hosting service I would need to build this simple SSR SPA website, nor what provider I should go for. Do you guys have any advice regarding that? A few friends of mine recommended me this Scaleway and this HostMach service, what do you guys think?​Thanks!

Submitted July 30, 2019 at 07:41PM by Lhaer

Execute shell script inside docker container

Hello!​I'm trying to shell into a php container then run a command with node. I have tried using child_process.exec() but i'm not getting any errors or output back. Please let me know if there is something else I can try.​const { exec, spawn, } = require('child_process'); const openShell = exec('docker-compose exec api bash;'); exec('shellscript.sh');

Submitted July 30, 2019 at 07:51PM by hihellowhatsuphi

Servicectl: a new opinionated process manager that aim to simplify native init systems for developers.

https://github.com/vmarchaud/servicectl

Submitted July 30, 2019 at 06:14PM by vmarchaud

Moving from Drupal to Strapi

https://www.reddit.com/r/Strapi/comments/cjpuc2/moving_from_drupal_to_strapi/

Submitted July 30, 2019 at 02:23PM by Kaidawei

npm link workflow question

I may be missing something, but there's something I haven't quite figured out with npm link.I understand that, once you link a dependency, it becomes locally available. My question is, how is a package that contains a link dependency handled when it gets published. Are the links replaced with references to the dependency in the NPM registry, or do you have to manually update to change from linked dependencies to standard depencies?

Submitted July 30, 2019 at 02:57PM by LetReasonRing

Any node module to join multiple tiff images to a a multi-page tiff?

is there a node module capable of taking multiple tiff images as buffers and merging them into one multi-page tiff and give its buffer?​Thanks!

Submitted July 30, 2019 at 12:13PM by BlueFrenchHornThief

Multer filepicker on element click?

Hey fellas,is it possible to get the filepicker by clicking on an element?I can only find solutions where
.Thans in advance!

Submitted July 30, 2019 at 11:04AM by rochenExklusive

Build the Serverless Fraud Detection using Amazon Lambda, Node.js, and Hazelcast

Hi all.Check out my blog post and learn how to build the complete serverless solution using Amazon Lambda, Node.js, and Hazelcast.Appreciate your feedback and comments!

Submitted July 30, 2019 at 08:53AM by ncherkas

How to add blogs to a personal website

I'm a newbie. I made a personal website that is mainly for marketing my resume. However I would like to expand and add a blog functionality so I can share about random topics as I please. I see people with minimalistic sites that just have a stack of links to their static blog pages. Is this how people usually do it? I was thinking I'd just code my blogs in HTML and serve them up via links on a blog tab, but surely there is a better way to do this? Any thoughts?

Submitted July 30, 2019 at 08:37AM by mTORC

Monday 29 July 2019

Using GPT-2 With Node?

Just played around with GPT-2 through a web interface, and it left me wondering: Is there any way to get this running with Node? Is there an API that links up, or maybe a port of it? Just wondering...

Submitted July 30, 2019 at 04:23AM by EuphoricPenguin22

could I use cookie-session instead of express-session for passport-auth0?

Sorry this post is related tohttps://www.reddit.com/r/node/comments/cjiokb/auth0passportjs_too_many_redirects_with_more_than/Sorry I am new to this,I am wondering if I can use cookie-session instead of express-session since JWT is supposed to not storing information in server.I am asking because I have read a few tutorial of passport and Auth0, and it also mentioned about expression-session only.I am facing issue with multiple instances + load balancer envrionment where after a user is login at Auth0 login page, and in /callback.router.get('/login', authenticate('auth0', { scope: 'openid email profile' }), (req, res) => res.redirect('/'));router.get('/callback', (req, res, next) => {authenticate('auth0', (authErr, user) => { if (authErr) { console.error(`Error authenticating user: ${authErr}`); return next(authErr); } if (!user) { return res.redirect('/login'); } the user is set to false and eventually I see:[xyzURL] redirected you too many times.Try clearing your cookies.ERR_TOO_MANY_REDIRECTSSince Auth0 is using JWT, could I use cookie-session? if so, what could I do wrong?PS.Here is my session config:const sessionConfig = { name: 'sessionId', domain: 'example.com', secret: uid.sync(18), secure: true, httpOnly: true, maxAge: 1800 * 1000 }; Thank you!Jay

Submitted July 30, 2019 at 05:03AM by ufsi7259

Jump-start your next full-stack web application in minutes with Codotype

https://alpha.codotype.io/generators/codotype-hackathon-starter/build

Submitted July 30, 2019 at 03:01AM by aeksco

How to retrieve external authentication tokens periodically?

I have a weird problem that I can’t seem to solve without using some weird hacks.I have 3 external api’s that I need to authenticate with for my app to function properly.I currently pass in secrets that are used to authenticate, then I receive tokens with a certain TTL.Right now, I am using setInterval() every 15 mins to re-retrieve the secrets.Is there a less hacky way to do this?

Submitted July 30, 2019 at 02:44AM by UkraineTheMotherLand

Pain points using proxies?

Hey r/node,I work with a small dev shop that's looking to potentially build a tool to make using proxies easier and more efficient.Instead of running with our assumptions, we thought we'd drop by a few communities that use proxies regularly and ask for some feedback on how you would like to see the overall proxy experience improved.We'd love to know the pain points you have when using proxies and/or any ideas on how to make proxies easier/more efficient to use.Feel free to drop those thoughts below and thanks in advance for your help!

Submitted July 30, 2019 at 01:02AM by devshop2019

auth0+passport.js too many redirects with more than 1 instance

Infrastructure:cloud:aws beanstalkturn on nginx for container proxy serverapplication load balancer - https only, default process (https)2+ instance in private subnetenabled end to end encryption followinghttps://docs.aws.amazon.com/elasticbeanstalk/latest/dg/configuring-https-endtoend.htmlhttps://docs.aws.amazon.com/elasticbeanstalk/latest/dg/https-singleinstance-docker.html​self-signed certificate on instanceinstance running docker​In local, we have a 3 container to mimic the infrastructure,​1 nginx: 443 as load balancer and https reverse proxy2 app container: 3000:3000, 3001:3001 respectivelyso, not end to end encryption yet​​software:authopassport(https://github.com/auth0/passport-auth0)expressreactcookie-session packageconst sessionConfig = {name: 'sessionId',secret: uid.sync(18),secure: true,httpOnly: true,secureProxy: true,maxAge: 1800 * 1000};workflow:open website, click login link, it then redirect us to auth0 login page, after input username/passport, we click submit.​We are encountering "redirect too many times" when we have more than 1 instance running. The issue goes away if I turn on sticky session on the target group in aws.​We are seeing the same when trying on the local docker environment.​In this code,​```router.get('/callback', (req, res, next) => {authenticate('auth0', (authErr, user) => {if (authErr) {console.error(`Error authenticating user: ${authErr}`);return next(authErr);}if (!user) {console.info(`No user data, redirecting to login page`);return res.redirect('/login');}```​The logic always hits - if (!user), and we are not sure why this happens with multiple instance, load balancer setup.​Please advise and help.​Jay

Submitted July 29, 2019 at 11:40PM by ufsi7259

Drag and drop page building for any site - Builder.io

https://builder.io

Submitted July 29, 2019 at 11:27PM by steve8708

How am I supposed to store emails?

The xxx part of an email xxx@gmail.com is supposed to be case sensitive, but it seems that it actually isnt, as in gmail etc. It isnt, so, how am i supposed to store emails?Currently I am decapitalizing the domain part like this WOODY@gMaiL.COM to WOODY@gmail.com, and storing it like so.The problem rn isobviously that if someone enters woody@gmail.com in login, it doesnt match WOODY@gmail.com.So how am i supposed to do this?Should i just decapitalize the input and whole email when storing and not care about the fact that the front part of a email SHOULD be case sensitive? Is that what everyone does?If so, then umm, what happens when someone has a actual case sensitive email? They just dont get the service?

Submitted July 29, 2019 at 10:07PM by livinglibary

Introducing a Node.js open source project

If you want your voice heard, you need to consistently share and distribute your content over the internet. I made a public open-source project to help you. Introducing #Shohratbaz(Fame Addict), it'll help you get the attention you deserve. This project is developed with Nodejs version 10.6 LTS. So it is a good resource for learning Nodejs in actionIt uses Node.jsIt has good samples of connection, reading and writing to MongoDBIt works with Facebook graph APIIt is under development, so if you watch or star the repository you will notice the changes and you may use it on your projectsHere's the GitHub link: https://github.com/amiryousefi/shohratbazYou can reach me on https://twitter.com/im_amiryousefi, if you got any question about this project, or generally Node.js

Submitted July 29, 2019 at 09:15PM by amiryousefi1

Access module constants

New to Nodejs here. How do you access a modules constants? Or is that bad practice?Example:car.jsconst engine = 'v8' const buildCar = (params) => { ... } module.exports = buildCar How would I access the `engine` constant?

Submitted July 29, 2019 at 05:50PM by bmo333

Handling Collections in Aggregates (0-to-Many, Many-to-Many) - Domain-Driven Design w/ TypeScript

https://khalilstemmler.com/articles/typescript-domain-driven-design/one-to-many-performance/

Submitted July 29, 2019 at 05:06PM by stemmlerjs

Passport.js with linkedin oauth v2 gives 500 error

avoiding run time problems

HI Guys,I was just wondering how you all make sure that after you refactor some code, how do you make sure that you do not run into runtime errors?A resolution of your variable or function that is not going to happen in the run time is quite destructive ( in some context). Obviously, testing your code thoroughly is the best way but I was just wondering if there was a complier (not exactly obviously) but something similar that tells you "dude you forgot to declare your variable".

Submitted July 29, 2019 at 02:21PM by kjroger94

Why this is empty in global scope in Nodejs?

Codefunction print() { console.log("local this", this) } console.log("global this", this) print() OUTPUTglobal this {} local this Object [global] { global: [Circular], clearInterval: [Function: clearInterval], clearTimeout: [Function: clearTimeout], setInterval: [Function: setInterval], setTimeout: [Function: setTimeout] { [Symbol(util.promisify.custom)]: [Function] }, queueMicrotask: [Function: queueMicrotask], clearImmediate: [Function: clearImmediate], setImmediate: [Function: setImmediate] { [Symbol(util.promisify.custom)]: [Function] } }

Submitted July 29, 2019 at 03:02PM by Chawki_

Top 25 Javascript Plugins for Webstorm & IntelliJ

https://blog.codota.com/top-25-javascript-plugins-for-webstorm-intellij/

Submitted July 29, 2019 at 01:49PM by weoter

Hosting Solution for Node based SaaS

Hi guys, I am planning on building a node and mongo based SaaS and I am searching for a scalable hosting solution for node, Digital Ocean and AWS Lightsail looks like decent bet, I am a front end developer and haven't worked with cloud based solutions like Digital Ocean/Lightsail so it would be really helpful if you guys could share your insights on this. If any of you guys are SaaS owners, it would be really helpful if you could share with me your hosting expense. Thanks a lot for any feedback, really appreciate it.

Submitted July 29, 2019 at 07:43AM by RamSubramanian

Sunday 28 July 2019

Is it possible to cache stream with request('API').pipe?

Hi guys, I want to ask a question about Nodejs stream with request library. I made an issue here but none respond to me.https://github.com/request/request/issues/3186Let me summarize it:This is an example from request's README.md file (https://github.com/request/request#streaming):request('http://google.com/doodle.png').pipe(fs.createWriteStream('doodle.png')) My concern is : Is it possible to cache request('http://google.com/doodle.png'), so it will reduce a lot of workload for external server.Thanks for reading my question!

Submitted July 29, 2019 at 04:24AM by ChauGiang

Looking for a SaaS, almost, that will run an integrated chat on my webpage

I have a project that I want to integrate chat-rooms into, but I don't want to build, run, and manage a chat service.Is there a service that deals with servers and management that I can plug in to my already existing app?Thanks!EDIT: It has to be group chats but not everyone is allowed into every group chat. I.e. it's not flat.

Submitted July 29, 2019 at 05:07AM by bszupnick

How could one close all instances of chromium? (Opened by an API using Puppeteer)

Hey guys, I have an API and I’m 99% certain it’ll close the puppeteer instance, but I have had instances where the node app processing the API crashed and orphaned a Chromium browser instance.This isn’t a mission critical API just a fairly useful internal tool I whipped together for a small team.I’d love for some automated way to close all browser instances of Chromium at, day, 12:00am everyday. That way if I don’t have time to debug it, I don’t have to worry about an accidental resource leak and the team can continue to use the API after the app restarts.Any ideas?

Submitted July 28, 2019 at 10:19PM by g3t0nmyl3v3l

First node app - need help!

Stack:node v12.7.0express 4.16.1node-powershellCode: https://github.com/tylerapplebaum/media-remoterun-script.js was a standalone version of this without the express renderer. Issue #1 is still an issue using this method too.Issue #1: When I run http://127.0.0.1:3000/getip, the browser returns the IP in the terminal window (yay!) but the request does not complete in the browser.Screenshots of issueIssue #2: I'd love to get the IP address to display in getip.ejs, but I'm not sure how to go about that.Happy to pay someone for their time, as I'd really like to learn this.

Submitted July 28, 2019 at 09:03PM by IDA_noob

How would you join two specific sockets to a chatroom using socket.io

I am using nodejs, in the backend with socket.io. I want to take in multiple sockets and then sort them by username and join the first one in the sort to the last one. An example would be connecting the socket with username that starts with A to Z, B to C and so on.The way I'm doing it now is I am attaching a username to each socket and putting it in an array and then sorting them. However, I cannot get the sockets to join each other when I do a socket.join('room 237') on both sockets. My guess is that when I join the sockets, I am joining the copy of the sockets in the array and not connecting the actual sockets, and I am not sure of what else to do.I even thought of hacky solutions to do it but I couldn't come up with any that were decent. I think there has to be a better way to do this and make it work.Any help is appreciated, thank you!

Submitted July 28, 2019 at 09:21PM by IRULETHISREDDIT

Express: Redirecting the User to another Route after waiting a specific amount of seconds.

How can i go about Redirecting the User to another Page. 5 Seconds after the current page has loaded.I have a login form. And when its submitted The User is Presented with an Alert with an Error message. If there isn't an error message, It shows a Success alert. I want to make it so that after 5 seconds of the Success Alert being shown, The User is redirected to their Dashboard.Of course this is something that i can live without. Its just something cool i wanna implement and it will also increase my knowledge about how to solve a similar problem if any arise.

Submitted July 28, 2019 at 03:59PM by Demoncious

Implement authentication service using system credentials

Hello.I want to ask if the following is possible:I want to create a page hosted on an ubuntu server. In this page if someone wants to login they must be users of the system.So If I want to login as user demo_user with the password "foo" a user demo_user with password foo should exist in the system.Any ideas or any guides?

Submitted July 28, 2019 at 04:14PM by mkcodergr

API Gateway in a Nutshell

https://www.pogsdotnet.com/2018/08/api-gateway-in-nutshell.html

Submitted July 28, 2019 at 03:23PM by acdota0001

Error when installing quick.db

Whenever I try to install quick.db, it keeps giving me errors and won't install, any fixes? https://pastebin.com/ar2xuPgw

Submitted July 28, 2019 at 02:01PM by Blocktunes

Looking for articles which describes Nodej event loop in much deeper level

Hi everyone,I'm looking for articles about Nodejs event loop in a much deeper level. Eg. https://nodejs.org/en/docs/guides/event-loop-timers-and-nexttick/. I would like to learn more about the phases which mentioned in that article.Thanks

Submitted July 28, 2019 at 12:16PM by rocket-racoon-berlin

Using Bull Queue for creating a scheduler

https://medium.com/making-smalltalk/automation-using-bull-queues-to-face-bear-market-d0fc8d99bcb4

Submitted July 28, 2019 at 10:45AM by 7lazy7

AnonChat App - A Node + Socket.io Project

Hey Reddit,To practice our webdev and node.js skills, we thought it would be interesting to make a chatroom project. So, we made AnonChat.You can create a chatroom in one click, enter any username, and share the room link with your friends for them to join. Say whatever you want, how you want - none of the chats are stored! You can see the chats only during your session, sort of like a Snapchat + Omegle concept. No login required, no account required, just chat!We launched on ProductHunt and would appreciate feedback and upvotes on our project :) To check out the ProductHunt page, click the link below:https://www.producthunt.com/posts/anonchatTo check out the app, click the link below:https://anonchatapp.herokuapp.com/

Submitted July 28, 2019 at 09:13AM by malhi3

Saturday 27 July 2019

Fixing Mixed-content warning...

Introducing kos-ts-controllers: Typescript API router specifically for Koa 2+.

https://github.com/iyobo/koa-ts-controllers

Submitted July 28, 2019 at 06:27AM by buffonomics

OpalChat.com - A NodeJS Project

So I've started working on this site, using nodejs for the API servers. Its going pretty well but I don't really talk to anyone else that's into NodeJS, so it'd be super cool to have some fellow noders around. Didn't want this to sound too self-promo, but I don't really know how else to draw the attention of fellow nodejs guys without showing what i've built off first. Yuhno?Anyway, would absolutely LOVE to talk more about the backend. Let me know what you think!

Submitted July 28, 2019 at 05:47AM by tj47201

Hosting for node and local database

I'm almost ready for public deployment on a node.js application. I need to use a mongodb database with it, and I don't want to pay for both a server to host the app and a separate cloud database. I'm wondering if I can host the app with a local database on the same server and if so what would be my most economical options for that?

Submitted July 28, 2019 at 04:51AM by fathergrigori54

good nodejs proxy server?

I've been using anyproxy but I have trouble getting it to do what I want and not sure they give support on their github. Any other alternatives?

Submitted July 27, 2019 at 11:51PM by donteatyourvegs

Z: A new transpiled language

Z is a transpiled, dynamically typed, loosely object oriented (in other words, it allows creation of objects whenever and wherever, and it doesn't support class-based design), and very functional. It transpiles to node.js, and can leverage the entire javascript ecosystem. It uses JavaScript's APIs, so it can be picked up in around a day or so. It is still in the alpha stage: there may be bugs with the compiler, or incomplete features. However, Z's pace of development is rapid, so new features (including bug fixes!) should be rolled out daily or weekly. By switching from JavaScript to Z for small projects you get:Fast Transpilation Time (Z's compiler can transpile thousands of lines per second.)Shorthand functionsA small standard library (5 modules, and growing)You still have the entire JavaScript ecosystem for the backendExpression SafetyPattern Matching (It's structural, like TypeScript's type system)Metaprogramming galore:Z supports meta declarations, which are basically the equivalent of #define in C.Z erases meta declarations at runtime, but compile time functions called dollar directives allow for use of metadata.Dollar directives are passed ASTs of the following expression or statement, allowing for crazy metaprogramming concepts. (Writing a for loop using an array literal - who would have thought that was possible? - with dollar directives, it is.)Z's dollar directives are not yet well documented, and have not been tested thoroughly. Use with caution.Elegant control flow: Z's built-in control constructs don't require parens around their conditions, and Z's "constructs" library contains many other control flow structures.Symbolic Names: Z dosen't have operators: instead Z's names can have symbols in them.Where Z is:WebsiteSubredditGithub OrgCompiler on NPMCompiler SourceStdlib on NPMStdlib Source

Submitted July 27, 2019 at 11:36PM by N8Programs

Second language to JS/Node??

Hi everyone, I have been doing Node for a while and learned it from a boot camp. I really enjoy it but I kind of want to pick up a second language to JavaScript for the back end. Do you have a second language you use for back end or just js with node? I was considering learning PHP but was worried it would confuse me and make me forget Node. Any experience I appreciate, thank you all very much.

Submitted July 27, 2019 at 10:06PM by CodedCoder

Cache control

I use cache control to cache the image with etag: version 1,when I request the image it gives with 200 response,on second request it will 200 but comes from cache drive on third time on reloading it doesn't give 304 code it again fetch the whole resource file from server

Submitted July 27, 2019 at 08:07PM by mohamedimy

Timestampy - Bunch of utilities useful when working with UNIX timestamps 🕒

https://github.com/xxczaki/timestampy

Submitted July 27, 2019 at 07:10PM by xxczaki

Parsing an uploaded CSV in Node in background.

I have a UI from which the user can upload a CSV file (POST request to /api/upload). The CSV file is then received by Express → parsed → written to the database. I have a couple questions regarding this process chain.All the actions (upload, parse, write to db) are happening on the same request endpoint (/api/upload). Should this be distributed among multiple endpoints?I'm facing some concurrency issues when multiple users upload files at the same instance. Is there any way to queue up requests when Express receives them?

Submitted July 27, 2019 at 04:37PM by AllDayIDreamOfSummer

Need some help with the designing the interfaces

I need to implement an app, where we do speech to text of audio files uploaded by the user.Requirement:- User uploads an audio file and specifies which transcription engine to use (google speech to text, nuance)- User receives the speech to text response.- Assume I can have other REST api's as well.How to:Is it good to have a separate multipart upload api to upload audio files that returns a file token and another transcript api which receives file token and engine type as params. Or do the file upload in the same transcript request?How to implement the app so that other engines can be added easily?How can we make this handle 1000's of requests?How to build microservices on this, so that the high processing modules can easily have multiple instances?Thanks a lot in advance.

Submitted July 27, 2019 at 11:01AM by stopcharla

Get list of globally installed packages

https://medium.com/@alberto.schiabel/npm-tricks-part-1-get-list-of-globally-installed-packages-39a240347ef0

Submitted July 27, 2019 at 09:54AM by mominriyadh

Node oracle db module installation errors

Need help in installing node oracledb version 4 in windows machine, Am using visual studio version 12.0 and python 2.7 version. When trying to do npm i oracledb getting below error.https://i.redd.it/dinah271isc31.png

Submitted July 27, 2019 at 08:15AM by bittusunil

Friday 26 July 2019

Instantly generate custom Express.js & MongoDB CRUD apps

https://alpha.codotype.io/generators/codotype-hackathon-starter/build

Submitted July 27, 2019 at 06:04AM by aeksco

How wrap express-jwt function to handle errors on its own

If I stick expressJwt(...) in route like router.post("/protected", expressJwt, nextFn) it works... But when the expressJwt is on it's own, you have to do error handling in the next function. I want to do it like so.exports.protect = (req, res, next) => { expressJwt({ secret: process.env.JWT_SECRET }) if (!req.user) return res.status(401).json("Unauthorized") return next() } But it doesn't work!Even making one giant function to handle a route and sticking expressJwt at the beginning fails.

Submitted July 27, 2019 at 01:17AM by dittospin

Couldn't solve coding challenge - advice on how to solve

Hey guys,I recently receive a coding challenge that I wasn't able to complete successfully and have been trying to understand what I was unable to code.I will include my code as well as the challenge.Challenge:The problemA common method of organizing files on a computer is to store them in hierarchical directories. For instance:photos/ birthdays/ joe/ Mary/vacations/weddings/In this challenge, you will implement commands that allow a user to create, move and delete directories.A successful solution will take the following input:CREATE fruitsCREATE vegetablesCREATE grainsCREATE fruits/applesCREATE fruits/apples/fujiLISTCREATE grains/squashMOVE grains/squash vegetablesCREATE foodsMOVE grains foodsMOVE fruits foodsMOVE vegetables foodsLISTDELETE fruits/applesDELETE foods/fruits/applesLISTand produce the following outputCREATE fruitsCREATE vegetablesCREATE grainsCREATE fruits/applesCREATE fruits/apples/fujiLISTfruitsapplesfuji grainsvegetablesCREATE grains/squashMOVE grains/squash vegetablesCREATE foodsMOVE grains foodsMOVE fruits foodsMOVE vegetables foodsLISTfoodsfruitsapples fuji grainsvegetablessquashDELETE fruits/applesCannot delete fruits/apples - fruits does not existDELETE foods/fruits/applesLISTfoodsfruitsgrainsvegetablessquash my code: https://pastebin.com/inn36dAZThe most glaring issue is that I was unable to find a way to parse the directories and create the tree in the directory dynamically so I hard coded some if statementsThank you for your help! it is appreciated

Submitted July 27, 2019 at 12:38AM by niirvana

How to write to a file the whole response of a HTTP request?

Hi all,I'm trying to get the whole response of a HTTP request with the "request" module.When I write the response to the console like this:const request = require("request"); const fs = require("fs"); request("http://www.google.com", function(error, response, body) { console.log("response:", response); }); the whole response is written to the console.When I try to write it to a file like this:const request = require("request"); const fs = require("fs"); callback = function(err) { if (err) { return console.log(err); } }; request("http://www.google.com", function(error, response, body) { //console.log("response:", response); var json = JSON.stringify(response); fs.writeFile("google.json", json, "utf8", callback); }); only a small part of the response is written to the file.E.g. response._readableState, response._events and others are missing.So, how can I write it all to a file as JSON, ideally without the object types e.g. IncomingMessage?

Submitted July 26, 2019 at 07:44PM by reditoro

Github can create a PR for security updates to NPM packages

https://help.github.com/en/articles/about-security-alerts-for-vulnerable-dependencies#alerts-and-automated-security-fixes-for-vulnerable-dependencieshttps://i.redd.it/u9q4sihz3pc31.pnghttps://i.redd.it/wf1cfej34pc31.png(not strictly for node, but very handy to know)also, be sure to update your lodash, you definitely have seen the npm audit by now saying how many packages were impactedhttps://snyk.io/blog/snyk-research-team-discovers-severe-prototype-pollution-security-vulnerabilities-affecting-all-versions-of-lodash/

Submitted July 26, 2019 at 08:03PM by bouldermikem

All this time i've been looking at zlib.createGunzip() and calling it Gun-Zip but it should be G-Un-Zip

i literally caught myself trying to remember which one decompresses and which one compresses. idiot.

Submitted July 26, 2019 at 06:07PM by calbatron

Build a Serverless React application

We try to get a better understanding of what serverless really means and if its beneficial to developers to use by trying it out in practice. https://buttercms.com/blog/what-is-serverless-and-how-to-use-it-in-practicehttps://i.redd.it/07xker5cooc31.png

Submitted July 26, 2019 at 06:34PM by Modiculous

[ASK] How to do REST version of GraphQL subscription?

I just finished GraphQL tutorial. Now I want to build something like GraphQL subscription in REST. But I don't even know where to start. As far as I've searched, it has something to do with Kafka and Rabbitmq, also don't know which one to use. One SO answer suggests 'HTTP long pulling'.All I want to do is, real-time notification when the data is updated or inserted. Is this called Pub/Sub or message queue?Please donate me some educational links and resources.P.S. I use Knex.js and PostgreSQL if this necessary.

Submitted July 26, 2019 at 05:01PM by xzenuu

Small, pretty, transport agnostic, HTTP/2-ready web server which can work in browser.

Plant is a new web server which is HTTP/2-ready, WebAPI compatible, transport agnostic, highly modular, very secure by default and small: Plant's size is 8 KiB + optional node.js HTTP transport is 38 KiB (minified, gzipped) ; 74 KiB and 125 KiB respectively (unminified, ungzipped).Plant was designed to use bleeding edge technologies, reduce complexity and make server portable. This portability gives you ability to write and test server-side APIs right in browser using only text editor. Plant has additional packages like http-adapter, router and bunch of http transports.const Plant = require('@plant/plant') const {createServer} = require('@plant/http') const plant = new Plant() plant.use('/greet', ({res}) => { res.body = 'Hello, World!' }) createServer(plant) .listen(8080) In-browser exampleThis is a very-very simple example of how it could work. It's just renders requestCodesandbox · PreviewDetailsHTTP/2-readyPlant can push responses to the client using HTTP/2 resource push mechanics.plant.use(({res}) => { res.push('/js/index.js') res.push('/css/style.css') res.html('...') } WebAPI compatibleObjects like Request, Response, Headers and streams have the same or familiar interfaces that already exists in WebAPI. Plant's Request and Response are mirrored from the Client, that's why Request object has Response's method json().plant.use(({req, res}) => { req.url.pathname // "/" req.headers.get('content-type') res.headers.set('content-length', 5) res.body = 'Hello' }) // Retrieve JSON with one single command plant.use('/echo', async ({req, res}) => { const body = await req.json() res.json(json) }) Plant is using ReadableStreams instead of Node streams. That's why it can work seamlessly in browser. For example in ServiceWorker.Transport agnosticPlant isn't tightly coupled with the Node.js http module server, instead Plant is using it as external dependency. You can easely create your own transport. That's why you able to deliver requests via anything: WebSockets, MessageChannel, raw TCP, or even email (why not). It makes things extremely simple, especially your tests.const Plant = require('@plant/plant'); const {createServer} = require('@plant/http2'); const plant = new Plant(); plant.use(({res, socket}) => { res.body = 'Hello, World!' }) createServer(plant, { key: '...', cert: '...', }) .listen(443) Create requests manually:const plant = new Plant() plant.use(({res}) => { res.body = 'Hi' }) const url = new URL('http://localhost:8080/') // Create HTTP context's params const req = new Plant.Request({ url, }); const res = new Plant.Response({ url, }); // Request peer. Peer represents other side of connection. const peer = new Plant.Peer({ uri: new Plant.URI({ protocol: 'ws:', hostname: window.location.hostname, port: window.location.port, }), }); // Create connection socket const socket = new Plant.Socket({ peer, // If socket allows write upstream, then onPush method could be defined to handle pushes. // onPush should return Promise which resolves when response sending completes. onPush(response) {}, }); const handleRequest = plant.getHandler() handleRequest({req, res, socket}) .then(() => { // Request handled. All requests (even faulty) should get there. }, (error) => { // Something went wrong }) ModularPlant is trying to separate responsibility between modules and not to bloat own size. Everything, especially transport related, is moved out of server package and could be replaced with you own code.Additional packages:httpNode.js native http module transporthttpsNode.js native https module transporthttp2Node.js native http2 module transporthttps2Node.js native http2 module with TLS transportrouterRouter packageSecure by defaultPlant is using the most strict Content-Security-Policy out of the box. And this is the only web server which bring security first and doesn't sacrifice it. This policy doesn't allow webpage to do anything, even run a single piece of JS. Default value of Content-Security-Policy header is very denial and should be used in production to protect client and server from accidents. Developers should specify exact permissions which their site requires.const plant = new Plant({ csp: Plant.CSP.STRICT, }) For development should be used Plant.CSP.LOCAL policy.Router exampleconst Plant = require('@plant/plant') const Router = require('@plant/router') const {createServer} = require('@plant/http') const userApi = new Router() router.post('/', () => {}) router.get('/:id', () => {}) router.put('/:id', () => {}) router.delete('/:id', () => {}) plant.use('/api/users/*', userApi) createServer(plant) .listen(8080) ReferencesGithub · NPMP.S.I'm an author of this package, so you could AMA. Also, notify me about grammatical errors. I would very appreciate it.

Submitted July 26, 2019 at 04:39PM by rmkn

How to make your NodeJS application or API secure

https://medium.com/@andreasdev/make-security-on-your-nodejs-api-the-priority-50da8dc71d68?source=friends_link&sk=cf67ce6258b85cd71dc75660fb48cceb

Submitted July 26, 2019 at 03:04PM by kiarash-irandoust

Hey there! We would be glad to recieve your opinion on our fee-free service that provides access to full public nodes! :)

https://nownodes.io/nodes-gallery

Submitted July 26, 2019 at 03:27PM by NOWNodes

Light Logger on GitHub

Hi! I'm create light logger to store our alerts and metrics. I'm share this, because our project no needed heavy solution. If you are looking for a solution that quickly installed and worked without configurations, please see this, maybe Light Logger will suit you https://github.com/philsitumorang/logger.TechStack: Docker, TypeScript/Node.js

Submitted July 26, 2019 at 12:56PM by philsitumorang

Three Ways to Define Functions in JavaScript

https://medium.com/better-programming/three-ways-to-define-functions-in-javascript-750a908e51d9?source=friends_link&sk=62cf55a6e2e0913b4febe19119f29ddb

Submitted July 26, 2019 at 01:39PM by noharashutosh

What are some well written libraries published on npm?

I am talking about code quality, test coverage, easy to get your head around type of projects

Submitted July 26, 2019 at 02:04PM by aku_soku_zan

I made a thing. Let me know what you think!

http://trumpdump.xyz/

Submitted July 26, 2019 at 11:41AM by Faucetap

NodeJS in Cluster Mode - Help

I just saw that I could use NodeJS in cluster mode,So I went ahead to see if it actually makes a difference. And, it did not. What am I doing wrong?I test an API of mine, I tested using NPM module loadtest.loadtest http://0.0.0.0:5000/someAPI -t 20 -c 10and I barely got any difference when starting server in cluster mode or as a single process. I used pm2 start process.js -i max to start in Cluster mode and pm2 start process.js to run as single process.Why don't I see a difference in the results? Should I increase the transactions and concurrent requests?

Submitted July 26, 2019 at 11:46AM by kjroger94

Tools and sites for learning Node JS for a beginner.

I have gone through w3schools and some random sites to host my own server and return a file on http calls on a React JS application. Looking to expand my knowledge and understanding of Node JS. I'm a frontend developer who is working her way upto being a MEAN/MERN Stack developer. I'm well-versed in HTML, CSS, JavaScript, Angular 2+ and React JS. MongoDB sources would be good too!

Submitted July 26, 2019 at 11:47AM by nanariv1

Iterators and generators work great together

https://medium.com//iterators-and-generators-work-great-together-80b196aaee2d?source=friends_link&sk=603577a956aeec1b885c76ae95154435

Submitted July 26, 2019 at 08:40AM by jsloverr

Help a non- developer working with a non- competent and expensive node developer

If a developer received an unfinished code for a recommender project that is written in node, Can he still continue the project or he has to start over ? Given that the initial code is written neatly.I hope you all understdand the angle of my question. I am thinking maybe the next developer 's style of coding is different and he normally that's the trend on developers that they don't take responsibility of an intervention on someone else's code.Thank you in advance.

Submitted July 26, 2019 at 07:39AM by pet-bavaria

Thursday 25 July 2019

Fetching time from database with GraphQL

I'm creating a GrahpQL API on top of an existing database in MySQL, using Typescript, TypeORM and TypeGrapgQL for the models. When I try fetching data from a field with type "time" in the database, it always returns null. When I copy the generated SQL-query to MySQL, I get the right result. How can I fetch time from the database with GraphQL?Example of column I want to fetch from:@Column("time", { nullable: true })@Field({ nullable: true })start_time: Date;

Submitted July 26, 2019 at 07:09AM by DefectUnicorn94

What the heck is a job queue in node?

I recently was asked to create a job queue as a code example for a potential employer. The problem was simple, or so I thought. Create an api that can take in a single url. The url should then be entered into a job queue for processing. The api returns a job id and another endpoint can be used to see if the job has finished.I assumed this was straight forward, create a module that generates a queue. Create a method on the module export that allows you to add an item to said queue. Allow the queue to decide if the item should be processed or put in line with other jobs.However, I was very kindly told this:it didn't really have a job queue. The endpoint POST route is responsible for the execution that grabs the HTML. So it basically doesn't even satisfy the requirements of the challenge.but it doesn't. Like all my endpoint does is say Scraper.add(url); Scraper being the name I gave to the queue because it literally only processes jobs that scrape the web. This doesn't create the queue, it doesn't do any of the processing, it just adds something to the queue.Google has been no help here because it's only convinced me even more that I did setup a queue. Can someone with more understanding of what exactly this term means help me understand what the fudge I did wrong.Too big to post the whole thing here but if you'd like to see the code it's here: https://github.com/ktranel/WebScraper

Submitted July 26, 2019 at 02:44AM by blindly_running

Tips for sanitizing user input

Hey all.I'm working on a node app and I'm looking for some tips on sanitizing user input. Sanitizing user input is always listed as something super important, but I can't really find any good posts about how exactly to do this.For a bit more context, I have a node.js express app, and I am saving data to a mysql database using knex. That data that I save will sometimes be sent back to the client and displayed in a react app.I'm using express-validator which is set up to validate the data, that is working no problem. express-validator also has sanitization methods, but they don't seem to actually remove things like script tags from user inputs, these are just passed right along to the database. I can escape the input with that package, but I'm looking for a way of just removing potentially harmful things like script tags from user input data.I guess my question is really, what strategy would you take here? Do you have any resources around sanitizing data? Am i maybe just missing the mark about what it really means?Really appreciate any feedback and guidance!

Submitted July 26, 2019 at 01:31AM by Northern_Nine

Efficiently deploying a Node.js application for production?

I am currently reviewing options for deploying a Node.js/Mongo DB application for production. I am familiar with various tools like Nginx, PM2, etc and I've deployed applications for small loads of traffic in the past.Let's say there are several hundred concurrent users, would a stack like this still be sufficient (Node.js, PM2, Nginx)? If no, where can I find material and examples for this type of deployment?

Submitted July 26, 2019 at 01:33AM by fishingBakersfield

Mini Web Apps: A Bounded Context for MicroFrontends with MicroServices

https://blog.bitsrc.io/mini-web-apps-a-bounded-context-for-microfrontends-with-microservices-f1482af9276f

Submitted July 25, 2019 at 05:49PM by JSislife

Is there any way to have multiple Node.js servers to communicate to one mongoose schema?

Let's say I have three servers (Public server, Admin server and Database server) and I would like to access from the first two one mongoose schema. The main server is the Public one where everything happens, but sometimes, from Admin server I would like to access that schema. I could write the schema on the first two servers, but that would mean bad code. If that is the only solution, I will do it. But, is there any other way of doing this? Could I write something on the database server so that when I connect with mongoose to the MongoDB server to receive the model from there?

Submitted July 25, 2019 at 05:20PM by flaviusbmth

Created this tiny js script (nodejs) to download all ebooks from books.goalkicker.com

https://github.com/41x3n/GoalKicker-Books-Script/blob/master/app.js

Submitted July 25, 2019 at 04:56PM by Katsuga50

Build Android App using Node JS (with node js runtime environment on android)

Android JS framework lets you write android applications using JavaScript, HTML and CSS or React Native with Node.js support. It is based on Node.js. It allows you to write fully featured android application in node js and provide you environment to use any npm package in your android app (i.e. SocketIO, fs, etc..)check out:website: https://android-js.github.ioproject: https://github.com/android-js/androidjsdocs: https://android-js.github.io/docs

Submitted July 25, 2019 at 04:35PM by Chhekur

Can I make programming language in node js?

as title says can i make functional interpreter in node js, would it be efficient and good idea. I tried to write lexer and parser in c++ but it was much easier to write one in javascript. Is it better to write simple interpreter in node js rather than c++ or go etc.

Submitted July 25, 2019 at 03:38PM by armor_panther

The Inside Scoop on MERN Stack | TECLA

https://www.tecla.io/blog/the-inside-scoop-on-mern-stack/

Submitted July 25, 2019 at 03:25PM by MMNaveda

Nodejs 11x release installation help

I have installed latest nodejs from https://nodejs.org/en/ , and now I see my project dependencies are broken with this version. I want to go back to 11.15 release. So I went to https://nodejs.org/dist/latest-v11.x/ and downloaded node-v11.15.0-darwin-x64.tar.gz and unzipped it too. But I don't see any .dmg package in it. How do I uninstall v12.7.0 and go to 11.15? Please help

Submitted July 25, 2019 at 12:36PM by arup_r

Can serverless cost more if someone go for DDoS?

As per billing method of serverless I'm thinking if someone from inside or outside of org tries to DDos my application then it will invoke functions more than expected times which will in turn increase the cost of running the application.So is it 100% possible or its just in my mind?

Submitted July 25, 2019 at 12:47PM by pverma8172

NodeJS & PostgreSQL integrated Angular admin template

https://flatlogic.com/admin-dashboards/sing-app-angular-node-js

Submitted July 25, 2019 at 12:47PM by ZestycloseChocolate

migrating stripe subscription to be SCA compliant (bad error)

I have a subscription, I collect card details on signup with a 7 day trial, after which the subscription bills monthly.I have followed the documentation to create a subscription.Testing the flow with a fake card 4000002500003155 which requires setup, I encountered an issue.My setup is as follows.​Frontend does: stripe.createToken()Server does stripe.updatePaymentDetails({source}) (with token):Server creates the subscription:stripe.subscriptions.create({ customer: self.stripe_customer_id,tax_percent: 20,expand: ['latest_invoice.payment_intent', 'pending_setup_intent'], ...plan}​As expected the subscription response: subscription.pending_setup_intentis not null and has { client_secret: 'seti__', status: 'requires_action', payment_method: 'card___', ... }.On the frontend I attempt to handle the pending setup intent on the frontend with stripe.handleCardSetup(client_secret, {}); but I got the following error.The payment method supplied (pm____) does not belong to a Customer, but you supplied Customer cus____. Please attach the payment method to this Customer before using it with a SetupIntent.​I tried to remedy this by attaching the paymentMethod to the user before step 5.stripe.paymentMethods.attach('card____', { customer: customer_id });But I got the following error:The payment method you provided has already been attached to a customer.​Any help really appreciated :)

Submitted July 25, 2019 at 12:15PM by harrydry

Why is return required after sending the response (expressjs)?

Hi everyone,I'm learning expressjs and was working with this code snippet for a small tutorial app,​var express = require("express");var app = express();app.get("/random/:min/:max", function (req, res) {var min = parseInt(req.params.min);var max = parseInt(req.params.max);if (isNaN(min) || isNaN(max)) {res.status(400);res.json({ error: "Bad request." });return;}var result = Math.round((Math.random() * (max - min)) + min);res.json({ result: result });});app.listen(3000, function () {console.log("App started on port 3000");});Now, inif (isNaN(min) || isNaN(max)) {res.status(400);res.json({ error: "Bad request." });return;}Why do we require return after returning response?

Submitted July 25, 2019 at 12:17PM by jay-random

Node.js Top 10 Articles (v.July 2019)

https://medium.com/@Mybridge/node-js-top-10-articles-for-the-past-month-v-july-2019-2cca3caa76f6

Submitted July 25, 2019 at 11:54AM by Rajnishro

[puppeteer] Can't get the height of certain web sites' pages

I'm using the excellent puppeteer library to scrape a few web sites' frontpages to get a screenshot of the whole page. While it works just fine for most of the web sites, there are a few where I can't get page's height; it ends up being the same height as the viewport height.Example site: https://www.dagbladet.no/Here's the code I currently use to get the page's height:const bodyHandle = await page.$('body'); const boundingBox = await bodyHandle.boundingBox(); const height = boundingBox.height; console.log("height: " + height); const altHeight = await page.evaluate(() => document.documentElement.offsetHeight); console.log("altHeight: " + altHeight); height and altHeight doesn't differ, but I put it in there in hope that a different approach would work.Any ideas?EDIT: I could just scroll down until I can't scroll anymore, but I'm afraid of "never ending" sites. I could of course have a max. scroll length as well, but not sure if it's an ideal solution.

Submitted July 25, 2019 at 10:44AM by UnityNorway

Build a basic authentication for rest api in node.js

​​var auth = "116asd1f2341dfas2f" //this is executed always before somone calls a request app.use(function (req, res, next) { var header=req.headers['authorization']; // get the header if(header != auth) { res.status(401) // HTTP status 404: NotFound .send('401 Unauthorized'); return } next(); }); ​Hello, I am new in the language Node.js - so please have understanding.​Is this a good way to protect a RestApi?My RestApi is accessible via the internet.​If it's not a good method, do you have any tips on what I could use?​And why does this code not provide a sufficient security?

Submitted July 25, 2019 at 10:48AM by superfliege90

Going Multithread with Node.js

https://medium.com//going-multithread-with-node-js-492258ba32cf?source=friends_link&sk=0752571422d5a59d12a051475e1eeb87

Submitted July 25, 2019 at 09:07AM by jsloverr

How do I get my system to use the correct version of node

I just installed node 10.16. running node -v in vscode terminal returns 10.16 but running that in the system terminal returns 8.10how do I fix this

Submitted July 25, 2019 at 07:02AM by dominic_l

Node.js node-oracledb 4.0 supports Advanced Queuing and Oracle DB named objects

https://blogs.oracle.com/opal/oracle-db-named-objects-and-advanced-queuing-support-new-in-node-oracledb-40

Submitted July 25, 2019 at 07:56AM by cjbj

What is THE BEST WAY to learn NodeJS in 2019 ⁉️

I've decided that I want to learn NodeJS.​Mostly all I've learned about coding, I've learned online. Things ranging from making RPGs on Unity to front-end development with ReactJS and React Native. ALL ONLINE.​However, I feel like my learning has been kinda all over the place. From YouTube to edX to Udemy to Coursera, you name it. I want to change that now 'cause I genuinely care about becoming a full-stack web developer by asking YOU, the real experts on Node... What is THE BEST WAY to learn NodeJS in 2019 ⁉️​I've come across three Udemy courses:https://www.udemy.com/the-complete-nodejs-developer-course-2/ by Andrew Mead.https://www.udemy.com/understand-nodejs/ by Anthony Alicea.https://www.udemy.com/course/nodejs-the-complete-guide/ by Maximilian Schwarzmüller.​One from Pirple https://pirple.thinkific.com/courses/the-nodejs-master-class which has also been referenced in this Reddit post.​One from Coursera https://www.coursera.org/learn/server-side-nodejs?.​One from edX https://www.edx.org/course/introduction-to-nodejs-4.​Along with several YouTube courses.​I'm more of a code-along kind of guy so I'd appreciate some input on these courses (i.e. if you've taken it or if you've heard of it) or others rather than some book (unless the book is REALLY the best way to learn NodeJS 😁) but really any response is welcome!TL;DR:​- How did you learn NodeJS?- From your experience, how would you recommend I (and people reading this) learn NodeJS?​Thanks in advance!​Dan.

Submitted July 25, 2019 at 07:17AM by chiarl

Wednesday 24 July 2019

What are the best ways of getting code reviews and dealing with self-doubt about one's code?

In the near future, I'll be uploading multiple large-scale Node.js back-ends and React Native front-ends to my GitHub Account. I have developed some methods of coding and commenting that I find make me more productive, and I've been using different design patterns and architectures - namely three tiers and Dependency Injection. The projects I plan to upload should be 10 times better (I hope) than what I currently have on GitHub.I've always felt that given enough time and given a project within reason, I can pretty much build whatever I want to build and make whatever vision I have for a project/design come to life in any stack that I know well enough.Despite that, I've never felt that my code, although functional, has been elegant enough. I've never felt that it's up to par with what a professional developer would do, or that it follows best practices, or that it uses design patterns in correct ways, etc. Despite having been doing Full Stack Development for two to three years now, I still don't feel that I'm good enough or know enough.So, when I upload these new projects that utilize my newly found architecture and patterns, what would be the best way to ask for advice from professional software developers to attain some sought of understanding about whether or not my code follows best practices well enough? Is r/node a good place to do that - to post links to repos? My only communication methods with fellow developers are through the Internet - namely Reddit and Slack - because I don't have many personal acquaintances with developers.Thanks for your time,Jamie

Submitted July 25, 2019 at 04:08AM by JamieCorkhill

How to Design & Persist Aggregates - Domain-Driven Design w/ TypeScript

https://khalilstemmler.com/articles/typescript-domain-driven-design/aggregate-design-persistence/

Submitted July 25, 2019 at 02:48AM by stemmlerjs

Override app.use middleware

So our application uses app.use(bodyParser.json()). For one of my post methods I want to actually get the RAW body. Is there a way to override one function to parse using raw? Or would I have to get rid of the app.use and define each method individually to use JSON or RAW?Current method is configured as:app.post('/myhook', bodyParser.raw({type: 'application/json'}), (request, response) => {This still gets a JSON body, presumably because the JSON parser middleware has already processed it.

Submitted July 25, 2019 at 03:16AM by pushc6

Now that's what I call having a hell lot of vulnerabilities...

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

Submitted July 25, 2019 at 03:13AM by matheusmk3

Nest, Koa or Fastify?

I'm a junior front end dev trying to get started with backend. Trying to find a good framework to get me started. Wont be using this on my day job. Just wanna learn to improve my skillset and be able to do my own projects and maybe some freelancing.Heard some positive feedback about Nest, Koa and Fastify and how modern they feel compared to Express. So I decided to make a post and ask your opinion.Thanks in advance!

Submitted July 25, 2019 at 01:57AM by enethor

Better Software Design with Application Layer Use Cases | Enterprise Node.js + TypeScript

https://khalilstemmler.com/articles/enterprise-typescript-nodejs/application-layer-use-cases/

Submitted July 24, 2019 at 09:48PM by stemmlerjs

Promise-Based Alternatives to Node's Default API

I'm a big fan of promises and async/await and not a really big fan of callbacks. I know there is util.promisify and writing your own wrapper functions for things like readline that don't play nice with promisify, but that just seems excessive. Is there a library or set of libraries out there that has all the nodejs APIs already wrapped in promises?​Thanks.

Submitted July 24, 2019 at 08:44PM by Droid2Win

Okay, so I will be starting a new job as a Node developer probably in the next week. I need some advice

I will gladly accept any kind of response as It is going to be my first ever job in any field as i am still 18 y/o. thanks everyone. so here are my questions: what to keep in mind for interview, what to keep in mind for production development, how hard it is to work on real world projects in a company compared to working on some apps from tutorials, etc.

Submitted July 24, 2019 at 08:16PM by warchild4l

Hack/HHVM vs Node

Facebook is using Hack/HHVM for server, so only because of interest how hard Node would need to be modified so Facebook could use it in production for everything, I know they never will but it is only a question? Would it even be possible for Node to power one of the biggest sites in the world?

Submitted July 24, 2019 at 07:53PM by texxxo

My story of getting node-gyp to work on windows (TL;DR: --target=8.16.0)

​You start off my finding this cool node module you want to install for your electron app on windows but see that it requires something called 'node-gyp'. After a quick run through duckduckgo you end up on the github page of node-gyp and read through the README file. It was not long before you grasp the meaning of node-gyp.This magical module seems to solve a problem you never thought you would face. The requirements were heavy but someone made an easy tool to install everything with just one command. "Thank god", you think to yourself, and decide to quickly open an elevated git bash terminal to type 'npm install --global windows-build-tools'.The program starts, cog wheels begin to turn and everything gets installed for you without you doing anything.Time passes and you see that the program has finished. After a quick reboot you finally get to the fun part and install the module you wanted from the beginning.C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\msbuild.exe\ failed with exit code: 1...After a long wall of red text you find this message engraved inside the terminal. In quick programmer fashion you pull up duckduckgo and search for 'node-gyp msbuild failed with exit code: 1'.It was by then that you started to be skeptical about everything just being a one liner. The internet was full of posts about node-gyp producing errors on windows and most of them were old, most before windows-build-tools existed. "I probably missed something" is what you thought. Starting to trace back the error, you find ~300 errors of node-gyp trying to compile the module you want to install. With increasing hate for the non-informative logs and posts of node-gyp you decide to end the day.The next day:With a fresh mind and body you again try to tackle the problem. This time you don't rely on some one line command tools but install the requirements for node-gyp manually.Two hours pass:C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\msbuild.exe\ failed with exit code: 1"Something isn't right.". Your spider senses tell you that the multiple versions of Visual Studio, Visual Studio Code, and mutliple compiler for everything may have screwed the program a bit. After booting your second development environment on a linux virtual machine you try developing your electron app in linux only to be greeted with the obvious error that the node module you wanted the whole time is for windows only."Do I really need this module?", was the first question that popped into your mind after wasting nearly two days trying to get this to work. The module was a wrapper for a dll that exposes functions of a program.Two days later:You spend the last two days experimenting with different methods to access the dll:You start with the language you're the most knowledgeable with, Java, and discover JNI and latter JNA. Your mind starts going towards the crazy side when you have to deal with stuff you never heard like "Pascal" and "Delphi". "What the hell is a Delphi", "What does Delphi have to do with Pascal", "Why is everything for Pascal 10 years old", "Are you telling me someone named their IDE after the language?", "..."The days get hotter and longer. It's 35 outside and 30 inside. Creating your own DLL wrapper will take too long. "Guess I back to node-gyp". You begin using your fried brain, 10 mugs of coffee and the Initial D - Eurobeat playlist to get node-gyp to work. And than...."Wait, everyone on the forums and github uses msbuild 2013/2015. Maybe I should try that.". While installing older versions you find the arguments for node-gyp and decide to experiment during the wait.It was then when you found the one line that changed everything:gyp verb get node dir compiling against --target node version: 12.6.0You can change the target node version for compiling. Just for fun you decide to run with --target=8.0.0 because you saw that this was the version before node10.Build succeeded.Wait WHATTTT. You stopped everything you've been doing and looked at the log.``` 2 Warning(s) 0 Error(s)Time Elapsed 00:00:04.69 gyp info ok ```It worked. You quickly find out that 10.16 also doesnt work and the latest version that does is 8.16.0. You've done it. Five days of intense mental pain, stress and wanting to cease existing you finally compiled the module and can work on the actual program.Authors note: Man. I somewhat had to rush the story in the end (starting at the Two days later mark) because I want to finally start working on the project. I tried a ton of methods to get what I want and the solution was just one argument away from saving me 5 days. Anyway.. I didnt spellcheck this but I just wanted to share this little story. I don't even know if the mods allow this post, if fun is allowed, but I want to try anyways. :)

Submitted July 24, 2019 at 06:54PM by _erri120_

I cannot run server “npm ERR! Code ELIFECYCLE npm ERR! Errno 1”

How to make Jest to include source codes in a node_modules in test coverage reports?

FAQ: Why do I want this? Because I have custom AWS Lambda Layers, so I have to structure source code this way.

Submitted July 24, 2019 at 03:04PM by ellenkult

Beginners Guide to Cloud Computing ☁️

https://medium.com/@lelouchb/beginners-guide-to-cloud-computing-%EF%B8%8F-c06d7558a8b

Submitted July 24, 2019 at 03:24PM by noharashutosh

How to use Express Router.route.all()

Hi, I'm trying to figure out how to use the .all() method of router.route() to remove some duplication in my code, but it doesn't seem to be working. I have my routes set up in the following way:router .route('/:slug') .get(hasToken, hasPermission('manage:event'), isEventOrganiser, getEventAsOrganiser) .patch(hasToken, hasPermission('manage:event'), isEventOrganiser, updateEvent) .delete(hasToken, hasPermission('manage:event'), isEventOwner, deleteEvent);Since all of the routes share the two first middlewares, what I've tried to do is to use .all() to first process the common middleware and then handle the middleware for the specific route being called, like so:router .route('/:slug') .all(hasToken, hasPermission('manage:event')) .get(isEventOrganiser, getEventAsOrganiser) .patch(isEventOrganiser, updateEvent) .delete(isEventOwner, deleteEvent);However, this results in my routes returning a 404. If I add some logging to e.g. the get() call, it never gets logged. Have I misunderstood how .all() works or am I doing something else wrong here?

Submitted July 24, 2019 at 11:33AM by sourtargets

Looking for alternatives to react-admin

I have a REST api built with feathers using mongoose services, Now i wish to deploy a admin dashboard, i am using react-admin on another project, but looking for something better and easy to customise.

Submitted July 24, 2019 at 11:56AM by mj_mohit

A node.js stack for universal javascript applications

https://frontless.js.org/

Submitted July 24, 2019 at 09:37AM by mr_nesterow

Flexible seed generation with superseed

A seed generation package I wrote@superseed/superseedFeedback appreciated :-).

Submitted July 24, 2019 at 09:43AM by faboulaws

Best way to pass database errors to handlers?

I'm writing a Mongoose/Koa/Typescript API. I'm wondering what the best way to pass errors from the db level (for example a broken unique rule), through a service layer (a collection of async methods that container business logic and talk to the DB), then to a Koa route. What is the best way to pass up errors and give appropriate response codes, as well as messages such as 'user already exists?

Submitted July 24, 2019 at 09:38AM by AmateurLlama

Build a New Customer Notification Pipeline in 7 Minutes with Stripe, Clearbit, Slack and Node.js

https://medium.com/@keithwhor/build-a-new-customer-notification-pipeline-in-7-minutes-with-stripe-clearbit-slack-and-node-js-9f9edd786925

Submitted July 24, 2019 at 08:42AM by keithwhor

Has NPM worked?

After chasing dependencies, auditing vulnerabilities, missing modules, etc. .... has npm made the installation process any easier, or has it actually made it more difficult and painful?

Submitted July 24, 2019 at 07:22AM by SoUpInYa

Tuesday 23 July 2019

REST APIs

https://www.reddit.com/r/webdev/comments/ch0nb6/rest_apis/

Submitted July 24, 2019 at 04:28AM by ncubez

Login to website, upload spreadsheet and submit form, then download response spreadsheet.

I need to use a service that doesn't have an API, what's the recommended way to achieve the above. I tried Googling for a solution, but I don't know exactly what to look for, I've never done this before.​Can somebody point me in the right direct, i.e. Package or term to Google for

Submitted July 24, 2019 at 05:12AM by IHaveNeverEatenACat

most common npm dependencies other than body-parser and nodemon?

Hi guys, what is some of the most common npm dependencies/libraries that you guys use for your project (specifically backend with express right now, will be learning react later). Im watching bunch of tutorials right now from youtube and udemy and two of the most common library i see required for web projects are body-parser and nodemon. Is there anyother libraries i need to learn and useful?

Submitted July 24, 2019 at 04:49AM by hakim131

Improving node skills

I would consider myself a decent nodejs dev but I’m looking to gain more insight on the framework and best practices since I’ve only used it in a single environment.Are there any video tutorials (YouTube, Lynda.com, pluralsite,etc) or written tutorials about writing Apis that follow best practices?

Submitted July 24, 2019 at 12:25AM by FoldingManager

Guys please help me fix nodemon

Guys, now i'm installing nodemon but when i try to use it gives me this:internal/modules/cjs/loader.js:638throw err; ^ Error: Cannot find module 'C:\c\Users\Stefan's PC\AppData\Roaming\npm\node_modules\nodemon\bin\nodemon.js'at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15) at Function.Module._load (internal/modules/cjs/loader.js:562:25) at Function.Module.runMain (internal/modules/cjs/loader.js:829:12) at startup (internal/bootstrap/node.js:283:19) at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3) How to fix this please tell me?

Submitted July 23, 2019 at 11:51PM by anevskii

JSDayIE 2019 is the first JavaScript conference in Ireland takes place on September 20th in Dublin

JSDayIE is the first JavaScript conference in Ireland and will take place in 2019, on September 20th at The Round Room at the Mansion House in Dawson Street, Dublin.JSDayIE 2019 PosterJSDayIE 2019 is a 1-day single-track tech conference dedicated to the JavaScript community in Ireland featuring over 450 attendees and some of the best JavaScript professionals and organizations.Tickets start at only 95 EUR (+VAT)! You can learn more at https://www.jsday.org/

Submitted July 23, 2019 at 11:06PM by ower89

Node v12.7.0 (Current)

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

Submitted July 23, 2019 at 11:25PM by dwaxe

[new npm library] 2d-array-rotation: rotates a given 2d array by right angles. (Kinda amazed something like this didn't already exist.)

https://www.npmjs.com/package/2d-array-rotation

Submitted July 23, 2019 at 10:56PM by jon_stout

Do you need a server to make REST requests?

I have an assignment that is due that calls for a REST request to be made to an external API. The wording of the assignment is a little confusing and therefore I am not sure where to start.Here is the assignment in question:Task: Write a NodeJS script that makes a REST request to get a list of users, filters the results, and deletes the user. The file will be ran through the terminal by running “node server.js Employee12345” Use these APIS: GET: http://dummy.restapiexample.com/api/v1/employees DELETE: dummy.restapiexample.com/api/v1/delete/{id}

Submitted July 23, 2019 at 08:24PM by springer937

I created Studly Caps

NPM: https://www.npmjs.com/package/studly-capsGithub: https://github.com/dyzhu12/studly-caps​It's my first ever "real" published npm module and was more of a learning opportunity to see how to publish a new module, bump the version, etc. It's a silly little package, but I guess it's available for others to use if they so desire!​Feedback is totally welcome -- feel free to open an issue or comment here!

Submitted July 23, 2019 at 07:32PM by ddyyzz

Instantly generate custom Express.js + MongoDB CRUD apps

https://alpha.codotype.io/generators/codotype-hackathon-starter/build

Submitted July 23, 2019 at 07:05PM by aeksco

Why development teams are adopting GraphQL?

https://blog.graphqleditor.com/why-companies-adopt-graphql/

Submitted July 23, 2019 at 05:31PM by oczekkk

Control Chrome from Node.js with Puppeteer

http://thecodebarbarian.com/control-chrome-from-node-js-with-puppeteer.html

Submitted July 23, 2019 at 05:35PM by code_barbarian

Cube.js design decisions

https://cube.dev/blog/design-decisions-for-the-first-embedded-analytics-open-source-framework/

Submitted July 23, 2019 at 04:19PM by asok090

Callbacks - function vs =>

I've been looking at some example code in order to build a practice Nodejs application and I've noticed that the callback functions vary in how they are called:​e.g. (see the first line of both examples):​ Artist.findById(req.params.id, (err, foundArtist) => { if(err){ console.log(err) } else { res.render("artists/edit", {artist: foundArtist}); } }); vs Artist.findById(req.params.id, function(err, foundArtist){ if(err){ console.log(err) } else { res.render("artists/edit", {artist: foundArtist}); } }); Are there any differences in how these work/best practices to follow?​I wasn't sure how to google this, so thought I'd ask it here.

Submitted July 23, 2019 at 02:18PM by Heck_

How Parser Combinators Work

https://www.youtube.com/watch?v=6oQLRhw5Ah0

Submitted July 23, 2019 at 02:12PM by FrancisStokes

Joi — awesome code validation for Node.js and Express

https://medium.com/p/514b5570ce20

Submitted July 23, 2019 at 12:26PM by jsloverr

Full Stack Web Developer Opportunity

Company: InstaLODType: Full-timeDescription: InstaLOD is a technology company that builds software that enables enterprise and entertainment companies to create magical 3D experiences. Our award-winning tech helps 3D artists working on massive productions to focus on the creative part instead of spending most time with tedious technical tasks. From military companies building next-generation simulations and data analysis to leading automotive and fashion brands such as NIO or Deckers and the biggest entertainment franchises created by gaming companies like 2K Games, Wargaming or Sony London: our technology plays a vital part in delivering their project.We're searching for passionate full stack web developers experienced with modern web frameworks and databases. We're not just looking for coworkers but for stakeholders and adventurers – driven people that want to make a difference through their work. Whether your passion is in design, architecture, or coding high-performance application solutions, you’re guaranteed to find something that keeps you motivated!The kind of people we’re looking for:Self-starter with a getting-things-done attitude: You have a solid background as a full stack developer (5+ years) and you’re not scared of big code re-factoring and tricky tasks. Your work methods are well-structured and self-organized and you love moving tasks from the backlog to done. You also understand the project, and create tasks for epics that need to be worked on next. Effectivity when working is important to you, so you rely on software such as Slack, GIT, Sourcetree, Sublime, Trello and JIRA.You love to improve and always seek to learn: You’re not only part of a team that’s just working on the code base. You’re part of a team that makes sure everybody’s skills and the quality of our code base continuously improves.Collaborative and Self-Aware: You understand what’s necessary to create a collaborative engineering culture. You help build understanding and empathy within your team, and actively work to bring people into the conversation and understand their viewpoint.Bonus Skills:Excellent understanding of modern web architecture (caching, scaling etc.).You have work experience at major companies or competitors in our space.Experience managing large engineering projects.Proficiency in more than one modern web framework (node.js, ruby, etc.)Experience with AWS Elastic BeanstalkAbility to perform R&D and integration of new technologiesLocation: Stuttgart, GermanyRemote: YesVisa Sponsorship: YesTechnologies: PHP, Javascript, Node.js, Ruby, MySQLContact: If you have any questions you can PM me, or send an up-to-date resume including sample code of previous work that you can share to [Michael@theabstract.co](mailto:Michael@theabstract.co) or you can visit our careers section and apply directly at https://instalod.com/career/

Submitted July 23, 2019 at 01:07PM by MichaelAbstractco

I just published Kettle, a templating engine tailored for boilerplates

While working on a boilerplate recently I grew tired of having to generate an entire project everytime I wanted to check out my typings, tests and linter. Because every templating engine I found broke the code syntax, I decided to build my own which leverages comments to handle templating.So now, I am able to work on boilerplates with live linting, typings and unit tests which drastically sped up my templating process.I just published it here as a node package for you to check out.Every feedback is welcome

Submitted July 23, 2019 at 11:48AM by moufoo

Nodejs Development Company in India

Node JS is an open-source, cross-platform, runtime environment for executing JavaScript code at the server-side. Node.js allows web application development to unify around a single programming language, rather than rely on a different language for writing server-side scripts. Mobiloitte is a leading Nodejs Development Company in IndiaNodejs Development Company in India

Submitted July 23, 2019 at 09:28AM by kettypery1

Can someone tell me how the heck `npm audit` is supposed to work?

In my project, npm install warns about potential security issues that we should fix. Sounds great, and I'd happily keep the dependencies up to date, but it's really not working the way I'd expect it to… Here's the scenario:$ npm audit fix tells me:updated 1 package in 6.63s fixed 4 of 5 vulnerabilities in 909376 scanned packages 1 vulnerability required manual review and could not be updatedHowever, running npm install right after, makes them come back:updated 1 package and audited 909376 packages in 9.84s found 5 vulnerabilities (3 moderate, 2 high) run `npm audit fix` to fix them, or `npm audit` for detailsWhy is that?Continuing, if I do npm audit, the first listed item is:``` === npm audit security report ===Run npm update js-yaml --depth 5 to resolve 4 vulnerabilities┌───────────────┬──────────────────────────────────────────────────────────────┐ │ Moderate │ Denial of Service │ ├───────────────┼──────────────────────────────────────────────────────────────┤ │ Package │ js-yaml │ ├───────────────┼──────────────────────────────────────────────────────────────┤ │ … │ … │ ├───────────────┼──────────────────────────────────────────────────────────────┤ │ More info │ https://npmjs.com/advisories/788 │ └───────────────┴──────────────────────────────────────────────────────────────┘ ```Following that helpful link, it tells me:``` RemediationUpgrade to version 3.13.0. ```But, if I check which version I have, it says:``` $ npm show js-yamljs-yaml@3.13.1 | MIT | deps: 2 | versions: 68 YAML 1.2 parser and serializer https://github.com/nodeca/js-yamlkeywords: yaml, parser, serializer, pyyamlbin: js-yaml … ```So, my current version is already higher than the version where the issue was remedied. Why does npm audit keep complaining about it?Thanks for any helpful pointers! 😇

Submitted July 23, 2019 at 09:09AM by bopp

Visualize Google Sheets Data in a NodeJS App

https://blog.crowdbotics.com/google-sheets-nodejs/

Submitted July 23, 2019 at 07:16AM by simplicius_

Is there a Node.js PDF Reference manual?

I'm hoping to find a copy of something like the Node.js API docs in non-html format (PDF preferred) for offline reference to libraries/features. Does this exist?

Submitted July 23, 2019 at 07:50AM by _easternidentity

Monday 22 July 2019

Instantly generate customized Hackathon Starter boilerplate apps

https://alpha.codotype.io/generators/codotype-hackathon-starter/build

Submitted July 23, 2019 at 06:50AM by aeksco

Prerequisites for building a runtime? (Question)

I have been developing with Node for a while and it's just been plain awesome. My question however is, what do i need to know to be able to develop something like Node. Take it as if I have an idea to build it but don't know where to start. PS: am not asking about the languages used to build it but the topics and areas i need to have a good understanding of to be able to implement such a thing e.g.networking

Submitted July 23, 2019 at 02:50AM by bincrab

What are existing solutions for evaluating user submitted node.js code?

I have a requirement to evaluate an arbitrary Node.js script with a list of arbitrary NPM dependencies. I imagine it as a HTTP service that accepts a POST request with a script(s) and a list of NPM dependencies, that defines, builds, and runs to completion a Docker container and returns the result. I would like to know if there are existing frameworks that service this function?My use case is similar to that of https://repl.it/

Submitted July 22, 2019 at 11:19PM by gajus0

Help, please. Values are not reassigned during loop iteration. This is my first node project and I think I may be stuck on asynchronous js concepts.

I have variables assigned in the first loop within the get request (like requestNo). The variables are not reassigned after each iteration. I am tracking the promised status of each pdf process and after the loop waiting for the promises to be settled before archiving all the PDFs.const express = require('express'); const pdftk = require('node-pdftk'); const archiver = require('archiver'); const Q = require('q'); const fs = require('fs'), path = require('path'), pdfFilePath = path.join(__dirname, 'VisaApplication.pdf'); const app = module.exports = express(); const code128 = [' ','!','"','#','$','%','&',"'",'(',')','*','+',',','-','.','/','0','1','2','3','4','5','6','7','8','9',':',';','<','=','>','?','@','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','[','\\',']','^','_','`','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','{','|','}','~','È','É','Ê','Ë','Ì','Í','Î','Ï','Ð','Ñ','Ò','Ó']; app.get('/VisaApplications.zip/:amount*?', function(req, res) { debugger; let amount = req.params.amount; let archive = archiver('zip'); let promises = []; archive.pipe(res); archive.on('error', function(err) { throw err; }); if (!amount) { amount = 1; } for ( let i = 0; i < amount; i++ ) { let date = new Date(); let datetime = date.getTime(); let seconds = datetime / 1000; let timestamp = Math.floor(seconds); let checksum = 103; let sNumber = timestamp.toString(); let randInt = Math.floor(Math.random() * 9999) + 1; let requestNo = randInt + sNumber for (let j = 0, len = requestNo.length; j < len; j += 1) { checksum += code128.indexOf(requestNo.charAt(j)) * j + 1; } checksum %= 103; let barcode1 = code128[103] + requestNo + code128[checksum] + code128[106]; let barcode2 = '* ' + requestNo + ' *'; promises.push( pdftk .input(pdfFilePath) .fillForm({ request_no: requestNo, Barcode1: barcode1, Barcode2: barcode2, }) .output() .then(buffer => { filename = 'VisaApplication' + (i + 1) + '.pdf'; archive.append(buffer, { name: filename }); }) .catch(err => { throw err; }) ); } res.writeHead(200, { 'Content-Type': 'application/pdf', 'Content-Disposition': 'attachment; filename=VisaApplications.zip' }); Q.allSettled(promises).done(function() { archive.finalize(); }); }); if (require.main === module) { app.listen(process.env.PORT || 5000, () => { console.log('Visa Application Zip Export App running on ' + process.env.PORT || 5000); }); }

Submitted July 22, 2019 at 11:38PM by updateSeason

Best way to write this signup handler and gracefully handle errors?

I'm writing an application with Koa and Objection. I wrote the following code for the signup.(routes file) router.post('/signup', async (ctx) => { try { const user = await userService.Signup(ctx.request.body); ctx.status = 201; ctx.body = user; } catch(err){ ctx.status = err.statusCode || err.status || 500; ctx.body = { message: 'Failed to create user.' }; } });(service file) async Signup(userInfo){ let {username, password} = userInfo; try{ password = await argon2.hash(password); const userRecord = await User.query().insert({username: username, password: password}).pick(['id', 'username']); if (!userRecord){ throw new Error('Could not create user.'); } return userRecord; } catch(err){ throw err; } } I was curious if somebody had any critiques on this implimentation. Also, could somebody point in the right direction for error handling? For example, sending errors like "username already taken".

Submitted July 22, 2019 at 11:09PM by AmateurLlama

Is it an anti-pattern to instantiate a new instance of Router() within every routes file?

I've tried instancing and passing around a single instance, but that introduces complexity and complications (the mappings of `req, res` get butchered). Just wondering if instantiating a new instance of `Router` within every routes file (e.g., users, animals, whatevers) is a bad practice.

Submitted July 22, 2019 at 08:30PM by IanAbsentia

Help with creating a HTTP Rest request

Needing a bit of assistance with consuming a REST API. The API is a list of users that I need to filter, and delete an individual user. Not sure if I should do it using HTTP or use some sort of framework such as Axios. I am able to get the list of users, but can't seem to filter a user individually.​Any assistance would help.

Submitted July 22, 2019 at 07:48PM by springer937

Building and Scaling IoT solutions with Microsoft Azure

https://blog.bitsrc.io/building-and-scaling-iot-solutions-with-microsoft-azure-a9d999df4b8

Submitted July 22, 2019 at 07:41PM by JSislife

Restify Error: `Handler (function) required` on server.put(). Any ideas?

https://stackoverflow.com/questions/57151019/implementing-server-put-returning-error-and-there-are-no-answers-available-wh

Submitted July 22, 2019 at 06:49PM by the-cherrytree

NodeJS MVC using express and knex/objection orm

I recently switched from php (laravel) framework to nodejs. And for my project, I created a simple MVC with repository pattern for nodejs using express and objection/knex js.​Here is github repo: https://github.com/puncoz-official/nodejs-express-mvc​Comments and suggestions are highly appreciated.

Submitted July 22, 2019 at 05:54PM by puncoz

accessing bull-queue to view job stats from nodejs

I need to access bull-queue to view job stats and show on the page. I'm using `bull-repl` to access the queue from CLI, as follows:~ > bull-repl BULL-REPL> connect marathon reddis://localhost:6379 Connected to reddis://localhost:6379, queue: marathon BULL-REPL | marathon> stats ┌───────────┬────────┐ │ (index) │ Values │ ├───────────┼────────┤ │ waiting │ 0 │ │ active │ 0 │ │ completed │ 55 │ │ failed │ 1 │ │ delayed │ 0 │ │ paused │ 0 │ └───────────┴────────┘I'm trying to do the same thing from JS with the following code:``` const shell = require('shelljs'); const ccommandExistsSync = require('command-exists').sync;function installBullRepl(){ if(ccommandExistsSync('bull-repl')){ queueStats(); } else{ shell.exec('npm i -g bull-repl'); queueStats(); } }function queueStats(){ let stats;shell.exec('bull-repl'); // launch `bull-repl` shell.exec('connect marathon reddis://localhost:6379'); // connect to redis instance stats = shell.exec(`stats`); // display count of jobs by groups return stats; }installBullRepl(); ```The first shell.exec runs, launching bull-repl, but the rest of the code that needs to be run inside the tool never executes, I assume it's because the shelljs runs each command independently. How can I get the last two commands to run within the tool?

Submitted July 22, 2019 at 05:10PM by yury-stanev

How to Publish Text, Image, Gif, & Video Twitter Posts with NodeJS

https://coderrocketfuel.com/article/publish-text-image-gif-and-video-twitter-posts-with-node-js

Submitted July 22, 2019 at 04:39PM by jkkill

User Input and connecting to mySQL using node.js

Hi,so I'm in the midst of constructing a website and I'm not a genius so if you could but it in layman's terms that would be great. we've recently moved our coding to node.js and want to connect to our database in mySQL based on user input.For example, if we wanted you to put in your value for weight, height, and age; we would have an output based on the average of those. so it would give an output from SQL. I hope that makes sense.

Submitted July 22, 2019 at 04:50PM by AppropriateSoft

passport-facebook login issue return _=_

Hi so right to the question,​So i have been trying to implement facebook login with my app (local) and when i pass the "email" permission in the scope it just returns the same URL but with "_=_" appended to it.I tried to using different permissions and they works. but the email permission is not working.​Here's my code.passport.jspassport.use("facebook",new FBStrategy({clientID: process.env....,clientSecret: process.env....,callbackURL: "http://localhost:5000/auth/facebook/callback",passReqToCallback: true,profileFields: ["id", "emails", "name"]},(accessToken, refreshToken, profile, done) => {console.log(accessToken, refreshToken, profile);}));routeroute.get("/facebook", passport.authenticate("facebook", { scope: ["email"] }));

Submitted July 22, 2019 at 03:41PM by Magic-Sarap

express-openapi-validator: Automatically validate API requests with ExpressJS and OpenAPI 3

https://github.com/cdimascio/express-openapi-validator

Submitted July 22, 2019 at 03:00PM by coracarm

Handling child process of a child process

Hi everyone. I've written a command line application and use child_process.spawn() to use other external processes.I have promisified my spawn calls, so that I can use async and await to sequence various external processes. Inside the promisifying wrapper, I use childProcess.on('exit', ...) to resolve the Promise.Here's what the code looks like:async function asyncChildProcess( command, commandArgs, commandOptions, options = {}, ) { const { onSuccess = () => {}, } = options; return new Promise((resolve) => { const childProcess = spawn(command, commandArgs, commandOptions); childProcess.on('exit', () => { onSuccess(); resolve(); }); }); } In one instance, one of my child processes spawns its own child process and exits. But since I am listening to the exit signal of the child process which I created, my Promise is prematurely resolved and I end up with a mess.What's the recommended way to handle child processes that spawn their own children, so that I can wait for all descendants of the child process spawned in my code to exit before I resolve the wrapping Promise?

Submitted July 22, 2019 at 01:42PM by nohablocoffeescript

Core Concepts of State in React.js and Why to Use It | Redwerk

https://redwerk.com/blog/core-concepts-of-state-in-react-js-and-why-to-use-it

Submitted July 22, 2019 at 01:49PM by redwerk

TypeScript Express tutorial #11. Node.js Two-Factor Authentication

https://wanago.io/2019/07/22/nodejs-two-factor-authentication/

Submitted July 22, 2019 at 10:07AM by _gnx

how to stream an API, and download a link in the response and download based in priority!! ?

OK, so i have a task in which to stream an API,and this API will list an objects in which an object will have a link,​my job is to download this link for each object,but my problemwith such task am not sure with the approach am heading to ( using stream to listen from an API and download links from the response of that API ) is there a better way, socket Io maybe am not sure.i have a problem in which i need to create to type of buffers (RUSH and NORMAL), in which i will download from the rush buffer first then go for the normal buffer ( so the rush has more priority then the normal),am not sure if this is even possible or there is even a better way, Redis maybe !.Guys any idea would be great, thanks in advance .

Submitted July 22, 2019 at 10:26AM by cw4i

How to run different postinstall script if environment is development/production

Hey! I'm trying to set up a postinstall script that would be slightly different in development vs. production. I'll probably use a bash script to do what I need to do, but I'm not sure how I would check whether we are in a production environment or not. It seems like there would be two ways to potentially do this:1) Run a different bash script based on the environment:``` ... (package.json, pseudocode)"scripts": {"postinstall": "if production 'sh setup-prod.sh' else 'sh setup-dev.sh'",...```2) Check the enviroment in the bash script:``` ... (package.json)"scripts": {"postinstall": "sh setup.sh",...(setup.sh, pseudocode) if (env === production) //do production stuff else // do development stuff ```Any ideas on how I could do this? Is there a way to access e.g. NODE_ENV in an npm script or in my .sh script?

Submitted July 22, 2019 at 09:35AM by sourtargets

Using AWS, Docker, Nginx, and subdomain routing to host all of your node apps for free. (Let me know what you think!)

https://www.koryporter.com/2019/07/21/using-aws-docker-nginx-and-subdomain-routing-to-host-all-of-your-node-apps-for-free

Submitted July 22, 2019 at 09:11AM by korziee

Sunday 21 July 2019

Building Well Structured REST-API in Minutes

Hey guys,I created a template project that includes code generation snippets to create all relevant parts that you need during REST API development.Using this template, single command will create all following parts will be created with initials;​https://i.redd.it/7171q0hlksb31.pngHope you will contribute to enhance performance and features.Building Enterprise Level Node.Js REST-API in Minutes

Submitted July 22, 2019 at 06:35AM by scstrider

Use another stream in stream's error handler

Use case: try to get file from the file system. If it doesn't exist fetch it from remote location. Process file and return the result.With promises I can do something like this(simplified pseudocode):function getFile() { return getFileFromFs() .catch(() => { // Ignore error and return another promise // that fetches same file from server return getServerInfo() .then(fetchFileFromServer) }) .then(transformFile); // transform file regardless of it's source } How can I do similar thing with streams?fs.createReadStream('./filePath') .on('error', async () => { // how can i perform async operations and stream // that file from the server here(pipe should still work)? }) .pipe(transformFile)

Submitted July 22, 2019 at 06:13AM by whyyouhavetobemad1

Next.js 9 vs Express + React

From its recent blog post Next seems to have coupled the back end (minus the DB) and front end.Obviously if your not using React don't use it, but besides that it seems to have some great DX. What are the pros/cons and use cases?

Submitted July 21, 2019 at 11:10PM by dittospin

Floyd: A GraphQL backend framework with first-class Typescript support.

https://github.com/floyd-framework/cli

Submitted July 21, 2019 at 10:25PM by iamtherealgrayson

Axios is not saving cookies for my sessions?

Node app using too much memory

I’m new to Node/JS and I decided to build a simple backend with one endpoint that retrieves two zips from 3rd party websites, unzips them (using adm-zip), reads in the data from a XML file in the zip (using xml2js) and cleans it up and stores it in as 1 object in memory.When a request comes into the endpoint, it should respond with the object stored in memory as JSON.The endpoint works fine though deployed on Heroku, the app uses around 250 mb of memory, though when I load tested the endpoint with say 40-50 users, memory spikes up to 1.5 GB and Heroku stops since the usage is way beyond what the free/hobby tier allows. Ideally I don’t want to have to go past the 512 MB tier since I won’t be monetizing it and it’s just a small hobby project so I can’t justify much of a monthly expense.I don’t know if there’s something wrong with the logic but I feel like the app shouldn’t be using as much memory as it is.This is the source code (around 150 lines total): https://github.com/maldahleh/dinesmart-apiI’d appreciate any tips or advice on whether the memory usage is normal or if there’s things I can do to minimize it.

Submitted July 21, 2019 at 08:12PM by maldahleh

Need help with Facebook auth.

Hello everyone,​I am trying to implement facebook auth on express react project of mine. I am using passport-facebook, but not able to make it work. Tried various of method found on stackoverflow/github/forums, tried passport-facebook-token strategy as well.​One thing that I have managed is to get information of user from facebook, but after that authenticating user to access other routes is the problem, problem that I have encountered mainly is when sign up is successful but during the sign in in console I get status code 401, i do not know why.​Maybe there there is someone who has done this before and can share snippet of the code or at least working structure, how in theory I should write a code to make facebook auth work on my project.​Thank you in advance

Submitted July 21, 2019 at 08:16PM by Garywil