Your Choice JavaScript News

Node News Friday, February 9

Node News TLDR / Table of Contents

  • axios/axios
    • axios – Promise based HTTP client for the browser and node.js
    • function, request, default //, // default //,
  • LeCoupa/awesome-cheatsheets
    • awesome-cheatsheets – 📚 Awesome cheatsheets for popular programming languages, frameworks and development tools. They include everything you should know in one single file.
    • completion callback, possible exception, zlib streams, crypto streams,
  • An Exhaustive Guide to Writing Dockerfiles for Node.js Web Apps
    • Step by step guide to writing highly optimized Dockerfiles for Node.js web app development and deployment. Covers adding hot reloading, serving static files and using multi-stage alpine builds.
    • docker, Node.js Docker Best, nginx docker, node express server,
  • Reading Humongous Files in Go – Martin Kock –
    • A real-world performance comparison between Node.js and Go for file parsing unsurprisingly turns out in Go’s favor — but how much? Being fairly new to Go aka. Golang, I was itching to try it out on a…
    • XML file, real-world performance comparison, humongous XML file, Node.js implementation, XML file line
  • tc39/proposal-bigint
    • proposal-bigint – Arbitrary precision integers in JavaScript
    • proposal, types, type, new primitive type, dynamically typed programming
  • 10 Best Practices for Writing Node.js REST APIs | @RisingStack
    • In this post we cover best practices for writing Node.js RESTful APIs – including route naming, authentication, API testing or using proper cache headers.
    • Node.js REST APIs, HTTP headers, black-box testing, standardized HTTP headers,
  • Diagnostics WG Summit – Feb 12-13, 2018 – Ottawa, ON Canada · Issue #121 · nodejs/diagnostics
    • diagnostics – Node.js Diagnostics Working Group
    • Tue Feb, Mon Feb, IBM office, action plan, depth breakout sections
  • airbnb/javascript
    • javascript – JavaScript Style Guide
    • style guide, line break, Automatic Semicolon Insertion, Orange Hill Development, reasonable approach
  • Learning Go as a Node.js Developer
    • With Docker and Kubernetes Go got quite some traction – it’s time to learn it!
    • go-to container scheduling, pay particular attention, code snippet, project specific dependencies, official setup guide
  • Do you want a better understanding of Buffer in Node.js? Check this out.
    • Are you always mystified, like me, whenever you come across words like Buffer, Stream, and binary data in Node.js? Does that feeling make you shrink from understanding them, thinking they are not…
    • buffer, data, binary data, ,

Score: 1795.4149442799248
URL: https://github.com/axios/axios
Tweeted At: Fri Feb 09 12:48:01 +0000 2018
Publish Date:
Author: axios

  • Promise based HTTP client for the browser and node.js – – Requests can be made by passing the relevant config to .
  • baseURL , `transformRequest` allows changes to the request data before it is sent to the server This is only applicable for request methods ‘PUT’, ‘POST’, and ‘PATCH’ The last function in the array must return a string or an instance of Buffer, ArrayBuffer, You may modify the headers object.
  • transformRequest [ ( , ) { Do whatever you want to transform the data data; }], `transformResponse` allows changes to the response data to be made before it is passed to then/catch transformResponse [ ( ) { Do whatever you want to transform the data data; }], `headers` are custom…
  • auth { username , password }, `responseType` indicates the type of data that the server will respond with responseType , `xsrfCookieName` is the name of the cookie to use as a value for xsrf token xsrfCookieName , `xsrfHeaderName` is the name of the http header that carries the xsrf token…
  • { `data` is the response that was provided by the server data {}, `status` is the HTTP status code from the server response status , `statusText` is the HTTP status message from the server response statusText , `headers` the headers that the server responded with headers {}, `config` is the…

Tags: function, request, default //, // default //,

Score: 1168.9008618675296
URL: https://github.com/LeCoupa/awesome-cheatsheets/blob/master/backend/node.js?platform=hootsuite
Tweeted At: Thu Feb 08 21:45:18 +0000 2018
Publish Date:
Author: LeCoupa

  • The top-level scope is not the global scope; var something inside a Node module will be local to that module.
  • unref(); // Allow you to create a timer that is active but if it is the only item left in the event loop, node won’t keep the program running.
  • exports.area = function (r) { – – – – return Math.PI * r * r; – – – – }; – – – – – – – – – // If you want the root of your module’s export to be a function (such as a constructor) – – -…
  • module.exports = function(width) { – – – – return { – – – – area: function() { – – – – return width * width; – – – – } – – – – }; – – – – } – – – – – – – – – -…
  • process.config; // An Object containing the JavaScript representation of the configure options that were used to compile the current node executable.

Tags: completion callback, possible exception, zlib streams, crypto streams,

Score: 669.7563232323232
URL: https://blog.hasura.io/an-exhaustive-guide-to-writing-dockerfiles-for-node-js-web-apps-bbee6bd2f3c4?gi=c8022fde8261
Tweeted At: Thu Feb 08 08:03:06 +0000 2018
Publish Date: 2018-02-07T13:18:51.883000+00:00
Author: Praveen Durairaj

  • Using nodemon for hot reloading during development.Optimising for Docker cache layers — placing commands in the right order so that npm install is executed only when necessary.Serving static files (bundles generated via React/Vue/Angular) using serve package.Using multi-stage alpine build to reduce final image size for production.
  • Simple Dockerfile ExampleFor the base image, we have used the latest LTS versionnode:carbonDuring image build, docker takes all files in the context directory.
  • If any files change, nodemon will automatically restart your node application.We’ll build the image and run nodemon so that the code is rebuilt whenever there is any change inside the app directory.
  • OptimisationsIn your Dockerfile, prefer COPY over ADD unless you are trying to add auto-extracting tar files, according to Docker’s best practices.Bypass package.json ‘s start command and bake it directly into the image itself.
  • Assuming you are building a UI app using React/Vue/Angular, you would ideally build your final bundle using npm run build which would generate a minified JS and CSS file.The other alternative is to either 1) build the files locally and use an nginx docker to serve these static files or…

