- Login to your cloud-box over
- Create it if you haven't done so already.
- This will be a robust environment for learning.
- Let's setup a loopback project on the [cloud-box]:
It will just a short while to finish.
$ cd ~/workspace/loopback-zero-to-hero $ slc loopback ? What's the name of your application? loopback-zero-to-hero ? Enter name of the directory to contain the project: loopback-zero-to-hero
A minimal set of files was placed in the
loopback-zero-to-herodirectory to facilitate your project development. And
npm installwas auto run as part of project setup.
Let's take the time to understand our directory structure:
$ cd ~/workspace/loopback-zero-to-hero $ tree -L 1 . ├── client ├── node_modules ├── package.json ├── README.md └── server
clientfolder is meant to house the source code for your project's frontend/UI. If you look at it right now, it has nothing but a README file:
$ cd ~/workspace/loopback-zero-to-hero $ tree -L 1 client client └── README.md
for all intents and purposes, it can simply be considered empty.
node_modulesfolder contains dependencies which were installed based on what's listed in the
package.jsonfile. If you are unfamiliar with this concept, you will need to brush up on the basics of NodeJS and the purpose of
serverfolder contains the bulk of your server-side logic which is where LoopBack shines! Take a peek:
$ cd ~/workspace/loopback-zero-to-hero $ tree -L 2 server server ├── boot │ ├── authentication.js │ ├── explorer.js │ ├── rest-api.js │ └── root.js ├── config.json ├── datasources.json ├── middleware.json ├── model-config.json └── server.js
jsfiles which will be run (alphabetically by default) when loopback starts
- some configuration files that will be easier to understand if we explain them in sections that follow
server.jsfile is the entry-point for launching loopback. Just like any NodeJS application, you can run it with
$ node server/server.js Browse your REST API at http://0.0.0.0:3000/explorer Web server listening at: http://0.0.0.0:3000/