We often use environment variables in our code(modules) and when testing code it should be available at run time. In this post, I will show you a few nice ways to pass environment variables to Mocha test cases. You can choose one suits your need best.
Mocha provides you rich set of CLI options. You can use the
-r) command-line option to preload
dotenv . In your
package.json file use this test command:
"test": "mocha tests/**/*.js …
Reading or writing a file in Deno is super easy. Deno provides both sync and async APIs for the file operations. This article will cover the basic read and write functionality for a file.
--allow-read and write permission with
If you simply want to read a file as a text string you can use
readTextFile the method returns a Promise that resolves to a utf8…
Deno 1.0.0 was released in May 2020. It Has built-in utilities like a dependency inspector (deno info), a code formatter (deno fmt), debugger, and Test runner. It also supports top-level await.
But Deno has been around only for 2 years now so a number of third party libraries are very less as compared to NPM repository. But don’t worry, If you are looking for a library that is not available at deno.land/x yet, Thanks to Deno, you can still run some npm packages in Deno.
Deno provides a Node compatibility layer, that will allow us to use some NPM packages…
Sometimes there are use cases when we have to call third party services (APIs) where cors are not allowed or only enabled for production or have to be dependent on a third party for it. In this post, I will discuss how cors works and then will create a basic cors proxy in Node as a workaround for the cases I have mentioned.
Before writing a Cors proxy it is important to understand how cors works. So let’s get started.
When you run a web server you can not access images, APIs, etc from different servers if CORS is not…
In order to write performant and clean code, one should understand the working of language(or platform) and its design principles and patterns. In this post, I will list a few common points that every Nodejs developer should know which will ultimately help you write better-performing code.
There are a few things below you should learn and understand as much as you can. This will give you good knowledge of the Nodejs event loop and will help you understand this post better.
In this blog post, I will show you how to set up working HTTPS with a green lock mark.
Steps to Generate Working SSL certificate For Localhost:
If you don’t want to do all these steps then check this out
Before getting into the detail of each step, let’s talk about a few terminologies:
Root Certificate: A Root SSL certificate is a certificate issued by a trusted certificate authority (CA).
In 2019, Node.js turned 10 years old, and the number of packages available on
Nodejs v12 is in LTS since October 2019, comes with a few good features and improvements.
You might be aware that Nodejs v12(Erbium) now has LTS since 2019–10–21 with awesome features and improvement. And you might not want to miss these…
Workers Threads Examples In Node.js
In part1, I have covered:
In this article, I will cover some use cases and a few coding examples.
Note: You can directly jump down for the example code.
If you have not read the previous post yet, I would recommend reading the first part of this article. Before continuing with this article let’s recall a few points from the previous post.
Workers thread were introduced in Node v10.x as an experimental API and now stable since v12.x. As we all know Nodejs single-threaded(Though it has Libuv thread pool) model is well suited for non-blocking IO operation. But Node.js shows poor performance when it runs CPU intensive (blocking code) because Node executes blocking code in the main thread and blocks other code for execution. The main purpose of this post is to cover:
What happens if we need to do synchronous intense stuff? Such…
Software Developer Engineer