Loopback 4: Modern ways to Build APIs in Typescript & NodeJs
3.4 (143 ratings)
Course Ratings are calculated from individual students’ ratings and a variety of other signals, like age of rating and reliability, to ensure that they reflect course quality fairly and accurately.
567 students enrolled

Loopback 4: Modern ways to Build APIs in Typescript & NodeJs

Build Amazing APIs with Typescript, NodeJs, MongoDB, and Mysql
3.4 (143 ratings)
Course Ratings are calculated from individual students’ ratings and a variety of other signals, like age of rating and reliability, to ensure that they reflect course quality fairly and accurately.
567 students enrolled
Created by Haider Malik
Last updated 1/2020
English
English [Auto]
Current price: $83.99 Original price: $119.99 Discount: 30% off
5 hours left at this price!
30-Day Money-Back Guarantee
This course includes
  • 5 hours on-demand video
  • 1 article
  • 34 downloadable resources
  • Full lifetime access
  • Access on mobile and TV
  • Certificate of Completion
Training 5 or more people?

Get your team access to 4,000+ top Udemy courses anytime, anywhere.

Try Udemy for Business
What you'll learn
  • Students will learn how to build REST APIs with NodeJs, Typescript, MysQL and MongoDB
  • Students will be able to do authentication and authorization in Loopback 4
  • Students will be able to test the REST APIs with Loopback 4
Course content
Expand all 47 lectures 05:13:48
+ Getting started with Loopback 4
2 lectures 11:53

LoopBack is a highly extensible, open-source Node.js framework based on Express that enables you to quickly create APIs and microservices composed from backend systems such as databases and SOAP or REST services.

The diagram below demonstrates how LoopBack serves as a composition bridge between incoming requests and outgoing integrations. It also shows the different personas who are interested in various capabilities provided by LoopBack.

Preview 02:44

The LoopBack 4 CLI is a command-line interface that scaffolds a project or an extension by generating the basic code. The CLI provides the fastest way to get started with a LoopBack 4 project that adheres to best practices.

Preview 09:09
+ Typescript Generics
9 lectures 27:02

A major part of software engineering is building components that not only have well-defined and consistent APIs, but are also reusable. Components that are capable of working on the data of today as well as the data of tomorrow will give you the most flexible capabilities for building up large software systems.

In languages like C# and Java, one of the main tools in the toolbox for creating reusable components is generics, that is, being able to create a component that can work over a variety of types rather than a single one. This allows users to consume these components and use their own types.


Preview 02:34

In this lecture, I will teach you how to install and setup typescript with Node.js

There are two main ways to get the TypeScript tools:

  • Via npm (the Node.js package manager)

  • By installing TypeScript’s Visual Studio plugins

  • For NPM users:

    > npm install -g typescript


    You have to create the .ts file and run the tsc and typescript file

Typescript Setup and Installation
03:57

The primary reason you create a generic function is because you have some code that meets two criteria:

  • It's a function or class that will work with a variety of data types

  • The function or class uses that data type in several places

You have other options: When you have code that works with a variety of data types, you could write one version of the function for each data type, but that's a lot of work and a maintenance nightmare. You could also write one function and have it use the any keyword for its data types, but that would mean abandoning type safety.

Provided that the data types involved are used in several places in your code, a generic function or class is a better solution than your other options: generic functions let you write one version of your code and ensure that the code consistently uses data types (and then, of course, let the developer specify the data type when calling the function/instantiating the class).

Preview 03:07

In the above example, the type variable T is specified with the function in the angle brackets getArray<T>. The type variable T is also used to specify the type of the arguments and the return value. This means that the data type which will be specified at the time of a function call, will also be the data type of the arguments and of the return value.

Generic Function with T Array Type
02:29

In this lecture I will teach how you can create generic function to accept multiple type variables. You can also create a generic function with multiple Type variables

Generic Function with Multiple Type Variables
02:22

In this lecture, I will teach you how to restrict the generic function to specified type.

Generic Constraints
02:19

In this lecture you will learn how to define interfaces to define the object properties and function type

Generic Interfaces to describe Object Properties
04:46

In this lecture, I will teach you how to create Interface to describe the function type

Create Interface to describe Function Types
03:17

TypeScript supports generic classes. The generic type parameter is specified in angular brackets after the name of the class. A generic class can have genericfields (member variables) or methods.

Generic Classes and Interfaces
02:11
+ Decorators
6 lectures 16:41

Decorators are simply functions that modify a class, property, method, or method parameter. The syntax is an “@” symbol followed by a function. The @readonlydecorator is a class decorator; it is passed a reference to the constructor function and returns a new constructor function that extends its behavior.

Method Decorators
03:03

Each kind of decorator requires a different function signature, as the decorator is provided with different parameters depending on the decorator use. This section will provide several practical examples that can be used as a starting point for your own decorators.

Arguments in Method Decorator
04:31

