Skip to content

This project is based on Mulesoft Dataweave and Salesforce to provide secure, reliable, API access for all the Scores apps and projects. It is hosted on Anypoint and acts as the transactional hub, in concert with the authentication API

Notifications You must be signed in to change notification settings

AmericaSCORESBayArea/salesforce-data-api

Repository files navigation

salesforce-data-api 📡

Our core Mulesoft app was built to interact with Scores data in Salesforce database. In a few words, is a RESTful API server that allows us to perform CRUD operations on Salesforce objects. Yet we extend its functionality!



Development and Testing the app

For development and testing purposes, we have 2 IDEs:

  1. Anypoint Code Builder (based on VS Code)
  2. Anypoint Studio (based on Eclipse)

Code Builder is supposed to replace the Studio IDE, but it is still missing some functionality that would make development simpler. For small fixes, we use Code Builder. For adding new flows or introducing major changes, we use Anypoint Studio. Since anything can be achieved in either IDE, setting up just one should be sufficient.

Note: Code Builder offers both local and cloud-based versions.

Anypoint Code Builder Setup (based on local version)

  1. Download VS Code
  2. Install Mulesoft Extenssion Pack
  3. Clone the repository and open the folder
  4. Create local.properties file in the src/main/resources/properties folder (reach out to someone from America SCORES to get Sandbox properties):
http.listener.host=0.0.0.0
http.listener.port=8091
fullDomain=0.0.0.0:8091

api.id=
keystore.key.password=
keystore.password=
 
sfdc.user=
sfdc.url=
sfdc.tkn=
sfdc.password=

typeform.clientid=
typeform.clientsecret=
typeform.tkn=

slack.enabled=
slack.client_id=
slack.client_secret=    
  1. Configure Runtime
  • Add -M-Denv=local and -M-Danypoint.platform.gatekeeper=disabled to Default Runtime Arguments
  • Select Mule and Java versions (click on any xml file in src/main/mule -> "Set Versions" button should appear; if not, right-click on any xml file in src/main/mule and select Project Properties). At the moment, we use Mule 4.6.X and Java 17
  1. Install Java seperately (depends on the system, visit https://www.java.com)
  2. Using terminal, generate the a new key pair (public and private keys) and a self-signed certificate (required for HTTPS, even for local) AND move it to ./src/main/resources folder:
keytool -genkeypair -keystore keystore.jks \
  -dname "CN=localhost, OU=Unknown, O=America SCORES Bay Area, L=San Francisco, ST=California, C=US" \
  -keypass $YOUR_KEYPASS_PASSWORD$ \
  -storepass $YOUR_STOREPASS_PASSWORD$ \
  -keyalg RSA \
  -sigalg SHA256withRSA \
  -keysize 2048 \
  -alias mule \
  -ext SAN=DNS:localhost,IP:127.0.0.1 \
  -validity 9999

mv keystore.jks `/src/main/resources`
  1. Add $YOUR_KEYPASS_PASSWORD$ and $YOUR_STOREPASS_PASSWORD$ to the local.properties file into keystore.key.password and keystore.password fields

  2. Run the project using VS Code Start button (Debug Mule Application). Ta-da! 🚀

☁️ What if I want to run a cloud instance?

  1. Create Anypoint Platform Account
  2. Go to the main dashboard
  3. Under "Anypoint Code Builder", click Get Started button
  4. Accept the terms and conditions (if you agree)
  5. Click Launch button (if it's greyed out, refresh the page and wait)
  6. Wait for the environment to get allocated and load. The first time it might take a while

Anypoint Studio Setup

  1. Download Anypoint Studio
  2. Clone the repository and import the folder (salesfroce-data-api) WITHOUT copying the content to Studio's workspace
  3. Create local.properties file in the src/main/resources/properties folder (reach out to someone from America SCORES to get Sandbox properties):
http.listener.host=0.0.0.0
http.listener.port=8091
fullDomain=0.0.0.0:8091

api.id=
keystore.key.password=
keystore.password=
 
sfdc.user=
sfdc.url=
sfdc.tkn=
sfdc.password=

typeform.clientid=
typeform.clientsecret=
typeform.tkn=

slack.enabled=
slack.client_id=
slack.client_secret=    
  1. Configure Runtime
  • Right click on the project and select "Run As" -> "Run Configurations..."
  • Create a new configuration under "Mule Applications"
  • Select the project to launch: salesforce-data-api
  • Scroll down, click "Install Runtime" and install Mule Server 4.6.X. Once installed and the Studio is restarted (you can trace progress at the right bottom), go back to the menu and select the correct Mule server
  • Click "Apply"
  • Switch to 'Arguments' and add -M-Denv=local and -M-Danypoint.platform.gatekeeper=disabled to VM arguments
  • Click "Apply"
  • Switch to 'JRE' and make sure that 17+ version is selected
  • Close configurations window
  1. Install Java seperately (depends on the system, visit https://www.java.com)
  2. Using terminal, generate the a new key pair (public and private keys) and a self-signed certificate (required for HTTPS, even for local) AND move it to ./src/main/resources folder:
keytool -genkeypair -keystore keystore.jks \
  -dname "CN=localhost, OU=Unknown, O=America SCORES Bay Area, L=San Francisco, ST=California, C=US" \
  -keypass $YOUR_KEYPASS_PASSWORD$ \
  -storepass $YOUR_STOREPASS_PASSWORD$ \
  -keyalg RSA \
  -sigalg SHA256withRSA \
  -keysize 2048 \
  -alias mule \
  -ext SAN=DNS:localhost,IP:127.0.0.1 \
  -validity 9999

mv keystore.jks `/src/main/resources`
  1. Add $YOUR_KEYPASS_PASSWORD$ and $YOUR_STOREPASS_PASSWORD$ to the local.properties file into keystore.key.password and keystore.password fields

  2. Run the project using the run or debug buttons. Ta-da! 🚀

About

This project is based on Mulesoft Dataweave and Salesforce to provide secure, reliable, API access for all the Scores apps and projects. It is hosted on Anypoint and acts as the transactional hub, in concert with the authentication API

Topics

Resources

Security policy

Stars

Watchers

Forks

Packages

No packages published