Flexible Entities with Class-transformer

Flexible Entities with Class-transformer

Hello dear readers!

Hello dear readers!

Introduction

Each developer worked, working or will work with API for getting remote data. These data returns as some kind of models, entities or format. But We often have a lot of problems with data format and code case.

Problems

For example let’s make request to TMDB to get latest movie:

{
  "title": "Movie name",
  "overview": "Movie overview",  
  "release_date": "2020-11-02",
  "adult": false,
  "runtime": 5400
}

Next We could use simple JavaScript object or class instance for storing data.

const response = await axios.get(
  'https://api.themoviedb.org/3/movie/latest',
  ...
)
const data = response.data;
// or
class LatestMovie {
  // Properties

  constructor(params) {
    // Init properties from params
  }
}

But both cases has problems:

  1. Simple JavaScript object don’t give any information about stored data and force us to work with snake_case code(No JS way);
  2. Class description has a lot of boilerplate code(describing properties and initialization in constructor and also working with snake_case code in constructor);

javascript typescript

What is Geek Coin

What is GeekCash, Geek Token

Best Visual Studio Code Themes of 2021

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

JavaScript Vs TypeScript 2021 | Difference Between JavaScript and TypeScript | Simple Explanation

JavaScript Vs TypeScript 2021 | Difference Between JavaScript and TypeScript | Simple Explanation. Let's check out the differences between JavaScript and TypeScript in the simplest of ways.

JavaScript vs TypeScript | JavaScript And TypeScript Difference | Full Stack Course

"This video on JavaScript vs TypeScript helps you understand the two languages and draw a comparison between them. JavaScript is a client-side scripting language while TypeScript is an OOP language developed to address the shortcomings of JavaScript. Although TypeScript supports all the features of JavaScript, they have significant differences.

What is TypeScript? Why TypeScript? and Why Not TypeScript?

TypeScript extends JavaScript by adding Types. There are many great reasons to switch to TypeScript. Especially if your team uses JavaScript. There are some reasons to not use TypeScript as there are with any language or framework.

Will TypeScript Replace JavaScript? Learn TypeScript | TypeScript Tutorial 2021

In today's video, I'm gonna show you all the basic concepts you need to know to be successful with TypeScript as well as how you can start using TypeScript right away with React. TypeScript will make you a better JavaScript developer for several reasons. You’ll feel confident when writing code. Fewer errors will appear in your production code. It will be easier to refactor code. You’ll write fewer tests. And overall, you’ll have a better coding experience in your editor.

Hire Dedicated JavaScript Developers -Hire JavaScript Developers

Hire dedicated JavaScript Developers who are proficient in AngularJS, ReactJS, NodeJS, & VueJS frameworks. Get flexible hiring models as per your business requirements.