You can make a decorator configurable by converting your decorator function into a decorator factory. A decorator factory is a function that returns a decorator function. The factory can have any number of parameters that can be used in the creation of the decorator.

Configurable Decorator using Decorator Factory
01:46

In this video, we are going to learn about property decorator. A property decorator can only be used to observe that a property of a specific name has been declared for a class. Property decorators ignore any return, underscoring their inability to affect the decorated properties

Property Decorator
04:28

In this video, you are going to learn about Parameter decorator. A parameter decorator can only be used to observe that a parameter has been declared on a method.

Parameter Decorator
02:15

In this lecture, you are going to learn about class decorator. It allows programmers to modify the behaviour of function or class.Decorators allow us to wrap another function in order to extend the behaviour of the wrapped function, without permanently modifying it.

Class Decorator
00:38
+ CRUD with Loopback
7 lectures 25:07

A model describes business domain objects, for example, Customer, Address, and Order. It usually defines a list of properties with name, type, and other constraints.

What is Loopback Model
02:21

In this lecture, we will create our first Loopback Model. A model describes business domain objects, for example, Customer, Address, and Order. It usually defines a list of properties with name, type, and other constraints.

Creating your first Loopback Model
03:56

Datasources are LoopBack’s way of connecting to various sources of data, such as databases, APIs, message queues and more. A DataSource in LoopBack 4 is a named configuration for a Connector instance that represents data in an external system. The Connector is used by legacy-juggler-bridge to power LoopBack 4 Repositories for Data operations.

Creating In-memory Datasource
03:51

The repository pattern is one of the more fundamental differences between LoopBack 3 and 4. In LoopBack 3, you would use the model class definitions themselves to perform CRUD operations. In LoopBack 4, the layer responsible for this has been separated from the definition of the model itself, into the repository layer.

A Repository represents a specialized Service interface that provides strong-typed data access (for example, CRUD) operations of a domain model against the underlying database or service.

Creating Repository for CRUD Operations
03:17

In LoopBack 4, controllers handle the request-response lifecycle for your API. Each function on a controller can be addressed individually to handle an incoming request (like a POST request to /todos), to perform business logic, and to return a response.

Controller is a class that implements operations defined by application’s API. It implements an application’s business logic and acts as a bridge between the HTTP/REST API and domain/database models

Creating Controller to define REST API Operations
04:01
Test Loopback REST APIs using Explorer
03:42

A Repository represents a specialized Service interface that provides strong-typed data access (for example, CRUD) operations of a domain model against the underlying database or service.

Digging into Loopback Repository
03:59
+ Connecting Loopback 4 with Mysql Database
3 lectures 21:15

In this video, I am going to show you how can you install Mysql on your machine

Installing MysQL
04:44

In this lecture, we will connect Mysql Datasource with Loopback 4. We will build datasource first, then repository to perform CRUD operations and then controller to implement the Business Logic

Connecting Mysql Database with Loopback 4
14:02

In this lecture, you will learn how to set up the id property to auto increment for table. You can set auto increment from Mysql alter table feature

Set Primary key Id property to Auto-increment
02:29
+ Loopback Relationship with Models
3 lectures 46:20

A hasMany relation denotes a one-to-many connection of a model to another model through referential integrity. The referential integrity is enforced by a foreign key constraint on the target model which usually references a primary key on the source mode

Implement HasMany Relationship between Models
20:35

A belongsTo relation denotes a many-to-one connection of a model to another model through referential integrity. The referential integrity is enforced by a foreign key constraint on the source model which usually references a primary key on the target model.

Implement BelongsTo Relationship
11:11

A hasOne relation denotes a one-to-one connection of a model to another model through referential integrity. The referential integrity is enforced by a foreign key constraint on the target model which usually references a primary key on the source model and a unique constraint on the same column/key to ensure one-to-one mapping. This relation indicates that each instance of the declaring or source model has exactly one instance of the target model.

Implement HasOne Relationship
14:34
+ Secure Loopback 4 Application with JSON WEB TOKEN Authentication
11 lectures 01:49:39

In the JSON Web Token (JWT) authentication approach, when the user provides the correct credentials to a login endpoint, the server creates a JWT token and returns it in the response. The token is of type string and consists of 3 parts: the header, the payload, and the signature. Each part is encrypted using a secret, and the parts are separated by a period.

What is JSON Web Token Authentication
03:01

In this video, I will teach you how to create a signup endpoint and user model. We will save the user in the database

Creating User model with Signup Endpoint
07:50

In this video, I will teach you how to validate user credentials for Signup. We do not allow user to signup without providing invalid email and invalid password

Validate User Credentials for Signup
08:23

Dependency injection is a technique whereby one object supplies the dependencies of another object. A "dependency" is an object that can be used, for example as a service. Before we can use methods of other classes, we first need to create the object of that class (i.e. class A needs to create an instance of class B). Dependency Injection is a set of software design principles and patterns that enables you to develop loosely coupled code.

