Sign in

I’m a Software Engineer from India. In ♡ with JavaScript and all amazing things there. Reach me: hey@dhruv479.dev
Photo by Surface on Unsplash

In this pandemic, a lot has changed and so the work culture with something we can’t get rid of, yes “Remote Meetings”. While at one of those meetings, I got curious about the meeting platform and after some search came to know what our browsers are capable of (inbuilt browser APIs).

So, I planned to develop a simple recorder that supports Audio, Video, and Screen Recording available at http://recorder.dhruv479.dev

To proceed further, you should be acquainted with some terms:

MediaRecorder: The MediaRecorder interface of the MediaStream API provides functionality to easily record media ref: MDN

MediaDevices: The MediaDevices interface provides…


Photo by Thomas Tastet on Unsplash

As the project grows, It becomes really troublesome to do all the manual repetitive things in consuming the API like adding a token to request, showing notification from response, handling error from response and the list goes on…
And also, if you want to make some change in the flow, it becomes a nightmare for the entire team to update every single API. Let’s start with an example:

// api-call.jstry {
const res = await axios.post('http://myserver.com/post', {
headers: {
authorization: 'my secret token'
}
});
const { success, data, message } = res.data;
successNotification(message);

doSomethingWithData(data);
} catch (error) {…


Photo by James Lee on Unsplash

Handling Errors is over-looked time and again by inexperienced developers but this has a significant impact on the stability, monitoring, performance of the application. I will continue on how to handle errors efficiently in your express application.

There is no definite way to handle errors, but some are better than others. let’s dive into this.

Handle Errors in Controllers(Bad Approach):

In this Approach, we handle errors in the controllers. For every failed condition/exception, the error will be raised and returned by the controller itself in the response.
For Example:

app.js ( Controller Level Error handling )

In this, we have a route /post that is…


high on javascript with coffee
high on javascript with coffee
Photo by Caspar Camille Rubin on Unsplash

Recently, I had to query a really big data set in MongoDB ~50 Mn documents and with around ~0.5 Mn in response being handled and exported to csv file in the required format.

Note: If you are in hurry, the complete solution is attached in the end, otherwise, I will recommend going through it.

For a better understanding, we will continue with an example where we will be needing to populate the empty data columns from the database.

So, I am here to make it easier for you, if you ever run into something similar. …

Dhruv Bansal

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store