4/21/2017 - 5:55 PM

Salesforce Org Local DB Mock REST API

Salesforce Org Local DB Mock REST API

Script purpose: to generate a json db schema file of all the sObjects you are using in your front-end app and accessing via the Salesforce REST API. Once json db schema file is generate, create fake data using it.

Script execution:

  • run a script in the terminal

  • when the script starts, ask for

    • instance url
    • token
  • once entered, ask for each sObject they'd like described

  • use curl to get json described data

  • go through each described sObject and ask the user which fields they'd like.

  • get each sObject and requested fields and create a massive JSON object that maps the sObjects from parent to child if needed.

  • generate a single json file (the db schema).

  • with the single json file, run it through faker to create fake data.

    • there needs to be a way to detect if there is a relationship field to then generate a file or files, then generate children of children files if necessary.
  • get the generated fake data and use json-server

    • JSON Server is a Node module, running an Express server, that let's you specify a JSON file to act as a data source for your mock REST API.