LoopBack - Getting Started

Getting started


Assuming you have already installed Node...

Install the StrongLoop tools for LoopBack applications.

$ npm install -g strongloop

Create app

Create a "Hello World" LoopBack application.

$ slc loopback
? What's the name of your application? hello-world
? Enter name of the directory to contain the project: hello-world

? Which version of LoopBack would you like to use? 3.x (current)
? What kind of application do you have in mind? hello-world (A project containing a controller,
including a single vanilla Message and a single remote method)

I'm all done. Running npm install for you to install the required dependencies.
If this fails, try running the command yourself.

Create models

$ slc loopback:model

The generator guides you through creating your model. Enter the values highlighted in green. To accept the default, just press Enter.

[?] Enter the model name: person
[?] Select the data-source to attach person to: db (memory)
[?] Select model`s base class (PersistedModel)
[?] Expose person via the REST API? Yes
[?] Custom plural form (used to build REST URL): people
[?] Common model or server only? common
Let's add some person properties now.

Define a firstname property for the person model

Enter an empty property name when done.
[?] Property name: firstname

Hit Enter to accept the default string type:

[?] Property type: (Use arrow keys)
❯ string

Make the property required.

[?] Required? (y/N) y

Repeat these steps for lastname property.

Press Enter when prompted for a property name to finish up and create the model.

Run the application

Run as you would any Node application.

$ node .
Browse your REST API at
Web server listening at:

When you're ready to think about moving to production, you can use slc start to run the app under the control of a local instance of StrongLoop Process Manager. This enables you to profile, monitor, and control clustering for the app and keep it running forever. See strong-pm.io for more information.

Explore your REST API

Load to see the built-in API Explorer.

The API Explorer enables you to exercise all the generated API endpoints. There are create, read, update, and delete (CRUD) endpoints for the people model you just created.

For more information, see the Using the API Explorer in the documentation. You may also want to follow the Getting Started tutorial.