Introduction to Dependency Injection
08:20

In this lecture, You will learn how to implement dependency injection in Loopback 4. You will learn how to bind value to Loopback 4 context object. Binding represents the items in context object. Binding represents items within a Context instance. A binding connects its value to a unique key as the address to access the entry in a context.


Encrypt User Password by Injecting Service
12:30

In this lecture, we are going to create the Login route with Loopback 4 and its api specification. When user will run the application he will be able to see the login route and its input parameters

Creating Login Route
05:26

In this video, I will show you how to find user on the based on email from Database table. We will also learn about how to verify user password by using bcrypt package.

Verify User Credentials while Login
17:26

In this video, you will learn how to create json web token by using jsonwebtoken package. There is a sign method I will use it to create a token.

Creating JSON Web Token
09:40

Binding represents items within a Context instance. A binding connects its value to a unique key as the address to access the entry in a context.

Attributes of a binding

A binding typically has the following attributes:

  • key: Each binding has a key to uniquely identify itself within the context

  • scope: The scope controls how the binding value is created and cached within the context

  • tags: Tags are names or name/value pairs to describe or annotate a binding

  • value: Each binding must be configured with a type of value provider so that it be resolved to a constant or calculated value


Refactoring Binding Keys to separate file
11:55

Loopback provides authentication strategy. We have to implement Authentication interface that provides authenticate method. We will create JWT strategy, extract token and verify token

Creating JWT Authentication Strategy
15:55

Loopback provides the authenticate decorator. I will show you how to use authenticate decorator to protect routes in controller function.

Apply Authentication on protected routes
09:13
+ Authorization in Loopback 4
3 lectures 45:37

In this lecture, You will learn how to divide your application into multiple roles. You can give access to any specific user/role.

Creating Admin Role with Permissions
17:18

In this video, I will teach you how to give permissions to your user. In this video, we have specified createJob permission to our admin. Only admin can access this route

Set Permissions for Admin Role
11:21

In this video, I will teach you how verify user permissions in interceptor. If you have multiple roles in application. I will teach you how to verify their permissions in interceptor.

Verify User Permissions in Authorize Interceptor
16:58
+ Bonus
2 lectures 10:12

In this lecture, I will teach you how to connect Loopback 4 application with MongoDB database.

Connecting Loopback 4 with MongoDB Database
06:37

In this lecture, I will show you how can you write test cases for your loopback 4 application. You will learn about integrating, unit and acceptance test in Loopback 4

Testing Loopback 4 Application
03:35
+ Learning Path to become a full-stack developer
1 lecture 00:02
Learning Path to Become a FullStack Developer
00:02
Requirements
  • Knowledge of Javascript is important
  • Basic Knowledge of Typescript is requried
  • Knowledge of NodeJs is required
Description

LoopBack is a highly-extensible, open-source Node.js framework that enables you to create dynamic end-to-end REST APIs with little or no coding. LoopBack 4 is the next step in the evolution of LoopBack. You can build Amazing APIs with Modern NodeJs, Typescript, Mysql and MongoDB.

Why Loopback 4:

  • A brand new LoopBack core to deliver great extensibility and flexibility written in TypeScript/ES2017.

  • You can Create powerful APIs easily with a new creation experience for defining REST API's and handling API requests/responses.

  • A new, improved programming model with Dependency Injection and new concepts such as Components, Mixins, Repositories, etc. make this the most extensible version yet.

  • Using OpenAPI-to-GraphQL, create a GraphQL interface for any REST API

LoopBack is a highly-extensible, open-source Node.js framework that enables you to:

  • Create dynamic end-to-end REST APIs with little or no coding.

  • Access data from major relational databases, MongoDB, SOAP and REST APIs.

  • Incorporate model relationships and access controls for complex APIs.

  • Separable components for file storage, third-party login, and OAuth 2.0.

What you will learn in this course:

  • Getting started with Typescript

  • Getting started with Loopback 4

  • Basic/Fundamentals of Typescript

  • Typescript Generics

  • Typescript Decorators

  • Typescript Classes

  • Typescript Interfaces

  • CRUD(Create, Read, Update, Delete) with Loopback 4

  • Build RESTFUL API and OpenAPI documentation

  • Exploring multiple datasources with Loopback 4 like Mysql, MongoDB.

  • Working with Relationship with Models like One to One, One to Many, Many to One.

  • Exploring Repositories, Controllers, Dependency Injections, Design Patterns in more depth

  • Authentication/Authorization in Loopback 4

  • Using External Component in Loopback 4

  • Exposing GraphQL API with Loopback 4


Who this course is for:
  • NodeJs developers who want to learn how to build REST APIS with Loopback 4
  • Existing Loopback 3 developers who want to explore the modern way to build RESTFUL APIS with Typescript
  • Typescript developers who want to learn how to build REST APIS with Typescript, NodeJs, Mysql and MongoDB