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…

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…

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).

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.

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….

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.

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.

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.