Front-End

Uploading File from Browser to S3 with JavaScript

Uploading a file from a browser to S3 for only authorised users is a pretty cool trick. It is even cooler if we can build it in a serverless way. Here is the entire solution for a simple serverless app to authenticate with AWS Cognito and upload a file to …

Front-End

Serverless Authentication with AWS Cognito and JavaScript

In a traditional web application, authentication is handled by server-side code and users are managed in the database layer. In the world of serverless apps, we can offload the heavy-lifting to a managed authentication service like AWS Cognito to simplify it. This post focuses on JavaScript code to authenticate users …

Front-End

Using setInterval() and setTimeout() with JavaScript

setInterval() and setTimeout() functions are the quickest solutions to loop functions with JavaScript, often used for a simple animation effects. For example, setInterval(function(){functionA()}, 1000) executes functionA() every second. On the other hand, setTimeout(function(){functionA()}, 1000) executes functionA() once after waiting for 1 seconds. Both can be stopped by clearInterval() and clearTimeout() …

Front-End

React Unit Test Code Snippets with Jest and Enzyme

Sometimes all I need is to see a snippet of code without much explanation when I try to find a solution online. This is because I am familiar enough with the language and framework and need a quick reminder. So, here it is. I created a post with a few …

Front-End

Unit Testing React Form with Jest and Enzyme

Jest is a JavaScript unit testing framework created by Facebook. I usually use mocha for unit testing Node.js code, but when it comes to testing React, Jest combined with Enzyme is pretty much the best. Enzyme is a JavaScript utility library created by Airbnb. It lets you simulate DOM rendering …