Skip to content
This repository was archived by the owner on Aug 18, 2021. It is now read-only.

Mock calls to microservices

Gustavo Denis edited this page Oct 31, 2019 · 1 revision
Main > Using Liquid for building your application > Mock calls to microservices

Both for asynchronous and synchronous processes.

##On the Front-End:

import { settings } from './Settings'  
const stubAPIData = require('../Mock/stubAPIData.json');

//Added lib from   
import LiquidFrontEndOnAzure from '@Liquid/react-liquid-frontend-on-azure' 

//Set Environment as options on start the application 
LiquidFrontEndOnAzure.useWorkBench(settings, stubAPIData);  

##On the Back-End:

 TO BE IMPLEMENT

On appsettings.json is important to add the "stub" item as "true".

##Define LightApi:

  "LightApi": {
    "Profiles": {
      "Host": "http://localhost",
      "Port": "1072",
      "Telemetry": true,
      "stub" : true
    }

##Structure JSON file of stub:

 {
  "hotels": {
    "post": [
      {
        "serviceRoute": "/save",
        "request": {
            "HotelId": 0,
            "Name": "Sh360 Platinum Seattle",
            "Description": "Is a 5-Star luxury hotel located in Seattle which was opened in 1996. It has quality rooms and a modern, well equipped conference area which can host events of every kind for up to 100 persons. Its an ideal stopover on your journey. Is set in the heart of the lush is perfect for holiday or business. If you just wish to relax there are many walks, cycle rides or car excursions to local quaint and historical villages and towns in picturesque surroundings. If you don't feel like outdoor exercise you can relax either in our Finnish sauna, bio sauna, infrared sauna, jacuzzi. Or, if your feeling up to it, why not work out gently in the gym. After a relaxing dinner and a quiet drink in our Bistro bar sleep should be no problem in one of our cosy and comfortable rooms. Our young and friendly staff are here to welcome and serve you. Hope to see you soon!",
            "Address": {
              "Street": "501 Ucgaj Turnpike",
              "Latitude": 0,
              "Longitude": 0,
              "PostCode": "60515"
            }
          },
        "response": [
          {
            "HotelId": 1,
            "Name": "Sh360 Platinum Seattle",
            "Description": "Is a 5-Star luxury hotel located in Seattle which was opened in 1996. It has quality rooms and a modern, well equipped conference area which can host events of every kind for up to 100 persons. Its an ideal stopover on your journey. Is set in the heart of the lush is perfect for holiday or business. If you just wish to relax there are many walks, cycle rides or car excursions to local quaint and historical villages and towns in picturesque surroundings. If you don't feel like outdoor exercise you can relax either in our Finnish sauna, bio sauna, infrared sauna, jacuzzi. Or, if your feeling up to it, why not work out gently in the gym. After a relaxing dinner and a quiet drink in our Bistro bar sleep should be no problem in one of our cosy and comfortable rooms. Our young and friendly staff are here to welcome and serve you. Hope to see you soon!",
            "Address": {
              "Street": "501 Ucgaj Turnpike",
              "Latitude": 0,
              "Longitude": 0,
              "PostCode": "60515"
            }
          }
        ]
      }
    ],
    "get": [
      {
        "serviceRoute": "/1",
        "request": {
        },
        "response": [
          {
            "HotelId": 1,
            "Name": "Sh360 Platinum Seattle",
            "Description": "Is a 5-Star luxury hotel located in Seattle which was opened in 1996. It has quality rooms and a modern, well equipped conference area which can host events of every kind for up to 100 persons. Its an ideal stopover on your journey. Is set in the heart of the lush is perfect for holiday or business. If you just wish to relax there are many walks, cycle rides or car excursions to local quaint and historical villages and towns in picturesque surroundings. If you don't feel like outdoor exercise you can relax either in our Finnish sauna, bio sauna, infrared sauna, jacuzzi. Or, if your feeling up to it, why not work out gently in the gym. After a relaxing dinner and a quiet drink in our Bistro bar sleep should be no problem in one of our cosy and comfortable rooms. Our young and friendly staff are here to welcome and serve you. Hope to see you soon!",
            "Address": {
              "Street": "501 Ucgaj Turnpike",
              "Latitude": 0,
              "Longitude": 0,
              "PostCode": "60515"
            }
          }
        ]
      }
    ]
  }
}

Clone this wiki locally