Welcome to my coding blog!

  • Environment Variables in JavaScript

    Environment variables in JavaScript are a set of key-value pairs that can be used to store data outside of the JavaScript code. This data can be anything from API keys to database credentials. Environment variables are often used to keep sensitive data secret, as they are not stored in the code itself. We can import…

  • Automatically Log or Append Data to Express Response

    Sometimes you need to log Express response in order to see what your application responded with. Doing it for each route can be tedious. A better approach is to use a middleware. The middleware also gives you the flexibility to choose responses from which routes to log. When you have access to your response in…

  • How to Configure ESLint with Prettier in React Project

    Install ESLint and Prettier Many modern JavaScript Projects use ESLint with Prettier setup. While ESLint keeps the style in good shape, Prettier is used to autoformate the code. In this article we will show our approach to setting up a React project with ESLint and Prettier (AirBnB). Let’s create a project and name it eslint-prettier-airbnb…

  • Logger Tagged Template Literal

    In his GitHub book You Don’t Know JS Kyle Simpson talks about tagged template literals. In Front End Master course he also gives an example of a useful console logger tagged template literal shown below: Here is how to use the function above: Here’s the output: References You Don’t Know JS Frontend Masters course JavaScript:…

  • Automated Deployment of Laravel Project

    In this article I would like to share my approach to automated deployment of a Laravel project. I have been successfully using this approach for my side projects. In this article I will share Laravel project deployment on Linux (Digital Ocean) server. In a nutshell deploying Laravel project consists of “building” it (installing composer dependencies,…

  • Logger Setup with Winston

    A simple setup with winston logger:

  • Adding Email Headers in Laravel Application

    Adding email headers in Laravel application is quite simple. SwiftMessage can be customized using withSwiftMessage method of Mailable base class: https://laravel.com/docs/8.x/mail#customizing-the-swiftmailer-message However you have to remember to do it every time you create a new “mailable” class. Some mail APIs require you to put a special header each time you send an email. In this…

  • API Server Logging with Laravel

    When you work with APIs it is usually a good idea to log requests and responses. I already covered how to do logging when you are consuming an API. You can read about it in this post. Here we will cover how to do it when building an API service with Laravel. For example, you…

  • Exporting Records with Timezone Adjustments

    As a rule, dates in a database are stored in UTC. So, when you export records from database constrained by dates, it is a good idea to use appropriate timezone in export query. You can do it in one of two ways. One way is create incoming dates in user’s timezone, then covert time to…

  • Retrying and Logging Requests with Guzzle

    When consuming 3d party API, you may want to do two things: In this article we will look at how to implement the above features using Guzzle, a popular PHP library for making API calls. Let us scaffold our app composer init composer require guzzlehttp/guzzle:~6.0 composer require monolog/monolog composer require –dev phpunit/phpunit:^8 We will be…