Category: Javascript Development

  • REST API Request Validation

    In this article we will look at how to validate POST requests to the REST API using Joi library. Joi lets you describe your data using a simple, intuitive, and readable language. We will also look at how to turn Joi errors into 422 Validation Error API responses. Describe REST API Request Shema with Joi…

  • API Gateway Webhooks Lambda HMAC Validation

    In the previous post HMAC Validation we explored how to validate HMAC in an API project. The video Webhooks Processing: HTTP API Gateway + SQS +Lambda shows how to created a scalable solution for receiving webhooks and throttling them with SQS and Lambda. In this article we will look at how to use HMAC Validation…

  • HMAC Validation

    In this HMAC Validation tutorial, we will define what HMAC is, its benefits, and implement HMAC validation as a middleware in an API project. HMAC stands for hash-based message authentication code. An HMAC algorithm works by hashing a message along with a secret key. The resulting hash is called a signature or digest. The message…

  • API Testing with Jest Mocks and SuperTest

    One of the main challenges in doing API testing is database dependency. In the last article Repository Pattern in JavaScript we looked at how to abstract data access operations. One of the main characteristics of the pattern is Testability: The Repository Pattern facilitates unit testing because you can easily replace the actual data access logic…

  • Repository Pattern in JavaScript

    The Repository Pattern is a structural pattern that abstracts and centralizes data access operations, providing a consistent and simplified interface for the application to interact with data sources. In essence, the Repository Pattern acts as a mediator or a middleman between the application’s business logic and the data storage, shielding the rest of the code…

  • 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:…

  • Logger Setup with Winston

    A simple setup with winston logger: