Initialize a LoopBack Node.js Project through the CLI

Bram Borggreve
InstructorBram Borggreve
Share this video with your friends

Social Share Links

Send Tweet

LoopBack is a framework built on top of Express for creating APIs. It allows you to create end-to-end REST APIs that can access data from many data sources such as MondoDB, PostgreSQL, MySQL or other REST APIs.

In this lesson you will learn how to install loopback-cli and create a new LoopBack API project. After creating the basic LoopBack project through the CLI, running the server will give us access to the project and API Explorer urls. The user model will be available to us because user authentication was enabled.

[00:00] The first thing we do is install LoopBack CLI, globally. This will give us access to the lb commands that we can use to build LoopBack applications. Next, we will create a folder called eggheadloopback, and cd into it.

[00:13] We'll run lb app in our new directory to create our LoopBack API project. This will prompt us for a couple of things. First, it asks us the name of the application. We accept the defaults. This is the name of the directory that we are in.

[00:27] The second question is which version of LoopBack we'd like to use. We pick version 3.x, which is the current version. The last question is the kind of application that we'd like to create. We accept the default, which is an API server with local user authentication enabled.

[00:42] The basic project will be created, and the dependencies will be installed using npm-install. After the installation is finished, we can start the API by running node., or npm-start. This will print out two URLs, to the API and to the explorer.

[00:56] When we open the first URL in the browser, we see a status message. This message shows us when the API was started and the up time. The second URL shows us the API explorer that can be used to interact with the API.

[01:09] It currently shows one model, the user model. This built-in model is enabled because we selected an API server with local user authentication.