Page Object Model (POM) is a design pattern, popularly used in test automation that creates Object Repository for web UI elements. The advantage of the model is that it reduces code duplication and improves test maintenance.

This story is a tutorial on what use Puppeteer, TypeScript, and Jest to write a simple end-to-end test (E2E). The tutorial will write some tests to cover some simple test cases. The tutorial also uses Page object modal pattern to complete these test cases.

We will use a demo e-commerce website —

With this website, we can write completed examples for the Login…

Face-api.js is a JavaScript API for face detection and face recognition in the browser and Node.js with TensorFlow.js

Sometimes, we have to implement face recognition or face landmark. With face-api.js, we can do this with just a few lines of code.

In the face-api.js repository, we can find examples for both browser and Node.js environments. They look simple enough for us. Let’s see what you can do with them.

In this story, we will try to implement a complete example that uses face-api.js and face landmark model to “Glassify” faces in an image.

Face Landmark With face-api.js

Initial TypeScript:

$ mkdir ts-faceapi-glassify
$ code ts-faceapi-glassify…

PM2 is a production process manager for Node.js applications with a built-in load balancer. It allows you to keep applications alive forever, to reload them without downtime and to facilitate common system admin tasks.

With PM2 CLI, you can manage your Node.js processes on your local server. If you have an online server (public with internet), you can use keymetrics service to manage your processes everywhere.

Maybe these features are enough for “normal” cases. But sometimes, your project requires a simple web interface to manage all Node.js in a local server. Or the project requires a processes manager module as…

Asynchronism may be a complicated thing. But it is definitely worth spending your time learning about, that is, if you want to build a backend system that is scalable. And create a frontend that facilitates good user experiences.

A notification system is a good example. When you want to send a notification to all users, maybe that task will take a lot of time. You don’t need to wait until the task is completed and you want to do something else at that time. A system that can handle the task asynchronously will solve your problem.

This article will show…

In a serverless project with the serverless framework and TypeScript (or JavaScript), when we have some way of handling dependence packages:

  • Bundled the entry function files to include the content of all related packages.
  • Bundled the entry function files which just include production logic code. But we also pack the node_modules folder with all related packages.
  • Keep node_modules in a layer . Almost the same as the second way. But now, node_modules is not a part of the function code. The function will run on the layer.

In the article, we will not deep drive to explain this topic. Just…

In this article, we will talk about starting a project with Serverless and TypeScript. The article requires basic knowledge about AWS serverless architecture, the Serverless framework, and TypeScript.

We will use the latest stable version of Serverless (2.35.0) to build a “simple” serverless project — A REST API with AWS Lambda function and API gateway.


$ mkdir ts-jest-serverless
$ cd ts-jest-serverless
$ npm install serverless --no-save

Install the serverless package with --no-save option to avoid creating package.json file. In the next part, we will use a template to initiate the project.

Typescript template

This is an easy way…

Now, with TensorFlow.js developers can easily run a machine learning model using JavaScript. With Pre-trained models, you can complete complex tasks easily, it not requires the knowledge to build a model from scratch.

For the first time, TensorFlow.js working as a front-end library for web browsers. But now, tfjs (aka TensorFlow.js) support to be used in backend JavaScript — Nodejs. This means you can create a web service that can work with a TensorFlow model by Nodejs instead of Python.

Follow this example code, we are going to build a web service that includes an API. …

Photo by Safar Safarov on Unsplash.

1. Using TypeScript

This is just my recommendation. I started working with Typescript in 2017, then I become a TypeScript lover. My team members love it too.

The primary benefits of using TypeScript are to catch more errors before they go into production and make it easier to work with your codebase.

TypeScript Benefits:

  • Static Typing — Easy to start if you come from strongly typed languages like C# of Java.
  • A better choice for large coding projects — When you are working in a team, your team should keep the codebase clean and maintainable. When large coding projects have many developers, there…

As you know, jwt tokens are born as a stateless entity. By itself, we can validate a jwt token just by a secret token and its expire time.

However, sometimes our service requires a token to become stateful, which means we can make a jwt token to be invalid in our service.

A particular case is when your service user login to the service, the service will generate a jwt token for the user, and the user can use this token to authenticate for other requests. A user can use their credential (username/password) to get a new jwt token every…

Photo by Bench Accounting on Unsplash.

This is a simple project — Writing an API service running on Nodejs. The service is a URL shortening service. The service also is an example of TDD style using Typescript, Jest, Express, and Mongoose.

Create and initialize the project

This project will be base on TDD with Typescript and Jest: Starter project.

Just clone the starter project from Github:

$ git clone url-shortener
$ cd url-shortener
$ npm ci

With url-shortener is the name of this project. You also can update the project name in package.json file.

"name": "url-shortener",
"version": "1.0.0",
"description": "",
"main": "index.js",

Install required dependencies

First of all, let’s install some…

Hoang Dinh

Just A Cat Lover

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