Giter VIP home page Giter VIP logo

days-off-loopback's Introduction

days-off-loopback

Server side application running on Loopback with data persisted on MongoDB.

Test days-off-loopback on your local machine

  1. Install MongoDB on your machine, run the MongoDB instance and create an empty DB called days-off
  2. clone this days-off-loopback repository on your local machine
  3. move to the folder you have just downloaded
  4. run npm install to install the required node modules
  5. run node . to launch the application
  6. check out and test the API methods on http://localhost:3000/explorer

Check out the cloud version on IBM Bluemix

Moving days-off-loopback to IBM Bluemix is pretty easy, all you need is to do is following this procedure:

On IBM Bluemix

  • get a Bluemix account
  • add a Loopback Starter application (e.g. days-off)
  • add a Cloudant NoSQL DB service and create a database
  • get the "Cloud Foundry" tools from the "Getting started" page

On your local machine

  • add a manifest.yml file to your copy of days-off-loopback
  • replace any reference to your local MongoDB instance with the credentials of a Cloud DB (e.g. Cloudant)
  • push your application to IBM Bluemix using Cloud Foundry. E.g. cf push days-off

My Bluemix account

I have activated a trial using a promotional code and it will expire in June 2017. Some of the links provided below may be no longer valid after that date.

Adding manifest.yml

Manifest.yml is used by IBM Bluemix to understand how the application is configured. More details on https://docs.cloudfoundry.org/devguide/deploy-apps/manifest.html. This is an example of manifest.yml

applications:
- path: .
  memory: 1024M
  instances: 1
  domain: mybluemix.net
  name: days-off-cloudant
  host: days-off-cloudant
  disk_quota: 1024M

Using Cloudant instead of MongoDB

The cloud version of this application persists data on Cloudant, which is a "Database As A Service" provided by IBM Bluemix. Moving a Loopback application from MongoDB to Cloudant is pretty straightforward.

  • Create a Cloudant DBAAS application, enter its specific dashboard and create a database (e.g. "days-off")

  • In the Cloudant dashboard go to Account > CORS and make sure that CORS is enabled and that "Databases will accept requests all the domains"

  • Get the credentials from "Cloud Foundry Apps > Connections > View Connections". You will get something like this

{
  "cloudantNoSQLDB": {
    "name": "Cloudant-3s",
    "label": "cloudantNoSQLDB",
    "plan": "shared",
    "credentials": {
      "username": "someusername",
      "password": "secret",
      "host": "myhost-bluemix.cloudant.com",
      "port": 443,
      "url": "https://someusername:[email protected]"
    }
  }
}
  • Now it's time to change the settings in days-off-loopback application. Go to server/datasources.json and replace it with something like this (of course you have to set your credentials
{
  "db": {
    "name": "db",
    "connector": "memory"
  },
  "Cloudant": {
    "url": "https://someusername:[email protected]",
    "database": "days-off",
    "username": "someusername",
    "password": "secret",
    "name": "Cloudant",
    "modelIndex": "",
    "connector": "cloudant"
  }
}
  • Finally, go to model-config.json and replace all the references to MongoDB with "Cloudant"

REST API

You can take advantage of the Swagger API explorer that is built-in with Loopback. It is available here https://days-off-cloudant.mybluemix.net/explorer/. As an alternative, you can run this Postman collection

Run in Postman

The order of the methods in the Postman collection represents a test suite that covers all the methods used by the available clients.

days-off-loopback's People

Contributors

scigoli avatar

Stargazers

Kasra Ghasemi avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.