A Node.js Single Page Application (SPA) that displays inspirational quotes from a custom Salesforce object.
- Fetches quotes from a Salesforce custom object via API
- Clean, responsive UI with card-based quote display
- Real-time loading states and error handling
- Express.js backend to proxy Salesforce API calls
- Node.js 18.x or higher
- A Salesforce account with API access
- A Salesforce Connected App for OAuth2 authentication (see Salesforce Setup below)
- A custom Quote object in Salesforce (see Salesforce Setup below)
-
Clone the repository:
git clone https://github.com/yourusername/WordsOfWisdom.git cd WordsOfWisdom -
Install dependencies:
npm install
-
Configure environment variables:
cp .env.example .env
Edit
.envwith your Salesforce credentials (see Configuration section). -
Start the application:
npm start
-
Open your browser and navigate to
http://localhost:3000
Create a .env file in the root directory with the following variables:
| Variable | Description |
|---|---|
SF_LOGIN_URL |
Salesforce login URL (default: https://login.salesforce.com). Use https://test.salesforce.com for sandbox orgs. |
SF_USERNAME |
Your Salesforce username |
SF_PASSWORD |
Your Salesforce password + security token |
SF_CLIENT_ID |
OAuth2 Consumer Key from your Connected App |
SF_CLIENT_SECRET |
OAuth2 Consumer Secret from your Connected App |
PORT |
Server port (default: 3000) |
This app relies on the availability of a Salesforce database. In order to create one and add your own quotes, please:
- Login to a Salesforce instance (Sign Up for a Developer Edition org if needed)
- Paste the following at the end of your Salesforce instance URL:
/packagingSetupUI/ipLanding.app?apvId=04t6S000000YP58QAG(this will install the Quotes custom object in the namespace the app expects) - Use installation key
2ddPaXrxUNE6rJ - Assign your user the
Quotescustom permission set - Navigate to the
Quotesapplication using the Salesforce App Launcher waffle - Enter your own quotes
This application uses OAuth2 Username-Password Flow for authentication. You need to create a Connected App in Salesforce:
- Go to Setup > App Manager > New Connected App
- Fill in the basic information:
- Connected App Name:
WordsOfWisdom - API Name:
WordsOfWisdom - Contact Email: Your email
- Connected App Name:
- Enable OAuth Settings:
- Check Enable OAuth Settings
- Callback URL:
https://login.salesforce.com/services/oauth2/callback(or your instance URL) - Selected OAuth Scopes: Add Full access (full) or at minimum Access and manage your data (api)
- Click Save and wait a few minutes for the app to be created
- Go to Manage Consumer Details to view and copy:
- Consumer Key → Use as
SF_CLIENT_ID - Consumer Secret → Use as
SF_CLIENT_SECRET
- Consumer Key → Use as
The application expects a custom Salesforce object with API name Quotes__Quote__c containing the following fields:
Quotes__Text__c(Long Text Area) - The quote textQuotes__Order__c(Number) - The display order for quotes
Add some quote records to your custom object with the Quotes__Text__c and Quotes__Order__c fields populated.
If you don't have a security token or need to reset it:
- Go to Settings > Reset My Security Token
- Append the security token to your password in the
.envfile
| Endpoint | Method | Description |
|---|---|---|
/api/quotes |
GET | Fetch all quotes from Salesforce |
/api/health |
GET | Health check endpoint |
WordsOfWisdom/
├── public/
│ ├── index.html # Main HTML page
│ ├── styles.css # Application styles
│ └── app.js # Frontend JavaScript
├── src/
│ ├── server.js # Express server
│ └── salesforceService.js # Salesforce API service
├── .env.example # Environment variables template
├── package.json # Node.js dependencies
└── README.md # This file
ISC
-
Open the repository in GitHub Codespaces (click Code > Codespaces > Create codespace on main)
-
Once the Codespace is ready, open the terminal and install dependencies:
npm install
-
Create your environment file:
cp .env.example .env
-
Edit
.envwith your Salesforce credentials:SF_LOGIN_URL=https://login.salesforce.com SF_USERNAME=your_username@example.com SF_PASSWORD=your_password_and_security_token SF_CLIENT_ID=your_connected_app_consumer_key SF_CLIENT_SECRET=your_connected_app_consumer_secret
-
Start the application:
npm start
-
Codespaces will prompt you to open the app in browser or forward the port. Click Open in Browser to view the application.
-
Install the Heroku CLI
-
Login and create app:
heroku login heroku create your-app-name
-
Set environment variables:
heroku config:set SF_LOGIN_URL=https://login.salesforce.com heroku config:set SF_USERNAME=your_username@example.com heroku config:set SF_PASSWORD=your_password_and_security_token heroku config:set SF_CLIENT_ID=your_connected_app_consumer_key heroku config:set SF_CLIENT_SECRET=your_connected_app_consumer_secret
-
Deploy:
git push heroku main
- Connect your GitHub repository to the hosting platform
- Set the environment variables (
SF_LOGIN_URL,SF_USERNAME,SF_PASSWORD,SF_CLIENT_ID,SF_CLIENT_SECRET) in the platform's dashboard - Deploy - most platforms auto-detect Node.js and run
npm start
-
SSH into your server and clone the repository:
git clone https://github.com/yourusername/WordsOfWisdom.git cd WordsOfWisdom -
Install Node.js (if not already installed) and dependencies:
npm install
-
Create and configure
.envfile with your Salesforce credentials -
Use a process manager like PM2 to run the app:
npm install -g pm2 pm2 start src/server.js --name wordsofwisdom
-
Set up a reverse proxy (nginx) to serve the app on port 80/443