Get started with Node.js and LoopBack 4

LoopBack is a Node.js API creation framework that enables you to create APIs quickly on top of backend resources. It has out-of-box integration with 20+ databases and services, including MongoDB, PostgreSQL, REST, SOAP, and more.

The latest version, LoopBack 4:

  • has a brand new core rewritten in TypeScript that makes this framework simpler to use and easier to extend than ever
  • supports OpenAPI for comprehensive bottom-up and top-down REST API experience
  • enables instance GraphQL endpoints from REST APIs

LoopBack4 diagram

Want to get started? Here are a few tutorials that help you learn LoopBack 4 fundamentals and step-by-step guides for getting started with the new version.

1. Get started tutorial

If you’re new to LoopBack 4, this getting started tutorial is a good place to start. The tutorial takes you through installing the necessary tools, creating and starting a project, and more.

After running the scaffolding application command lb4 app, the application is ready to run with the /ping endpoint. By modifying the Controller, you can change the behavior of that endpoint.

If you want to skip this tutorial, make sure you have Node.js 8.9+ installed. Simply run:

npm install -g @loopback/cli

After the LoopBack 4 CLI module has been installed, run lb4 app and see what you can do.

2. Todo tutorial

Next step, follow the Todo tutorial. If you have a backend database to connect and want to have a model to represent it, this tutorial is for you. It shows you how to create REST APIs and connect to a database with just 5 steps! Along the way, this tutorial explains some of the key concepts introduced in LoopBack 4.

To summarize, 5 steps to create REST APIs include:

  1. lb4 app – scaffold a LoopBack 4 application
  2. lb4 model – add a model for business domain objects
  3. lb4 datasource – add a datasource for data persistence
  4. lb4 repository – add a repository to bind the model and datasource
  5. lb4 controller – add a controller that exposes REST APIs

3. TodoList Tutorial

In a real-life application, there are usually multiple models involved, and they are connected to each other. In this case, you need to know how model relations work in LoopBack 4. Don’t worry, we’ve got it covered. The TodoList tutorial shows you how to build an application with a few types of model relations.

What if you need to call other services?

After completing the above tutorials, you probably get a pretty good idea in creating APIs that eventually connect to databases. What if you need to call other REST or SOAP web services? Read our tutorial: Calling other APIs and web services

Follow us

Besides the LoopBack 4 documentation page, there are other ways to stay connected with the latest features and articles:

Diana Lau