training.shoppinpal.com
  • Introduction
  • 1. The Ideal Workspace
    • The Perfect Machine
      • For Biz Team
      • For Developers
      • For Designers
    • Setup a machine in the cloud
      • Solution
      • Setup box on Azure
        • Create a machine on Azure
        • Test drive your remote machine
        • Setup Dropbox On Azure
      • Setup box on DigitalOcean
        • Setup UI
        • Shared FileSystem
          • Dropbox
            • Use locally developed node modules in another project
          • sshfs
        • Long Running Sessions
      • Feedback
  • 2. Learning Git
    • Static Code Analysis
  • 3. The Backend
    • Use Containers
    • Setup a loopback project
    • Lockdown
    • Build a better mousetrap
    • The abyss stares back
    • Built-in models
    • Extending built-in models
    • Understanding UserModel
    • Boot Scripts
    • Promises
    • Find roles for current user
    • Loopback Console
    • Current User
  • 4. Multi-tenancy With Loopback
    • What is Multi-Tenancy
    • Architecting with Loopback
    • Define scope for Roles
    • Role Resolvers
    • Access Control For Tenants
    • Better Programming with multi-tenancy
  • 5. The Frontend
    • The Browser
    • Unit Testing
      • Motivation behind this blog
      • How to write a test
      • Karma and Jasmin
      • Writing Tests
    • End-2-End Testing
    • Angular 1.x
    • Angular 2
      • Testing
  • 6. ElasticSearch
    • Better Search with NGram
    • NGram with Elasticsearch
    • Fun with Path Hierarchy Tokenizer
    • Working with Mappings and Analyzers
  • 7. Promises
    • What are Promises
    • Promise Implementations
    • Nuances
    • What should we use
  • 8. Learning Docker
    • Docker Swarm
  • 9. Queues & Workers
    • PHP workers in AWS EBS
    • NodeJS workers in AWS EBS
      • SQS Daemon by AWS
      • SQS Daemon in NodeJS
      • SQS polling by worker
    • Gearman
  • 10. Docker
    • Capabilities
  • Appendix
    • Bug in WebStorm deployments
    • The Perfect Terminal
    • Scalable App Deployment with AWS
    • Chrome Tips & Tricks
    • Host your own Gitbook
    • Gitbook Tips & Tricks
    • How to handle support incidents
    • Dev Resources
    • Debug e2e Tests on CircleCI
    • Logging
    • Authentication Principles
    • Mac
    • nvm
    • Unify testing with npm
      • Debugging Mocha
    • Sequence Diagrams
    • Project Sync via IDE
      • SFTP with WebStorm
      • SFTP with Visual Studio
    • Soft Linking
    • NodeJS Profiling
      • How to find node.js performance optimization killers
    • Setup Packer on Azure
Powered by GitBook
On this page
  • Setup a loopback project
  • What just happened?
  1. 3. The Backend

Setup a loopback project

PreviousUse ContainersNextLockdown

Last updated 7 years ago

Setup a loopback project

  1. Login to your over ssh.

    • Create it if you haven't done so already.

    • This will be a robust environment for learning.

  2. Let's setup a loopback project on the [cloud-box]:

     $ 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

    It will just a short while to finish.

What just happened?

  • A minimal set of files was placed in the loopback-zero-to-hero directory to facilitate your project development. And npm install was 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
  • The client folder 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.

  • The node_modules folder contains dependencies which were installed based on what's listed in the package.json file. If you are unfamiliar with this concept, you will need to brush up on the basics of NodeJS and the purpose of package.json file.

  • The server folder 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
    • boot folder contains js files 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.js file is the entry-point for launching loopback. Just like any NodeJS application, you can run it with node path/to/file.js:

      $ 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/

      press ctrl+c to exit.

cloud-box