Tags: docker, Node.js Docker Best, nginx docker, node express server,

Score: 273.58788308237376
URL: https://medium.com/@cookie80/reading-humongous-files-in-go-c894b05ac020
Tweeted At: Fri Feb 09 11:06:44 +0000 2018
Publish Date: 2018-01-21T19:10:54.979000+00:00
Author: Martin Kock

  • Reading Humongous Files in GoA real-world performance comparison between Node.js and Go for file parsing unsurprisingly turns out in Go’s favor — but how much?Being fairly new to Go aka.
  • Try it out, it’s really At my work, my boss just so happened to find himself in a situation where he needed to parse a humongous XML file — a perfect opportunity to show off my new Golang skills!The file in question is a UTF-8 encoded XML file from DMR, the Danish…
  • Not only was this a chance to build something in Go, it was also a test to see if Go would be faster than Node.js for this kind of task.
  • Various techniques could be implemented to speed up both the TypeScript and the Go code — such as dividing the work and processing the XML file using asynchronous functions (in Node.js) and channels (in Go).
  • For now, we’ll stick to sequential processing.Both implementations read the XML file line by line, in a loop, using a file reading stream (in Node.js) and a line scanner (in Go).

Tags: XML file, real-world performance comparison, humongous XML file, Node.js implementation, XML file line

Score: 257.22270009340446
URL: https://github.com/tc39/proposal-bigint
Tweeted At: Thu Feb 08 05:53:35 +0000 2018
Publish Date:
Author: tc39

  • Read and add two unsigned 64-bit integers in asm.js on the heap: – – In many cases in JavaScript coding, integers larger than 253 come up, where casting to a double-precision float would lose real, relevant data: – – This proposal provides a new, second primitive numeric type, , to…
  • When adding two values of different numeric types, between large integers and floating point numbers, the mathematical value of the result may be outside of the domain of either.
  • To avoid this problem, this proposal bans implicit coercions between Numbers and BigInts, including operations which are mixed type.
  • One particular hazard, if BigInts were to be operated on with static methods, is that users may convert the BigInt into a Number in order to use the operator on it–this would work most of the time, just not with big enough values, so it might pass tests.
  • As part of integrating BigInts into the JavaScript specification, a high amount of rigor will be required to differentiate three types floating around in the specification: Mathematical values, BigInts and Numbers.

Tags: proposal, types, type, new primitive type, dynamically typed programming

Score: 99.13243837016222
URL: https://blog.risingstack.com/10-best-practices-for-writing-node-js-rest-apis/
Tweeted At: Thu Feb 08 18:07:04 +0000 2018
Publish Date: 2017-02-21T10:11:17+00:00
Author: Gergely Nemeth

  • In this article we cover best practices for writing Node.js REST APIs, including topics like naming your routes, authentication, black-box testing & using proper cache headers for these resources.
  • Still, while we help our customers to find issues in their applications with Trace, our Node.js monitoring tool we constantly experience that developers have a lot of problems with REST APIs.
  • One of the modules that can help you with black-box testing Node.js REST APIs is supertest.
  • A simple test case which checks if a user is returned using the test runner mocha can be implemented like this: – – You may ask: how does the data gets populated into the database which serves the REST API?
  • If you are about to start developing a Node.js REST API or creating a new version of an older one, we have collected four real-life examples that are worth checking out: – – I hope that now you have a better understanding of how APIs should be written using Node.js….

