A NestJS API for logging iPhone payments to MongoDB and Google Sheets
Efficient, serverless transaction tracking powered by Google Cloud Run and Shortcut automations.
This NestJS API serves as a serverless backend that enables:
- Generating access tokens via API keys.
- Receiving transaction data from an iOS Shortcut automation after Apple Pay events.
- Storing transactions in MongoDB.
- Appending them to a Google Spreadsheet.
Hosted on Google Cloud Run, it's fully scalable and optimized for event-driven usage.
- Framework: NestJS
- Database: MongoDB
- Spreadsheet Integration: Google Sheets API
- Hosting: Google Cloud Run
- Automation Trigger: Apple Shortcuts (on iPhone)
npm install
# Development mode
npm run start
# Watch mode
npm run start:dev
# Production build
npm run start:prod
# Unit tests
npm run test
# End-to-end tests
npm run test:e2e
# Test coverage
npm run test:cov
- Request Access Token
Send a POST request with your API key:
POST /auth/login
Content-Type: application/json
{
"secret_token": "your-api-key"
}
Response:
{
"access_token": "eyJhbGciOiJIUzI1NiIs..."
}
- Send a Transaction
Your iOS Shortcut sends a POST request like this:
POST /transactions
Authorization: Bearer <access_token>
Content-Type: application/json
{
"amount": 4.47,
"card": "Swile",
"currency": "EUR",
"date": "2025-05-05",
"location": "Dijon, Bourgogne-Franche-Compté",
"store": "ALDI"
}
- Shortcut automation triggers payment event.
- Sends data with the access token to the API.
- Transaction is saved to MongoDB.
- A new row is appended to your Google Spreadsheet.
This API runs on Google Cloud Run:
-
Build Docker image:
docker build -t gcr.io/YOUR_PROJECT_ID/your-app-name .
-
Push to Google Container Registry:
docker push gcr.io/YOUR_PROJECT_ID/your-app-name
-
Deploy:
gcloud run deploy your-app-name \ --image gcr.io/YOUR_PROJECT_ID/your-app-name \ --platform managed \ --region YOUR_REGION \ --allow-unauthenticated
Feel free to submit issues, suggest improvements, or fork and PR. The project welcomes any community input that improves reliability or usability.
This project is MIT licensed.