This API is primarily used by the Thrive Church Official App for serving users with content for both the Bible and our recorded / live sermons.
- .NET 8
- MongoDB
- ESV API
- Docker (for debugging and deployment)
Visiting ~/swagger/index.html in your browser will allow you to view the Swagger UI for the API and easily send API requests as well as view response objects.
Note: In general, the Caching that this application uses will expire thirty (30) seconds after an initial request. However, the persistent cache is set to expire after 48 hours from the initial request.
If you wish to poll this API for whether or not the LiveSermon object is still active, the response will contain the Expiration Time (in UTC) for the LiveSermon object. Using this you will be able to gague how much longer the stream will be active. This will prevent having to poll the route in a loop to determine if right now the time has passed.
The Thrive Church Official API takes advantage of Rate Limiting on all requests, and will count rejected requests towards subsequent limits.
More information about how this API handles rate limiting can be found within RateLimits.md
The API supports Docker-based debugging in Visual Studio, allowing you to debug the application running in a Linux container.
- Docker Desktop for Windows
- Visual Studio with Docker support
- .NET 8 SDK
- Open the solution in Visual Studio
- Select "Docker" profile from the debug dropdown
- Press F5 to start debugging
The API will be available at:
- Swagger UI: http://localhost:8080/swagger
- API Base: http://localhost:8080
- Host Port: 8080
- Container Port: 8080
- Mapping:
8080:8080
The Docker debug configuration requires the same environment variables as local development. Visual Studio will automatically mount your source code and configuration files into the container.
Required environment variables (set via User Secrets or environment):
MongoConnectionString- MongoDB connection stringJWT__SecretKey- JWT secret key for authenticationJWT__Issuer- JWT token issuerJWT__Audience- JWT token audienceS3__AccessKey- AWS S3 access key (if using S3)S3__SecretKey- AWS S3 secret key (if using S3)
- Dockerfile:
API/ThriveChurchOfficialAPI/ThriveChurchOfficialAPI/Dockerfile - Launch Settings:
API/ThriveChurchOfficialAPI/ThriveChurchOfficialAPI/Properties/launchSettings.json
- ✅ Full breakpoint support
- ✅ Hot reload enabled
- ✅ Source code mounted for live editing
- ✅ Visual Studio remote debugger (vsdbg)
- ✅ Swagger UI available during debugging
Port 8080 already in use?
# Check what's using port 8080
netstat -ano | findstr ":8080"
# Stop any Docker containers using the port
docker ps -a --filter "publish=8080" --format "{{.ID}}" | ForEach-Object { docker rm -f $_ }Container won't start?
- Ensure Docker Desktop is running
- Check Docker logs:
docker logs ThriveChurchOfficialAPI - Verify environment variables are set correctly
TIME_WAIT issues? Windows keeps ports in TIME_WAIT state for 120 seconds by default. You can reduce this to 30 seconds:
# Requires admin privileges and reboot
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters" `
-Name "TcpTimedWaitDelay" -Value 30 -PropertyType DWord -ForceThe API is deployed to AWS App Runner via GitHub Actions CI/CD pipeline.
- Container Registry: Amazon ECR
- Hosting: AWS App Runner (auto-scaling, automatic HTTPS)
- CI/CD: GitHub Actions (
.github/workflows/deploy.yml)
- Push to
masterbranch triggers GitHub Actions - Docker image is built using
API/ThriveChurchOfficialAPI/Dockerfile - Image is tagged with commit SHA and
latest, then pushed to ECR - App Runner automatically deploys the new image
| File | Purpose |
|---|---|
API/ThriveChurchOfficialAPI/Dockerfile |
Production builds (CI/CD) |
API/ThriveChurchOfficialAPI/ThriveChurchOfficialAPI/Dockerfile |
Local debugging (Visual Studio) |
The following secrets must be configured in GitHub repository settings:
| Secret | Description |
|---|---|
AWS_ACCESS_KEY_ID |
IAM user access key with ECR and App Runner permissions |
AWS_SECRET_ACCESS_KEY |
IAM user secret access key |
Configure these in the AWS App Runner console:
| Variable | Description |
|---|---|
MongoConnectionString |
MongoDB Atlas connection string |
HangfireConnectionString |
MongoDB connection for Hangfire jobs |
JWT__SecretKey |
JWT secret key (min 256 bits) |
JWT__Issuer |
JWT issuer (e.g., ThriveChurchOfficialAPI) |
JWT__Audience |
JWT audience (e.g., ThriveChurchClients) |
S3__BucketName |
AWS S3 bucket name |
S3__AccessKey |
AWS S3 access key |
S3__SecretKey |
AWS S3 secret key |
S3__Region |
AWS region (e.g., us-east-2) |
S3__BaseUrl |
S3 bucket base URL |
EsvApiKey |
ESV API key |
EmailPW |
Email password |
-
Create ECR Repository:
aws ecr create-repository --repository-name thrive-fl/thrivechurchofficialapi --region us-east-1
-
Create IAM User with policies:
AmazonEC2ContainerRegistryPowerUserAWSAppRunnerFullAccess
-
Add GitHub Secrets (Settings → Secrets → Actions)
-
Create App Runner Service:
- Source: Amazon ECR
- Repository: Your ECR repository ARN
- Deployment trigger: Automatic
- Port: 8080
- Add environment variables (see table above)
-
Configure Custom Domain (optional):
- Add custom domain in App Runner console
- Update DNS records in Route 53
The easiest way to get started is to use Docker debugging in Visual Studio (see Docker Development Setup above). Alternatively, you can run the API locally with .NET 8 SDK installed.
You will need to make sure you have the following settings in your AppSettings.json.
EsvApiKey- If you wish to connect to the ESV Api, you will need to request an Auth Token from the ESV API website. Simply include this token without "Token" for this setting.MongoConnectionString- Use this for connecting to your MongoDB instance; should contain the prefix "mongodb://".OverrideEsvApiKey- Use this setting to override a check for your ESV API Key.- Set to
"true"if you want to skip the ckeck for your API Key. - Set to
"false"if you want to use the PassagesController and make requests. NOTE: If this setting is set to false and no API Key is found, the application will throw an exception.
- Set to
IpRateLimiting- Use this for setting your configurable Rate Limiting settings. See RateLimits.md for more information.S3- Use this if you'd like to store your audio files in an S3 bucket. This can store your AWS credentials, but its recommended to in fact not do this for long-term access (we'll likely change this later to improve this for all sensitive options in AppSettings.json)."BucketName": "bucket-name","AccessKey": "AKIA...","SecretKey": "...","Region": "us-east-1","BaseUrl": "https://bucket-name.s3.us-east-1.amazonaws.com","MaxFileSizeMB": 50,"AllowedExtensions": [ ".mp3" ]
JWT- Required for Authentication - Use this for configuring JWT token authentication for protected API endpoints. All non-GET endpoints require valid JWT authentication."SecretKey": "YourSecureRandomKey256BitsLong"- CRITICAL: Use a cryptographically secure random key in production (minimum 256 bits)"Issuer": "YourIssuer"- Token issuer identifier"Audience": "YourAudience"- Token audience identifier"ExpirationMinutes": 60- JWT token expiration time in minutes"RefreshTokenExpirationDays": 7- Refresh token expiration time in days
The API uses JWT (JSON Web Token) authentication for all endpoints that modify data (POST, PUT, DELETE). GET endpoints remain public for read-only access.