Spring application logs after establishing connection with the MongoDB
Spring application logs after establishing connection with a local MongoDB instance

The Spring configuration gives a lot of flexibility on how to configure different parts of the framework and its dependencies. When it comes to Spring Data MongoDB, the same is true. However, some of the configuration options are better choice depending on the situation (environments) or if the property is…

There are multiple ways of setting environment variables, such as defining it in the bash profile on the host, part of a pm2 deployment file — ecosystem.js, .env file or, any other method you might use. Having said that, knowing which environment variables are set for the current process can be challenging. Besides, if we add the fact that pm2 expects an explicit flag --update-env to the restart/reload command in order to reload environment variables, it becomes hard to be sure about the current env variables state.

Luckily, pm2 has a command that does just that. The pm2 env id will show all the environment variables loaded to the pm2 process with the specified id.

list of pm2 enviroment variables for the id 1

The id can be obtained by running the pm2 l command.

Door lock
Photo by iMattSmart on Unsplash

Axios, like many other popular HTTP clients, has built-in support for basic auth. However, very often in code reviews, and while browsing stack overflow answers I run into implementations similar to this:

Formatting and base64 encoding username & password

While there is nothing wrong with the code itself, there is a simpler way to achieve the same thing.

Using axios api for a basic auth

As you can see, the axios provides an elegant way to invoke APIs protected with basic auth, hiding away the base64 encoding and string concatenation.

If you liked this short post, check out my other axios related writings.

As web APIs are growing in popularity day by day, there is an increasing need for a convenient, portable, widely recognized & available format/tool to document or try out APIs. Many developer’s tools have recognized that cURL fits those requirements and started offering a way to export it. …

Hamza Sabljakovic

Software engineer based in Stockholm, Sweden.

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