Tags: Node.js REST APIs, HTTP headers, black-box testing, standardized HTTP headers,

Score: 110.7610341261634
URL: https://github.com/nodejs/diagnostics/issues/121
Tweeted At: Thu Feb 08 20:37:10 +0000 2018
Publish Date:
Author: nodejs

  • Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
  • Already on GitHub?
  • Sign in to your account

Tags: Tue Feb, Mon Feb, IBM office, action plan, depth breakout sections

Score: 62.22004175365345
URL: https://github.com/airbnb/javascript
Tweeted At: Fri Feb 09 11:49:21 +0000 2018
Publish Date:
Author: airbnb

  • This guide is available in other languages too.
  • See Translation – – 25.1 When attaching data payloads to events (whether DOM events or something more proprietary like Backbone events), pass an object literal (also known as a “hash”) instead of a raw value.
  • This style guide is also available in other languages: – – Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ‘Software’), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge,…
  • IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  • We encourage you to fork this guide and change the rules to fit your team’s style guide.

Tags: style guide, line break, Automatic Semicolon Insertion, Orange Hill Development, reasonable approach

Score: 59.997342781222315
URL: https://nemethgergely.com/learning-go-as-a-nodejs-developer/
Tweeted At: Fri Feb 09 03:09:03 +0000 2018
Publish Date: 2018-02-08T08:00:00+00:00
Author: Gergely Nemeth

  • Go has a C-like syntax: – – To install Go, follow the official setup guide: someone who writes a considerable amount of JavaScript code, one of the first questions I had was how does Go handle dependency management?
  • will create similar files that would – to describe the project, just like in the Node.js ecosystem.
  • Let’s see what happened in the code snippet above line by line: – – The example above works, but reads the files one after each other – time to go asynchronous!
  • Using , we can rewrite the file reading code snippet to run concurrently this way: – – In the Node.js space we have a ton of options when it comes to picking a framework for writing HTTP services – Go is no different.
  • After some searching on Google, I chose Gin to start with.

Tags: go-to container scheduling, pay particular attention, code snippet, project specific dependencies, official setup guide

Score: 57.45567504835591
URL: https://medium.freecodecamp.org/do-you-want-a-better-understanding-of-buffer-in-node-js-check-this-out-2e29de2968e8?gi=61d578714ac0
Tweeted At: Thu Feb 08 21:36:27 +0000 2018
Publish Date: 2017-12-13T16:12:13.556000+00:00
Author: Justice Mba

  • Are you always mystified, like me, whenever you come across words like Buffer, Stream, and binary data in Node.js?
  • And that’s exactly why I’m writing this piece — to help us demystify some of these features and take our Node.js learning to the next level.When introducing Buffer, the official Node.js docs states in part…… mechanism for reading or manipulating streams of binary data.
  • For example, the following are five different binaries, five different sets of 1s and 0s:10, 01, 001, 1110, 00101011Each number in a binary, each 1 and 0 in a set are called a Bit, which is a short form of Binary digIT.To store or represent a piece of data, a…
  • The point here is, computers stores all data types in binaries, and this is known as binary data.If you’re super interested in the nitty-gritty of Character Encoding, you might like this gentle and detailed introduction.Now we understand what binary data is, but what are streams of binary data from our…
  • It is a small physical location in your computer, usually in the RAM, where data are temporally gathered, wait, and are eventually sent out for processing during streaming.We can think of the whole stream and buffer process as a bus station.

Tags: buffer, data, binary data, ,

Top Node Courses

The Complete Node.js Developer Course (2nd Edition) (60,232 students enrolled)

By Andrew Mead
  • Build, test, and launch Node apps
  • Create Express web servers and APIs
  • Store data with Mongoose and MongoDB
  • Use cutting-edge ES6/ES7 JavaScript
  • Deploy your Node apps to production
  • Create real-time web apps with SocketIO

Learn more.


Angular (Angular 2+) & NodeJS - The MEAN Stack Guide (26,806 students enrolled)

By Maximilian Schwarzmüller
  • Build real Angular + NodeJS applications
  • Understand how Angular works and how it interacts with Backends
  • Connect any Angular Frontend with a NodeJS Backend
  • Use MongoDB with Mongoose to interact with Data on the Backend
  • Use ExpressJS as a NodeJS Framework
  • Provide a great user experience by using Optimistic Updating on the Frontend
  • Improve any Angular (+ NodeJS) application by adding Error Handling

Learn more.