Become a member
to unlock all features

Level Up!

Access all courses & lessons on egghead today and lock-in your price for life.


    Initialize a LoopBack Node.js Project through the CLI

    Bram BorggreveBram Borggreve

    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.



    Become a Member to view code

    You must be a Member to view code

    Access all courses and lessons, track your progress, gain confidence and expertise.

    Become a Member
    and unlock code for this lesson




    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.

    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.

    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.

    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.

    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.

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