Serverless function to populate Remote Jobs for the RemoteJobs Android App
This Firebase Cloud Functions project aggregates remote job listings from multiple sources and provides them through a fast, cached API endpoint.
- RemoteOK - Remote jobs API
- WeWorkRemotely - Multiple RSS feeds for different categories
- Remotive - Remote jobs RSS feed
- Remote.co - Remote jobs RSS feed
- Web3Jobs - Web3 career API
The system uses a two-function architecture for optimal performance:
- Scheduled Function (
updateRemoteJobsCache) - Runs every hour to fetch and cache jobs - HTTP Function (
getRemoteJobs) - Serves cached data to clients
- Response Time: < 100ms (vs 10-30s before optimization)
- Cache Updates: Every hour via Cloud Scheduler
- Data Storage: Firestore with public read access
- Cost Reduction: ~90% reduction in execution costs
Returns cached remote job listings with metadata.
Response Format:
{
"jobs": [
{
"id": "string",
"company": "string",
"position": "string",
"date": "UTC timestamp",
"image": { "uri": "string" },
"description": "string",
"url": "string",
"tags": ["string"],
"source": "string",
"location": "string (optional)"
}
],
"metadata": {
"lastUpdated": "ISO timestamp",
"jobCount": 150,
"cacheAgeMinutes": 5,
"cacheStatus": "cached"
}
}Cache Status Values:
cached- Data served from Firestore cachelive-fetch- Cache didn't exist, fetched live datafallback-fetch- Cache read failed, fetched live data as fallback
- Node.js 22
- Firebase CLI
- Firebase project with Firestore enabled
- Billing enabled (required for Cloud Scheduler)
# Clone the repository
git clone https://github.com/flavioislima/RemoteJobsServerless.git
cd RemoteJobsServerless
# Install dependencies
cd functions
npm install# Start Firebase emulators
firebase emulators:start
# Functions will be available at:
# http://localhost:5001/YOUR-PROJECT/us-central1/getRemoteJobsSee TESTING.md for detailed testing instructions.
# Deploy Firestore rules and indexes
firebase deploy --only firestore:rules,firestore:indexes
# Deploy Cloud Functions
firebase deploy --only functions
# Manually trigger first cache update
gcloud scheduler jobs run firebase-schedule-updateRemoteJobsCache --location=us-central1See DEPLOYMENT.md for detailed deployment instructions.
RemoteJobsServerless/
├── functions/
│ ├── index.js # Main Cloud Functions code
│ ├── package.json # Node.js dependencies
│ └── .eslintrc # ESLint configuration
├── firestore.rules # Firestore security rules
├── firestore.indexes.json # Firestore indexes
├── firebase.json # Firebase configuration
├── DEPLOYMENT.md # Deployment guide
├── TESTING.md # Testing guide
└── README.md # This file
Helper function that fetches jobs from all sources, aggregates them, and returns formatted data with metadata.
Scheduled function that runs hourly to update the Firestore cache with fresh job data.
HTTP function that serves cached job data to clients with fallback to live fetching if cache is unavailable.
# All function logs
firebase functions:log
# Specific function
firebase functions:log --only updateRemoteJobsCache- Open Firebase Console
- Navigate to Firestore Database
- Check
remoteJobs/latestdocument - Review metadata for source status and timestamps
View scheduled job status:
gcloud scheduler jobs describe firebase-schedule-updateRemoteJobsCache --location=us-central1Modify the schedule in functions/index.js:
.pubsub.schedule('every 1 hours') // Current: hourly
// Options:
.pubsub.schedule('every 30 minutes') // Every 30 minutes
.pubsub.schedule('0 */2 * * *') // Every 2 hours
.pubsub.schedule('0 9 * * *') // Daily at 9 AM UTCAfter changing, redeploy:
firebase deploy --only functions:updateRemoteJobsCacheCheck Cloud Scheduler status and manually trigger:
gcloud scheduler jobs run firebase-schedule-updateRemoteJobsCache --location=us-central1- Verify cache exists in Firestore
- Check
cacheStatusin API response - Review function logs for errors
Individual source failures are normal and expected. The system continues operating with data from successful sources. Check the metadata.sources object in Firestore for per-source status.
- Firestore: ~$0.01-0.05/month (storage + operations)
- Cloud Scheduler: $0.10/month (1 job)
- Cloud Functions: ~$0.05-0.20/month (execution time)
Total: ~$0.15-0.35/month
- Fork the repository
- Create a feature branch
- Make your changes
- Test locally with emulators
- Submit a pull request
MIT License - see LICENSE file for details
- RemoteJobs Android App - Android client application
For issues or questions:
- Check TESTING.md and DEPLOYMENT.md
- Review Firebase Console logs
- Open an issue on GitHub