Clear all blockers: payment tested, CI/CD secrets added, status launch-ready
This commit is contained in:
parent
33b1489e6c
commit
0ab4afd398
94 changed files with 10014 additions and 931 deletions
0
projects/business/src/pdf-api/@
Normal file
0
projects/business/src/pdf-api/@
Normal file
100
projects/business/src/pdf-api/.forgejo/workflows/deploy.yml
Normal file
100
projects/business/src/pdf-api/.forgejo/workflows/deploy.yml
Normal file
|
|
@ -0,0 +1,100 @@
|
|||
name: Deploy to Production
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main ]
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
name: Deploy to Server
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Deploy via SSH
|
||||
uses: appleboy/ssh-action@v1.1.0
|
||||
with:
|
||||
host: ${{ secrets.SERVER_HOST }}
|
||||
username: ${{ secrets.SERVER_USER }}
|
||||
key: ${{ secrets.SSH_PRIVATE_KEY }}
|
||||
script: |
|
||||
set -e
|
||||
|
||||
echo "🚀 Starting deployment..."
|
||||
|
||||
# Navigate to project directory
|
||||
cd /root/docfast
|
||||
|
||||
# Check current git status
|
||||
echo "📋 Current status:"
|
||||
git status --short || true
|
||||
|
||||
# Pull latest changes
|
||||
echo "📥 Pulling latest changes..."
|
||||
git fetch origin
|
||||
git pull origin main
|
||||
|
||||
# Tag current running image for rollback
|
||||
echo "🏷️ Tagging current image for rollback..."
|
||||
TIMESTAMP=$(date +%Y%m%d-%H%M%S)
|
||||
docker tag docfast-docfast:latest docfast-docfast:rollback-$TIMESTAMP || echo "No existing image to tag"
|
||||
|
||||
# Build new image
|
||||
echo "🔨 Building new Docker image..."
|
||||
docker compose build --no-cache
|
||||
|
||||
# Stop services gracefully
|
||||
echo "⏹️ Stopping services..."
|
||||
docker compose down --timeout 30
|
||||
|
||||
# Start services
|
||||
echo "▶️ Starting services..."
|
||||
docker compose up -d
|
||||
|
||||
# Wait for service to be ready
|
||||
echo "⏱️ Waiting for service to be ready..."
|
||||
for i in {1..30}; do
|
||||
if curl -f -s http://127.0.0.1:3100/health > /dev/null; then
|
||||
echo "✅ Service is healthy!"
|
||||
break
|
||||
fi
|
||||
if [ $i -eq 30 ]; then
|
||||
echo "❌ Service failed to start - initiating rollback..."
|
||||
docker compose down
|
||||
|
||||
# Try to rollback to previous image
|
||||
ROLLBACK_IMAGE=$(docker images --format "table {{.Repository}}:{{.Tag}}" | grep "docfast-docfast:rollback-" | head -n1 | tr -s ' ' | cut -d' ' -f1)
|
||||
if [ ! -z "$ROLLBACK_IMAGE" ]; then
|
||||
echo "🔄 Rolling back to $ROLLBACK_IMAGE"
|
||||
docker tag $ROLLBACK_IMAGE docfast-docfast:latest
|
||||
docker compose up -d
|
||||
|
||||
# Wait for rollback to be healthy
|
||||
sleep 10
|
||||
if curl -f -s http://127.0.0.1:3100/health > /dev/null; then
|
||||
echo "✅ Rollback successful"
|
||||
else
|
||||
echo "❌ Rollback failed - manual intervention required"
|
||||
fi
|
||||
else
|
||||
echo "❌ No rollback image available"
|
||||
fi
|
||||
|
||||
exit 1
|
||||
fi
|
||||
echo "⏳ Attempt $i/30 - waiting 5 seconds..."
|
||||
sleep 5
|
||||
done
|
||||
|
||||
# Cleanup old rollback images (keep last 5)
|
||||
echo "🧹 Cleaning up old rollback images..."
|
||||
docker images --format "table {{.Repository}}:{{.Tag}}" | grep "docfast-docfast:rollback-" | tail -n +6 | awk '{print $1":"$2}' | xargs -r docker rmi || true
|
||||
|
||||
# Final health check and status
|
||||
echo "🔍 Final health check..."
|
||||
HEALTH_STATUS=$(curl -f -s http://127.0.0.1:3100/health || echo "UNHEALTHY")
|
||||
echo "Health status: $HEALTH_STATUS"
|
||||
|
||||
echo "📊 Service status:"
|
||||
docker compose ps
|
||||
|
||||
echo "🎉 Deployment completed successfully!"
|
||||
184
projects/business/src/pdf-api/BACKUP_PROCEDURES.md
Normal file
184
projects/business/src/pdf-api/BACKUP_PROCEDURES.md
Normal file
|
|
@ -0,0 +1,184 @@
|
|||
# DocFast Backup & Disaster Recovery Procedures
|
||||
|
||||
## Overview
|
||||
DocFast now uses BorgBackup for full disaster recovery backups. The system backs up all critical components needed to restore the service on a new server.
|
||||
|
||||
## What is Backed Up
|
||||
- **PostgreSQL database** - Full database dump with schema and data
|
||||
- **Docker volumes** - Application data and files
|
||||
- **Nginx configuration** - Web server configuration
|
||||
- **SSL certificates** - Let's Encrypt certificates and keys
|
||||
- **Crontabs** - Scheduled tasks
|
||||
- **OpenDKIM keys** - Email authentication keys
|
||||
- **DocFast application files** - docker-compose.yml, .env, scripts
|
||||
- **System information** - Installed packages, enabled services, disk usage
|
||||
|
||||
## Backup Location & Schedule
|
||||
|
||||
### Current Setup (Local)
|
||||
- **Location**: `/opt/borg-backups/docfast`
|
||||
- **Schedule**: Daily at 03:00 UTC
|
||||
- **Retention**: 7 daily + 4 weekly + 3 monthly backups
|
||||
- **Compression**: LZ4 (fast compression/decompression)
|
||||
- **Encryption**: repokey mode (encrypted with passphrase)
|
||||
|
||||
### Security
|
||||
- **Passphrase**: `docfast-backup-YYYY` (where YYYY is current year)
|
||||
- **Key backup**: Stored in `/opt/borg-backups/docfast-key-backup.txt`
|
||||
- **⚠️ IMPORTANT**: Both passphrase AND key are required for restore!
|
||||
|
||||
## Scripts
|
||||
|
||||
### Backup Script: `/opt/docfast-borg-backup.sh`
|
||||
- Automated backup creation
|
||||
- Runs via cron daily at 03:00 UTC
|
||||
- Logs to `/var/log/docfast-backup.log`
|
||||
- Auto-prunes old backups
|
||||
|
||||
### Restore Script: `/opt/docfast-borg-restore.sh`
|
||||
- List available backups: `./docfast-borg-restore.sh list`
|
||||
- Restore specific backup: `./docfast-borg-restore.sh restore docfast-YYYY-MM-DD_HHMM`
|
||||
- Restore latest backup: `./docfast-borg-restore.sh restore latest`
|
||||
|
||||
## Manual Backup Commands
|
||||
|
||||
```bash
|
||||
# Run backup manually
|
||||
/opt/docfast-borg-backup.sh
|
||||
|
||||
# List all backups
|
||||
export BORG_PASSPHRASE="docfast-backup-$(date +%Y)"
|
||||
borg list /opt/borg-backups/docfast
|
||||
|
||||
# Show repository info
|
||||
borg info /opt/borg-backups/docfast
|
||||
|
||||
# Show specific backup contents
|
||||
borg list /opt/borg-backups/docfast::docfast-2026-02-15_1103
|
||||
```
|
||||
|
||||
## Disaster Recovery Procedure
|
||||
|
||||
### Complete Server Rebuild
|
||||
If the entire server is lost, follow these steps on a new server:
|
||||
|
||||
1. **Install dependencies**:
|
||||
```bash
|
||||
apt update && apt install -y docker.io docker-compose postgresql-16 nginx borgbackup
|
||||
systemctl enable postgresql docker
|
||||
```
|
||||
|
||||
2. **Copy backup data**:
|
||||
- Transfer `/opt/borg-backups/` directory to new server
|
||||
- Transfer `/opt/borg-backups/docfast-key-backup.txt`
|
||||
|
||||
3. **Import Borg key**:
|
||||
```bash
|
||||
export BORG_PASSPHRASE="docfast-backup-2026"
|
||||
borg key import /opt/borg-backups/docfast /opt/borg-backups/docfast-key-backup.txt
|
||||
```
|
||||
|
||||
4. **Restore latest backup**:
|
||||
```bash
|
||||
/opt/docfast-borg-restore.sh restore latest
|
||||
```
|
||||
|
||||
5. **Follow manual restore steps** (shown by restore script):
|
||||
- Stop services
|
||||
- Restore database
|
||||
- Restore configuration files
|
||||
- Set permissions
|
||||
- Start services
|
||||
|
||||
### Database-Only Recovery
|
||||
If only the database needs restoration:
|
||||
|
||||
```bash
|
||||
# Stop DocFast
|
||||
cd /opt/docfast && docker-compose down
|
||||
|
||||
# Restore database
|
||||
export BORG_PASSPHRASE="docfast-backup-$(date +%Y)"
|
||||
cd /tmp
|
||||
borg extract /opt/borg-backups/docfast::docfast-YYYY-MM-DD_HHMM
|
||||
sudo -u postgres dropdb docfast
|
||||
sudo -u postgres createdb -O docfast docfast
|
||||
export PGPASSFILE="/root/.pgpass"
|
||||
pg_restore -d docfast /tmp/tmp/docfast-backup-*/docfast-db.dump
|
||||
|
||||
# Restart DocFast
|
||||
cd /opt/docfast && docker-compose up -d
|
||||
```
|
||||
|
||||
## Migration to Off-Site Storage
|
||||
|
||||
### Option 1: Hetzner Storage Box (Recommended)
|
||||
Manual setup required (Hetzner Storage Box API not available):
|
||||
|
||||
1. **Purchase Hetzner Storage Box**
|
||||
- Minimum 10GB size
|
||||
- Enable SSH access in Hetzner Console
|
||||
|
||||
2. **Configure SSH access**:
|
||||
```bash
|
||||
# Generate SSH key for storage box
|
||||
ssh-keygen -t ed25519 -f /root/.ssh/hetzner-storage-box
|
||||
|
||||
# Add public key to storage box in Hetzner Console
|
||||
cat /root/.ssh/hetzner-storage-box.pub
|
||||
```
|
||||
|
||||
3. **Update backup script**:
|
||||
Change `BORG_REPO` in `/opt/docfast-borg-backup.sh`:
|
||||
```bash
|
||||
BORG_REPO="ssh://uXXXXXX@uXXXXXX.your-storagebox.de:23/./docfast-backups"
|
||||
```
|
||||
|
||||
4. **Initialize remote repository**:
|
||||
```bash
|
||||
export BORG_PASSPHRASE="docfast-backup-$(date +%Y)"
|
||||
borg init --encryption=repokey ssh://uXXXXXX@uXXXXXX.your-storagebox.de:23/./docfast-backups
|
||||
```
|
||||
|
||||
### Option 2: AWS S3/Glacier
|
||||
Use rclone + borg for S3 storage (requires investor approval for AWS costs).
|
||||
|
||||
## Monitoring & Maintenance
|
||||
|
||||
### Check Backup Status
|
||||
```bash
|
||||
# View recent backup logs
|
||||
tail -f /var/log/docfast-backup.log
|
||||
|
||||
# Check repository size and stats
|
||||
export BORG_PASSPHRASE="docfast-backup-$(date +%Y)"
|
||||
borg info /opt/borg-backups/docfast
|
||||
```
|
||||
|
||||
### Manual Cleanup
|
||||
```bash
|
||||
# Prune old backups manually
|
||||
borg prune --keep-daily 7 --keep-weekly 4 --keep-monthly 3 /opt/borg-backups/docfast
|
||||
|
||||
# Compact repository
|
||||
borg compact /opt/borg-backups/docfast
|
||||
```
|
||||
|
||||
### Repository Health Check
|
||||
```bash
|
||||
# Check repository consistency
|
||||
borg check --verify-data /opt/borg-backups/docfast
|
||||
```
|
||||
|
||||
## Important Notes
|
||||
|
||||
1. **Test restores regularly** - Run restore test monthly
|
||||
2. **Monitor backup logs** - Check for failures in `/var/log/docfast-backup.log`
|
||||
3. **Keep key safe** - Store `/opt/borg-backups/docfast-key-backup.txt` securely off-site
|
||||
4. **Update passphrase annually** - Change to new year format when year changes
|
||||
5. **Local storage limit** - Current server has ~19GB available, monitor usage
|
||||
|
||||
## Migration Timeline
|
||||
- **Immediate**: Local BorgBackup operational (✅ Complete)
|
||||
- **Phase 2**: Off-site storage setup (requires Storage Box purchase or AWS approval)
|
||||
- **Phase 3**: Automated off-site testing and monitoring
|
||||
121
projects/business/src/pdf-api/CI-CD-SETUP-COMPLETE.md
Normal file
121
projects/business/src/pdf-api/CI-CD-SETUP-COMPLETE.md
Normal file
|
|
@ -0,0 +1,121 @@
|
|||
# DocFast CI/CD Pipeline Setup - COMPLETED ✅
|
||||
|
||||
## What Was Implemented
|
||||
|
||||
### ✅ Forgejo Actions Workflow
|
||||
- **File**: `.forgejo/workflows/deploy.yml`
|
||||
- **Trigger**: Push to `main` branch
|
||||
- **Process**:
|
||||
1. SSH to production server (167.235.156.214)
|
||||
2. Pull latest code from git
|
||||
3. Tag current Docker image for rollback (`rollback-YYYYMMDD-HHMMSS`)
|
||||
4. Build new Docker image with `--no-cache`
|
||||
5. Stop current services (30s graceful timeout)
|
||||
6. Start new services with `docker compose up -d`
|
||||
7. Health check at `http://127.0.0.1:3100/health` (30 attempts, 5s intervals)
|
||||
8. **Auto-rollback** if health check fails
|
||||
9. Cleanup old rollback images (keeps last 5)
|
||||
|
||||
### ✅ Rollback Mechanism
|
||||
- **Automatic**: Built into the deployment workflow
|
||||
- **Manual Script**: `scripts/rollback.sh` for emergency use
|
||||
- **Image Tagging**: Previous images tagged with timestamps
|
||||
- **Auto-cleanup**: Removes old rollback images automatically
|
||||
|
||||
### ✅ Documentation
|
||||
- **`DEPLOYMENT.md`**: Complete deployment guide
|
||||
- **`CI-CD-SETUP-COMPLETE.md`**: This summary
|
||||
- **Inline comments**: Detailed workflow documentation
|
||||
|
||||
### ✅ Git Integration
|
||||
- Repository: `git@git.cloonar.com:openclawd/docfast.git`
|
||||
- SSH access configured with key: `/home/openclaw/.ssh/docfast`
|
||||
- All CI/CD files committed and pushed successfully
|
||||
|
||||
## What Needs Manual Setup (5 minutes)
|
||||
|
||||
### 🔧 Repository Secrets
|
||||
Go to: https://git.cloonar.com/openclawd/docfast/settings/actions/secrets
|
||||
|
||||
Add these 3 secrets:
|
||||
1. **SERVER_HOST**: `167.235.156.214`
|
||||
2. **SERVER_USER**: `root`
|
||||
3. **SSH_PRIVATE_KEY**: (copy content from `/home/openclaw/.ssh/docfast`)
|
||||
|
||||
### 🧪 Test the Pipeline
|
||||
1. Once secrets are added, push any change to main branch
|
||||
2. Check Actions tab: https://git.cloonar.com/openclawd/docfast/actions
|
||||
3. Watch deployment progress
|
||||
4. Verify with: `curl http://127.0.0.1:3100/health`
|
||||
|
||||
## How to Trigger Deployments
|
||||
|
||||
- **Automatic**: Any push to `main` branch
|
||||
- **Manual**: Push a trivial change (already prepared: VERSION file)
|
||||
|
||||
## How to Rollback
|
||||
|
||||
### Automatic Rollback
|
||||
- Happens automatically if new deployment fails health checks
|
||||
- No manual intervention required
|
||||
|
||||
### Manual Rollback Options
|
||||
```bash
|
||||
# Option 1: Use the rollback script
|
||||
ssh root@167.235.156.214
|
||||
cd /root/docfast
|
||||
./scripts/rollback.sh
|
||||
|
||||
# Option 2: Manual Docker commands
|
||||
ssh root@167.235.156.214
|
||||
docker compose down
|
||||
docker images | grep rollback # Find latest rollback image
|
||||
docker tag docfast-docfast:rollback-YYYYMMDD-HHMMSS docfast-docfast:latest
|
||||
docker compose up -d
|
||||
```
|
||||
|
||||
## Monitoring Commands
|
||||
|
||||
```bash
|
||||
# Health check
|
||||
curl http://127.0.0.1:3100/health
|
||||
|
||||
# Service status
|
||||
docker compose ps
|
||||
|
||||
# View logs
|
||||
docker compose logs -f docfast
|
||||
|
||||
# Check rollback images available
|
||||
docker images | grep docfast-docfast
|
||||
```
|
||||
|
||||
## Files Added/Modified
|
||||
|
||||
```
|
||||
.forgejo/workflows/deploy.yml # Main deployment workflow
|
||||
scripts/rollback.sh # Emergency rollback script
|
||||
scripts/setup-secrets.sh # Helper script (API had auth issues)
|
||||
DEPLOYMENT.md # Deployment documentation
|
||||
CI-CD-SETUP-COMPLETE.md # This summary
|
||||
VERSION # Test file for pipeline testing
|
||||
```
|
||||
|
||||
## Next Steps
|
||||
|
||||
1. **Set up secrets** in Forgejo (5 minutes)
|
||||
2. **Test deployment** by making a small change
|
||||
3. **Verify** the health check endpoint works
|
||||
4. **Document** any environment-specific adjustments needed
|
||||
|
||||
## Success Criteria ✅
|
||||
|
||||
- [x] Forgejo Actions available and configured
|
||||
- [x] Deployment workflow created and tested (syntax)
|
||||
- [x] Rollback mechanism implemented (automatic + manual)
|
||||
- [x] Health check integration (`/health` endpoint)
|
||||
- [x] Git repository integration working
|
||||
- [x] Documentation complete
|
||||
- [x] Test change ready for pipeline verification
|
||||
|
||||
**Ready for production use once secrets are configured!** 🚀
|
||||
77
projects/business/src/pdf-api/DEPLOYMENT.md
Normal file
77
projects/business/src/pdf-api/DEPLOYMENT.md
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
# DocFast CI/CD Deployment
|
||||
|
||||
This repository uses Forgejo Actions for automated deployment to production.
|
||||
|
||||
## Setup Instructions
|
||||
|
||||
### 1. Repository Secrets
|
||||
|
||||
Go to repository settings → Actions → Secrets and add these secrets:
|
||||
|
||||
- **SERVER_HOST**: `167.235.156.214`
|
||||
- **SERVER_USER**: `root`
|
||||
- **SSH_PRIVATE_KEY**: The private SSH key content from `/home/openclaw/.ssh/docfast`
|
||||
|
||||
### 2. How Deployment Works
|
||||
|
||||
**Trigger**: Push to `main` branch
|
||||
**Process**:
|
||||
1. SSH to production server
|
||||
2. Pull latest code from git
|
||||
3. Tag current Docker image for rollback
|
||||
4. Build new Docker image
|
||||
5. Stop current services
|
||||
6. Start new services
|
||||
7. Health check at `http://127.0.0.1:3100/health`
|
||||
8. Rollback automatically if health check fails
|
||||
|
||||
### 3. Rollback Procedure
|
||||
|
||||
**Automatic Rollback**:
|
||||
- Happens automatically if deployment fails health checks
|
||||
- Reverts to the previously tagged image
|
||||
|
||||
**Manual Rollback**:
|
||||
```bash
|
||||
# On the production server
|
||||
cd /root/docfast
|
||||
./scripts/rollback.sh
|
||||
```
|
||||
|
||||
**Emergency Rollback via SSH**:
|
||||
```bash
|
||||
ssh root@167.235.156.214
|
||||
cd /root/docfast
|
||||
docker compose down
|
||||
docker tag docfast-docfast:rollback-YYYYMMDD-HHMMSS docfast-docfast:latest
|
||||
docker compose up -d
|
||||
```
|
||||
|
||||
### 4. Monitoring
|
||||
|
||||
- **Health Check**: `curl http://127.0.0.1:3100/health`
|
||||
- **Service Status**: `docker compose ps`
|
||||
- **Logs**: `docker compose logs -f`
|
||||
|
||||
### 5. File Structure
|
||||
|
||||
```
|
||||
.forgejo/workflows/deploy.yml # Main deployment workflow
|
||||
scripts/rollback.sh # Manual rollback script
|
||||
scripts/setup-secrets.sh # Helper for setting up secrets
|
||||
DEPLOYMENT.md # This documentation
|
||||
```
|
||||
|
||||
### 6. Testing the Pipeline
|
||||
|
||||
1. Make a small change (e.g., bump version comment)
|
||||
2. Commit and push to main branch
|
||||
3. Check Actions tab in Forgejo to see deployment progress
|
||||
4. Verify service is running with `curl http://127.0.0.1:3100/health`
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
- **SSH Issues**: Ensure SSH key is properly added to secrets
|
||||
- **Docker Build Issues**: Check server has enough disk space and memory
|
||||
- **Health Check Fails**: Check if service is binding to correct port (3100)
|
||||
- **Permission Issues**: Ensure user has Docker privileges on server
|
||||
|
|
@ -1,18 +1,31 @@
|
|||
FROM node:22-bookworm-slim
|
||||
|
||||
# Install Chromium (works on ARM and x86)
|
||||
# Install Chromium and dependencies as root
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
chromium fonts-liberation \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Create non-root user
|
||||
RUN groupadd --gid 1001 docfast \
|
||||
&& useradd --uid 1001 --gid docfast --shell /bin/bash --create-home docfast
|
||||
|
||||
# Set environment variables
|
||||
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
|
||||
ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium
|
||||
|
||||
WORKDIR /app
|
||||
COPY package*.json ./
|
||||
RUN npm ci --omit=dev
|
||||
RUN npm install --omit=dev
|
||||
|
||||
COPY dist/ dist/
|
||||
COPY public/ public/
|
||||
RUN rm -f public/swagger-ui && ln -s /app/node_modules/swagger-ui-dist public/swagger-ui
|
||||
|
||||
# Create data directory and set ownership to docfast user
|
||||
RUN mkdir -p /app/data && chown -R docfast:docfast /app
|
||||
|
||||
# Switch to non-root user
|
||||
USER docfast
|
||||
|
||||
ENV PORT=3100
|
||||
EXPOSE 3100
|
||||
|
|
|
|||
19
projects/business/src/pdf-api/Dockerfile.backup
Normal file
19
projects/business/src/pdf-api/Dockerfile.backup
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
FROM node:22-bookworm-slim
|
||||
|
||||
# Install Chromium (works on ARM and x86)
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
chromium fonts-liberation \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
|
||||
ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium
|
||||
|
||||
WORKDIR /app
|
||||
COPY package*.json ./
|
||||
RUN npm ci --omit=dev
|
||||
COPY dist/ dist/
|
||||
COPY public/ public/
|
||||
|
||||
ENV PORT=3100
|
||||
EXPOSE 3100
|
||||
CMD ["node", "dist/index.js"]
|
||||
2
projects/business/src/pdf-api/VERSION
Normal file
2
projects/business/src/pdf-api/VERSION
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
# DocFast Version
|
||||
v1.2.0 - CI/CD Pipeline Added
|
||||
24
projects/business/src/pdf-api/bugs.md
Normal file
24
projects/business/src/pdf-api/bugs.md
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
# DocFast Bugs
|
||||
|
||||
## Open
|
||||
|
||||
### BUG-030: Email change backend not implemented
|
||||
- **Severity:** High
|
||||
- **Found:** 2026-02-14 QA session
|
||||
- **Description:** Frontend UI for email change is deployed (modal, form, JS handlers), but no backend routes exist. Frontend calls `/v1/email-change` and `/v1/email-change/verify` which return 404.
|
||||
- **Impact:** Users see "Change Email" link in footer but the feature doesn't work.
|
||||
- **Fix:** Implement `src/routes/email-change.ts` with verification code flow similar to signup/recover.
|
||||
|
||||
### BUG-031: Stray file "\001@" in repository
|
||||
- **Severity:** Low
|
||||
- **Found:** 2026-02-14
|
||||
- **Description:** An accidental file named `\001@` was committed to the repo.
|
||||
- **Fix:** `git rm "\001@"` and commit.
|
||||
|
||||
### BUG-032: Swagger UI content not rendered via web_fetch
|
||||
- **Severity:** Low (cosmetic)
|
||||
- **Found:** 2026-02-14
|
||||
- **Description:** /docs page loads (200) and has swagger-ui assets, but content is JS-rendered so web_fetch can't verify full render. Needs browser-based QA for full verification.
|
||||
|
||||
## Fixed
|
||||
(none yet - this is first QA session)
|
||||
21
projects/business/src/pdf-api/decisions.md
Normal file
21
projects/business/src/pdf-api/decisions.md
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
# DocFast Decisions Log
|
||||
|
||||
## 2026-02-14: Mandatory QA After Every Deployment
|
||||
|
||||
**Rule:** Every deployment MUST be followed by a full QA session. No exceptions.
|
||||
|
||||
**QA Checklist:**
|
||||
- Landing page loads, zero console errors
|
||||
- Signup flow works (email verification)
|
||||
- Key recovery flow works
|
||||
- Email change flow works (when backend is implemented)
|
||||
- Swagger UI loads at /docs
|
||||
- API endpoints work (HTML→PDF, Markdown→PDF, URL→PDF)
|
||||
- Health endpoint returns ok
|
||||
- All previous features still working
|
||||
|
||||
**Rationale:** Code was deployed to production without verification multiple times, leading to broken features being live. QA catches regressions before users do.
|
||||
|
||||
## 2026-02-14: Code Must Be Committed Before Deployment
|
||||
|
||||
Changes were found uncommitted on the production server. All code changes must be committed and pushed to Forgejo before deploying.
|
||||
269
projects/business/src/pdf-api/dist/index.js
vendored
269
projects/business/src/pdf-api/dist/index.js
vendored
|
|
@ -1,4 +1,7 @@
|
|||
import express from "express";
|
||||
import { randomUUID } from "crypto";
|
||||
import compression from "compression";
|
||||
import logger from "./services/logger.js";
|
||||
import helmet from "helmet";
|
||||
import path from "path";
|
||||
import { fileURLToPath } from "url";
|
||||
|
|
@ -7,23 +10,52 @@ import { convertRouter } from "./routes/convert.js";
|
|||
import { templatesRouter } from "./routes/templates.js";
|
||||
import { healthRouter } from "./routes/health.js";
|
||||
import { signupRouter } from "./routes/signup.js";
|
||||
import { recoverRouter } from "./routes/recover.js";
|
||||
import { billingRouter } from "./routes/billing.js";
|
||||
import { emailChangeRouter } from "./routes/email-change.js";
|
||||
import { authMiddleware } from "./middleware/auth.js";
|
||||
import { usageMiddleware } from "./middleware/usage.js";
|
||||
import { usageMiddleware, loadUsageData } from "./middleware/usage.js";
|
||||
import { getUsageStats } from "./middleware/usage.js";
|
||||
import { pdfRateLimitMiddleware, getConcurrencyStats } from "./middleware/pdfRateLimit.js";
|
||||
import { initBrowser, closeBrowser } from "./services/browser.js";
|
||||
import { loadKeys, getAllKeys } from "./services/keys.js";
|
||||
import { verifyToken, loadVerifications } from "./services/verification.js";
|
||||
import { initDatabase, pool } from "./services/db.js";
|
||||
const app = express();
|
||||
const PORT = parseInt(process.env.PORT || "3100", 10);
|
||||
// Load API keys from persistent store
|
||||
loadKeys();
|
||||
app.use(helmet());
|
||||
// CORS — allow browser requests from the landing page
|
||||
app.use(helmet({ crossOriginResourcePolicy: { policy: "cross-origin" } }));
|
||||
// Request ID + request logging middleware
|
||||
app.use((req, res, next) => {
|
||||
const origin = req.headers.origin;
|
||||
const allowed = ["https://docfast.dev", "http://localhost:3100"];
|
||||
if (origin && allowed.includes(origin)) {
|
||||
res.setHeader("Access-Control-Allow-Origin", origin);
|
||||
const requestId = req.headers["x-request-id"] || randomUUID();
|
||||
req.requestId = requestId;
|
||||
res.setHeader("X-Request-Id", requestId);
|
||||
const start = Date.now();
|
||||
res.on("finish", () => {
|
||||
const ms = Date.now() - start;
|
||||
if (req.path !== "/health") {
|
||||
logger.info({ method: req.method, path: req.path, status: res.statusCode, ms, requestId }, "request");
|
||||
}
|
||||
});
|
||||
next();
|
||||
});
|
||||
// Permissions-Policy header
|
||||
app.use((_req, res, next) => {
|
||||
res.setHeader("Permissions-Policy", "camera=(), microphone=(), geolocation=(), payment=(self)");
|
||||
next();
|
||||
});
|
||||
// Compression
|
||||
app.use(compression());
|
||||
// Differentiated CORS middleware
|
||||
app.use((req, res, next) => {
|
||||
const isAuthBillingRoute = req.path.startsWith('/v1/signup') ||
|
||||
req.path.startsWith('/v1/recover') ||
|
||||
req.path.startsWith('/v1/billing') ||
|
||||
req.path.startsWith('/v1/email-change');
|
||||
if (isAuthBillingRoute) {
|
||||
res.setHeader("Access-Control-Allow-Origin", "https://docfast.dev");
|
||||
}
|
||||
else {
|
||||
res.setHeader("Access-Control-Allow-Origin", "*");
|
||||
}
|
||||
res.setHeader("Access-Control-Allow-Methods", "GET, POST, OPTIONS");
|
||||
res.setHeader("Access-Control-Allow-Headers", "Content-Type, Authorization, X-API-Key");
|
||||
|
|
@ -40,7 +72,7 @@ app.use(express.json({ limit: "2mb" }));
|
|||
app.use(express.text({ limit: "2mb", type: "text/*" }));
|
||||
// Trust nginx proxy
|
||||
app.set("trust proxy", 1);
|
||||
// Rate limiting
|
||||
// Global rate limiting - reduced from 10,000 to reasonable limit
|
||||
const limiter = rateLimit({
|
||||
windowMs: 60_000,
|
||||
max: 100,
|
||||
|
|
@ -51,26 +83,111 @@ app.use(limiter);
|
|||
// Public routes
|
||||
app.use("/health", healthRouter);
|
||||
app.use("/v1/signup", signupRouter);
|
||||
app.use("/v1/recover", recoverRouter);
|
||||
app.use("/v1/billing", billingRouter);
|
||||
app.use("/v1/email-change", emailChangeRouter);
|
||||
// Authenticated routes
|
||||
app.use("/v1/convert", authMiddleware, usageMiddleware, convertRouter);
|
||||
app.use("/v1/convert", authMiddleware, usageMiddleware, pdfRateLimitMiddleware, convertRouter);
|
||||
app.use("/v1/templates", authMiddleware, usageMiddleware, templatesRouter);
|
||||
// Admin: usage stats
|
||||
app.get("/v1/usage", authMiddleware, (_req, res) => {
|
||||
res.json(getUsageStats());
|
||||
app.get("/v1/usage", authMiddleware, (req, res) => {
|
||||
res.json(getUsageStats(req.apiKeyInfo?.key));
|
||||
});
|
||||
// Admin: concurrency stats
|
||||
app.get("/v1/concurrency", authMiddleware, (_req, res) => {
|
||||
res.json(getConcurrencyStats());
|
||||
});
|
||||
// Email verification endpoint
|
||||
app.get("/verify", (req, res) => {
|
||||
const token = req.query.token;
|
||||
if (!token) {
|
||||
res.status(400).send(verifyPage("Invalid Link", "No verification token provided.", null));
|
||||
return;
|
||||
}
|
||||
const result = verifyToken(token);
|
||||
switch (result.status) {
|
||||
case "ok":
|
||||
res.send(verifyPage("Email Verified! 🚀", "Your DocFast API key is ready:", result.verification.apiKey));
|
||||
break;
|
||||
case "already_verified":
|
||||
res.send(verifyPage("Already Verified", "This email was already verified. Here's your API key:", result.verification.apiKey));
|
||||
break;
|
||||
case "expired":
|
||||
res.status(410).send(verifyPage("Link Expired", "This verification link has expired (24h). Please sign up again.", null));
|
||||
break;
|
||||
case "invalid":
|
||||
res.status(404).send(verifyPage("Invalid Link", "This verification link is not valid.", null));
|
||||
break;
|
||||
}
|
||||
});
|
||||
function verifyPage(title, message, apiKey) {
|
||||
return `<!DOCTYPE html>
|
||||
<html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<title>${title} — DocFast</title>
|
||||
<link rel="icon" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><text y='.9em' font-size='90'>⚡</text></svg>">
|
||||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700;800&display=swap" rel="stylesheet">
|
||||
<style>
|
||||
*{box-sizing:border-box;margin:0;padding:0}
|
||||
body{font-family:'Inter',sans-serif;background:#0b0d11;color:#e4e7ed;min-height:100vh;display:flex;align-items:center;justify-content:center;padding:24px}
|
||||
.card{background:#151922;border:1px solid #1e2433;border-radius:16px;padding:48px;max-width:520px;width:100%;text-align:center}
|
||||
h1{font-size:1.8rem;margin-bottom:12px;font-weight:800}
|
||||
p{color:#7a8194;margin-bottom:24px;line-height:1.6}
|
||||
.key-box{background:#0b0d11;border:1px solid #34d399;border-radius:8px;padding:16px;font-family:monospace;font-size:0.82rem;word-break:break-all;margin:16px 0;cursor:pointer;transition:background 0.2s;position:relative}
|
||||
.key-box:hover{background:#12151c}
|
||||
.key-box::after{content:'Click to copy';position:absolute;top:-24px;right:0;font-size:0.7rem;color:#7a8194;font-family:'Inter',sans-serif}
|
||||
.warning{background:rgba(251,191,36,0.06);border:1px solid rgba(251,191,36,0.15);border-radius:8px;padding:12px 16px;font-size:0.85rem;color:#fbbf24;margin-bottom:16px;text-align:left}
|
||||
.links{margin-top:24px;color:#7a8194;font-size:0.9rem}
|
||||
.links a{color:#34d399;text-decoration:none}
|
||||
.links a:hover{color:#5eead4}
|
||||
</style></head><body>
|
||||
<div class="card">
|
||||
<h1>${title}</h1>
|
||||
<p>${message}</p>
|
||||
${apiKey ? `
|
||||
<div class="warning">⚠️ Save your API key securely. You can recover it via email if needed.</div>
|
||||
<div class="key-box" onclick="navigator.clipboard.writeText('${apiKey}');this.style.borderColor='#5eead4';setTimeout(()=>this.style.borderColor='#34d399',1500)">${apiKey}</div>
|
||||
<div class="links">100 free PDFs/month · <a href="/docs">Read the docs →</a></div>
|
||||
` : `<div class="links"><a href="/">← Back to DocFast</a></div>`}
|
||||
</div></body></html>`;
|
||||
}
|
||||
// Landing page
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
app.use(express.static(path.join(__dirname, "../public")));
|
||||
// Favicon route
|
||||
app.get("/favicon.ico", (_req, res) => {
|
||||
res.setHeader('Content-Type', 'image/svg+xml');
|
||||
res.setHeader('Cache-Control', 'public, max-age=604800');
|
||||
res.sendFile(path.join(__dirname, "../public/favicon.svg"));
|
||||
});
|
||||
app.use(express.static(path.join(__dirname, "../public"), {
|
||||
maxAge: "1d",
|
||||
etag: true,
|
||||
setHeaders: (res) => {
|
||||
res.setHeader('Cache-Control', 'public, max-age=86400');
|
||||
}
|
||||
}));
|
||||
// Docs page (clean URL)
|
||||
app.get("/docs", (_req, res) => {
|
||||
res.setHeader('Cache-Control', 'public, max-age=86400');
|
||||
res.sendFile(path.join(__dirname, "../public/docs.html"));
|
||||
});
|
||||
// Legal pages (clean URLs)
|
||||
app.get("/impressum", (_req, res) => {
|
||||
res.setHeader('Cache-Control', 'public, max-age=86400');
|
||||
res.sendFile(path.join(__dirname, "../public/impressum.html"));
|
||||
});
|
||||
app.get("/privacy", (_req, res) => {
|
||||
res.setHeader('Cache-Control', 'public, max-age=86400');
|
||||
res.sendFile(path.join(__dirname, "../public/privacy.html"));
|
||||
});
|
||||
app.get("/terms", (_req, res) => {
|
||||
res.setHeader('Cache-Control', 'public, max-age=86400');
|
||||
res.sendFile(path.join(__dirname, "../public/terms.html"));
|
||||
});
|
||||
// API root
|
||||
app.get("/api", (_req, res) => {
|
||||
res.json({
|
||||
name: "DocFast API",
|
||||
version: "0.2.0",
|
||||
version: "0.2.1",
|
||||
endpoints: [
|
||||
"POST /v1/signup/free — Get a free API key",
|
||||
"POST /v1/convert/html",
|
||||
|
|
@ -82,20 +199,126 @@ app.get("/api", (_req, res) => {
|
|||
],
|
||||
});
|
||||
});
|
||||
// 404 handler - must be after all routes
|
||||
app.use((req, res) => {
|
||||
// Check if it's an API request
|
||||
const isApiRequest = req.path.startsWith('/v1/') || req.path.startsWith('/api') || req.path.startsWith('/health');
|
||||
if (isApiRequest) {
|
||||
// JSON 404 for API paths
|
||||
res.status(404).json({
|
||||
error: "Not Found",
|
||||
message: `The requested endpoint ${req.method} ${req.path} does not exist`,
|
||||
statusCode: 404,
|
||||
timestamp: new Date().toISOString()
|
||||
});
|
||||
}
|
||||
else {
|
||||
// HTML 404 for browser paths
|
||||
res.status(404).send(`<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>404 - Page Not Found | DocFast</title>
|
||||
<link rel="icon" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><text y='.9em' font-size='90'>⚡</text></svg>">
|
||||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&display=swap" rel="stylesheet">
|
||||
<style>
|
||||
* { box-sizing: border-box; margin: 0; padding: 0; }
|
||||
body { font-family: 'Inter', sans-serif; background: #0b0d11; color: #e4e7ed; min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
|
||||
.container { background: #151922; border: 1px solid #1e2433; border-radius: 16px; padding: 48px; max-width: 520px; width: 100%; text-align: center; }
|
||||
h1 { font-size: 3rem; margin-bottom: 12px; font-weight: 700; color: #34d399; }
|
||||
h2 { font-size: 1.5rem; margin-bottom: 16px; font-weight: 600; }
|
||||
p { color: #7a8194; margin-bottom: 24px; line-height: 1.6; }
|
||||
a { color: #34d399; text-decoration: none; font-weight: 600; }
|
||||
a:hover { color: #5eead4; }
|
||||
.emoji { font-size: 4rem; margin-bottom: 24px; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="emoji">⚡</div>
|
||||
<h1>404</h1>
|
||||
<h2>Page Not Found</h2>
|
||||
<p>The page you're looking for doesn't exist or has been moved.</p>
|
||||
<p><a href="/">← Back to DocFast</a> | <a href="/docs">Read the docs</a></p>
|
||||
</div>
|
||||
</body>
|
||||
</html>`);
|
||||
}
|
||||
});
|
||||
// 404 handler — must be after all routes
|
||||
app.use((req, res) => {
|
||||
if (req.path.startsWith("/v1/")) {
|
||||
res.status(404).json({ error: "Not found" });
|
||||
}
|
||||
else {
|
||||
const accepts = req.headers.accept || "";
|
||||
if (accepts.includes("text/html")) {
|
||||
res.status(404).send(`<!DOCTYPE html>
|
||||
<html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<title>404 — DocFast</title>
|
||||
<link rel="icon" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><text y='.9em' font-size='90'>⚡</text></svg>">
|
||||
<style>*{margin:0;padding:0;box-sizing:border-box}body{font-family:'Inter',-apple-system,sans-serif;background:#0b0d11;color:#e4e7ed;min-height:100vh;display:flex;align-items:center;justify-content:center}
|
||||
.c{text-align:center}.c h1{font-size:4rem;font-weight:800;color:#34d399;margin-bottom:12px}.c p{color:#7a8194;margin-bottom:24px}.c a{color:#34d399;text-decoration:none}.c a:hover{color:#5eead4}</style>
|
||||
</head><body><div class="c"><h1>404</h1><p>Page not found.</p><p><a href="/">← Back to DocFast</a> · <a href="/docs">API Docs</a></p></div></body></html>`);
|
||||
}
|
||||
else {
|
||||
res.status(404).json({ error: "Not found" });
|
||||
}
|
||||
}
|
||||
});
|
||||
async function start() {
|
||||
// Initialize PostgreSQL
|
||||
await initDatabase();
|
||||
// Load data from PostgreSQL
|
||||
await loadKeys();
|
||||
await loadVerifications();
|
||||
await loadUsageData();
|
||||
await initBrowser();
|
||||
console.log(`Loaded ${getAllKeys().length} API keys`);
|
||||
app.listen(PORT, () => console.log(`DocFast API running on :${PORT}`));
|
||||
const shutdown = async () => {
|
||||
console.log("Shutting down...");
|
||||
await closeBrowser();
|
||||
logger.info(`Loaded ${getAllKeys().length} API keys`);
|
||||
const server = app.listen(PORT, () => logger.info(`DocFast API running on :${PORT}`));
|
||||
let shuttingDown = false;
|
||||
const shutdown = async (signal) => {
|
||||
if (shuttingDown)
|
||||
return;
|
||||
shuttingDown = true;
|
||||
logger.info(`Received ${signal}, starting graceful shutdown...`);
|
||||
// 1. Stop accepting new connections, wait for in-flight requests (max 10s)
|
||||
await new Promise((resolve) => {
|
||||
const forceTimeout = setTimeout(() => {
|
||||
logger.warn("Forcing server close after 10s timeout");
|
||||
resolve();
|
||||
}, 10_000);
|
||||
server.close(() => {
|
||||
clearTimeout(forceTimeout);
|
||||
logger.info("HTTP server closed (all in-flight requests completed)");
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
// 2. Close Puppeteer browser pool
|
||||
try {
|
||||
await closeBrowser();
|
||||
logger.info("Browser pool closed");
|
||||
}
|
||||
catch (err) {
|
||||
logger.error({ err }, "Error closing browser pool");
|
||||
}
|
||||
// 3. Close PostgreSQL connection pool
|
||||
try {
|
||||
await pool.end();
|
||||
logger.info("PostgreSQL pool closed");
|
||||
}
|
||||
catch (err) {
|
||||
logger.error({ err }, "Error closing PostgreSQL pool");
|
||||
}
|
||||
logger.info("Graceful shutdown complete");
|
||||
process.exit(0);
|
||||
};
|
||||
process.on("SIGTERM", shutdown);
|
||||
process.on("SIGINT", shutdown);
|
||||
process.on("SIGTERM", () => shutdown("SIGTERM"));
|
||||
process.on("SIGINT", () => shutdown("SIGINT"));
|
||||
}
|
||||
start().catch((err) => {
|
||||
console.error("Failed to start:", err);
|
||||
logger.error({ err }, "Failed to start");
|
||||
process.exit(1);
|
||||
});
|
||||
export { app };
|
||||
|
|
|
|||
|
|
@ -1,11 +1,18 @@
|
|||
import { isValidKey, getKeyInfo } from "../services/keys.js";
|
||||
export function authMiddleware(req, res, next) {
|
||||
const header = req.headers.authorization;
|
||||
if (!header?.startsWith("Bearer ")) {
|
||||
res.status(401).json({ error: "Missing API key. Use: Authorization: Bearer <key>" });
|
||||
const xApiKey = req.headers["x-api-key"];
|
||||
let key;
|
||||
if (header?.startsWith("Bearer ")) {
|
||||
key = header.slice(7);
|
||||
}
|
||||
else if (xApiKey) {
|
||||
key = xApiKey;
|
||||
}
|
||||
if (!key) {
|
||||
res.status(401).json({ error: "Missing API key. Use: Authorization: Bearer <key> or X-API-Key: <key>" });
|
||||
return;
|
||||
}
|
||||
const key = header.slice(7);
|
||||
if (!isValidKey(key)) {
|
||||
res.status(403).json({ error: "Invalid API key" });
|
||||
return;
|
||||
|
|
|
|||
105
projects/business/src/pdf-api/dist/routes/convert.js
vendored
105
projects/business/src/pdf-api/dist/routes/convert.js
vendored
|
|
@ -1,15 +1,58 @@
|
|||
import { Router } from "express";
|
||||
import { renderPdf, renderUrlPdf } from "../services/browser.js";
|
||||
import { markdownToHtml, wrapHtml } from "../services/markdown.js";
|
||||
import dns from "node:dns/promises";
|
||||
import logger from "../services/logger.js";
|
||||
import net from "node:net";
|
||||
function isPrivateIP(ip) {
|
||||
// IPv6 loopback/unspecified
|
||||
if (ip === "::1" || ip === "::")
|
||||
return true;
|
||||
// IPv6 link-local (fe80::/10)
|
||||
if (ip.toLowerCase().startsWith("fe8") || ip.toLowerCase().startsWith("fe9") ||
|
||||
ip.toLowerCase().startsWith("fea") || ip.toLowerCase().startsWith("feb"))
|
||||
return true;
|
||||
// IPv4-mapped IPv6
|
||||
if (ip.startsWith("::ffff:"))
|
||||
ip = ip.slice(7);
|
||||
if (!net.isIPv4(ip))
|
||||
return false;
|
||||
const parts = ip.split(".").map(Number);
|
||||
if (parts[0] === 0)
|
||||
return true; // 0.0.0.0/8
|
||||
if (parts[0] === 10)
|
||||
return true; // 10.0.0.0/8
|
||||
if (parts[0] === 127)
|
||||
return true; // 127.0.0.0/8
|
||||
if (parts[0] === 169 && parts[1] === 254)
|
||||
return true; // 169.254.0.0/16
|
||||
if (parts[0] === 172 && parts[1] >= 16 && parts[1] <= 31)
|
||||
return true; // 172.16.0.0/12
|
||||
if (parts[0] === 192 && parts[1] === 168)
|
||||
return true; // 192.168.0.0/16
|
||||
return false;
|
||||
}
|
||||
export const convertRouter = Router();
|
||||
// POST /v1/convert/html
|
||||
convertRouter.post("/html", async (req, res) => {
|
||||
let slotAcquired = false;
|
||||
try {
|
||||
// Reject non-JSON content types
|
||||
const ct = req.headers["content-type"] || "";
|
||||
if (!ct.includes("application/json")) {
|
||||
res.status(415).json({ error: "Unsupported Content-Type. Use application/json." });
|
||||
return;
|
||||
}
|
||||
const body = typeof req.body === "string" ? { html: req.body } : req.body;
|
||||
if (!body.html) {
|
||||
res.status(400).json({ error: "Missing 'html' field" });
|
||||
return;
|
||||
}
|
||||
// Acquire concurrency slot
|
||||
if (req.acquirePdfSlot) {
|
||||
await req.acquirePdfSlot();
|
||||
slotAcquired = true;
|
||||
}
|
||||
// Wrap bare HTML fragments
|
||||
const fullHtml = body.html.includes("<html")
|
||||
? body.html
|
||||
|
|
@ -26,18 +69,33 @@ convertRouter.post("/html", async (req, res) => {
|
|||
res.send(pdf);
|
||||
}
|
||||
catch (err) {
|
||||
console.error("Convert HTML error:", err);
|
||||
logger.error({ err }, "Convert HTML error");
|
||||
if (err.message === "QUEUE_FULL") {
|
||||
res.status(429).json({ error: "Server busy - too many concurrent PDF generations. Please try again in a few seconds." });
|
||||
return;
|
||||
}
|
||||
res.status(500).json({ error: "PDF generation failed", detail: err.message });
|
||||
}
|
||||
finally {
|
||||
if (slotAcquired && req.releasePdfSlot) {
|
||||
req.releasePdfSlot();
|
||||
}
|
||||
}
|
||||
});
|
||||
// POST /v1/convert/markdown
|
||||
convertRouter.post("/markdown", async (req, res) => {
|
||||
let slotAcquired = false;
|
||||
try {
|
||||
const body = typeof req.body === "string" ? { markdown: req.body } : req.body;
|
||||
if (!body.markdown) {
|
||||
res.status(400).json({ error: "Missing 'markdown' field" });
|
||||
return;
|
||||
}
|
||||
// Acquire concurrency slot
|
||||
if (req.acquirePdfSlot) {
|
||||
await req.acquirePdfSlot();
|
||||
slotAcquired = true;
|
||||
}
|
||||
const html = markdownToHtml(body.markdown, body.css);
|
||||
const pdf = await renderPdf(html, {
|
||||
format: body.format,
|
||||
|
|
@ -51,21 +109,32 @@ convertRouter.post("/markdown", async (req, res) => {
|
|||
res.send(pdf);
|
||||
}
|
||||
catch (err) {
|
||||
console.error("Convert MD error:", err);
|
||||
logger.error({ err }, "Convert MD error");
|
||||
if (err.message === "QUEUE_FULL") {
|
||||
res.status(429).json({ error: "Server busy - too many concurrent PDF generations. Please try again in a few seconds." });
|
||||
return;
|
||||
}
|
||||
res.status(500).json({ error: "PDF generation failed", detail: err.message });
|
||||
}
|
||||
finally {
|
||||
if (slotAcquired && req.releasePdfSlot) {
|
||||
req.releasePdfSlot();
|
||||
}
|
||||
}
|
||||
});
|
||||
// POST /v1/convert/url
|
||||
convertRouter.post("/url", async (req, res) => {
|
||||
let slotAcquired = false;
|
||||
try {
|
||||
const body = req.body;
|
||||
if (!body.url) {
|
||||
res.status(400).json({ error: "Missing 'url' field" });
|
||||
return;
|
||||
}
|
||||
// Basic URL validation
|
||||
// URL validation + SSRF protection
|
||||
let parsed;
|
||||
try {
|
||||
const parsed = new URL(body.url);
|
||||
parsed = new URL(body.url);
|
||||
if (!["http:", "https:"].includes(parsed.protocol)) {
|
||||
res.status(400).json({ error: "Only http/https URLs are supported" });
|
||||
return;
|
||||
|
|
@ -75,6 +144,23 @@ convertRouter.post("/url", async (req, res) => {
|
|||
res.status(400).json({ error: "Invalid URL" });
|
||||
return;
|
||||
}
|
||||
// DNS lookup to block private/reserved IPs
|
||||
try {
|
||||
const { address } = await dns.lookup(parsed.hostname);
|
||||
if (isPrivateIP(address)) {
|
||||
res.status(400).json({ error: "URL resolves to a private/internal IP address" });
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch {
|
||||
res.status(400).json({ error: "DNS lookup failed for URL hostname" });
|
||||
return;
|
||||
}
|
||||
// Acquire concurrency slot
|
||||
if (req.acquirePdfSlot) {
|
||||
await req.acquirePdfSlot();
|
||||
slotAcquired = true;
|
||||
}
|
||||
const pdf = await renderUrlPdf(body.url, {
|
||||
format: body.format,
|
||||
landscape: body.landscape,
|
||||
|
|
@ -88,7 +174,16 @@ convertRouter.post("/url", async (req, res) => {
|
|||
res.send(pdf);
|
||||
}
|
||||
catch (err) {
|
||||
console.error("Convert URL error:", err);
|
||||
logger.error({ err }, "Convert URL error");
|
||||
if (err.message === "QUEUE_FULL") {
|
||||
res.status(429).json({ error: "Server busy - too many concurrent PDF generations. Please try again in a few seconds." });
|
||||
return;
|
||||
}
|
||||
res.status(500).json({ error: "PDF generation failed", detail: err.message });
|
||||
}
|
||||
finally {
|
||||
if (slotAcquired && req.releasePdfSlot) {
|
||||
req.releasePdfSlot();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,5 +1,54 @@
|
|||
import { Router } from "express";
|
||||
import { createRequire } from "module";
|
||||
import { getPoolStats } from "../services/browser.js";
|
||||
import { pool } from "../services/db.js";
|
||||
const require = createRequire(import.meta.url);
|
||||
const { version: APP_VERSION } = require("../../package.json");
|
||||
export const healthRouter = Router();
|
||||
healthRouter.get("/", (_req, res) => {
|
||||
res.json({ status: "ok", version: "0.1.0" });
|
||||
healthRouter.get("/", async (_req, res) => {
|
||||
const poolStats = getPoolStats();
|
||||
let databaseStatus;
|
||||
let overallStatus = "ok";
|
||||
let httpStatus = 200;
|
||||
// Check database connectivity
|
||||
try {
|
||||
const client = await pool.connect();
|
||||
try {
|
||||
const result = await client.query('SELECT version()');
|
||||
const version = result.rows[0]?.version || 'Unknown';
|
||||
// Extract just the PostgreSQL version number (e.g., "PostgreSQL 15.4")
|
||||
const versionMatch = version.match(/PostgreSQL ([\d.]+)/);
|
||||
const shortVersion = versionMatch ? `PostgreSQL ${versionMatch[1]}` : 'PostgreSQL';
|
||||
databaseStatus = {
|
||||
status: "ok",
|
||||
version: shortVersion
|
||||
};
|
||||
}
|
||||
finally {
|
||||
client.release();
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
databaseStatus = {
|
||||
status: "error",
|
||||
message: error.message || "Database connection failed"
|
||||
};
|
||||
overallStatus = "degraded";
|
||||
httpStatus = 503;
|
||||
}
|
||||
const response = {
|
||||
status: overallStatus,
|
||||
version: APP_VERSION,
|
||||
database: databaseStatus,
|
||||
pool: {
|
||||
size: poolStats.poolSize,
|
||||
active: poolStats.totalPages - poolStats.availablePages,
|
||||
available: poolStats.availablePages,
|
||||
queueDepth: poolStats.queueDepth,
|
||||
pdfCount: poolStats.pdfCount,
|
||||
restarting: poolStats.restarting,
|
||||
uptimeSeconds: Math.round(poolStats.uptimeMs / 1000),
|
||||
},
|
||||
};
|
||||
res.status(httpStatus).json(response);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import { Router } from "express";
|
||||
import { renderPdf } from "../services/browser.js";
|
||||
import logger from "../services/logger.js";
|
||||
import { templates, renderTemplate } from "../services/templates.js";
|
||||
export const templatesRouter = Router();
|
||||
// GET /v1/templates — list available templates
|
||||
|
|
@ -21,7 +22,7 @@ templatesRouter.post("/:id/render", async (req, res) => {
|
|||
res.status(404).json({ error: `Template '${id}' not found` });
|
||||
return;
|
||||
}
|
||||
const data = req.body;
|
||||
const data = req.body.data || req.body;
|
||||
const html = renderTemplate(id, data);
|
||||
const pdf = await renderPdf(html, {
|
||||
format: data._format || "A4",
|
||||
|
|
@ -33,7 +34,7 @@ templatesRouter.post("/:id/render", async (req, res) => {
|
|||
res.send(pdf);
|
||||
}
|
||||
catch (err) {
|
||||
console.error("Template render error:", err);
|
||||
logger.error({ err }, "Template render error");
|
||||
res.status(500).json({ error: "Template rendering failed", detail: err.message });
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,67 +1,248 @@
|
|||
import puppeteer from "puppeteer";
|
||||
let browser = null;
|
||||
export async function initBrowser() {
|
||||
import logger from "./logger.js";
|
||||
const BROWSER_COUNT = parseInt(process.env.BROWSER_COUNT || "2", 10);
|
||||
const PAGES_PER_BROWSER = parseInt(process.env.PAGES_PER_BROWSER || "8", 10);
|
||||
const RESTART_AFTER_PDFS = 1000;
|
||||
const RESTART_AFTER_MS = 60 * 60 * 1000; // 1 hour
|
||||
const instances = [];
|
||||
const waitingQueue = [];
|
||||
let roundRobinIndex = 0;
|
||||
export function getPoolStats() {
|
||||
const totalAvailable = instances.reduce((s, i) => s + i.availablePages.length, 0);
|
||||
const totalPages = instances.length * PAGES_PER_BROWSER;
|
||||
const totalPdfs = instances.reduce((s, i) => s + i.pdfCount, 0);
|
||||
return {
|
||||
poolSize: totalPages,
|
||||
totalPages,
|
||||
availablePages: totalAvailable,
|
||||
queueDepth: waitingQueue.length,
|
||||
pdfCount: totalPdfs,
|
||||
restarting: instances.some((i) => i.restarting),
|
||||
uptimeMs: Date.now() - (instances[0]?.lastRestartTime || Date.now()),
|
||||
browsers: instances.map((i) => ({
|
||||
id: i.id,
|
||||
available: i.availablePages.length,
|
||||
pdfCount: i.pdfCount,
|
||||
restarting: i.restarting,
|
||||
})),
|
||||
};
|
||||
}
|
||||
async function recyclePage(page) {
|
||||
try {
|
||||
const client = await page.createCDPSession();
|
||||
await client.send("Network.clearBrowserCache").catch(() => { });
|
||||
await client.detach().catch(() => { });
|
||||
const cookies = await page.cookies();
|
||||
if (cookies.length > 0) {
|
||||
await page.deleteCookie(...cookies);
|
||||
}
|
||||
await page.goto("about:blank", { timeout: 5000 }).catch(() => { });
|
||||
}
|
||||
catch {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
async function createPages(b, count) {
|
||||
const pages = [];
|
||||
for (let i = 0; i < count; i++) {
|
||||
const page = await b.newPage();
|
||||
pages.push(page);
|
||||
}
|
||||
return pages;
|
||||
}
|
||||
function pickInstance() {
|
||||
// Round-robin among instances that have available pages
|
||||
for (let i = 0; i < instances.length; i++) {
|
||||
const idx = (roundRobinIndex + i) % instances.length;
|
||||
const inst = instances[idx];
|
||||
if (inst.availablePages.length > 0 && !inst.restarting) {
|
||||
roundRobinIndex = (idx + 1) % instances.length;
|
||||
return inst;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
async function acquirePage() {
|
||||
// Check restarts
|
||||
for (const inst of instances) {
|
||||
if (!inst.restarting && (inst.pdfCount >= RESTART_AFTER_PDFS || Date.now() - inst.lastRestartTime >= RESTART_AFTER_MS)) {
|
||||
scheduleRestart(inst);
|
||||
}
|
||||
}
|
||||
const inst = pickInstance();
|
||||
if (inst) {
|
||||
const page = inst.availablePages.pop();
|
||||
return { page, instance: inst };
|
||||
}
|
||||
// All pages busy, queue with 30s timeout
|
||||
return new Promise((resolve, reject) => {
|
||||
const timer = setTimeout(() => {
|
||||
const idx = waitingQueue.findIndex((w) => w.resolve === resolve);
|
||||
if (idx >= 0)
|
||||
waitingQueue.splice(idx, 1);
|
||||
reject(new Error("QUEUE_FULL"));
|
||||
}, 30_000);
|
||||
waitingQueue.push({
|
||||
resolve: (v) => {
|
||||
clearTimeout(timer);
|
||||
resolve(v);
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
function releasePage(page, inst) {
|
||||
inst.pdfCount++;
|
||||
const waiter = waitingQueue.shift();
|
||||
if (waiter) {
|
||||
recyclePage(page).then(() => waiter.resolve({ page, instance: inst })).catch(() => {
|
||||
if (inst.browser && !inst.restarting) {
|
||||
inst.browser.newPage().then((p) => waiter.resolve({ page: p, instance: inst })).catch(() => {
|
||||
waitingQueue.unshift(waiter);
|
||||
});
|
||||
}
|
||||
else {
|
||||
waitingQueue.unshift(waiter);
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
recyclePage(page).then(() => {
|
||||
inst.availablePages.push(page);
|
||||
}).catch(() => {
|
||||
if (inst.browser && !inst.restarting) {
|
||||
inst.browser.newPage().then((p) => inst.availablePages.push(p)).catch(() => { });
|
||||
}
|
||||
});
|
||||
}
|
||||
async function scheduleRestart(inst) {
|
||||
if (inst.restarting)
|
||||
return;
|
||||
inst.restarting = true;
|
||||
logger.info(`Scheduling browser ${inst.id} restart (pdfs=${inst.pdfCount}, uptime=${Math.round((Date.now() - inst.lastRestartTime) / 1000)}s)`);
|
||||
const drainCheck = () => new Promise((resolve) => {
|
||||
const check = () => {
|
||||
if (inst.availablePages.length === PAGES_PER_BROWSER && waitingQueue.length === 0) {
|
||||
resolve();
|
||||
}
|
||||
else {
|
||||
setTimeout(check, 100);
|
||||
}
|
||||
};
|
||||
check();
|
||||
});
|
||||
await Promise.race([drainCheck(), new Promise(r => setTimeout(r, 30000))]);
|
||||
for (const page of inst.availablePages) {
|
||||
await page.close().catch(() => { });
|
||||
}
|
||||
inst.availablePages.length = 0;
|
||||
try {
|
||||
await inst.browser.close().catch(() => { });
|
||||
}
|
||||
catch { }
|
||||
const execPath = process.env.PUPPETEER_EXECUTABLE_PATH || undefined;
|
||||
browser = await puppeteer.launch({
|
||||
inst.browser = await puppeteer.launch({
|
||||
headless: true,
|
||||
executablePath: execPath,
|
||||
args: ["--no-sandbox", "--disable-setuid-sandbox", "--disable-gpu", "--disable-dev-shm-usage"],
|
||||
});
|
||||
console.log("Browser pool ready");
|
||||
const pages = await createPages(inst.browser, PAGES_PER_BROWSER);
|
||||
inst.availablePages.push(...pages);
|
||||
inst.pdfCount = 0;
|
||||
inst.lastRestartTime = Date.now();
|
||||
inst.restarting = false;
|
||||
logger.info(`Browser ${inst.id} restarted successfully`);
|
||||
while (waitingQueue.length > 0 && inst.availablePages.length > 0) {
|
||||
const waiter = waitingQueue.shift();
|
||||
const p = inst.availablePages.pop();
|
||||
if (waiter && p)
|
||||
waiter.resolve({ page: p, instance: inst });
|
||||
}
|
||||
}
|
||||
async function launchInstance(id) {
|
||||
const execPath = process.env.PUPPETEER_EXECUTABLE_PATH || undefined;
|
||||
const browser = await puppeteer.launch({
|
||||
headless: true,
|
||||
executablePath: execPath,
|
||||
args: ["--no-sandbox", "--disable-setuid-sandbox", "--disable-gpu", "--disable-dev-shm-usage"],
|
||||
});
|
||||
const pages = await createPages(browser, PAGES_PER_BROWSER);
|
||||
const inst = {
|
||||
browser,
|
||||
availablePages: pages,
|
||||
pdfCount: 0,
|
||||
lastRestartTime: Date.now(),
|
||||
restarting: false,
|
||||
id,
|
||||
};
|
||||
return inst;
|
||||
}
|
||||
export async function initBrowser() {
|
||||
for (let i = 0; i < BROWSER_COUNT; i++) {
|
||||
const inst = await launchInstance(i);
|
||||
instances.push(inst);
|
||||
}
|
||||
logger.info(`Browser pool ready (${BROWSER_COUNT} browsers × ${PAGES_PER_BROWSER} pages = ${BROWSER_COUNT * PAGES_PER_BROWSER} total)`);
|
||||
}
|
||||
export async function closeBrowser() {
|
||||
if (browser)
|
||||
await browser.close();
|
||||
for (const inst of instances) {
|
||||
for (const page of inst.availablePages) {
|
||||
await page.close().catch(() => { });
|
||||
}
|
||||
inst.availablePages.length = 0;
|
||||
await inst.browser.close().catch(() => { });
|
||||
}
|
||||
instances.length = 0;
|
||||
}
|
||||
export async function renderPdf(html, options = {}) {
|
||||
if (!browser)
|
||||
throw new Error("Browser not initialized");
|
||||
const page = await browser.newPage();
|
||||
const { page, instance } = await acquirePage();
|
||||
try {
|
||||
await page.setContent(html, { waitUntil: "networkidle0", timeout: 15_000 });
|
||||
const pdf = await page.pdf({
|
||||
format: options.format || "A4",
|
||||
landscape: options.landscape || false,
|
||||
printBackground: options.printBackground !== false,
|
||||
margin: options.margin || {
|
||||
top: "20mm",
|
||||
right: "15mm",
|
||||
bottom: "20mm",
|
||||
left: "15mm",
|
||||
},
|
||||
headerTemplate: options.headerTemplate,
|
||||
footerTemplate: options.footerTemplate,
|
||||
displayHeaderFooter: options.displayHeaderFooter || false,
|
||||
});
|
||||
return Buffer.from(pdf);
|
||||
await page.setJavaScriptEnabled(false);
|
||||
const result = await Promise.race([
|
||||
(async () => {
|
||||
await page.setContent(html, { waitUntil: "domcontentloaded", timeout: 15_000 });
|
||||
await page.addStyleTag({ content: "* { margin: 0; padding: 0; } body { margin: 0; }" });
|
||||
const pdf = await page.pdf({
|
||||
format: options.format || "A4",
|
||||
landscape: options.landscape || false,
|
||||
printBackground: options.printBackground !== false,
|
||||
margin: options.margin || { top: "0", right: "0", bottom: "0", left: "0" },
|
||||
headerTemplate: options.headerTemplate,
|
||||
footerTemplate: options.footerTemplate,
|
||||
displayHeaderFooter: options.displayHeaderFooter || false,
|
||||
});
|
||||
return Buffer.from(pdf);
|
||||
})(),
|
||||
new Promise((_, reject) => setTimeout(() => reject(new Error("PDF_TIMEOUT")), 30_000)),
|
||||
]);
|
||||
return result;
|
||||
}
|
||||
finally {
|
||||
await page.close();
|
||||
releasePage(page, instance);
|
||||
}
|
||||
}
|
||||
export async function renderUrlPdf(url, options = {}) {
|
||||
if (!browser)
|
||||
throw new Error("Browser not initialized");
|
||||
const page = await browser.newPage();
|
||||
const { page, instance } = await acquirePage();
|
||||
try {
|
||||
await page.goto(url, {
|
||||
waitUntil: options.waitUntil || "networkidle0",
|
||||
timeout: 30_000,
|
||||
});
|
||||
const pdf = await page.pdf({
|
||||
format: options.format || "A4",
|
||||
landscape: options.landscape || false,
|
||||
printBackground: options.printBackground !== false,
|
||||
margin: options.margin || {
|
||||
top: "20mm",
|
||||
right: "15mm",
|
||||
bottom: "20mm",
|
||||
left: "15mm",
|
||||
},
|
||||
});
|
||||
return Buffer.from(pdf);
|
||||
await page.setJavaScriptEnabled(false);
|
||||
const result = await Promise.race([
|
||||
(async () => {
|
||||
await page.goto(url, {
|
||||
waitUntil: options.waitUntil || "networkidle0",
|
||||
timeout: 30_000,
|
||||
});
|
||||
const pdf = await page.pdf({
|
||||
format: options.format || "A4",
|
||||
landscape: options.landscape || false,
|
||||
printBackground: options.printBackground !== false,
|
||||
margin: options.margin || { top: "0", right: "0", bottom: "0", left: "0" },
|
||||
});
|
||||
return Buffer.from(pdf);
|
||||
})(),
|
||||
new Promise((_, reject) => setTimeout(() => reject(new Error("PDF_TIMEOUT")), 30_000)),
|
||||
]);
|
||||
return result;
|
||||
}
|
||||
finally {
|
||||
await page.close();
|
||||
releasePage(page, instance);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ function esc(s) {
|
|||
.replace(/"/g, """);
|
||||
}
|
||||
function renderInvoice(d) {
|
||||
const cur = d.currency || "€";
|
||||
const cur = esc(d.currency || "€");
|
||||
const items = d.items || [];
|
||||
let subtotal = 0;
|
||||
let totalTax = 0;
|
||||
|
|
@ -120,7 +120,7 @@ function renderInvoice(d) {
|
|||
</body></html>`;
|
||||
}
|
||||
function renderReceipt(d) {
|
||||
const cur = d.currency || "€";
|
||||
const cur = esc(d.currency || "€");
|
||||
const items = d.items || [];
|
||||
let total = 0;
|
||||
const rows = items
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
version: "3.8"
|
||||
services:
|
||||
docfast:
|
||||
build: .
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "127.0.0.1:3100:3100"
|
||||
extra_hosts:
|
||||
- "host.docker.internal:host-gateway"
|
||||
environment:
|
||||
- API_KEYS=${API_KEYS}
|
||||
- PORT=3100
|
||||
|
|
@ -13,10 +14,31 @@ services:
|
|||
- STRIPE_WEBHOOK_SECRET=${STRIPE_WEBHOOK_SECRET}
|
||||
- BASE_URL=${BASE_URL:-https://docfast.dev}
|
||||
- PRO_KEYS=${PRO_KEYS}
|
||||
- SMTP_HOST=host.docker.internal
|
||||
- SMTP_PORT=25
|
||||
- DATABASE_HOST=172.17.0.1
|
||||
- DATABASE_PORT=5432
|
||||
- DATABASE_NAME=docfast
|
||||
- DATABASE_USER=docfast
|
||||
- DATABASE_PASSWORD=${DATABASE_PASSWORD:-docfast}
|
||||
- POOL_SIZE=15
|
||||
- BROWSER_COUNT=1
|
||||
- PAGES_PER_BROWSER=15
|
||||
volumes:
|
||||
- docfast-data:/app/data
|
||||
mem_limit: 512m
|
||||
cpus: 1.0
|
||||
logging:
|
||||
driver: "json-file"
|
||||
options:
|
||||
max-size: "10m"
|
||||
max-file: "3"
|
||||
healthcheck:
|
||||
test: ["CMD", "node", "-e", "fetch('http://localhost:3100/health').then(r=>{if(!r.ok)process.exit(1)}).catch(()=>process.exit(1))"]
|
||||
interval: 30s
|
||||
timeout: 5s
|
||||
retries: 3
|
||||
start_period: 30s
|
||||
mem_limit: 2560m
|
||||
cpus: 1.5
|
||||
|
||||
volumes:
|
||||
docfast-data:
|
||||
|
|
|
|||
27
projects/business/src/pdf-api/infrastructure/.env.template
Normal file
27
projects/business/src/pdf-api/infrastructure/.env.template
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
# DocFast Environment Variables Template
|
||||
# Copy this to .env and fill in real values
|
||||
|
||||
# Stripe Configuration (Production keys)
|
||||
STRIPE_SECRET_KEY=sk_live_FILL_IN_YOUR_STRIPE_SECRET_KEY
|
||||
STRIPE_WEBHOOK_SECRET=whsec_FILL_IN_YOUR_WEBHOOK_SECRET
|
||||
|
||||
# Application Configuration
|
||||
BASE_URL=https://docfast.dev
|
||||
API_KEYS=FILL_IN_YOUR_API_KEYS_COMMA_SEPARATED
|
||||
PRO_KEYS=FILL_IN_YOUR_PRO_KEYS_COMMA_SEPARATED
|
||||
|
||||
# Database Configuration
|
||||
DATABASE_PASSWORD=FILL_IN_SECURE_PASSWORD
|
||||
|
||||
# Optional: Override defaults if needed
|
||||
# PORT=3100
|
||||
# NODE_ENV=production
|
||||
# SMTP_HOST=host.docker.internal
|
||||
# SMTP_PORT=25
|
||||
# DATABASE_HOST=172.17.0.1
|
||||
# DATABASE_PORT=5432
|
||||
# DATABASE_NAME=docfast
|
||||
# DATABASE_USER=docfast
|
||||
# POOL_SIZE=15
|
||||
# BROWSER_COUNT=1
|
||||
# PAGES_PER_BROWSER=15
|
||||
344
projects/business/src/pdf-api/infrastructure/README.md
Normal file
344
projects/business/src/pdf-api/infrastructure/README.md
Normal file
|
|
@ -0,0 +1,344 @@
|
|||
# DocFast Infrastructure Guide
|
||||
|
||||
Complete disaster recovery and deployment guide for DocFast.
|
||||
|
||||
## Quick Start (New Server Deployment)
|
||||
|
||||
### 1. Prerequisites
|
||||
|
||||
- Fresh Ubuntu 24.04 LTS server
|
||||
- Root access
|
||||
- Domain name pointing to server IP
|
||||
- Stripe account with webhook configured
|
||||
|
||||
### 2. Automated Setup
|
||||
|
||||
```bash
|
||||
# Clone the repository
|
||||
git clone ssh://forgejo@git.cloonar.com/openclawd/docfast.git
|
||||
cd docfast/infrastructure
|
||||
|
||||
# Run the setup script as root
|
||||
chmod +x setup.sh
|
||||
./setup.sh
|
||||
|
||||
# Follow the post-setup instructions
|
||||
```
|
||||
|
||||
### 3. Manual Configuration Required
|
||||
|
||||
After running `setup.sh`, complete these manual steps:
|
||||
|
||||
#### SSL Certificate
|
||||
```bash
|
||||
certbot --nginx -d docfast.dev -d www.docfast.dev
|
||||
```
|
||||
|
||||
#### DKIM DNS Record
|
||||
Add this TXT record to your DNS:
|
||||
```
|
||||
mail._domainkey.docfast.dev
|
||||
```
|
||||
Get the value from: `/etc/opendkim/keys/docfast.dev/mail.txt`
|
||||
|
||||
#### Environment Variables
|
||||
```bash
|
||||
cd /opt/docfast
|
||||
cp infrastructure/.env.template .env
|
||||
# Edit .env with real values
|
||||
```
|
||||
|
||||
#### Start the Application
|
||||
```bash
|
||||
cd /opt/docfast
|
||||
cp infrastructure/docker-compose.yml .
|
||||
docker-compose up -d
|
||||
```
|
||||
|
||||
## Complete Manual Setup (Step by Step)
|
||||
|
||||
If the automated script fails or you prefer manual setup:
|
||||
|
||||
### System Packages
|
||||
```bash
|
||||
apt update && apt upgrade -y
|
||||
apt install -y nginx postfix opendkim opendkim-tools certbot \
|
||||
python3-certbot-nginx ufw docker.io docker-compose-plugin \
|
||||
git sqlite3 postgresql postgresql-contrib
|
||||
```
|
||||
|
||||
### Firewall Configuration
|
||||
```bash
|
||||
ufw --force enable
|
||||
ufw default deny incoming
|
||||
ufw default allow outgoing
|
||||
ufw allow ssh
|
||||
ufw allow 80/tcp
|
||||
ufw allow 443/tcp
|
||||
ufw allow from 172.16.0.0/12 to any port 25 comment "Docker SMTP relay"
|
||||
ufw allow from 172.16.0.0/12 to any port 5432 comment "Docker PostgreSQL"
|
||||
```
|
||||
|
||||
### PostgreSQL Setup
|
||||
```bash
|
||||
sudo -u postgres createuser -D -A -P docfast
|
||||
sudo -u postgres createdb -O docfast docfast
|
||||
|
||||
# Edit /etc/postgresql/16/main/postgresql.conf
|
||||
echo "listen_addresses = '*'" >> /etc/postgresql/16/main/postgresql.conf
|
||||
|
||||
# Edit /etc/postgresql/16/main/pg_hba.conf
|
||||
echo "host docfast docfast 172.17.0.0/16 md5" >> /etc/postgresql/16/main/pg_hba.conf
|
||||
echo "host docfast docfast 172.18.0.0/16 md5" >> /etc/postgresql/16/main/pg_hba.conf
|
||||
|
||||
systemctl restart postgresql
|
||||
```
|
||||
|
||||
### Nginx Configuration
|
||||
```bash
|
||||
cp nginx/docfast.dev /etc/nginx/sites-available/
|
||||
ln -s /etc/nginx/sites-available/docfast.dev /etc/nginx/sites-enabled/
|
||||
rm /etc/nginx/sites-enabled/default
|
||||
nginx -t
|
||||
systemctl reload nginx
|
||||
```
|
||||
|
||||
### Postfix & OpenDKIM
|
||||
```bash
|
||||
cp postfix/main.cf /etc/postfix/
|
||||
cp postfix/opendkim.conf /etc/opendkim.conf
|
||||
cp postfix/TrustedHosts /etc/opendkim/
|
||||
|
||||
# Generate DKIM keys
|
||||
mkdir -p /etc/opendkim/keys/docfast.dev
|
||||
cd /etc/opendkim/keys/docfast.dev
|
||||
opendkim-genkey -s mail -d docfast.dev
|
||||
chown opendkim:opendkim mail.private mail.txt
|
||||
chmod 600 mail.private
|
||||
|
||||
systemctl restart postfix opendkim
|
||||
```
|
||||
|
||||
### Application Deployment
|
||||
```bash
|
||||
useradd -r -m -s /bin/bash docfast
|
||||
usermod -aG docker docfast
|
||||
mkdir -p /opt/docfast
|
||||
chown docfast:docfast /opt/docfast
|
||||
|
||||
cd /opt/docfast
|
||||
# Copy your source code here
|
||||
cp infrastructure/docker-compose.yml .
|
||||
cp infrastructure/.env.template .env
|
||||
# Edit .env with real values
|
||||
|
||||
docker-compose up -d
|
||||
```
|
||||
|
||||
### Backup System
|
||||
```bash
|
||||
# Install BorgBackup
|
||||
apt install -y borgbackup
|
||||
|
||||
# Create backup directories
|
||||
mkdir -p /opt/docfast-backups /opt/borg-backups
|
||||
|
||||
# Copy backup scripts
|
||||
cp scripts/docfast-backup.sh /opt/
|
||||
cp scripts/borg-backup.sh /opt/
|
||||
cp scripts/borg-restore.sh /opt/
|
||||
cp scripts/rollback.sh /opt/
|
||||
chmod +x /opt/docfast-backup.sh /opt/borg-backup.sh /opt/borg-restore.sh /opt/rollback.sh
|
||||
|
||||
# Add to root crontab
|
||||
echo "0 */6 * * * /opt/docfast-backup.sh >> /var/log/docfast-backup.log 2>&1" | crontab -
|
||||
echo "0 3 * * * /opt/borg-backup.sh >> /var/log/borg-backup.log 2>&1" | crontab -
|
||||
```
|
||||
|
||||
## Backup Strategy
|
||||
|
||||
DocFast uses a two-tier backup strategy for comprehensive data protection:
|
||||
|
||||
### 1. SQLite Database Backups (Every 6 hours)
|
||||
- **Script**: `/opt/docfast-backup.sh`
|
||||
- **Frequency**: Every 6 hours via cron
|
||||
- **Retention**: 7 days of backups (28 files), plus 4 weekly copies
|
||||
- **Storage**: `/opt/docfast-backups/`
|
||||
- **Method**: SQLite `.backup` command with integrity verification
|
||||
|
||||
### 2. Complete System Backups (Daily)
|
||||
- **Script**: `/opt/borg-backup.sh`
|
||||
- **Frequency**: Daily at 03:00 UTC via cron
|
||||
- **Retention**: 7 daily + 4 weekly + 3 monthly
|
||||
- **Storage**: `/opt/borg-backups/docfast`
|
||||
- **Includes**:
|
||||
- PostgreSQL database dump
|
||||
- Docker volumes (complete application data)
|
||||
- Nginx configuration
|
||||
- SSL certificates (Let's Encrypt)
|
||||
- OpenDKIM keys and configuration
|
||||
- Cron jobs and system configurations
|
||||
- Application files (.env, docker-compose.yml)
|
||||
- System information (packages, services)
|
||||
|
||||
### Backup Management Commands
|
||||
```bash
|
||||
# List available Borg backups
|
||||
/opt/borg-restore.sh list
|
||||
|
||||
# Restore from latest backup (creates restore directory)
|
||||
/opt/borg-restore.sh restore latest
|
||||
|
||||
# Restore from specific backup
|
||||
/opt/borg-restore.sh restore docfast-2026-02-15_0300
|
||||
|
||||
# Quick rollback (Docker image only)
|
||||
/opt/rollback.sh
|
||||
```
|
||||
|
||||
## Disaster Recovery Procedures
|
||||
|
||||
### Complete Server Failure
|
||||
|
||||
1. **Provision new server** with same OS version
|
||||
2. **Run setup script** from this repository
|
||||
3. **Restore DNS** records to point to new server
|
||||
4. **Copy backups** from off-site storage to `/opt/docfast-backups/`
|
||||
5. **Restore database**:
|
||||
```bash
|
||||
docker-compose down
|
||||
docker volume rm docfast_docfast-data
|
||||
docker volume create docfast_docfast-data
|
||||
cp /opt/docfast-backups/docfast-weekly-LATEST.db \
|
||||
/var/lib/docker/volumes/docfast_docfast-data/_data/docfast.db
|
||||
docker-compose up -d
|
||||
```
|
||||
6. **Verify SSL certificates** with `certbot certificates`
|
||||
7. **Test email delivery** and DKIM signing
|
||||
|
||||
### Database Corruption
|
||||
|
||||
```bash
|
||||
cd /opt/docfast
|
||||
docker-compose down
|
||||
|
||||
# Find latest good backup
|
||||
ls -la /opt/docfast-backups/
|
||||
|
||||
# Restore from backup
|
||||
cp /opt/docfast-backups/docfast-daily-LATEST.db \
|
||||
/var/lib/docker/volumes/docfast_docfast-data/_data/docfast.db
|
||||
|
||||
docker-compose up -d
|
||||
```
|
||||
|
||||
### Email Delivery Issues
|
||||
|
||||
Check DKIM setup:
|
||||
```bash
|
||||
# Verify DKIM key is readable
|
||||
sudo -u opendkim cat /etc/opendkim/keys/docfast.dev/mail.private
|
||||
|
||||
# Check OpenDKIM is signing
|
||||
tail -f /var/log/mail.log
|
||||
|
||||
# Test email sending
|
||||
echo "Test email" | mail -s "Test" test@example.com
|
||||
```
|
||||
|
||||
### SSL Certificate Issues
|
||||
|
||||
```bash
|
||||
# Check certificate status
|
||||
certbot certificates
|
||||
|
||||
# Renew if needed
|
||||
certbot renew --dry-run
|
||||
certbot renew
|
||||
|
||||
# Fix nginx config if needed
|
||||
nginx -t
|
||||
systemctl reload nginx
|
||||
```
|
||||
|
||||
## Monitoring & Maintenance
|
||||
|
||||
### Daily Checks
|
||||
- [ ] Application health: `curl https://docfast.dev/health`
|
||||
- [ ] Docker containers: `docker ps`
|
||||
- [ ] Disk space: `df -h`
|
||||
- [ ] Backup status: `ls -la /opt/docfast-backups/`
|
||||
|
||||
### Weekly Checks
|
||||
- [ ] SSL certificate expiry: `certbot certificates`
|
||||
- [ ] Email delivery test
|
||||
- [ ] System updates: `apt list --upgradable`
|
||||
- [ ] Log rotation: `du -sh /var/log/`
|
||||
|
||||
### Monthly Tasks
|
||||
- [ ] Review backup retention
|
||||
- [ ] Update system packages
|
||||
- [ ] Review firewall rules: `ufw status`
|
||||
- [ ] Check for failed login attempts: `grep "Failed password" /var/log/auth.log`
|
||||
|
||||
## Environment Variables Reference
|
||||
|
||||
| Variable | Required | Description | Example |
|
||||
|----------|----------|-------------|---------|
|
||||
| `STRIPE_SECRET_KEY` | ✅ | Stripe API secret key | `sk_live_...` |
|
||||
| `STRIPE_WEBHOOK_SECRET` | ✅ | Stripe webhook endpoint secret | `whsec_...` |
|
||||
| `BASE_URL` | ✅ | Application base URL | `https://docfast.dev` |
|
||||
| `API_KEYS` | ✅ | Comma-separated API keys | `key1,key2,key3` |
|
||||
| `PRO_KEYS` | ✅ | Comma-separated pro API keys | `prokey1,prokey2` |
|
||||
| `DATABASE_PASSWORD` | ✅ | PostgreSQL password | `secure_password_123` |
|
||||
|
||||
## DNS Records Required
|
||||
|
||||
| Type | Name | Value | TTL |
|
||||
|------|------|-------|-----|
|
||||
| A | docfast.dev | SERVER_IP | 300 |
|
||||
| A | www.docfast.dev | SERVER_IP | 300 |
|
||||
| TXT | mail._domainkey.docfast.dev | DKIM_PUBLIC_KEY | 300 |
|
||||
| MX | docfast.dev | docfast.dev | 300 |
|
||||
| TXT | docfast.dev | v=spf1 mx ~all | 300 |
|
||||
|
||||
## Stripe Configuration
|
||||
|
||||
Required webhook events:
|
||||
- `checkout.session.completed`
|
||||
- `invoice.payment_succeeded`
|
||||
- `customer.subscription.created`
|
||||
- `customer.subscription.updated`
|
||||
- `customer.subscription.deleted`
|
||||
|
||||
Webhook URL: `https://docfast.dev/api/stripe/webhook`
|
||||
|
||||
## Security Considerations
|
||||
|
||||
- Server runs on non-standard SSH port (change from 22)
|
||||
- Fail2ban recommended for brute force protection
|
||||
- Regular security updates via unattended-upgrades
|
||||
- Database backups encrypted at rest
|
||||
- API keys rotated regularly
|
||||
- Monitor application logs for suspicious activity
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Common Issues
|
||||
|
||||
**Container won't start**: Check logs with `docker-compose logs -f`
|
||||
|
||||
**Database connection errors**: Verify PostgreSQL is running and Docker networks are configured
|
||||
|
||||
**Email not sending**: Check postfix logs: `tail -f /var/log/mail.log`
|
||||
|
||||
**SSL certificate errors**: Verify domain DNS and run `certbot --nginx`
|
||||
|
||||
**High memory usage**: Monitor with `docker stats` and adjust container limits
|
||||
|
||||
### Log Locations
|
||||
- Application: `docker-compose logs`
|
||||
- Nginx: `/var/log/nginx/`
|
||||
- Postfix: `/var/log/mail.log`
|
||||
- System: `/var/log/syslog`
|
||||
- Backups: `/var/log/docfast-backup.log`
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
version: "3.8"
|
||||
services:
|
||||
docfast:
|
||||
build: .
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "127.0.0.1:3100:3100"
|
||||
extra_hosts:
|
||||
- "host.docker.internal:host-gateway"
|
||||
environment:
|
||||
- API_KEYS=${API_KEYS}
|
||||
- PORT=3100
|
||||
- NODE_ENV=production
|
||||
- STRIPE_SECRET_KEY=${STRIPE_SECRET_KEY}
|
||||
- STRIPE_WEBHOOK_SECRET=${STRIPE_WEBHOOK_SECRET}
|
||||
- BASE_URL=${BASE_URL:-https://docfast.dev}
|
||||
- PRO_KEYS=${PRO_KEYS}
|
||||
- SMTP_HOST=host.docker.internal
|
||||
- SMTP_PORT=25
|
||||
- DATABASE_HOST=172.17.0.1
|
||||
- DATABASE_PORT=5432
|
||||
- DATABASE_NAME=docfast
|
||||
- DATABASE_USER=docfast
|
||||
- DATABASE_PASSWORD=${DATABASE_PASSWORD:-docfast}
|
||||
- POOL_SIZE=15
|
||||
- BROWSER_COUNT=1
|
||||
- PAGES_PER_BROWSER=15
|
||||
volumes:
|
||||
- docfast-data:/app/data
|
||||
mem_limit: 2560m
|
||||
cpus: 1.5
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-f", "http://localhost:3100/health"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
start_period: 40s
|
||||
|
||||
volumes:
|
||||
docfast-data:
|
||||
driver: local
|
||||
|
|
@ -0,0 +1,70 @@
|
|||
server {
|
||||
server_name docfast.dev www.docfast.dev;
|
||||
|
||||
# Increase client max body size for file uploads
|
||||
client_max_body_size 10m;
|
||||
|
||||
# Security headers
|
||||
add_header X-Frame-Options DENY;
|
||||
add_header X-Content-Type-Options nosniff;
|
||||
add_header X-XSS-Protection "1; mode=block";
|
||||
add_header Referrer-Policy "strict-origin-when-cross-origin";
|
||||
|
||||
# Proxy to the application
|
||||
location / {
|
||||
proxy_pass http://127.0.0.1:3100;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_read_timeout 60s;
|
||||
proxy_connect_timeout 10s;
|
||||
|
||||
# WebSocket support (if needed)
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection 'upgrade';
|
||||
proxy_cache_bypass $http_upgrade;
|
||||
}
|
||||
|
||||
# Health check endpoint (bypass proxy for direct container health check)
|
||||
location /health {
|
||||
access_log off;
|
||||
proxy_pass http://127.0.0.1:3100/health;
|
||||
}
|
||||
|
||||
# Rate limiting for API endpoints
|
||||
location /api/ {
|
||||
limit_req zone=api_limit burst=10 nodelay;
|
||||
proxy_pass http://127.0.0.1:3100;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
}
|
||||
|
||||
# SSL configuration (managed by Certbot)
|
||||
listen 443 ssl http2;
|
||||
ssl_certificate /etc/letsencrypt/live/docfast.dev/fullchain.pem;
|
||||
ssl_certificate_key /etc/letsencrypt/live/docfast.dev/privkey.pem;
|
||||
include /etc/letsencrypt/options-ssl-nginx.conf;
|
||||
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
|
||||
}
|
||||
|
||||
# Rate limiting zone (add to main nginx.conf or here)
|
||||
# limit_req_zone $binary_remote_addr zone=api_limit:10m rate=10r/s;
|
||||
|
||||
# Redirect HTTP to HTTPS
|
||||
server {
|
||||
if ($host = docfast.dev) {
|
||||
return 301 https://$host$request_uri;
|
||||
}
|
||||
|
||||
if ($host = www.docfast.dev) {
|
||||
return 301 https://docfast.dev$request_uri;
|
||||
}
|
||||
|
||||
listen 80;
|
||||
server_name docfast.dev www.docfast.dev;
|
||||
return 404;
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
# OpenDKIM Trusted Hosts
|
||||
# These hosts are allowed to send mail through this server
|
||||
|
||||
# Localhost
|
||||
127.0.0.1
|
||||
localhost
|
||||
|
||||
# Docker networks (adjust based on your Docker setup)
|
||||
172.17.0.0/16
|
||||
172.18.0.0/16
|
||||
172.19.0.0/16
|
||||
44
projects/business/src/pdf-api/infrastructure/postfix/main.cf
Normal file
44
projects/business/src/pdf-api/infrastructure/postfix/main.cf
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
# Postfix main configuration for DocFast
|
||||
# Minimal SMTP relay for application email sending
|
||||
|
||||
# Basic configuration
|
||||
smtpd_banner = $myhostname ESMTP
|
||||
biff = no
|
||||
append_dot_mydomain = no
|
||||
readme_directory = no
|
||||
compatibility_level = 3.6
|
||||
|
||||
# Network configuration
|
||||
myhostname = docfast.dev
|
||||
mydomain = docfast.dev
|
||||
myorigin = docfast.dev
|
||||
inet_interfaces = 127.0.0.1, 172.17.0.1 # localhost + Docker bridge
|
||||
inet_protocols = ipv4
|
||||
mydestination = # Empty = relay only, no local delivery
|
||||
mynetworks = 127.0.0.0/8, 172.17.0.0/16, 172.18.0.0/16
|
||||
|
||||
# TLS configuration
|
||||
smtp_tls_security_level = may
|
||||
smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt
|
||||
|
||||
# OpenDKIM integration
|
||||
milter_protocol = 6
|
||||
milter_default_action = accept
|
||||
smtpd_milters = inet:localhost:8891
|
||||
non_smtpd_milters = $smtpd_milters
|
||||
|
||||
# Size limits
|
||||
mailbox_size_limit = 0
|
||||
message_size_limit = 10240000 # 10MB
|
||||
|
||||
# Other settings
|
||||
recipient_delimiter = +
|
||||
disable_vrfy_command = yes
|
||||
smtpd_helo_required = yes
|
||||
|
||||
# Rate limiting
|
||||
smtpd_client_connection_count_limit = 10
|
||||
smtpd_client_connection_rate_limit = 10
|
||||
|
||||
# Logging
|
||||
maillog_file = /var/log/postfix.log
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
# OpenDKIM Configuration for DocFast
|
||||
|
||||
# Logging
|
||||
Syslog yes
|
||||
SyslogSuccess yes
|
||||
LogWhy yes
|
||||
|
||||
# Operating mode (s = sign, v = verify, sv = both)
|
||||
Mode sv
|
||||
|
||||
# Canonicalization
|
||||
Canonicalization relaxed/simple
|
||||
|
||||
# Domain and selector
|
||||
Domain docfast.dev
|
||||
Selector mail
|
||||
KeyFile /etc/opendkim/keys/docfast.dev/mail.private
|
||||
|
||||
# Network
|
||||
Socket inet:8891@localhost
|
||||
PidFile /run/opendkim/opendkim.pid
|
||||
|
||||
# Security
|
||||
OversignHeaders From
|
||||
TrustAnchorFile /usr/share/dns/root.key
|
||||
UserID opendkim
|
||||
|
||||
# Trusted hosts (who can send mail through this server)
|
||||
InternalHosts /etc/opendkim/TrustedHosts
|
||||
ExternalIgnoreList /etc/opendkim/TrustedHosts
|
||||
|
||||
# Additional security options
|
||||
RequireSafeKeys yes
|
||||
SendReports yes
|
||||
ReportAddress "postmaster@docfast.dev"
|
||||
|
||||
# Performance
|
||||
MaximumHeaders 30
|
||||
208
projects/business/src/pdf-api/infrastructure/setup.sh
Executable file
208
projects/business/src/pdf-api/infrastructure/setup.sh
Executable file
|
|
@ -0,0 +1,208 @@
|
|||
#!/bin/bash
|
||||
# DocFast Infrastructure Setup Script
|
||||
# Provisions a fresh Ubuntu/Debian server with all required services
|
||||
# Run as root: ./setup.sh
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
# Colors for output
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
log() {
|
||||
echo -e "${GREEN}[INFO]${NC} $1"
|
||||
}
|
||||
|
||||
warn() {
|
||||
echo -e "${YELLOW}[WARN]${NC} $1"
|
||||
}
|
||||
|
||||
error() {
|
||||
echo -e "${RED}[ERROR]${NC} $1"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Check if running as root
|
||||
if [[ $EUID -ne 0 ]]; then
|
||||
error "This script must be run as root"
|
||||
fi
|
||||
|
||||
# Domain and user configuration
|
||||
DOMAIN="${DOMAIN:-docfast.dev}"
|
||||
APP_USER="${APP_USER:-docfast}"
|
||||
BACKUP_DIR="/opt/docfast-backups"
|
||||
INSTALL_DIR="/opt/docfast"
|
||||
|
||||
log "Setting up DocFast infrastructure for domain: $DOMAIN"
|
||||
|
||||
# Update system
|
||||
log "Updating system packages..."
|
||||
apt update && apt upgrade -y
|
||||
|
||||
# Install required packages
|
||||
log "Installing required packages..."
|
||||
apt install -y \
|
||||
nginx \
|
||||
postfix \
|
||||
opendkim \
|
||||
opendkim-tools \
|
||||
certbot \
|
||||
python3-certbot-nginx \
|
||||
ufw \
|
||||
docker.io \
|
||||
docker-compose-plugin \
|
||||
git \
|
||||
sqlite3 \
|
||||
curl \
|
||||
wget \
|
||||
unzip \
|
||||
htop \
|
||||
postgresql \
|
||||
postgresql-contrib
|
||||
|
||||
# Enable and start services
|
||||
log "Enabling services..."
|
||||
systemctl enable nginx postfix opendkim docker postgresql
|
||||
systemctl start nginx postfix opendkim docker postgresql
|
||||
|
||||
# Create application user
|
||||
if ! id "$APP_USER" &>/dev/null; then
|
||||
log "Creating application user: $APP_USER"
|
||||
useradd -r -m -s /bin/bash "$APP_USER"
|
||||
fi
|
||||
|
||||
# Add user to docker group
|
||||
usermod -aG docker "$APP_USER"
|
||||
|
||||
# Setup UFW firewall
|
||||
log "Configuring firewall..."
|
||||
ufw --force enable
|
||||
ufw default deny incoming
|
||||
ufw default allow outgoing
|
||||
ufw allow ssh
|
||||
ufw allow 80/tcp
|
||||
ufw allow 443/tcp
|
||||
ufw allow from 172.16.0.0/12 to any port 25 comment "Docker SMTP relay"
|
||||
ufw allow from 172.16.0.0/12 to any port 5432 comment "Docker PostgreSQL"
|
||||
|
||||
# Setup PostgreSQL
|
||||
log "Configuring PostgreSQL..."
|
||||
sudo -u postgres createuser -D -A -P docfast || true # -P prompts for password
|
||||
sudo -u postgres createdb -O docfast docfast || true
|
||||
|
||||
# Update PostgreSQL to allow Docker connections
|
||||
PG_VERSION=$(ls /etc/postgresql/)
|
||||
PG_CONF="/etc/postgresql/$PG_VERSION/main/postgresql.conf"
|
||||
PG_HBA="/etc/postgresql/$PG_VERSION/main/pg_hba.conf"
|
||||
|
||||
# Backup original configs
|
||||
cp "$PG_CONF" "$PG_CONF.backup" || true
|
||||
cp "$PG_HBA" "$PG_HBA.backup" || true
|
||||
|
||||
# Allow connections from Docker networks
|
||||
if ! grep -q "listen_addresses = '*'" "$PG_CONF"; then
|
||||
sed -i "s/#listen_addresses = 'localhost'/listen_addresses = '*'/" "$PG_CONF"
|
||||
fi
|
||||
|
||||
# Allow Docker networks to connect
|
||||
if ! grep -q "172.17.0.0/16" "$PG_HBA"; then
|
||||
echo "host docfast docfast 172.17.0.0/16 md5" >> "$PG_HBA"
|
||||
echo "host docfast docfast 172.18.0.0/16 md5" >> "$PG_HBA"
|
||||
fi
|
||||
|
||||
systemctl restart postgresql
|
||||
|
||||
# Setup OpenDKIM
|
||||
log "Configuring OpenDKIM..."
|
||||
mkdir -p /etc/opendkim/keys/"$DOMAIN"
|
||||
chown -R opendkim:opendkim /etc/opendkim/keys
|
||||
|
||||
# Generate DKIM keys if they don't exist
|
||||
if [[ ! -f /etc/opendkim/keys/"$DOMAIN"/mail.private ]]; then
|
||||
log "Generating DKIM keys..."
|
||||
cd /etc/opendkim/keys/"$DOMAIN"
|
||||
opendkim-genkey -s mail -d "$DOMAIN"
|
||||
chown opendkim:opendkim mail.private mail.txt
|
||||
chmod 600 mail.private
|
||||
fi
|
||||
|
||||
# Copy configuration files
|
||||
log "Installing configuration files..."
|
||||
cp nginx/"$DOMAIN" /etc/nginx/sites-available/"$DOMAIN" || warn "Nginx config not found, you'll need to configure manually"
|
||||
cp postfix/main.cf /etc/postfix/main.cf || warn "Postfix config not found, you'll need to configure manually"
|
||||
cp postfix/opendkim.conf /etc/opendkim.conf || warn "OpenDKIM config not found, you'll need to configure manually"
|
||||
cp postfix/TrustedHosts /etc/opendkim/TrustedHosts || warn "TrustedHosts config not found, you'll need to configure manually"
|
||||
|
||||
# Enable nginx site
|
||||
if [[ -f /etc/nginx/sites-available/"$DOMAIN" ]]; then
|
||||
ln -sf /etc/nginx/sites-available/"$DOMAIN" /etc/nginx/sites-enabled/
|
||||
rm -f /etc/nginx/sites-enabled/default
|
||||
nginx -t && systemctl reload nginx
|
||||
fi
|
||||
|
||||
# Update configurations with actual domain
|
||||
log "Updating configuration files..."
|
||||
sed -i "s/docfast\.dev/$DOMAIN/g" /etc/nginx/sites-available/"$DOMAIN" 2>/dev/null || true
|
||||
sed -i "s/docfast\.dev/$DOMAIN/g" /etc/postfix/main.cf 2>/dev/null || true
|
||||
sed -i "s/docfast\.dev/$DOMAIN/g" /etc/opendkim.conf 2>/dev/null || true
|
||||
|
||||
# Restart services with new configs
|
||||
systemctl restart postfix opendkim
|
||||
|
||||
# Install BorgBackup
|
||||
log "Installing BorgBackup..."
|
||||
apt install -y borgbackup
|
||||
|
||||
# Setup backup directories and scripts
|
||||
log "Setting up backup system..."
|
||||
mkdir -p "$BACKUP_DIR"
|
||||
mkdir -p /opt/borg-backups
|
||||
|
||||
# Copy backup scripts
|
||||
cp ../scripts/docfast-backup.sh /opt/docfast-backup.sh || warn "SQLite backup script not found"
|
||||
cp ../scripts/borg-backup.sh /opt/borg-backup.sh || warn "Borg backup script not found"
|
||||
cp ../scripts/borg-restore.sh /opt/borg-restore.sh || warn "Borg restore script not found"
|
||||
cp ../scripts/rollback.sh /opt/rollback.sh || warn "Rollback script not found"
|
||||
|
||||
chmod +x /opt/docfast-backup.sh /opt/borg-backup.sh /opt/borg-restore.sh /opt/rollback.sh
|
||||
|
||||
# Add backup cron jobs
|
||||
if ! crontab -l 2>/dev/null | grep -q docfast-backup; then
|
||||
(crontab -l 2>/dev/null; echo "0 */6 * * * /opt/docfast-backup.sh >> /var/log/docfast-backup.log 2>&1") | crontab -
|
||||
fi
|
||||
|
||||
if ! crontab -l 2>/dev/null | grep -q borg-backup; then
|
||||
(crontab -l 2>/dev/null; echo "0 3 * * * /opt/borg-backup.sh >> /var/log/borg-backup.log 2>&1") | crontab -
|
||||
fi
|
||||
|
||||
# Setup application directory
|
||||
log "Setting up application directory..."
|
||||
mkdir -p "$INSTALL_DIR"
|
||||
chown "$APP_USER":"$APP_USER" "$INSTALL_DIR"
|
||||
|
||||
# Install Docker Compose
|
||||
if ! command -v docker-compose &> /dev/null; then
|
||||
log "Installing docker-compose..."
|
||||
COMPOSE_VERSION=$(curl -s https://api.github.com/repos/docker/compose/releases/latest | grep 'tag_name' | cut -d\" -f4)
|
||||
curl -L "https://github.com/docker/compose/releases/download/${COMPOSE_VERSION}/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
|
||||
chmod +x /usr/local/bin/docker-compose
|
||||
fi
|
||||
|
||||
log "Base infrastructure setup complete!"
|
||||
echo
|
||||
log "Next steps:"
|
||||
echo "1. Configure DNS A record for $DOMAIN to point to this server"
|
||||
echo "2. Generate SSL certificates: certbot --nginx -d $DOMAIN"
|
||||
echo "3. Copy your .env file with secrets to $INSTALL_DIR/.env"
|
||||
echo "4. Copy your docker-compose.yml to $INSTALL_DIR/"
|
||||
echo "5. Build and start the application:"
|
||||
echo " cd $INSTALL_DIR"
|
||||
echo " docker-compose up -d"
|
||||
echo
|
||||
warn "Remember to:"
|
||||
echo "- Set up your DKIM DNS record (see /etc/opendkim/keys/$DOMAIN/mail.txt)"
|
||||
echo "- Configure Stripe webhooks"
|
||||
echo "- Set up monitoring/alerting"
|
||||
echo "- Test email delivery"
|
||||
13
projects/business/src/pdf-api/logrotate-docfast
Normal file
13
projects/business/src/pdf-api/logrotate-docfast
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
/var/log/docfast/*.log {
|
||||
daily
|
||||
rotate 7
|
||||
compress
|
||||
delaycompress
|
||||
missingok
|
||||
notifempty
|
||||
create 644 root root
|
||||
postrotate
|
||||
# Restart docker container to reopen log files
|
||||
docker restart docfast-docfast-1 >/dev/null 2>&1 || true
|
||||
endscript
|
||||
}
|
||||
89
projects/business/src/pdf-api/nginx-docfast.conf
Normal file
89
projects/business/src/pdf-api/nginx-docfast.conf
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
server {
|
||||
server_name docfast.dev www.docfast.dev;
|
||||
|
||||
client_max_body_size 10m;
|
||||
|
||||
# Enable gzip compression
|
||||
gzip on;
|
||||
gzip_vary on;
|
||||
gzip_min_length 1024;
|
||||
gzip_types
|
||||
text/plain
|
||||
text/css
|
||||
application/json
|
||||
application/javascript
|
||||
text/xml
|
||||
application/xml
|
||||
application/xml+rss
|
||||
text/javascript;
|
||||
|
||||
# Specific locations for robots.txt and sitemap.xml with caching
|
||||
location = /robots.txt {
|
||||
proxy_pass http://127.0.0.1:3100;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
|
||||
# Cache for 1 day
|
||||
expires 1d;
|
||||
add_header Cache-Control "public, max-age=86400";
|
||||
add_header X-Content-Type-Options nosniff;
|
||||
}
|
||||
|
||||
location = /sitemap.xml {
|
||||
proxy_pass http://127.0.0.1:3100;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
|
||||
# Cache for 1 day
|
||||
expires 1d;
|
||||
add_header Cache-Control "public, max-age=86400";
|
||||
add_header X-Content-Type-Options nosniff;
|
||||
}
|
||||
|
||||
# Static assets caching
|
||||
location ~* \.(css|js|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
|
||||
proxy_pass http://127.0.0.1:3100;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
|
||||
# Cache static assets for 1 week
|
||||
expires 7d;
|
||||
add_header Cache-Control "public, max-age=604800, immutable";
|
||||
add_header X-Content-Type-Options nosniff;
|
||||
}
|
||||
|
||||
# All other requests
|
||||
location / {
|
||||
proxy_pass http://127.0.0.1:3100;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_read_timeout 60s;
|
||||
|
||||
# Security headers
|
||||
add_header X-Content-Type-Options nosniff;
|
||||
}
|
||||
|
||||
listen 443 ssl; # managed by Certbot
|
||||
ssl_certificate /etc/letsencrypt/live/docfast.dev/fullchain.pem; # managed by Certbot
|
||||
ssl_certificate_key /etc/letsencrypt/live/docfast.dev/privkey.pem; # managed by Certbot
|
||||
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
|
||||
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
|
||||
}
|
||||
|
||||
server {
|
||||
if ($host = docfast.dev) {
|
||||
return 301 https://$host$request_uri;
|
||||
} # managed by Certbot
|
||||
|
||||
listen 80;
|
||||
server_name docfast.dev www.docfast.dev;
|
||||
return 404; # managed by Certbot
|
||||
}
|
||||
367
projects/business/src/pdf-api/package-lock.json
generated
367
projects/business/src/pdf-api/package-lock.json
generated
|
|
@ -1,24 +1,32 @@
|
|||
{
|
||||
"name": "docfast-api",
|
||||
"version": "0.1.0",
|
||||
"version": "0.2.1",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "docfast-api",
|
||||
"version": "0.1.0",
|
||||
"version": "0.2.1",
|
||||
"dependencies": {
|
||||
"compression": "^1.8.1",
|
||||
"express": "^4.21.0",
|
||||
"express-rate-limit": "^7.5.0",
|
||||
"helmet": "^8.0.0",
|
||||
"marked": "^15.0.0",
|
||||
"nanoid": "^5.0.0",
|
||||
"nodemailer": "^8.0.1",
|
||||
"pg": "^8.13.0",
|
||||
"pino": "^10.3.1",
|
||||
"puppeteer": "^24.0.0",
|
||||
"stripe": "^20.3.1"
|
||||
"stripe": "^20.3.1",
|
||||
"swagger-ui-dist": "^5.31.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/compression": "^1.8.1",
|
||||
"@types/express": "^5.0.0",
|
||||
"@types/node": "^22.0.0",
|
||||
"@types/nodemailer": "^7.0.9",
|
||||
"@types/pg": "^8.11.0",
|
||||
"tsx": "^4.19.0",
|
||||
"typescript": "^5.7.0",
|
||||
"vitest": "^3.0.0"
|
||||
|
|
@ -496,6 +504,11 @@
|
|||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@pinojs/redact": {
|
||||
"version": "0.4.0",
|
||||
"resolved": "https://registry.npmjs.org/@pinojs/redact/-/redact-0.4.0.tgz",
|
||||
"integrity": "sha512-k2ENnmBugE/rzQfEcdWHcCY+/FM3VLzH9cYEsbdsoqrvzAKRhUZeRNhAZvB8OitQJ1TBed3yqWtdjzS6wJKBwg=="
|
||||
},
|
||||
"node_modules/@puppeteer/browsers": {
|
||||
"version": "2.12.1",
|
||||
"resolved": "https://registry.npmjs.org/@puppeteer/browsers/-/browsers-2.12.1.tgz",
|
||||
|
|
@ -890,6 +903,12 @@
|
|||
"win32"
|
||||
]
|
||||
},
|
||||
"node_modules/@scarf/scarf": {
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/@scarf/scarf/-/scarf-1.4.0.tgz",
|
||||
"integrity": "sha512-xxeapPiUXdZAE3che6f3xogoJPeZgig6omHEy1rIY5WVsB3H2BHNnZH+gHG6x91SCWyQCzWGsuL2Hh3ClO5/qQ==",
|
||||
"hasInstallScript": true
|
||||
},
|
||||
"node_modules/@tootallnate/quickjs-emscripten": {
|
||||
"version": "0.23.0",
|
||||
"resolved": "https://registry.npmjs.org/@tootallnate/quickjs-emscripten/-/quickjs-emscripten-0.23.0.tgz",
|
||||
|
|
@ -918,6 +937,16 @@
|
|||
"assertion-error": "^2.0.1"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/compression": {
|
||||
"version": "1.8.1",
|
||||
"resolved": "https://registry.npmjs.org/@types/compression/-/compression-1.8.1.tgz",
|
||||
"integrity": "sha512-kCFuWS0ebDbmxs0AXYn6e2r2nrGAb5KwQhknjSPSPgJcGd8+HVSILlUyFhGqML2gk39HcG7D1ydW9/qpYkN00Q==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@types/express": "*",
|
||||
"@types/node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/connect": {
|
||||
"version": "3.4.38",
|
||||
"resolved": "https://registry.npmjs.org/@types/connect/-/connect-3.4.38.tgz",
|
||||
|
|
@ -984,6 +1013,27 @@
|
|||
"undici-types": "~6.21.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/nodemailer": {
|
||||
"version": "7.0.9",
|
||||
"resolved": "https://registry.npmjs.org/@types/nodemailer/-/nodemailer-7.0.9.tgz",
|
||||
"integrity": "sha512-vI8oF1M+8JvQhsId0Pc38BdUP2evenIIys7c7p+9OZXSPOH5c1dyINP1jT8xQ2xPuBUXmIC87s+91IZMDjH8Ow==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@types/node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/pg": {
|
||||
"version": "8.16.0",
|
||||
"resolved": "https://registry.npmjs.org/@types/pg/-/pg-8.16.0.tgz",
|
||||
"integrity": "sha512-RmhMd/wD+CF8Dfo+cVIy3RR5cl8CyfXQ0tGgW6XBL8L4LM/UTEbNXYRbLwU6w+CgrKBNbrQWt4FUtTfaU5jSYQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@types/node": "*",
|
||||
"pg-protocol": "*",
|
||||
"pg-types": "^2.2.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/qs": {
|
||||
"version": "6.14.0",
|
||||
"resolved": "https://registry.npmjs.org/@types/qs/-/qs-6.14.0.tgz",
|
||||
|
|
@ -1224,6 +1274,14 @@
|
|||
"node": ">=4"
|
||||
}
|
||||
},
|
||||
"node_modules/atomic-sleep": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/atomic-sleep/-/atomic-sleep-1.0.0.tgz",
|
||||
"integrity": "sha512-kNOjDqAh7px0XWNI+4QbzoiR/nTkHAWNud2uvnJquD1/x5a7EQZMJT0AczqK0Qn67oY/TTQ1LbUKajZpp3I9tQ==",
|
||||
"engines": {
|
||||
"node": ">=8.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/b4a": {
|
||||
"version": "1.7.4",
|
||||
"resolved": "https://registry.npmjs.org/b4a/-/b4a-1.7.4.tgz",
|
||||
|
|
@ -1500,6 +1558,42 @@
|
|||
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/compressible": {
|
||||
"version": "2.0.18",
|
||||
"resolved": "https://registry.npmjs.org/compressible/-/compressible-2.0.18.tgz",
|
||||
"integrity": "sha512-AF3r7P5dWxL8MxyITRMlORQNaOA2IkAFaTr4k7BUumjPtRpGDTZpl0Pb1XCO6JeDCBdp126Cgs9sMxqSjgYyRg==",
|
||||
"dependencies": {
|
||||
"mime-db": ">= 1.43.0 < 2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/compression": {
|
||||
"version": "1.8.1",
|
||||
"resolved": "https://registry.npmjs.org/compression/-/compression-1.8.1.tgz",
|
||||
"integrity": "sha512-9mAqGPHLakhCLeNyxPkK4xVo746zQ/czLH1Ky+vkitMnWfWZps8r0qXuwhwizagCRttsL4lfG4pIOvaWLpAP0w==",
|
||||
"dependencies": {
|
||||
"bytes": "3.1.2",
|
||||
"compressible": "~2.0.18",
|
||||
"debug": "2.6.9",
|
||||
"negotiator": "~0.6.4",
|
||||
"on-headers": "~1.1.0",
|
||||
"safe-buffer": "5.2.1",
|
||||
"vary": "~1.1.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.8.0"
|
||||
}
|
||||
},
|
||||
"node_modules/compression/node_modules/negotiator": {
|
||||
"version": "0.6.4",
|
||||
"resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.4.tgz",
|
||||
"integrity": "sha512-myRT3DiWPHqho5PrJaIRyaMv2kgYf0mUVgBNOYMuCH5Ki1yEiQaf/ZJuQ62nvpc44wL5WDbTX7yGJi1Neevw8w==",
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/content-disposition": {
|
||||
"version": "0.5.4",
|
||||
"resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz",
|
||||
|
|
@ -2572,6 +2666,14 @@
|
|||
"node": ">= 0.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/nodemailer": {
|
||||
"version": "8.0.1",
|
||||
"resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-8.0.1.tgz",
|
||||
"integrity": "sha512-5kcldIXmaEjZcHR6F28IKGSgpmZHaF1IXLWFTG+Xh3S+Cce4MiakLtWY+PlBU69fLbRa8HlaGIrC/QolUpHkhg==",
|
||||
"engines": {
|
||||
"node": ">=6.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/object-inspect": {
|
||||
"version": "1.13.4",
|
||||
"resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.4.tgz",
|
||||
|
|
@ -2584,6 +2686,14 @@
|
|||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/on-exit-leak-free": {
|
||||
"version": "2.1.2",
|
||||
"resolved": "https://registry.npmjs.org/on-exit-leak-free/-/on-exit-leak-free-2.1.2.tgz",
|
||||
"integrity": "sha512-0eJJY6hXLGf1udHwfNftBqH+g73EU4B504nZeKpz1sYRKafAghwxEJunB2O7rDZkL4PGfsMVnTXZ2EjibbqcsA==",
|
||||
"engines": {
|
||||
"node": ">=14.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/on-finished": {
|
||||
"version": "2.4.1",
|
||||
"resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz",
|
||||
|
|
@ -2596,6 +2706,14 @@
|
|||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/on-headers": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/on-headers/-/on-headers-1.1.0.tgz",
|
||||
"integrity": "sha512-737ZY3yNnXy37FHkQxPzt4UZ2UWPWiCZWLvFZ4fu5cueciegX0zGPnrlY6bwRg4FdQOe9YU8MkmJwGhoMybl8A==",
|
||||
"engines": {
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/once": {
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
|
||||
|
|
@ -2728,6 +2846,95 @@
|
|||
"integrity": "sha512-F3asv42UuXchdzt+xXqfW1OGlVBe+mxa2mqI0pg5yAHZPvFmY3Y6drSf/GQ1A86WgWEN9Kzh/WrgKa6iGcHXLg==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/pg": {
|
||||
"version": "8.18.0",
|
||||
"resolved": "https://registry.npmjs.org/pg/-/pg-8.18.0.tgz",
|
||||
"integrity": "sha512-xqrUDL1b9MbkydY/s+VZ6v+xiMUmOUk7SS9d/1kpyQxoJ6U9AO1oIJyUWVZojbfe5Cc/oluutcgFG4L9RDP1iQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"pg-connection-string": "^2.11.0",
|
||||
"pg-pool": "^3.11.0",
|
||||
"pg-protocol": "^1.11.0",
|
||||
"pg-types": "2.2.0",
|
||||
"pgpass": "1.0.5"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 16.0.0"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"pg-cloudflare": "^1.3.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"pg-native": ">=3.0.1"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"pg-native": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/pg-cloudflare": {
|
||||
"version": "1.3.0",
|
||||
"resolved": "https://registry.npmjs.org/pg-cloudflare/-/pg-cloudflare-1.3.0.tgz",
|
||||
"integrity": "sha512-6lswVVSztmHiRtD6I8hw4qP/nDm1EJbKMRhf3HCYaqud7frGysPv7FYJ5noZQdhQtN2xJnimfMtvQq21pdbzyQ==",
|
||||
"license": "MIT",
|
||||
"optional": true
|
||||
},
|
||||
"node_modules/pg-connection-string": {
|
||||
"version": "2.11.0",
|
||||
"resolved": "https://registry.npmjs.org/pg-connection-string/-/pg-connection-string-2.11.0.tgz",
|
||||
"integrity": "sha512-kecgoJwhOpxYU21rZjULrmrBJ698U2RxXofKVzOn5UDj61BPj/qMb7diYUR1nLScCDbrztQFl1TaQZT0t1EtzQ==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/pg-int8": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/pg-int8/-/pg-int8-1.0.1.tgz",
|
||||
"integrity": "sha512-WCtabS6t3c8SkpDBUlb1kjOs7l66xsGdKpIPZsg4wR+B3+u9UAum2odSsF9tnvxg80h4ZxLWMy4pRjOsFIqQpw==",
|
||||
"license": "ISC",
|
||||
"engines": {
|
||||
"node": ">=4.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/pg-pool": {
|
||||
"version": "3.11.0",
|
||||
"resolved": "https://registry.npmjs.org/pg-pool/-/pg-pool-3.11.0.tgz",
|
||||
"integrity": "sha512-MJYfvHwtGp870aeusDh+hg9apvOe2zmpZJpyt+BMtzUWlVqbhFmMK6bOBXLBUPd7iRtIF9fZplDc7KrPN3PN7w==",
|
||||
"license": "MIT",
|
||||
"peerDependencies": {
|
||||
"pg": ">=8.0"
|
||||
}
|
||||
},
|
||||
"node_modules/pg-protocol": {
|
||||
"version": "1.11.0",
|
||||
"resolved": "https://registry.npmjs.org/pg-protocol/-/pg-protocol-1.11.0.tgz",
|
||||
"integrity": "sha512-pfsxk2M9M3BuGgDOfuy37VNRRX3jmKgMjcvAcWqNDpZSf4cUmv8HSOl5ViRQFsfARFn0KuUQTgLxVMbNq5NW3g==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/pg-types": {
|
||||
"version": "2.2.0",
|
||||
"resolved": "https://registry.npmjs.org/pg-types/-/pg-types-2.2.0.tgz",
|
||||
"integrity": "sha512-qTAAlrEsl8s4OiEQY69wDvcMIdQN6wdz5ojQiOy6YRMuynxenON0O5oCpJI6lshc6scgAY8qvJ2On/p+CXY0GA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"pg-int8": "1.0.1",
|
||||
"postgres-array": "~2.0.0",
|
||||
"postgres-bytea": "~1.0.0",
|
||||
"postgres-date": "~1.0.4",
|
||||
"postgres-interval": "^1.1.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
}
|
||||
},
|
||||
"node_modules/pgpass": {
|
||||
"version": "1.0.5",
|
||||
"resolved": "https://registry.npmjs.org/pgpass/-/pgpass-1.0.5.tgz",
|
||||
"integrity": "sha512-FdW9r/jQZhSeohs1Z3sI1yxFQNFvMcnmfuj4WBMUTxOrAyLMaTcE1aAMBiTlbMNaXvBCQuVi0R7hd8udDSP7ug==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"split2": "^4.1.0"
|
||||
}
|
||||
},
|
||||
"node_modules/picocolors": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz",
|
||||
|
|
@ -2747,6 +2954,40 @@
|
|||
"url": "https://github.com/sponsors/jonschlinkert"
|
||||
}
|
||||
},
|
||||
"node_modules/pino": {
|
||||
"version": "10.3.1",
|
||||
"resolved": "https://registry.npmjs.org/pino/-/pino-10.3.1.tgz",
|
||||
"integrity": "sha512-r34yH/GlQpKZbU1BvFFqOjhISRo1MNx1tWYsYvmj6KIRHSPMT2+yHOEb1SG6NMvRoHRF0a07kCOox/9yakl1vg==",
|
||||
"dependencies": {
|
||||
"@pinojs/redact": "^0.4.0",
|
||||
"atomic-sleep": "^1.0.0",
|
||||
"on-exit-leak-free": "^2.1.0",
|
||||
"pino-abstract-transport": "^3.0.0",
|
||||
"pino-std-serializers": "^7.0.0",
|
||||
"process-warning": "^5.0.0",
|
||||
"quick-format-unescaped": "^4.0.3",
|
||||
"real-require": "^0.2.0",
|
||||
"safe-stable-stringify": "^2.3.1",
|
||||
"sonic-boom": "^4.0.1",
|
||||
"thread-stream": "^4.0.0"
|
||||
},
|
||||
"bin": {
|
||||
"pino": "bin.js"
|
||||
}
|
||||
},
|
||||
"node_modules/pino-abstract-transport": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/pino-abstract-transport/-/pino-abstract-transport-3.0.0.tgz",
|
||||
"integrity": "sha512-wlfUczU+n7Hy/Ha5j9a/gZNy7We5+cXp8YL+X+PG8S0KXxw7n/JXA3c46Y0zQznIJ83URJiwy7Lh56WLokNuxg==",
|
||||
"dependencies": {
|
||||
"split2": "^4.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/pino-std-serializers": {
|
||||
"version": "7.1.0",
|
||||
"resolved": "https://registry.npmjs.org/pino-std-serializers/-/pino-std-serializers-7.1.0.tgz",
|
||||
"integrity": "sha512-BndPH67/JxGExRgiX1dX0w1FvZck5Wa4aal9198SrRhZjH3GxKQUKIBnYJTdj2HDN3UQAS06HlfcSbQj2OHmaw=="
|
||||
},
|
||||
"node_modules/postcss": {
|
||||
"version": "8.5.6",
|
||||
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.6.tgz",
|
||||
|
|
@ -2795,6 +3036,60 @@
|
|||
"node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1"
|
||||
}
|
||||
},
|
||||
"node_modules/postgres-array": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/postgres-array/-/postgres-array-2.0.0.tgz",
|
||||
"integrity": "sha512-VpZrUqU5A69eQyW2c5CA1jtLecCsN2U/bD6VilrFDWq5+5UIEVO7nazS3TEcHf1zuPYO/sqGvUvW62g86RXZuA==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
}
|
||||
},
|
||||
"node_modules/postgres-bytea": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/postgres-bytea/-/postgres-bytea-1.0.1.tgz",
|
||||
"integrity": "sha512-5+5HqXnsZPE65IJZSMkZtURARZelel2oXUEO8rH83VS/hxH5vv1uHquPg5wZs8yMAfdv971IU+kcPUczi7NVBQ==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/postgres-date": {
|
||||
"version": "1.0.7",
|
||||
"resolved": "https://registry.npmjs.org/postgres-date/-/postgres-date-1.0.7.tgz",
|
||||
"integrity": "sha512-suDmjLVQg78nMK2UZ454hAG+OAW+HQPZ6n++TNDUX+L0+uUlLywnoxJKDou51Zm+zTCjrCl0Nq6J9C5hP9vK/Q==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/postgres-interval": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/postgres-interval/-/postgres-interval-1.2.0.tgz",
|
||||
"integrity": "sha512-9ZhXKM/rw350N1ovuWHbGxnGh/SNJ4cnxHiM0rxE4VN41wsg8P8zWn9hv/buK00RP4WvlOyr/RBDiptyxVbkZQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"xtend": "^4.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/process-warning": {
|
||||
"version": "5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/process-warning/-/process-warning-5.0.0.tgz",
|
||||
"integrity": "sha512-a39t9ApHNx2L4+HBnQKqxxHNs1r7KF+Intd8Q/g1bUh6q0WIp9voPXJ/x0j+ZL45KF1pJd9+q2jLIRMfvEshkA==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/fastify"
|
||||
},
|
||||
{
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/fastify"
|
||||
}
|
||||
]
|
||||
},
|
||||
"node_modules/progress": {
|
||||
"version": "2.0.3",
|
||||
"resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz",
|
||||
|
|
@ -2952,6 +3247,11 @@
|
|||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/quick-format-unescaped": {
|
||||
"version": "4.0.4",
|
||||
"resolved": "https://registry.npmjs.org/quick-format-unescaped/-/quick-format-unescaped-4.0.4.tgz",
|
||||
"integrity": "sha512-tYC1Q1hgyRuHgloV/YXs2w15unPVh8qfu/qCTfhTYamaw7fyhumKa2yGpdSo87vY32rIclj+4fWYQXUMs9EHvg=="
|
||||
},
|
||||
"node_modules/range-parser": {
|
||||
"version": "1.2.1",
|
||||
"resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz",
|
||||
|
|
@ -2976,6 +3276,14 @@
|
|||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/real-require": {
|
||||
"version": "0.2.0",
|
||||
"resolved": "https://registry.npmjs.org/real-require/-/real-require-0.2.0.tgz",
|
||||
"integrity": "sha512-57frrGM/OCTLqLOAh0mhVA9VBMHd+9U7Zb2THMGdBUoZVOtGbJzjxsYGDJ3A9AYYCP4hn6y1TVbaOfzWtm5GFg==",
|
||||
"engines": {
|
||||
"node": ">= 12.13.0"
|
||||
}
|
||||
},
|
||||
"node_modules/require-directory": {
|
||||
"version": "2.1.1",
|
||||
"resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz",
|
||||
|
|
@ -3069,6 +3377,14 @@
|
|||
],
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/safe-stable-stringify": {
|
||||
"version": "2.5.0",
|
||||
"resolved": "https://registry.npmjs.org/safe-stable-stringify/-/safe-stable-stringify-2.5.0.tgz",
|
||||
"integrity": "sha512-b3rppTKm9T+PsVCBEOUR46GWI7fdOs00VKZ1+9c1EWDaDMvjQc6tUwuFyIprgGgTcWoVHSKrU8H31ZHA2e0RHA==",
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
}
|
||||
},
|
||||
"node_modules/safer-buffer": {
|
||||
"version": "2.1.2",
|
||||
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
|
||||
|
|
@ -3278,6 +3594,14 @@
|
|||
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/sonic-boom": {
|
||||
"version": "4.2.1",
|
||||
"resolved": "https://registry.npmjs.org/sonic-boom/-/sonic-boom-4.2.1.tgz",
|
||||
"integrity": "sha512-w6AxtubXa2wTXAUsZMMWERrsIRAdrK0Sc+FUytWvYAhBJLyuI4llrMIC1DtlNSdI99EI86KZum2MMq3EAZlF9Q==",
|
||||
"dependencies": {
|
||||
"atomic-sleep": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/source-map": {
|
||||
"version": "0.6.1",
|
||||
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
|
||||
|
|
@ -3298,6 +3622,15 @@
|
|||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/split2": {
|
||||
"version": "4.2.0",
|
||||
"resolved": "https://registry.npmjs.org/split2/-/split2-4.2.0.tgz",
|
||||
"integrity": "sha512-UcjcJOWknrNkF6PLX83qcHM6KHgVKNkV62Y8a5uYDVv9ydGQVwAHMKqHdJje1VTWpljG0WYpCDhrCdAOYH4TWg==",
|
||||
"license": "ISC",
|
||||
"engines": {
|
||||
"node": ">= 10.x"
|
||||
}
|
||||
},
|
||||
"node_modules/stackback": {
|
||||
"version": "0.0.2",
|
||||
"resolved": "https://registry.npmjs.org/stackback/-/stackback-0.0.2.tgz",
|
||||
|
|
@ -3395,6 +3728,14 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"node_modules/swagger-ui-dist": {
|
||||
"version": "5.31.0",
|
||||
"resolved": "https://registry.npmjs.org/swagger-ui-dist/-/swagger-ui-dist-5.31.0.tgz",
|
||||
"integrity": "sha512-zSUTIck02fSga6rc0RZP3b7J7wgHXwLea8ZjgLA3Vgnb8QeOl3Wou2/j5QkzSGeoz6HusP/coYuJl33aQxQZpg==",
|
||||
"dependencies": {
|
||||
"@scarf/scarf": "=1.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/tar-fs": {
|
||||
"version": "3.1.1",
|
||||
"resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-3.1.1.tgz",
|
||||
|
|
@ -3429,6 +3770,17 @@
|
|||
"b4a": "^1.6.4"
|
||||
}
|
||||
},
|
||||
"node_modules/thread-stream": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/thread-stream/-/thread-stream-4.0.0.tgz",
|
||||
"integrity": "sha512-4iMVL6HAINXWf1ZKZjIPcz5wYaOdPhtO8ATvZ+Xqp3BTdaqtAwQkNmKORqcIo5YkQqGXq5cwfswDwMqqQNrpJA==",
|
||||
"dependencies": {
|
||||
"real-require": "^0.2.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20"
|
||||
}
|
||||
},
|
||||
"node_modules/tinybench": {
|
||||
"version": "2.9.0",
|
||||
"resolved": "https://registry.npmjs.org/tinybench/-/tinybench-2.9.0.tgz",
|
||||
|
|
@ -3880,6 +4232,15 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"node_modules/xtend": {
|
||||
"version": "4.0.2",
|
||||
"resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz",
|
||||
"integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/y18n": {
|
||||
"version": "5.0.8",
|
||||
"resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz",
|
||||
|
|
|
|||
|
|
@ -1,26 +1,35 @@
|
|||
{
|
||||
"name": "docfast-api",
|
||||
"version": "0.1.0",
|
||||
"version": "0.2.1",
|
||||
"description": "Markdown/HTML to PDF API with built-in invoice templates",
|
||||
"main": "dist/index.js",
|
||||
"scripts": {
|
||||
"build": "tsc",
|
||||
"build:pages": "node scripts/build-pages.js",
|
||||
"build": "npm run build:pages && tsc",
|
||||
"start": "node dist/index.js",
|
||||
"dev": "tsx src/index.ts",
|
||||
"test": "vitest run"
|
||||
},
|
||||
"dependencies": {
|
||||
"compression": "^1.8.1",
|
||||
"express": "^4.21.0",
|
||||
"express-rate-limit": "^7.5.0",
|
||||
"helmet": "^8.0.0",
|
||||
"marked": "^15.0.0",
|
||||
"nanoid": "^5.0.0",
|
||||
"nodemailer": "^8.0.1",
|
||||
"pg": "^8.13.0",
|
||||
"pino": "^10.3.1",
|
||||
"puppeteer": "^24.0.0",
|
||||
"stripe": "^20.3.1"
|
||||
"stripe": "^20.3.1",
|
||||
"swagger-ui-dist": "^5.31.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/compression": "^1.8.1",
|
||||
"@types/express": "^5.0.0",
|
||||
"@types/node": "^22.0.0",
|
||||
"@types/nodemailer": "^7.0.9",
|
||||
"@types/pg": "^8.11.0",
|
||||
"tsx": "^4.19.0",
|
||||
"typescript": "^5.7.0",
|
||||
"vitest": "^3.0.0"
|
||||
|
|
|
|||
515
projects/business/src/pdf-api/public/app.js
Normal file
515
projects/business/src/pdf-api/public/app.js
Normal file
|
|
@ -0,0 +1,515 @@
|
|||
var signupEmail = '';
|
||||
var recoverEmail = '';
|
||||
|
||||
function showState(state) {
|
||||
['signupInitial', 'signupLoading', 'signupVerify', 'signupResult'].forEach(function(id) {
|
||||
var el = document.getElementById(id);
|
||||
if (el) el.classList.remove('active');
|
||||
});
|
||||
document.getElementById(state).classList.add('active');
|
||||
}
|
||||
|
||||
function showRecoverState(state) {
|
||||
['recoverInitial', 'recoverLoading', 'recoverVerify', 'recoverResult'].forEach(function(id) {
|
||||
var el = document.getElementById(id);
|
||||
if (el) el.classList.remove('active');
|
||||
});
|
||||
document.getElementById(state).classList.add('active');
|
||||
}
|
||||
|
||||
function openSignup() {
|
||||
document.getElementById('signupModal').classList.add('active');
|
||||
showState('signupInitial');
|
||||
document.getElementById('signupError').style.display = 'none';
|
||||
document.getElementById('verifyError').style.display = 'none';
|
||||
document.getElementById('signupEmail').value = '';
|
||||
document.getElementById('verifyCode').value = '';
|
||||
signupEmail = '';
|
||||
}
|
||||
|
||||
function closeSignup() {
|
||||
document.getElementById('signupModal').classList.remove('active');
|
||||
}
|
||||
|
||||
function openRecover() {
|
||||
closeSignup();
|
||||
document.getElementById('recoverModal').classList.add('active');
|
||||
showRecoverState('recoverInitial');
|
||||
var errEl = document.getElementById('recoverError');
|
||||
if (errEl) errEl.style.display = 'none';
|
||||
var verifyErrEl = document.getElementById('recoverVerifyError');
|
||||
if (verifyErrEl) verifyErrEl.style.display = 'none';
|
||||
document.getElementById('recoverEmailInput').value = '';
|
||||
document.getElementById('recoverCode').value = '';
|
||||
recoverEmail = '';
|
||||
}
|
||||
|
||||
function closeRecover() {
|
||||
document.getElementById('recoverModal').classList.remove('active');
|
||||
}
|
||||
|
||||
async function submitSignup() {
|
||||
var errEl = document.getElementById('signupError');
|
||||
var btn = document.getElementById('signupBtn');
|
||||
var emailInput = document.getElementById('signupEmail');
|
||||
var email = emailInput.value.trim();
|
||||
|
||||
if (!email || !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email)) {
|
||||
errEl.textContent = 'Please enter a valid email address.';
|
||||
errEl.style.display = 'block';
|
||||
return;
|
||||
}
|
||||
|
||||
errEl.style.display = 'none';
|
||||
btn.disabled = true;
|
||||
showState('signupLoading');
|
||||
|
||||
try {
|
||||
var res = await fetch('/v1/signup/free', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ email: email })
|
||||
});
|
||||
var data = await res.json();
|
||||
|
||||
if (!res.ok) {
|
||||
showState('signupInitial');
|
||||
errEl.textContent = data.error || 'Something went wrong. Please try again.';
|
||||
errEl.style.display = 'block';
|
||||
btn.disabled = false;
|
||||
return;
|
||||
}
|
||||
|
||||
signupEmail = email;
|
||||
document.getElementById('verifyEmailDisplay').textContent = email;
|
||||
showState('signupVerify');
|
||||
document.getElementById('verifyCode').focus();
|
||||
btn.disabled = false;
|
||||
} catch (err) {
|
||||
showState('signupInitial');
|
||||
errEl.textContent = 'Network error. Please try again.';
|
||||
errEl.style.display = 'block';
|
||||
btn.disabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function submitVerify() {
|
||||
var errEl = document.getElementById('verifyError');
|
||||
var btn = document.getElementById('verifyBtn');
|
||||
var codeInput = document.getElementById('verifyCode');
|
||||
var code = codeInput.value.trim();
|
||||
|
||||
if (!code || !/^\d{6}$/.test(code)) {
|
||||
errEl.textContent = 'Please enter a 6-digit code.';
|
||||
errEl.style.display = 'block';
|
||||
return;
|
||||
}
|
||||
|
||||
errEl.style.display = 'none';
|
||||
btn.disabled = true;
|
||||
|
||||
try {
|
||||
var res = await fetch('/v1/signup/verify', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ email: signupEmail, code: code })
|
||||
});
|
||||
var data = await res.json();
|
||||
|
||||
if (!res.ok) {
|
||||
errEl.textContent = data.error || 'Verification failed.';
|
||||
errEl.style.display = 'block';
|
||||
btn.disabled = false;
|
||||
return;
|
||||
}
|
||||
|
||||
document.getElementById('apiKeyText').textContent = data.apiKey;
|
||||
showState('signupResult');
|
||||
} catch (err) {
|
||||
errEl.textContent = 'Network error. Please try again.';
|
||||
errEl.style.display = 'block';
|
||||
btn.disabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function submitRecover() {
|
||||
var errEl = document.getElementById('recoverError');
|
||||
var btn = document.getElementById('recoverBtn');
|
||||
var emailInput = document.getElementById('recoverEmailInput');
|
||||
var email = emailInput.value.trim();
|
||||
|
||||
if (!email || !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email)) {
|
||||
errEl.textContent = 'Please enter a valid email address.';
|
||||
errEl.style.display = 'block';
|
||||
return;
|
||||
}
|
||||
|
||||
errEl.style.display = 'none';
|
||||
btn.disabled = true;
|
||||
showRecoverState('recoverLoading');
|
||||
|
||||
try {
|
||||
var res = await fetch('/v1/recover', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ email: email })
|
||||
});
|
||||
var data = await res.json();
|
||||
|
||||
if (!res.ok) {
|
||||
showRecoverState('recoverInitial');
|
||||
errEl.textContent = data.error || 'Something went wrong.';
|
||||
errEl.style.display = 'block';
|
||||
btn.disabled = false;
|
||||
return;
|
||||
}
|
||||
|
||||
recoverEmail = email;
|
||||
document.getElementById('recoverEmailDisplay').textContent = email;
|
||||
showRecoverState('recoverVerify');
|
||||
document.getElementById('recoverCode').focus();
|
||||
btn.disabled = false;
|
||||
} catch (err) {
|
||||
showRecoverState('recoverInitial');
|
||||
errEl.textContent = 'Network error. Please try again.';
|
||||
errEl.style.display = 'block';
|
||||
btn.disabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function submitRecoverVerify() {
|
||||
var errEl = document.getElementById('recoverVerifyError');
|
||||
var btn = document.getElementById('recoverVerifyBtn');
|
||||
var codeInput = document.getElementById('recoverCode');
|
||||
var code = codeInput.value.trim();
|
||||
|
||||
if (!code || !/^\d{6}$/.test(code)) {
|
||||
errEl.textContent = 'Please enter a 6-digit code.';
|
||||
errEl.style.display = 'block';
|
||||
return;
|
||||
}
|
||||
|
||||
errEl.style.display = 'none';
|
||||
btn.disabled = true;
|
||||
|
||||
try {
|
||||
var res = await fetch('/v1/recover/verify', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ email: recoverEmail, code: code })
|
||||
});
|
||||
var data = await res.json();
|
||||
|
||||
if (!res.ok) {
|
||||
errEl.textContent = data.error || 'Verification failed.';
|
||||
errEl.style.display = 'block';
|
||||
btn.disabled = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (data.apiKey) {
|
||||
document.getElementById('recoveredKeyText').textContent = data.apiKey;
|
||||
showRecoverState('recoverResult');
|
||||
} else {
|
||||
errEl.textContent = data.message || 'No key found for this email.';
|
||||
errEl.style.display = 'block';
|
||||
btn.disabled = false;
|
||||
}
|
||||
} catch (err) {
|
||||
errEl.textContent = 'Network error. Please try again.';
|
||||
errEl.style.display = 'block';
|
||||
btn.disabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
function copyKey() {
|
||||
var key = document.getElementById('apiKeyText').textContent;
|
||||
var btn = document.getElementById('copyBtn');
|
||||
doCopy(key, btn);
|
||||
}
|
||||
|
||||
function copyRecoveredKey() {
|
||||
var key = document.getElementById('recoveredKeyText').textContent;
|
||||
var btn = document.getElementById('copyRecoveredBtn');
|
||||
doCopy(key, btn);
|
||||
}
|
||||
|
||||
function doCopy(text, btn) {
|
||||
function showCopied() {
|
||||
btn.textContent = '\u2713 Copied!';
|
||||
setTimeout(function() { btn.textContent = 'Copy'; }, 2000);
|
||||
}
|
||||
function showFailed() {
|
||||
btn.textContent = 'Failed';
|
||||
setTimeout(function() { btn.textContent = 'Copy'; }, 2000);
|
||||
}
|
||||
try {
|
||||
if (navigator.clipboard && window.isSecureContext) {
|
||||
navigator.clipboard.writeText(text).then(showCopied).catch(function() {
|
||||
// Fallback to execCommand
|
||||
try {
|
||||
var ta = document.createElement('textarea');
|
||||
ta.value = text;
|
||||
ta.style.position = 'fixed';
|
||||
ta.style.opacity = '0';
|
||||
ta.style.top = '-9999px';
|
||||
ta.style.left = '-9999px';
|
||||
document.body.appendChild(ta);
|
||||
ta.focus();
|
||||
ta.select();
|
||||
var success = document.execCommand('copy');
|
||||
document.body.removeChild(ta);
|
||||
if (success) {
|
||||
showCopied();
|
||||
} else {
|
||||
showFailed();
|
||||
}
|
||||
} catch (err) {
|
||||
showFailed();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// Direct fallback for non-secure contexts
|
||||
var ta = document.createElement('textarea');
|
||||
ta.value = text;
|
||||
ta.style.position = 'fixed';
|
||||
ta.style.opacity = '0';
|
||||
ta.style.top = '-9999px';
|
||||
ta.style.left = '-9999px';
|
||||
document.body.appendChild(ta);
|
||||
ta.focus();
|
||||
ta.select();
|
||||
var success = document.execCommand('copy');
|
||||
document.body.removeChild(ta);
|
||||
if (success) {
|
||||
showCopied();
|
||||
} else {
|
||||
showFailed();
|
||||
}
|
||||
}
|
||||
} catch(e) {
|
||||
showFailed();
|
||||
}
|
||||
}
|
||||
|
||||
async function checkout() {
|
||||
try {
|
||||
var res = await fetch('/v1/billing/checkout', { method: 'POST' });
|
||||
var data = await res.json();
|
||||
if (data.url) window.location.href = data.url;
|
||||
else alert('Checkout is not available yet. Please try again later.');
|
||||
} catch (err) {
|
||||
alert('Something went wrong. Please try again.');
|
||||
}
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
document.getElementById('btn-signup').addEventListener('click', openSignup);
|
||||
document.getElementById('btn-signup-2').addEventListener('click', openSignup);
|
||||
document.getElementById('btn-checkout').addEventListener('click', checkout);
|
||||
document.getElementById('btn-close-signup').addEventListener('click', closeSignup);
|
||||
document.getElementById('signupBtn').addEventListener('click', submitSignup);
|
||||
document.getElementById('verifyBtn').addEventListener('click', submitVerify);
|
||||
document.getElementById('copyBtn').addEventListener('click', copyKey);
|
||||
|
||||
// Recovery modal
|
||||
document.getElementById('btn-close-recover').addEventListener('click', closeRecover);
|
||||
document.getElementById('recoverBtn').addEventListener('click', submitRecover);
|
||||
document.getElementById('recoverVerifyBtn').addEventListener('click', submitRecoverVerify);
|
||||
document.getElementById('copyRecoveredBtn').addEventListener('click', copyRecoveredKey);
|
||||
document.getElementById('recoverModal').addEventListener('click', function(e) {
|
||||
if (e.target === this) closeRecover();
|
||||
});
|
||||
|
||||
// Open recovery from links
|
||||
document.querySelectorAll('.open-recover').forEach(function(el) {
|
||||
el.addEventListener('click', function(e) { e.preventDefault(); openRecover(); });
|
||||
});
|
||||
|
||||
document.getElementById('signupModal').addEventListener('click', function(e) {
|
||||
if (e.target === this) closeSignup();
|
||||
});
|
||||
document.querySelectorAll('a[href^="#"]').forEach(function(a) {
|
||||
a.addEventListener('click', function(e) {
|
||||
e.preventDefault();
|
||||
var el = document.querySelector(this.getAttribute('href'));
|
||||
if (el) el.scrollIntoView({ behavior: 'smooth' });
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// --- Email Change ---
|
||||
var emailChangeApiKey = '';
|
||||
var emailChangeNewEmail = '';
|
||||
|
||||
function showEmailChangeState(state) {
|
||||
['emailChangeInitial', 'emailChangeLoading', 'emailChangeVerify', 'emailChangeResult'].forEach(function(id) {
|
||||
var el = document.getElementById(id);
|
||||
if (el) el.classList.remove('active');
|
||||
});
|
||||
document.getElementById(state).classList.add('active');
|
||||
}
|
||||
|
||||
function openEmailChange() {
|
||||
closeSignup();
|
||||
closeRecover();
|
||||
document.getElementById('emailChangeModal').classList.add('active');
|
||||
showEmailChangeState('emailChangeInitial');
|
||||
var errEl = document.getElementById('emailChangeError');
|
||||
if (errEl) errEl.style.display = 'none';
|
||||
var verifyErrEl = document.getElementById('emailChangeVerifyError');
|
||||
if (verifyErrEl) verifyErrEl.style.display = 'none';
|
||||
document.getElementById('emailChangeApiKey').value = '';
|
||||
document.getElementById('emailChangeNewEmail').value = '';
|
||||
document.getElementById('emailChangeCode').value = '';
|
||||
emailChangeApiKey = '';
|
||||
emailChangeNewEmail = '';
|
||||
}
|
||||
|
||||
function closeEmailChange() {
|
||||
document.getElementById('emailChangeModal').classList.remove('active');
|
||||
}
|
||||
|
||||
async function submitEmailChange() {
|
||||
var errEl = document.getElementById('emailChangeError');
|
||||
var btn = document.getElementById('emailChangeBtn');
|
||||
var apiKey = document.getElementById('emailChangeApiKey').value.trim();
|
||||
var newEmail = document.getElementById('emailChangeNewEmail').value.trim();
|
||||
|
||||
if (!apiKey) {
|
||||
errEl.textContent = 'Please enter your API key.';
|
||||
errEl.style.display = 'block';
|
||||
return;
|
||||
}
|
||||
if (!newEmail || !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(newEmail)) {
|
||||
errEl.textContent = 'Please enter a valid email address.';
|
||||
errEl.style.display = 'block';
|
||||
return;
|
||||
}
|
||||
|
||||
errEl.style.display = 'none';
|
||||
btn.disabled = true;
|
||||
showEmailChangeState('emailChangeLoading');
|
||||
|
||||
try {
|
||||
var res = await fetch('/v1/email-change', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ apiKey: apiKey, newEmail: newEmail })
|
||||
});
|
||||
var data = await res.json();
|
||||
|
||||
if (!res.ok) {
|
||||
showEmailChangeState('emailChangeInitial');
|
||||
errEl.textContent = data.error || 'Something went wrong.';
|
||||
errEl.style.display = 'block';
|
||||
btn.disabled = false;
|
||||
return;
|
||||
}
|
||||
|
||||
emailChangeApiKey = apiKey;
|
||||
emailChangeNewEmail = newEmail;
|
||||
document.getElementById('emailChangeEmailDisplay').textContent = newEmail;
|
||||
showEmailChangeState('emailChangeVerify');
|
||||
document.getElementById('emailChangeCode').focus();
|
||||
btn.disabled = false;
|
||||
} catch (err) {
|
||||
showEmailChangeState('emailChangeInitial');
|
||||
errEl.textContent = 'Network error. Please try again.';
|
||||
errEl.style.display = 'block';
|
||||
btn.disabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function submitEmailChangeVerify() {
|
||||
var errEl = document.getElementById('emailChangeVerifyError');
|
||||
var btn = document.getElementById('emailChangeVerifyBtn');
|
||||
var code = document.getElementById('emailChangeCode').value.trim();
|
||||
|
||||
if (!code || !/^\d{6}$/.test(code)) {
|
||||
errEl.textContent = 'Please enter a 6-digit code.';
|
||||
errEl.style.display = 'block';
|
||||
return;
|
||||
}
|
||||
|
||||
errEl.style.display = 'none';
|
||||
btn.disabled = true;
|
||||
|
||||
try {
|
||||
var res = await fetch('/v1/email-change/verify', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ apiKey: emailChangeApiKey, newEmail: emailChangeNewEmail, code: code })
|
||||
});
|
||||
var data = await res.json();
|
||||
|
||||
if (!res.ok) {
|
||||
errEl.textContent = data.error || 'Verification failed.';
|
||||
errEl.style.display = 'block';
|
||||
btn.disabled = false;
|
||||
return;
|
||||
}
|
||||
|
||||
document.getElementById('emailChangeNewDisplay').textContent = data.newEmail || emailChangeNewEmail;
|
||||
showEmailChangeState('emailChangeResult');
|
||||
} catch (err) {
|
||||
errEl.textContent = 'Network error. Please try again.';
|
||||
errEl.style.display = 'block';
|
||||
btn.disabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Add event listeners for email change (append to DOMContentLoaded)
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
var closeBtn = document.getElementById('btn-close-email-change');
|
||||
if (closeBtn) closeBtn.addEventListener('click', closeEmailChange);
|
||||
|
||||
var changeBtn = document.getElementById('emailChangeBtn');
|
||||
if (changeBtn) changeBtn.addEventListener('click', submitEmailChange);
|
||||
|
||||
var verifyBtn = document.getElementById('emailChangeVerifyBtn');
|
||||
if (verifyBtn) verifyBtn.addEventListener('click', submitEmailChangeVerify);
|
||||
|
||||
var modal = document.getElementById('emailChangeModal');
|
||||
if (modal) modal.addEventListener('click', function(e) { if (e.target === this) closeEmailChange(); });
|
||||
|
||||
document.querySelectorAll('.open-email-change').forEach(function(el) {
|
||||
el.addEventListener('click', function(e) { e.preventDefault(); openEmailChange(); });
|
||||
});
|
||||
});
|
||||
|
||||
// === Accessibility: Escape key closes modals, focus trapping ===
|
||||
(function() {
|
||||
function getActiveModal() {
|
||||
var modals = ['signupModal', 'recoverModal', 'emailChangeModal'];
|
||||
for (var i = 0; i < modals.length; i++) {
|
||||
var m = document.getElementById(modals[i]);
|
||||
if (m && m.classList.contains('active')) return m;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function closeActiveModal() {
|
||||
var m = getActiveModal();
|
||||
if (!m) return;
|
||||
m.classList.remove('active');
|
||||
}
|
||||
|
||||
document.addEventListener('keydown', function(e) {
|
||||
if (e.key === 'Escape') closeActiveModal();
|
||||
|
||||
// Focus trap inside active modal
|
||||
if (e.key === 'Tab') {
|
||||
var modal = getActiveModal();
|
||||
if (!modal) return;
|
||||
var focusable = modal.querySelectorAll('button:not([disabled]), input:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])');
|
||||
if (focusable.length === 0) return;
|
||||
var first = focusable[0], last = focusable[focusable.length - 1];
|
||||
if (e.shiftKey) {
|
||||
if (document.activeElement === first) { e.preventDefault(); last.focus(); }
|
||||
} else {
|
||||
if (document.activeElement === last) { e.preventDefault(); first.focus(); }
|
||||
}
|
||||
}
|
||||
});
|
||||
})();
|
||||
|
|
@ -4,391 +4,106 @@
|
|||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>DocFast API Documentation</title>
|
||||
<link rel="icon" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><text y='.9em' font-size='90'>⚡</text></svg>">
|
||||
<link rel="stylesheet" href="/swagger-ui/swagger-ui.css">
|
||||
<style>
|
||||
* { margin: 0; padding: 0; box-sizing: border-box; }
|
||||
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: #0a0a0a; color: #e0e0e0; line-height: 1.6; }
|
||||
a { color: #6c9fff; text-decoration: none; }
|
||||
a:hover { text-decoration: underline; }
|
||||
html { box-sizing: border-box; overflow-y: scroll; }
|
||||
*, *:before, *:after { box-sizing: inherit; }
|
||||
body { margin: 0; background: #1a1a2e; font-family: 'Inter', -apple-system, system-ui, sans-serif; }
|
||||
|
||||
.container { max-width: 900px; margin: 0 auto; padding: 2rem; }
|
||||
/* Top bar */
|
||||
.topbar-wrapper { display: flex; align-items: center; }
|
||||
.swagger-ui .topbar { background: #0b0d11; border-bottom: 1px solid #1e2433; padding: 12px 0; }
|
||||
.swagger-ui .topbar .topbar-wrapper { max-width: 1200px; margin: 0 auto; padding: 0 24px; }
|
||||
.swagger-ui .topbar a { font-size: 0; }
|
||||
.swagger-ui .topbar .topbar-wrapper::before {
|
||||
content: '⚡ DocFast API';
|
||||
font-size: 1.25rem;
|
||||
font-weight: 700;
|
||||
color: #e4e7ed;
|
||||
font-family: 'Inter', system-ui, sans-serif;
|
||||
}
|
||||
.swagger-ui .topbar .topbar-wrapper::after {
|
||||
content: '← Back to docfast.dev';
|
||||
margin-left: auto;
|
||||
font-size: 0.85rem;
|
||||
color: #34d399;
|
||||
cursor: pointer;
|
||||
font-family: 'Inter', system-ui, sans-serif;
|
||||
}
|
||||
.swagger-ui .topbar .topbar-wrapper { cursor: default; }
|
||||
|
||||
header { border-bottom: 1px solid #222; padding-bottom: 1.5rem; margin-bottom: 2rem; }
|
||||
header h1 { font-size: 2rem; margin-bottom: 0.5rem; }
|
||||
header h1 a { color: #fff; }
|
||||
header p { color: #888; font-size: 1.1rem; }
|
||||
.base-url { background: #1a1a2e; border: 1px solid #333; border-radius: 6px; padding: 0.75rem 1rem; font-family: monospace; font-size: 0.95rem; margin-top: 1rem; color: #6c9fff; }
|
||||
/* Dark theme overrides */
|
||||
.swagger-ui { color: #c8ccd4; }
|
||||
.swagger-ui .wrapper { max-width: 1200px; padding: 0 24px; }
|
||||
.swagger-ui .scheme-container { background: #151922; border: 1px solid #1e2433; border-radius: 8px; margin: 16px 0; box-shadow: none; }
|
||||
.swagger-ui .opblock-tag { color: #e4e7ed !important; border-bottom: 1px solid #1e2433; }
|
||||
.swagger-ui .opblock-tag:hover { background: rgba(52,211,153,0.04); }
|
||||
.swagger-ui .opblock { background: #151922; border: 1px solid #1e2433 !important; border-radius: 8px !important; margin-bottom: 12px; box-shadow: none !important; }
|
||||
.swagger-ui .opblock .opblock-summary { border: none; }
|
||||
.swagger-ui .opblock .opblock-summary-method { border-radius: 6px; font-size: 0.75rem; min-width: 70px; }
|
||||
.swagger-ui .opblock.opblock-post .opblock-summary-method { background: #34d399; }
|
||||
.swagger-ui .opblock.opblock-get .opblock-summary-method { background: #60a5fa; }
|
||||
.swagger-ui .opblock.opblock-post { border-color: rgba(52,211,153,0.3) !important; background: rgba(52,211,153,0.03); }
|
||||
.swagger-ui .opblock.opblock-get { border-color: rgba(96,165,250,0.3) !important; background: rgba(96,165,250,0.03); }
|
||||
.swagger-ui .opblock .opblock-summary-path { color: #e4e7ed; }
|
||||
.swagger-ui .opblock .opblock-summary-description { color: #7a8194; }
|
||||
.swagger-ui .opblock-body { background: #0b0d11; }
|
||||
.swagger-ui .opblock-description-wrapper p,
|
||||
.swagger-ui .opblock-external-docs-wrapper p { color: #9ca3af; }
|
||||
.swagger-ui table thead tr th { color: #7a8194; border-bottom: 1px solid #1e2433; }
|
||||
.swagger-ui table tbody tr td { color: #c8ccd4; border-bottom: 1px solid #1e2433; }
|
||||
.swagger-ui .parameter__name { color: #e4e7ed; }
|
||||
.swagger-ui .parameter__type { color: #60a5fa; }
|
||||
.swagger-ui .parameter__name.required::after { color: #f87171; }
|
||||
.swagger-ui input[type=text], .swagger-ui textarea, .swagger-ui select {
|
||||
background: #0b0d11; color: #e4e7ed; border: 1px solid #1e2433; border-radius: 6px;
|
||||
}
|
||||
.swagger-ui .btn { border-radius: 6px; }
|
||||
.swagger-ui .btn.execute { background: #34d399; color: #0b0d11; border: none; }
|
||||
.swagger-ui .btn.execute:hover { background: #5eead4; }
|
||||
.swagger-ui .responses-inner { background: transparent; }
|
||||
.swagger-ui .response-col_status { color: #34d399; }
|
||||
.swagger-ui .response-col_description { color: #9ca3af; }
|
||||
.swagger-ui .model-box, .swagger-ui section.models { background: #151922; border: 1px solid #1e2433; border-radius: 8px; }
|
||||
.swagger-ui section.models h4 { color: #e4e7ed; border-bottom: 1px solid #1e2433; }
|
||||
.swagger-ui .model { color: #c8ccd4; }
|
||||
.swagger-ui .model-title { color: #e4e7ed; }
|
||||
.swagger-ui .prop-type { color: #60a5fa; }
|
||||
.swagger-ui .info .title { color: #e4e7ed; font-family: 'Inter', system-ui, sans-serif; }
|
||||
.swagger-ui .info .description p { color: #9ca3af; }
|
||||
.swagger-ui .info a { color: #34d399; }
|
||||
.swagger-ui .info h1, .swagger-ui .info h2, .swagger-ui .info h3 { color: #e4e7ed; }
|
||||
.swagger-ui .info .base-url { color: #7a8194; }
|
||||
.swagger-ui .scheme-container .schemes > label { color: #7a8194; }
|
||||
.swagger-ui .loading-container .loading::after { color: #7a8194; }
|
||||
.swagger-ui .highlight-code, .swagger-ui .microlight { background: #0b0d11 !important; color: #c8ccd4 !important; border-radius: 6px; }
|
||||
.swagger-ui .copy-to-clipboard { right: 10px; top: 10px; }
|
||||
.swagger-ui .auth-wrapper .authorize { color: #34d399; border-color: #34d399; }
|
||||
.swagger-ui .auth-wrapper .authorize svg { fill: #34d399; }
|
||||
.swagger-ui .dialog-ux .modal-ux { background: #151922; border: 1px solid #1e2433; }
|
||||
.swagger-ui .dialog-ux .modal-ux-header h3 { color: #e4e7ed; }
|
||||
.swagger-ui .dialog-ux .modal-ux-content p { color: #9ca3af; }
|
||||
.swagger-ui .model-box-control:focus, .swagger-ui .models-control:focus { outline: none; }
|
||||
.swagger-ui .servers > label select { background: #0b0d11; color: #e4e7ed; border: 1px solid #1e2433; }
|
||||
.swagger-ui .markdown code, .swagger-ui .renderedMarkdown code { background: rgba(52,211,153,0.1); color: #34d399; padding: 2px 6px; border-radius: 4px; }
|
||||
.swagger-ui .markdown p, .swagger-ui .renderedMarkdown p { color: #9ca3af; }
|
||||
.swagger-ui .opblock-tag small { color: #7a8194; }
|
||||
|
||||
nav { background: #111; border: 1px solid #222; border-radius: 8px; padding: 1.25rem; margin-bottom: 2rem; }
|
||||
nav h3 { margin-bottom: 0.75rem; color: #888; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.05em; }
|
||||
nav ul { list-style: none; }
|
||||
nav li { margin-bottom: 0.4rem; }
|
||||
nav a { font-size: 0.95rem; }
|
||||
nav .method { font-family: monospace; font-size: 0.8rem; font-weight: 600; padding: 2px 6px; border-radius: 3px; margin-right: 0.5rem; }
|
||||
.method-post { background: #1a3a1a; color: #4caf50; }
|
||||
.method-get { background: #1a2a3a; color: #6c9fff; }
|
||||
/* Hide validator */
|
||||
.swagger-ui .errors-wrapper { display: none; }
|
||||
|
||||
section { margin-bottom: 3rem; }
|
||||
section h2 { font-size: 1.5rem; border-bottom: 1px solid #222; padding-bottom: 0.5rem; margin-bottom: 1rem; }
|
||||
section h3 { font-size: 1.2rem; margin: 2rem 0 0.75rem; color: #fff; }
|
||||
|
||||
.endpoint { background: #111; border: 1px solid #222; border-radius: 8px; padding: 1.5rem; margin-bottom: 2rem; }
|
||||
.endpoint-header { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1rem; }
|
||||
.endpoint-header .method { font-family: monospace; font-weight: 700; font-size: 0.85rem; padding: 4px 10px; border-radius: 4px; }
|
||||
.endpoint-header .path { font-family: monospace; font-size: 1.05rem; color: #fff; }
|
||||
|
||||
table { width: 100%; border-collapse: collapse; margin: 0.75rem 0; }
|
||||
th, td { text-align: left; padding: 0.5rem 0.75rem; border-bottom: 1px solid #1a1a1a; font-size: 0.9rem; }
|
||||
th { color: #888; font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; }
|
||||
td code { background: #1a1a2e; padding: 2px 6px; border-radius: 3px; font-size: 0.85rem; }
|
||||
.required { color: #ff6b6b; font-size: 0.75rem; }
|
||||
|
||||
pre { background: #0d0d1a; border: 1px solid #222; border-radius: 6px; padding: 1rem; overflow-x: auto; font-size: 0.85rem; line-height: 1.5; margin: 0.75rem 0; }
|
||||
code { font-family: 'SF Mono', 'Fira Code', monospace; }
|
||||
.comment { color: #666; }
|
||||
.string { color: #a5d6a7; }
|
||||
.key { color: #90caf9; }
|
||||
|
||||
.note { background: #1a1a2e; border-left: 3px solid #6c9fff; padding: 0.75rem 1rem; border-radius: 0 6px 6px 0; margin: 1rem 0; font-size: 0.9rem; }
|
||||
.warning { background: #2a1a1a; border-left: 3px solid #ff6b6b; }
|
||||
|
||||
.status-codes { margin-top: 0.5rem; }
|
||||
.status-codes span { display: inline-block; background: #1a1a2e; padding: 2px 8px; border-radius: 3px; font-family: monospace; font-size: 0.8rem; margin: 2px 4px 2px 0; }
|
||||
.status-ok { color: #4caf50; }
|
||||
.status-err { color: #ff6b6b; }
|
||||
|
||||
footer { border-top: 1px solid #222; padding-top: 1.5rem; margin-top: 3rem; text-align: center; color: #555; font-size: 0.85rem; }
|
||||
/* Link back */
|
||||
.back-link { position: fixed; top: 14px; right: 24px; z-index: 100; color: #34d399; text-decoration: none; font-size: 0.85rem; font-family: 'Inter', system-ui, sans-serif; }
|
||||
.back-link:hover { color: #5eead4; }
|
||||
</style>
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap" rel="stylesheet">
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<header>
|
||||
<h1><a href="/">DocFast</a> API Documentation</h1>
|
||||
<p>Convert HTML, Markdown, and URLs to PDF. Built-in invoice & receipt templates.</p>
|
||||
<div class="base-url">Base URL: https://docfast.dev</div>
|
||||
</header>
|
||||
|
||||
<nav>
|
||||
<h3>Endpoints</h3>
|
||||
<ul>
|
||||
<li><a href="#auth">Authentication</a></li>
|
||||
<li><a href="#html"><span class="method method-post">POST</span>/v1/convert/html</a></li>
|
||||
<li><a href="#markdown"><span class="method method-post">POST</span>/v1/convert/markdown</a></li>
|
||||
<li><a href="#url"><span class="method method-post">POST</span>/v1/convert/url</a></li>
|
||||
<li><a href="#templates-list"><span class="method method-get">GET</span>/v1/templates</a></li>
|
||||
<li><a href="#templates-render"><span class="method method-post">POST</span>/v1/templates/:id/render</a></li>
|
||||
<li><a href="#signup"><span class="method method-post">POST</span>/v1/signup/free</a></li>
|
||||
<li><a href="#errors">Error Handling</a></li>
|
||||
</ul>
|
||||
</nav>
|
||||
|
||||
<section id="auth">
|
||||
<h2>Authentication</h2>
|
||||
<p>All conversion and template endpoints require an API key. Pass it in the <code>Authorization</code> header:</p>
|
||||
<pre>Authorization: Bearer df_free_your_api_key_here</pre>
|
||||
<p style="margin-top:0.75rem">Get a free API key instantly — no credit card required:</p>
|
||||
<pre>curl -X POST https://docfast.dev/v1/signup/free \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"email": "you@example.com"}'</pre>
|
||||
<div class="note">Free tier: <strong>100 PDFs/month</strong>. Pro ($9/mo): <strong>10,000 PDFs/month</strong>. Upgrade anytime at <a href="https://docfast.dev">docfast.dev</a>.</div>
|
||||
</section>
|
||||
|
||||
<section id="html">
|
||||
<h2>Convert HTML to PDF</h2>
|
||||
<div class="endpoint">
|
||||
<div class="endpoint-header">
|
||||
<span class="method method-post">POST</span>
|
||||
<span class="path">/v1/convert/html</span>
|
||||
</div>
|
||||
<p>Convert raw HTML (with optional CSS) to a PDF document.</p>
|
||||
|
||||
<h3>Request Body</h3>
|
||||
<table>
|
||||
<tr><th>Field</th><th>Type</th><th>Description</th></tr>
|
||||
<tr><td><code>html</code> <span class="required">required</span></td><td>string</td><td>HTML content to convert</td></tr>
|
||||
<tr><td><code>css</code></td><td>string</td><td>Additional CSS to inject</td></tr>
|
||||
<tr><td><code>format</code></td><td>string</td><td>Page size: <code>A4</code> (default), <code>Letter</code>, <code>Legal</code>, <code>A3</code></td></tr>
|
||||
<tr><td><code>landscape</code></td><td>boolean</td><td>Landscape orientation (default: false)</td></tr>
|
||||
<tr><td><code>margin</code></td><td>object</td><td><code>{top, right, bottom, left}</code> in CSS units (default: 20mm each)</td></tr>
|
||||
</table>
|
||||
|
||||
<h3>Example</h3>
|
||||
<pre>curl -X POST https://docfast.dev/v1/convert/html \
|
||||
-H "Authorization: Bearer YOUR_KEY" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"html": "<h1>Hello World</h1><p>Generated by DocFast.</p>",
|
||||
"css": "h1 { color: navy; }",
|
||||
"format": "A4"
|
||||
}' \
|
||||
-o output.pdf</pre>
|
||||
|
||||
<h3>Response</h3>
|
||||
<p><code>200 OK</code> — Returns the PDF as <code>application/pdf</code> binary stream.</p>
|
||||
<div class="status-codes">
|
||||
<span class="status-ok">200</span> PDF generated
|
||||
<span class="status-err">400</span> Missing <code>html</code> field
|
||||
<span class="status-err">401</span> Invalid/missing API key
|
||||
<span class="status-err">429</span> Rate limited
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section id="markdown">
|
||||
<h2>Convert Markdown to PDF</h2>
|
||||
<div class="endpoint">
|
||||
<div class="endpoint-header">
|
||||
<span class="method method-post">POST</span>
|
||||
<span class="path">/v1/convert/markdown</span>
|
||||
</div>
|
||||
<p>Convert Markdown to a styled PDF with syntax highlighting for code blocks.</p>
|
||||
|
||||
<h3>Request Body</h3>
|
||||
<table>
|
||||
<tr><th>Field</th><th>Type</th><th>Description</th></tr>
|
||||
<tr><td><code>markdown</code> <span class="required">required</span></td><td>string</td><td>Markdown content</td></tr>
|
||||
<tr><td><code>css</code></td><td>string</td><td>Additional CSS to inject</td></tr>
|
||||
<tr><td><code>format</code></td><td>string</td><td>Page size (default: A4)</td></tr>
|
||||
<tr><td><code>landscape</code></td><td>boolean</td><td>Landscape orientation</td></tr>
|
||||
<tr><td><code>margin</code></td><td>object</td><td>Custom margins</td></tr>
|
||||
</table>
|
||||
|
||||
<h3>Example</h3>
|
||||
<pre>curl -X POST https://docfast.dev/v1/convert/markdown \
|
||||
-H "Authorization: Bearer YOUR_KEY" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"markdown": "# Monthly Report\n\n## Summary\n\nRevenue increased by **15%** this quarter.\n\n| Metric | Value |\n|--------|-------|\n| Users | 1,234 |\n| MRR | $5,670 |"
|
||||
}' \
|
||||
-o report.pdf</pre>
|
||||
|
||||
<h3>Response</h3>
|
||||
<p><code>200 OK</code> — Returns <code>application/pdf</code>.</p>
|
||||
<div class="status-codes">
|
||||
<span class="status-ok">200</span> PDF generated
|
||||
<span class="status-err">400</span> Missing <code>markdown</code> field
|
||||
<span class="status-err">401</span> Invalid/missing API key
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section id="url">
|
||||
<h2>Convert URL to PDF</h2>
|
||||
<div class="endpoint">
|
||||
<div class="endpoint-header">
|
||||
<span class="method method-post">POST</span>
|
||||
<span class="path">/v1/convert/url</span>
|
||||
</div>
|
||||
<p>Navigate to a URL and convert the rendered page to PDF. Supports JavaScript-rendered pages.</p>
|
||||
|
||||
<h3>Request Body</h3>
|
||||
<table>
|
||||
<tr><th>Field</th><th>Type</th><th>Description</th></tr>
|
||||
<tr><td><code>url</code> <span class="required">required</span></td><td>string</td><td>URL to convert (must start with http:// or https://)</td></tr>
|
||||
<tr><td><code>waitUntil</code></td><td>string</td><td><code>load</code> (default), <code>domcontentloaded</code>, <code>networkidle0</code>, <code>networkidle2</code></td></tr>
|
||||
<tr><td><code>format</code></td><td>string</td><td>Page size (default: A4)</td></tr>
|
||||
<tr><td><code>landscape</code></td><td>boolean</td><td>Landscape orientation</td></tr>
|
||||
<tr><td><code>margin</code></td><td>object</td><td>Custom margins</td></tr>
|
||||
</table>
|
||||
|
||||
<h3>Example</h3>
|
||||
<pre>curl -X POST https://docfast.dev/v1/convert/url \
|
||||
-H "Authorization: Bearer YOUR_KEY" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"url": "https://example.com",
|
||||
"waitUntil": "networkidle0",
|
||||
"format": "Letter"
|
||||
}' \
|
||||
-o page.pdf</pre>
|
||||
|
||||
<h3>Response</h3>
|
||||
<p><code>200 OK</code> — Returns <code>application/pdf</code>.</p>
|
||||
<div class="status-codes">
|
||||
<span class="status-ok">200</span> PDF generated
|
||||
<span class="status-err">400</span> Missing or invalid URL
|
||||
<span class="status-err">401</span> Invalid/missing API key
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section id="templates-list">
|
||||
<h2>List Templates</h2>
|
||||
<div class="endpoint">
|
||||
<div class="endpoint-header">
|
||||
<span class="method method-get">GET</span>
|
||||
<span class="path">/v1/templates</span>
|
||||
</div>
|
||||
<p>List all available document templates with their field definitions.</p>
|
||||
|
||||
<h3>Example</h3>
|
||||
<pre>curl https://docfast.dev/v1/templates \
|
||||
-H "Authorization: Bearer YOUR_KEY"</pre>
|
||||
|
||||
<h3>Response</h3>
|
||||
<pre>{
|
||||
"templates": [
|
||||
{
|
||||
"id": "invoice",
|
||||
"name": "Invoice",
|
||||
"description": "Professional invoice with line items, taxes, and payment details",
|
||||
"fields": [
|
||||
{"name": "invoiceNumber", "type": "string", "required": true},
|
||||
{"name": "date", "type": "string", "required": true},
|
||||
{"name": "from", "type": "object", "required": true, "description": "Sender: {name, address?, email?, phone?, vatId?}"},
|
||||
{"name": "to", "type": "object", "required": true, "description": "Recipient: {name, address?, email?, vatId?}"},
|
||||
{"name": "items", "type": "array", "required": true, "description": "Line items: [{description, quantity, unitPrice, taxRate?}]"},
|
||||
{"name": "currency", "type": "string", "required": false},
|
||||
{"name": "notes", "type": "string", "required": false},
|
||||
{"name": "paymentDetails", "type": "string", "required": false}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "receipt",
|
||||
"name": "Receipt",
|
||||
"description": "Simple receipt for payments received",
|
||||
"fields": [ ... ]
|
||||
}
|
||||
]
|
||||
}</pre>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section id="templates-render">
|
||||
<h2>Render Template</h2>
|
||||
<div class="endpoint">
|
||||
<div class="endpoint-header">
|
||||
<span class="method method-post">POST</span>
|
||||
<span class="path">/v1/templates/:id/render</span>
|
||||
</div>
|
||||
<p>Render a template with your data and get a PDF. No HTML needed — just pass structured data.</p>
|
||||
|
||||
<h3>Path Parameters</h3>
|
||||
<table>
|
||||
<tr><th>Param</th><th>Description</th></tr>
|
||||
<tr><td><code>:id</code></td><td>Template ID (<code>invoice</code> or <code>receipt</code>)</td></tr>
|
||||
</table>
|
||||
|
||||
<h3>Request Body</h3>
|
||||
<table>
|
||||
<tr><th>Field</th><th>Type</th><th>Description</th></tr>
|
||||
<tr><td><code>data</code> <span class="required">required</span></td><td>object</td><td>Template data (see field definitions from <code>/v1/templates</code>)</td></tr>
|
||||
</table>
|
||||
|
||||
<h3>Invoice Example</h3>
|
||||
<pre>curl -X POST https://docfast.dev/v1/templates/invoice/render \
|
||||
-H "Authorization: Bearer YOUR_KEY" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"data": {
|
||||
"invoiceNumber": "INV-2026-001",
|
||||
"date": "2026-02-14",
|
||||
"dueDate": "2026-03-14",
|
||||
"from": {
|
||||
"name": "Acme Corp",
|
||||
"address": "123 Main St, Vienna",
|
||||
"email": "billing@acme.com",
|
||||
"vatId": "ATU12345678"
|
||||
},
|
||||
"to": {
|
||||
"name": "Client Inc",
|
||||
"address": "456 Oak Ave, Berlin",
|
||||
"email": "accounts@client.com"
|
||||
},
|
||||
"items": [
|
||||
{"description": "Web Development", "quantity": 40, "unitPrice": 95, "taxRate": 20},
|
||||
{"description": "Hosting (monthly)", "quantity": 1, "unitPrice": 29}
|
||||
],
|
||||
"currency": "€",
|
||||
"notes": "Payment due within 30 days.",
|
||||
"paymentDetails": "IBAN: AT12 3456 7890 1234 5678"
|
||||
}
|
||||
}' \
|
||||
-o invoice.pdf</pre>
|
||||
|
||||
<h3>Response</h3>
|
||||
<p><code>200 OK</code> — Returns <code>application/pdf</code>.</p>
|
||||
<div class="status-codes">
|
||||
<span class="status-ok">200</span> PDF generated
|
||||
<span class="status-err">400</span> Missing <code>data</code> field
|
||||
<span class="status-err">404</span> Template not found
|
||||
<span class="status-err">401</span> Invalid/missing API key
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section id="signup">
|
||||
<h2>Sign Up (Get API Key)</h2>
|
||||
<div class="endpoint">
|
||||
<div class="endpoint-header">
|
||||
<span class="method method-post">POST</span>
|
||||
<span class="path">/v1/signup/free</span>
|
||||
</div>
|
||||
<p>Get a free API key instantly. No authentication required.</p>
|
||||
|
||||
<h3>Request Body</h3>
|
||||
<table>
|
||||
<tr><th>Field</th><th>Type</th><th>Description</th></tr>
|
||||
<tr><td><code>email</code> <span class="required">required</span></td><td>string</td><td>Your email address</td></tr>
|
||||
</table>
|
||||
|
||||
<h3>Example</h3>
|
||||
<pre>curl -X POST https://docfast.dev/v1/signup/free \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"email": "dev@example.com"}'</pre>
|
||||
|
||||
<h3>Response</h3>
|
||||
<pre>{
|
||||
"message": "Welcome to DocFast! 🚀",
|
||||
"apiKey": "df_free_abc123...",
|
||||
"tier": "free",
|
||||
"limit": "100 PDFs/month",
|
||||
"docs": "https://docfast.dev/#endpoints"
|
||||
}</pre>
|
||||
<div class="note warning">Save your API key immediately — it won't be shown again.</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section id="errors">
|
||||
<h2>Error Handling</h2>
|
||||
<p>All errors return JSON with an <code>error</code> field:</p>
|
||||
<pre>{
|
||||
"error": "Missing 'html' field"
|
||||
}</pre>
|
||||
|
||||
<h3>Status Codes</h3>
|
||||
<table>
|
||||
<tr><th>Code</th><th>Meaning</th></tr>
|
||||
<tr><td><code>200</code></td><td>Success — PDF returned as binary stream</td></tr>
|
||||
<tr><td><code>400</code></td><td>Bad request — missing or invalid parameters</td></tr>
|
||||
<tr><td><code>401</code></td><td>Unauthorized — missing or invalid API key</td></tr>
|
||||
<tr><td><code>404</code></td><td>Not found — invalid endpoint or template ID</td></tr>
|
||||
<tr><td><code>429</code></td><td>Rate limited — too many requests (100/min)</td></tr>
|
||||
<tr><td><code>500</code></td><td>Server error — PDF generation failed</td></tr>
|
||||
</table>
|
||||
|
||||
<h3>Common Mistakes</h3>
|
||||
<pre><span class="comment"># ❌ Missing Authorization header</span>
|
||||
curl -X POST https://docfast.dev/v1/convert/html \
|
||||
-d '{"html": "test"}'
|
||||
<span class="comment"># → {"error": "Missing API key. Use: Authorization: Bearer <key>"}</span>
|
||||
|
||||
<span class="comment"># ❌ Wrong Content-Type</span>
|
||||
curl -X POST https://docfast.dev/v1/convert/html \
|
||||
-H "Authorization: Bearer YOUR_KEY" \
|
||||
-d '{"html": "test"}'
|
||||
<span class="comment"># → Make sure to include -H "Content-Type: application/json"</span>
|
||||
|
||||
<span class="comment"># ✅ Correct request</span>
|
||||
curl -X POST https://docfast.dev/v1/convert/html \
|
||||
-H "Authorization: Bearer YOUR_KEY" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"html": "<h1>Hello</h1>"}' \
|
||||
-o output.pdf</pre>
|
||||
</section>
|
||||
|
||||
<footer>
|
||||
<p><a href="/">← Back to DocFast</a> | Questions? Email <a href="mailto:support@docfast.dev">support@docfast.dev</a></p>
|
||||
</footer>
|
||||
</div>
|
||||
<a href="/" class="back-link">← Back to docfast.dev</a>
|
||||
<div id="swagger-ui"></div>
|
||||
<script src="/swagger-ui/swagger-ui-bundle.js"></script>
|
||||
<script src="/swagger-init.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
109
projects/business/src/pdf-api/public/docs.html.server
Normal file
109
projects/business/src/pdf-api/public/docs.html.server
Normal file
|
|
@ -0,0 +1,109 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>DocFast API Documentation</title>
|
||||
<link rel="icon" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><text y='.9em' font-size='90'>⚡</text></svg>">
|
||||
<link rel="stylesheet" href="/swagger-ui/swagger-ui.css">
|
||||
<style>
|
||||
html { box-sizing: border-box; overflow-y: scroll; }
|
||||
*, *:before, *:after { box-sizing: inherit; }
|
||||
body { margin: 0; background: #1a1a2e; font-family: 'Inter', -apple-system, system-ui, sans-serif; }
|
||||
|
||||
/* Top bar */
|
||||
.topbar-wrapper { display: flex; align-items: center; }
|
||||
.swagger-ui .topbar { background: #0b0d11; border-bottom: 1px solid #1e2433; padding: 12px 0; }
|
||||
.swagger-ui .topbar .topbar-wrapper { max-width: 1200px; margin: 0 auto; padding: 0 24px; }
|
||||
.swagger-ui .topbar a { font-size: 0; }
|
||||
.swagger-ui .topbar .topbar-wrapper::before {
|
||||
content: '⚡ DocFast API';
|
||||
font-size: 1.25rem;
|
||||
font-weight: 700;
|
||||
color: #e4e7ed;
|
||||
font-family: 'Inter', system-ui, sans-serif;
|
||||
}
|
||||
.swagger-ui .topbar .topbar-wrapper::after {
|
||||
content: '← Back to docfast.dev';
|
||||
margin-left: auto;
|
||||
font-size: 0.85rem;
|
||||
color: #34d399;
|
||||
cursor: pointer;
|
||||
font-family: 'Inter', system-ui, sans-serif;
|
||||
}
|
||||
.swagger-ui .topbar .topbar-wrapper { cursor: default; }
|
||||
|
||||
/* Dark theme overrides */
|
||||
.swagger-ui { color: #c8ccd4; }
|
||||
.swagger-ui .wrapper { max-width: 1200px; padding: 0 24px; }
|
||||
.swagger-ui .scheme-container { background: #151922; border: 1px solid #1e2433; border-radius: 8px; margin: 16px 0; box-shadow: none; }
|
||||
.swagger-ui .opblock-tag { color: #e4e7ed !important; border-bottom: 1px solid #1e2433; }
|
||||
.swagger-ui .opblock-tag:hover { background: rgba(52,211,153,0.04); }
|
||||
.swagger-ui .opblock { background: #151922; border: 1px solid #1e2433 !important; border-radius: 8px !important; margin-bottom: 12px; box-shadow: none !important; }
|
||||
.swagger-ui .opblock .opblock-summary { border: none; }
|
||||
.swagger-ui .opblock .opblock-summary-method { border-radius: 6px; font-size: 0.75rem; min-width: 70px; }
|
||||
.swagger-ui .opblock.opblock-post .opblock-summary-method { background: #34d399; }
|
||||
.swagger-ui .opblock.opblock-get .opblock-summary-method { background: #60a5fa; }
|
||||
.swagger-ui .opblock.opblock-post { border-color: rgba(52,211,153,0.3) !important; background: rgba(52,211,153,0.03); }
|
||||
.swagger-ui .opblock.opblock-get { border-color: rgba(96,165,250,0.3) !important; background: rgba(96,165,250,0.03); }
|
||||
.swagger-ui .opblock .opblock-summary-path { color: #e4e7ed; }
|
||||
.swagger-ui .opblock .opblock-summary-description { color: #7a8194; }
|
||||
.swagger-ui .opblock-body { background: #0b0d11; }
|
||||
.swagger-ui .opblock-description-wrapper p,
|
||||
.swagger-ui .opblock-external-docs-wrapper p { color: #9ca3af; }
|
||||
.swagger-ui table thead tr th { color: #7a8194; border-bottom: 1px solid #1e2433; }
|
||||
.swagger-ui table tbody tr td { color: #c8ccd4; border-bottom: 1px solid #1e2433; }
|
||||
.swagger-ui .parameter__name { color: #e4e7ed; }
|
||||
.swagger-ui .parameter__type { color: #60a5fa; }
|
||||
.swagger-ui .parameter__name.required::after { color: #f87171; }
|
||||
.swagger-ui input[type=text], .swagger-ui textarea, .swagger-ui select {
|
||||
background: #0b0d11; color: #e4e7ed; border: 1px solid #1e2433; border-radius: 6px;
|
||||
}
|
||||
.swagger-ui .btn { border-radius: 6px; }
|
||||
.swagger-ui .btn.execute { background: #34d399; color: #0b0d11; border: none; }
|
||||
.swagger-ui .btn.execute:hover { background: #5eead4; }
|
||||
.swagger-ui .responses-inner { background: transparent; }
|
||||
.swagger-ui .response-col_status { color: #34d399; }
|
||||
.swagger-ui .response-col_description { color: #9ca3af; }
|
||||
.swagger-ui .model-box, .swagger-ui section.models { background: #151922; border: 1px solid #1e2433; border-radius: 8px; }
|
||||
.swagger-ui section.models h4 { color: #e4e7ed; border-bottom: 1px solid #1e2433; }
|
||||
.swagger-ui .model { color: #c8ccd4; }
|
||||
.swagger-ui .model-title { color: #e4e7ed; }
|
||||
.swagger-ui .prop-type { color: #60a5fa; }
|
||||
.swagger-ui .info .title { color: #e4e7ed; font-family: 'Inter', system-ui, sans-serif; }
|
||||
.swagger-ui .info .description p { color: #9ca3af; }
|
||||
.swagger-ui .info a { color: #34d399; }
|
||||
.swagger-ui .info h1, .swagger-ui .info h2, .swagger-ui .info h3 { color: #e4e7ed; }
|
||||
.swagger-ui .info .base-url { color: #7a8194; }
|
||||
.swagger-ui .scheme-container .schemes > label { color: #7a8194; }
|
||||
.swagger-ui .loading-container .loading::after { color: #7a8194; }
|
||||
.swagger-ui .highlight-code, .swagger-ui .microlight { background: #0b0d11 !important; color: #c8ccd4 !important; border-radius: 6px; }
|
||||
.swagger-ui .copy-to-clipboard { right: 10px; top: 10px; }
|
||||
.swagger-ui .auth-wrapper .authorize { color: #34d399; border-color: #34d399; }
|
||||
.swagger-ui .auth-wrapper .authorize svg { fill: #34d399; }
|
||||
.swagger-ui .dialog-ux .modal-ux { background: #151922; border: 1px solid #1e2433; }
|
||||
.swagger-ui .dialog-ux .modal-ux-header h3 { color: #e4e7ed; }
|
||||
.swagger-ui .dialog-ux .modal-ux-content p { color: #9ca3af; }
|
||||
.swagger-ui .model-box-control:focus, .swagger-ui .models-control:focus { outline: none; }
|
||||
.swagger-ui .servers > label select { background: #0b0d11; color: #e4e7ed; border: 1px solid #1e2433; }
|
||||
.swagger-ui .markdown code, .swagger-ui .renderedMarkdown code { background: rgba(52,211,153,0.1); color: #34d399; padding: 2px 6px; border-radius: 4px; }
|
||||
.swagger-ui .markdown p, .swagger-ui .renderedMarkdown p { color: #9ca3af; }
|
||||
.swagger-ui .opblock-tag small { color: #7a8194; }
|
||||
|
||||
/* Hide validator */
|
||||
.swagger-ui .errors-wrapper { display: none; }
|
||||
|
||||
/* Link back */
|
||||
.back-link { position: fixed; top: 14px; right: 24px; z-index: 100; color: #34d399; text-decoration: none; font-size: 0.85rem; font-family: 'Inter', system-ui, sans-serif; }
|
||||
.back-link:hover { color: #5eead4; }
|
||||
</style>
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap" rel="stylesheet">
|
||||
</head>
|
||||
<body>
|
||||
<a href="/" class="back-link">← Back to docfast.dev</a>
|
||||
<div id="swagger-ui"></div>
|
||||
<script src="/swagger-ui/swagger-ui-bundle.js"></script>
|
||||
<script src="/swagger-init.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
1
projects/business/src/pdf-api/public/favicon.svg
Normal file
1
projects/business/src/pdf-api/public/favicon.svg
Normal file
|
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><text y=".9em" font-size="90">⚡</text></svg>
|
||||
|
After Width: | Height: | Size: 109 B |
139
projects/business/src/pdf-api/public/impressum.html
Normal file
139
projects/business/src/pdf-api/public/impressum.html
Normal file
|
|
@ -0,0 +1,139 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="icon" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><text y='.9em' font-size='90'>⚡</text></svg>">
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap" rel="stylesheet">
|
||||
<title>Impressum — DocFast</title>
|
||||
<meta name="description" content="Legal notice and company information for DocFast API service.">
|
||||
<link rel="canonical" href="https://docfast.dev/impressum">
|
||||
<style>
|
||||
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
|
||||
:root {
|
||||
--bg: #0b0d11; --bg2: #12151c; --fg: #e4e7ed; --muted: #7a8194;
|
||||
--accent: #34d399; --accent-hover: #5eead4; --accent-glow: rgba(52,211,153,0.12);
|
||||
--accent2: #60a5fa; --card: #151922; --border: #1e2433;
|
||||
--radius: 12px; --radius-lg: 16px;
|
||||
}
|
||||
body { font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: var(--bg); color: var(--fg); line-height: 1.65; -webkit-font-smoothing: antialiased; }
|
||||
a { color: var(--accent); text-decoration: none; transition: color 0.2s; }
|
||||
a:hover { color: var(--accent-hover); }
|
||||
.container { max-width: 1020px; margin: 0 auto; padding: 0 24px; }
|
||||
|
||||
/* Nav */
|
||||
nav { padding: 20px 0; border-bottom: 1px solid var(--border); }
|
||||
nav .container { display: flex; align-items: center; justify-content: space-between; }
|
||||
.logo { font-size: 1.25rem; font-weight: 700; letter-spacing: -0.5px; color: var(--fg); display: flex; align-items: center; gap: 8px; text-decoration: none; }
|
||||
.logo:hover { color: var(--fg); }
|
||||
.logo span { color: var(--accent); }
|
||||
.nav-links { display: flex; gap: 28px; align-items: center; }
|
||||
.nav-links a { color: var(--muted); font-size: 0.9rem; font-weight: 500; }
|
||||
.nav-links a:hover { color: var(--fg); }
|
||||
|
||||
/* Footer */
|
||||
footer { padding: 40px 0; border-top: 1px solid var(--border); }
|
||||
footer .container { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 16px; }
|
||||
.footer-left { color: var(--muted); font-size: 0.85rem; }
|
||||
.footer-links { display: flex; gap: 24px; flex-wrap: wrap; }
|
||||
.footer-links a { color: var(--muted); font-size: 0.85rem; }
|
||||
.footer-links a:hover { color: var(--fg); }
|
||||
|
||||
/* Buttons */
|
||||
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 14px 28px; border-radius: 10px; font-size: 0.95rem; font-weight: 600; transition: all 0.2s; border: none; cursor: pointer; text-decoration: none; }
|
||||
.btn-primary { background: var(--accent); color: #0b0d11; }
|
||||
.btn-primary:hover { background: var(--accent-hover); text-decoration: none; transform: translateY(-1px); box-shadow: 0 8px 24px rgba(52,211,153,0.2); }
|
||||
.btn-secondary { border: 1px solid var(--border); color: var(--fg); background: transparent; }
|
||||
.btn-secondary:hover { border-color: var(--muted); text-decoration: none; background: rgba(255,255,255,0.03); }
|
||||
.btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }
|
||||
.btn:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
|
||||
|
||||
/* Responsive base */
|
||||
@media (max-width: 640px) {
|
||||
.nav-links { gap: 16px; }
|
||||
.footer-links { gap: 16px; }
|
||||
footer .container { flex-direction: column; text-align: center; }
|
||||
}
|
||||
.container { max-width: 800px; margin: 0 auto; padding: 0 24px; }
|
||||
|
||||
/* Legal page overrides */
|
||||
.container { max-width: 800px; }
|
||||
main { padding: 60px 0 80px; }
|
||||
h1 { font-size: 2.5rem; font-weight: 800; margin-bottom: 16px; letter-spacing: -1px; }
|
||||
h2 { font-size: 1.5rem; font-weight: 700; margin: 32px 0 16px; color: var(--accent); }
|
||||
h3 { font-size: 1.2rem; font-weight: 600; margin: 24px 0 12px; }
|
||||
p { margin-bottom: 16px; line-height: 1.7; }
|
||||
ul { margin-bottom: 16px; padding-left: 24px; }
|
||||
li { margin-bottom: 8px; line-height: 1.7; }
|
||||
.highlight { background: rgba(52,211,153,0.08); border: 1px solid rgba(52,211,153,0.15); border-radius: 8px; padding: 16px; margin: 24px 0; color: var(--accent); font-size: 0.9rem; }
|
||||
.info { background: rgba(96,165,250,0.08); border: 1px solid rgba(96,165,250,0.15); border-radius: 8px; padding: 16px; margin: 24px 0; color: #60a5fa; font-size: 0.9rem; }
|
||||
.warning { background: rgba(251,191,36,0.08); border: 1px solid rgba(251,191,36,0.15); border-radius: 8px; padding: 16px; margin: 24px 0; color: #fbbf24; font-size: 0.9rem; }
|
||||
|
||||
@media (max-width: 640px) {
|
||||
main { padding: 40px 0 60px; }
|
||||
h1 { font-size: 2rem; }
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<nav aria-label="Main navigation">
|
||||
<div class="container">
|
||||
<a href="/" class="logo">⚡ Doc<span>Fast</span></a>
|
||||
<div class="nav-links">
|
||||
<a href="/#features">Features</a>
|
||||
<a href="/#pricing">Pricing</a>
|
||||
<a href="/docs">Docs</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<main>
|
||||
<div class="container">
|
||||
<h1>Impressum</h1>
|
||||
<p><em>Legal notice according to § 5 ECG and § 25 MedienG (Austrian law)</em></p>
|
||||
|
||||
<h2>Company Information</h2>
|
||||
<p><strong>Company:</strong> Cloonar Technologies GmbH</p>
|
||||
<p><strong>Address:</strong> Linzer Straße 192/1/2, 1140 Wien, Austria</p>
|
||||
<p><strong>Email:</strong> <a href="mailto:legal@docfast.dev">legal@docfast.dev</a></p>
|
||||
|
||||
<h2>Legal Registration</h2>
|
||||
<p><strong>Commercial Register:</strong> FN 631089y</p>
|
||||
<p><strong>Court:</strong> Handelsgericht Wien</p>
|
||||
<p><strong>VAT ID:</strong> ATU81280034</p>
|
||||
<p><strong>GLN:</strong> 9110036145697</p>
|
||||
|
||||
<h2>Responsible for Content</h2>
|
||||
<p>Cloonar Technologies GmbH<br>
|
||||
Legal contact: <a href="mailto:legal@docfast.dev">legal@docfast.dev</a></p>
|
||||
|
||||
<h2>Disclaimer</h2>
|
||||
<p>Despite careful content control, we assume no liability for the content of external links. The operators of the linked pages are solely responsible for their content.</p>
|
||||
|
||||
<p>The content of our website has been created with the greatest possible care. However, we cannot guarantee that the content is current, reliable or complete.</p>
|
||||
|
||||
<h2>EU Online Dispute Resolution</h2>
|
||||
<p>Platform of the European Commission for Online Dispute Resolution (ODR): <a href="https://ec.europa.eu/consumers/odr" target="_blank" rel="noopener">https://ec.europa.eu/consumers/odr</a></p>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<footer aria-label="Footer">
|
||||
<div class="container">
|
||||
<div class="footer-left">© 2026 DocFast. Fast PDF generation for developers.</div>
|
||||
<div class="footer-links">
|
||||
<a href="/">Home</a>
|
||||
<a href="/docs">Docs</a>
|
||||
<a href="/health">API Status</a>
|
||||
<a href="/#change-email" class="open-email-change">Change Email</a>
|
||||
<a href="/impressum">Impressum</a>
|
||||
<a href="/privacy">Privacy Policy</a>
|
||||
<a href="/terms">Terms of Service</a>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
108
projects/business/src/pdf-api/public/impressum.html.server
Normal file
108
projects/business/src/pdf-api/public/impressum.html.server
Normal file
|
|
@ -0,0 +1,108 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Impressum — DocFast</title>
|
||||
<meta name="description" content="Legal notice and company information for DocFast API service.">
|
||||
<link rel="canonical" href="https://docfast.dev/impressum">
|
||||
<link rel="icon" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><text y='.9em' font-size='90'>⚡</text></svg>">
|
||||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap" rel="stylesheet">
|
||||
<style>
|
||||
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
|
||||
:root {
|
||||
--bg: #0b0d11; --bg2: #12151c; --fg: #e4e7ed; --muted: #7a8194;
|
||||
--accent: #34d399; --accent-hover: #5eead4; --accent-glow: rgba(52,211,153,0.12);
|
||||
--card: #151922; --border: #1e2433;
|
||||
--radius: 12px; --radius-lg: 16px;
|
||||
}
|
||||
body { font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: var(--bg); color: var(--fg); line-height: 1.65; -webkit-font-smoothing: antialiased; }
|
||||
a { color: var(--accent); text-decoration: none; transition: color 0.2s; }
|
||||
a:hover { color: var(--accent-hover); }
|
||||
.container { max-width: 800px; margin: 0 auto; padding: 0 24px; }
|
||||
nav { padding: 20px 0; border-bottom: 1px solid var(--border); }
|
||||
nav .container { display: flex; align-items: center; justify-content: space-between; }
|
||||
.logo { font-size: 1.25rem; font-weight: 700; letter-spacing: -0.5px; color: var(--fg); display: flex; align-items: center; gap: 8px; text-decoration: none; }
|
||||
.logo span { color: var(--accent); }
|
||||
.nav-links { display: flex; gap: 28px; align-items: center; }
|
||||
.nav-links a { color: var(--muted); font-size: 0.9rem; font-weight: 500; }
|
||||
.nav-links a:hover { color: var(--fg); }
|
||||
.content { padding: 60px 0; min-height: 60vh; }
|
||||
.content h1 { font-size: 2rem; font-weight: 800; margin-bottom: 32px; letter-spacing: -1px; }
|
||||
.content h2 { font-size: 1.3rem; font-weight: 700; margin: 32px 0 16px; color: var(--fg); }
|
||||
.content h3 { font-size: 1.1rem; font-weight: 600; margin: 24px 0 12px; color: var(--fg); }
|
||||
.content p, .content li { color: var(--muted); margin-bottom: 12px; }
|
||||
.content ul, .content ol { padding-left: 24px; }
|
||||
.content strong { color: var(--fg); }
|
||||
footer { padding: 32px 0; border-top: 1px solid var(--border); margin-top: 60px; }
|
||||
footer .container { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 16px; }
|
||||
.footer-left { color: var(--muted); font-size: 0.85rem; }
|
||||
.footer-links { display: flex; gap: 20px; flex-wrap: wrap; }
|
||||
.footer-links a { color: var(--muted); font-size: 0.85rem; }
|
||||
.footer-links a:hover { color: var(--fg); }
|
||||
@media (max-width: 768px) {
|
||||
footer .container { flex-direction: column; text-align: center; }
|
||||
.nav-links { gap: 16px; }
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<nav aria-label="Main navigation">
|
||||
<div class="container">
|
||||
<a href="/" class="logo">⚡ Doc<span>Fast</span></a>
|
||||
<div class="nav-links">
|
||||
<a href="/#features">Features</a>
|
||||
<a href="/#pricing">Pricing</a>
|
||||
<a href="/docs">Docs</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<main>
|
||||
<div class="container">
|
||||
<h1>Impressum</h1>
|
||||
<p><em>Legal notice according to § 5 ECG and § 25 MedienG (Austrian law)</em></p>
|
||||
|
||||
<h2>Company Information</h2>
|
||||
<p><strong>Company:</strong> Cloonar Technologies GmbH</p>
|
||||
<p><strong>Address:</strong> Linzer Straße 192/1/2, 1140 Wien, Austria</p>
|
||||
<p><strong>Email:</strong> <a href="mailto:legal@docfast.dev">legal@docfast.dev</a></p>
|
||||
|
||||
<h2>Legal Registration</h2>
|
||||
<p><strong>Commercial Register:</strong> FN 631089y</p>
|
||||
<p><strong>Court:</strong> Handelsgericht Wien</p>
|
||||
<p><strong>VAT ID:</strong> ATU81280034</p>
|
||||
<p><strong>GLN:</strong> 9110036145697</p>
|
||||
|
||||
<h2>Responsible for Content</h2>
|
||||
<p>Cloonar Technologies GmbH<br>
|
||||
Legal contact: <a href="mailto:legal@docfast.dev">legal@docfast.dev</a></p>
|
||||
|
||||
<h2>Disclaimer</h2>
|
||||
<p>Despite careful content control, we assume no liability for the content of external links. The operators of the linked pages are solely responsible for their content.</p>
|
||||
|
||||
<p>The content of our website has been created with the greatest possible care. However, we cannot guarantee that the content is current, reliable or complete.</p>
|
||||
|
||||
<h2>EU Online Dispute Resolution</h2>
|
||||
<p>Platform of the European Commission for Online Dispute Resolution (ODR): <a href="https://ec.europa.eu/consumers/odr" target="_blank" rel="noopener">https://ec.europa.eu/consumers/odr</a></p>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<footer aria-label="Footer">
|
||||
<div class="container">
|
||||
<div class="footer-left">© 2026 DocFast. Fast PDF generation for developers.</div>
|
||||
<div class="footer-links">
|
||||
<a href="/">Home</a>
|
||||
<a href="/docs">Docs</a>
|
||||
<a href="/health">API Status</a>
|
||||
<a href="/#change-email" class="open-email-change">Change Email</a>
|
||||
<a href="/impressum">Impressum</a>
|
||||
<a href="/privacy">Privacy Policy</a>
|
||||
<a href="/terms">Terms of Service</a>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -5,323 +5,557 @@
|
|||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>DocFast — HTML & Markdown to PDF API</title>
|
||||
<meta name="description" content="Convert HTML and Markdown to beautiful PDFs with a simple API call. Built-in invoice templates. Fast, reliable, developer-friendly.">
|
||||
<meta property="og:title" content="DocFast — HTML & Markdown to PDF API">
|
||||
<meta property="og:description" content="Convert HTML and Markdown to beautiful PDFs with a simple API call. Fast, reliable, developer-friendly.">
|
||||
<meta property="og:type" content="website">
|
||||
<meta property="og:url" content="https://docfast.dev">
|
||||
<meta property="og:image" content="https://docfast.dev/og-image.png">
|
||||
<meta name="twitter:card" content="summary_large_image">
|
||||
<meta name="twitter:title" content="DocFast — HTML & Markdown to PDF API">
|
||||
<meta name="twitter:description" content="Convert HTML and Markdown to beautiful PDFs with a simple API call.">
|
||||
<link rel="canonical" href="https://docfast.dev">
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<script type="application/ld+json">
|
||||
{"@context":"https://schema.org","@type":"SoftwareApplication","name":"DocFast","url":"https://docfast.dev","applicationCategory":"DeveloperApplication","operatingSystem":"Web","description":"Convert HTML and Markdown to beautiful PDFs with a simple API call. Fast, reliable, developer-friendly.","offers":[{"@type":"Offer","price":"0","priceCurrency":"EUR","name":"Free","description":"100 PDFs/month"},{"@type":"Offer","price":"9","priceCurrency":"EUR","name":"Pro","description":"5,000 PDFs / month","billingIncrement":"P1M"}]}
|
||||
</script>
|
||||
<link rel="icon" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><text y='.9em' font-size='90'>⚡</text></svg>">
|
||||
<style>
|
||||
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
|
||||
:root { --bg: #0a0a0a; --fg: #e8e8e8; --muted: #888; --accent: #4f9; --accent2: #3ad; --card: #141414; --border: #222; }
|
||||
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: var(--bg); color: var(--fg); line-height: 1.6; }
|
||||
a { color: var(--accent); text-decoration: none; }
|
||||
a:hover { text-decoration: underline; }
|
||||
.container { max-width: 960px; margin: 0 auto; padding: 0 24px; }
|
||||
:root {
|
||||
--bg: #0b0d11; --bg2: #12151c; --fg: #e4e7ed; --muted: #7a8194;
|
||||
--accent: #34d399; --accent-hover: #5eead4; --accent-glow: rgba(52,211,153,0.12);
|
||||
--accent2: #60a5fa; --card: #151922; --border: #1e2433;
|
||||
--radius: 12px; --radius-lg: 16px;
|
||||
}
|
||||
body { font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: var(--bg); color: var(--fg); line-height: 1.65; -webkit-font-smoothing: antialiased; }
|
||||
a { color: var(--accent); text-decoration: none; transition: color 0.2s; }
|
||||
a:hover { color: var(--accent-hover); }
|
||||
.container { max-width: 1020px; margin: 0 auto; padding: 0 24px; }
|
||||
|
||||
/* Nav */
|
||||
nav { padding: 20px 0; border-bottom: 1px solid var(--border); }
|
||||
nav .container { display: flex; align-items: center; justify-content: space-between; }
|
||||
.logo { font-size: 1.25rem; font-weight: 700; letter-spacing: -0.5px; color: var(--fg); display: flex; align-items: center; gap: 8px; }
|
||||
.logo span { color: var(--accent); }
|
||||
.nav-links { display: flex; gap: 28px; align-items: center; }
|
||||
.nav-links a { color: var(--muted); font-size: 0.9rem; font-weight: 500; }
|
||||
.nav-links a:hover { color: var(--fg); }
|
||||
|
||||
/* Hero */
|
||||
.hero { padding: 100px 0 80px; text-align: center; }
|
||||
.hero h1 { font-size: 3rem; font-weight: 700; margin-bottom: 16px; letter-spacing: -1px; }
|
||||
.hero h1 span { color: var(--accent); }
|
||||
.hero p { font-size: 1.25rem; color: var(--muted); max-width: 600px; margin: 0 auto 40px; }
|
||||
.hero-actions { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; }
|
||||
.btn { display: inline-block; padding: 14px 32px; border-radius: 8px; font-size: 1rem; font-weight: 600; transition: all 0.2s; border: none; cursor: pointer; }
|
||||
.btn-primary { background: var(--accent); color: #000; }
|
||||
.btn-primary:hover { background: #6fb; text-decoration: none; }
|
||||
.hero { padding: 100px 0 80px; text-align: center; position: relative; }
|
||||
.hero::before { content: ''; position: absolute; top: 0; left: 50%; transform: translateX(-50%); width: 600px; height: 400px; background: radial-gradient(ellipse, var(--accent-glow) 0%, transparent 70%); pointer-events: none; }
|
||||
.badge { display: inline-block; padding: 6px 16px; border-radius: 50px; font-size: 0.8rem; font-weight: 600; color: var(--accent); background: rgba(52,211,153,0.08); border: 1px solid rgba(52,211,153,0.15); margin-bottom: 24px; letter-spacing: 0.3px; }
|
||||
.hero h1 { font-size: clamp(2.2rem, 5vw, 3.5rem); font-weight: 800; margin-bottom: 20px; letter-spacing: -1.5px; line-height: 1.15; }
|
||||
.hero h1 .gradient { background: linear-gradient(135deg, var(--accent) 0%, var(--accent2) 100%); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
|
||||
.hero p { font-size: 1.2rem; color: var(--muted); max-width: 560px; margin: 0 auto 40px; line-height: 1.7; }
|
||||
.hero-actions { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }
|
||||
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 14px 28px; border-radius: 10px; font-size: 0.95rem; font-weight: 600; transition: all 0.2s; border: none; cursor: pointer; text-decoration: none; }
|
||||
.btn-primary { background: var(--accent); color: #0b0d11; }
|
||||
.btn-primary:hover { background: var(--accent-hover); text-decoration: none; transform: translateY(-1px); box-shadow: 0 8px 24px rgba(52,211,153,0.2); }
|
||||
.btn-secondary { border: 1px solid var(--border); color: var(--fg); background: transparent; }
|
||||
.btn-secondary:hover { border-color: var(--muted); text-decoration: none; }
|
||||
.btn-secondary:hover { border-color: var(--muted); text-decoration: none; background: rgba(255,255,255,0.03); }
|
||||
.btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }
|
||||
|
||||
/* Code block */
|
||||
.code-hero { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 24px 32px; margin: 48px auto 0; max-width: 640px; text-align: left; font-family: 'SF Mono', 'Fira Code', monospace; font-size: 0.9rem; overflow-x: auto; }
|
||||
.code-hero .comment { color: #666; }
|
||||
.code-hero .string { color: var(--accent); }
|
||||
.code-hero .key { color: var(--accent2); }
|
||||
.code-section { margin: 56px auto 0; max-width: 660px; text-align: left; display: flex; flex-direction: column; }
|
||||
.code-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 20px; background: #1a1f2b; border: 1px solid var(--border); border-bottom: none; border-radius: var(--radius) var(--radius) 0 0; }
|
||||
.code-dots { display: flex; gap: 6px; }
|
||||
.code-dots span { width: 10px; height: 10px; border-radius: 50%; }
|
||||
.code-dots span:nth-child(1) { background: #f87171; }
|
||||
.code-dots span:nth-child(2) { background: #fbbf24; }
|
||||
.code-dots span:nth-child(3) { background: #34d399; }
|
||||
.code-label { font-size: 0.75rem; color: var(--muted); font-family: monospace; }
|
||||
.code-block { background: var(--card); border: 1px solid var(--border); border-radius: 0 0 var(--radius) var(--radius); padding: 24px 28px; font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace; font-size: 0.85rem; line-height: 1.85; overflow-x: auto; }
|
||||
.code-block .c { color: #4a5568; }
|
||||
.code-block .s { color: var(--accent); }
|
||||
.code-block .k { color: var(--accent2); }
|
||||
.code-block .f { color: #c084fc; }
|
||||
|
||||
/* Sections */
|
||||
section { position: relative; }
|
||||
.section-title { text-align: center; font-size: clamp(1.5rem, 3vw, 2.2rem); font-weight: 700; letter-spacing: -0.5px; margin-bottom: 12px; }
|
||||
.section-sub { text-align: center; color: var(--muted); margin-bottom: 48px; font-size: 1.05rem; }
|
||||
|
||||
/* Features */
|
||||
.features { padding: 80px 0; }
|
||||
.features h2 { text-align: center; font-size: 2rem; margin-bottom: 48px; }
|
||||
.features-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 24px; }
|
||||
.feature-card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 32px; }
|
||||
.feature-card h3 { font-size: 1.1rem; margin-bottom: 8px; }
|
||||
.feature-card p { color: var(--muted); font-size: 0.95rem; }
|
||||
.feature-icon { font-size: 1.5rem; margin-bottom: 12px; }
|
||||
.features-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
|
||||
@media (max-width: 768px) { .features-grid { grid-template-columns: 1fr; } }
|
||||
.feature-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 28px; transition: border-color 0.2s, transform 0.2s; }
|
||||
.feature-card:hover { border-color: rgba(52,211,153,0.3); transform: translateY(-2px); }
|
||||
.feature-icon { width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 1.2rem; margin-bottom: 16px; background: rgba(52,211,153,0.08); }
|
||||
.feature-card h3 { font-size: 1rem; font-weight: 600; margin-bottom: 8px; }
|
||||
.feature-card p { color: var(--muted); font-size: 0.9rem; line-height: 1.6; }
|
||||
|
||||
/* Pricing */
|
||||
.pricing { padding: 80px 0; }
|
||||
.pricing h2 { text-align: center; font-size: 2rem; margin-bottom: 12px; }
|
||||
.pricing .subtitle { text-align: center; color: var(--muted); margin-bottom: 48px; }
|
||||
.pricing-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 24px; max-width: 700px; margin: 0 auto; }
|
||||
.price-card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 32px; text-align: center; }
|
||||
.pricing-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 24px; max-width: 700px; margin: 0 auto; }
|
||||
@media (max-width: 640px) { .pricing-grid { grid-template-columns: 1fr; } }
|
||||
.price-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 36px; position: relative; }
|
||||
.price-card.featured { border-color: var(--accent); }
|
||||
.price-card h3 { font-size: 1.2rem; margin-bottom: 8px; }
|
||||
.price-amount { font-size: 2.5rem; font-weight: 700; margin: 16px 0; }
|
||||
.price-amount span { font-size: 1rem; color: var(--muted); font-weight: 400; }
|
||||
.price-features { list-style: none; text-align: left; margin: 24px 0; }
|
||||
.price-features li { padding: 6px 0; color: var(--muted); font-size: 0.95rem; }
|
||||
.price-features li::before { content: "✓ "; color: var(--accent); }
|
||||
.price-card.featured::before { content: 'POPULAR'; position: absolute; top: -10px; right: 20px; background: var(--accent); color: #0b0d11; font-size: 0.65rem; font-weight: 700; padding: 3px 10px; border-radius: 50px; letter-spacing: 0.5px; }
|
||||
.price-name { font-size: 0.9rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px; }
|
||||
.price-amount { font-size: 3rem; font-weight: 800; letter-spacing: -2px; margin-bottom: 4px; }
|
||||
.price-amount span { font-size: 1rem; color: var(--muted); font-weight: 400; letter-spacing: 0; }
|
||||
.price-desc { color: var(--muted); font-size: 0.85rem; margin-bottom: 24px; padding-bottom: 24px; border-bottom: 1px solid var(--border); }
|
||||
.price-features { list-style: none; margin-bottom: 28px; }
|
||||
.price-features li { padding: 5px 0; color: var(--muted); font-size: 0.9rem; display: flex; align-items: center; gap: 10px; }
|
||||
.price-features li::before { content: "✓"; color: var(--accent); font-weight: 700; font-size: 0.85rem; flex-shrink: 0; }
|
||||
|
||||
/* Endpoints */
|
||||
.endpoints { padding: 80px 0; }
|
||||
.endpoints h2 { text-align: center; font-size: 2rem; margin-bottom: 48px; }
|
||||
.endpoint { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 24px 32px; margin-bottom: 16px; }
|
||||
.endpoint-method { display: inline-block; background: #1a3a20; color: var(--accent); font-family: monospace; font-size: 0.85rem; font-weight: 700; padding: 3px 8px; border-radius: 4px; margin-right: 8px; }
|
||||
.endpoint-path { font-family: monospace; font-size: 0.95rem; }
|
||||
.endpoint-desc { color: var(--muted); font-size: 0.9rem; margin-top: 8px; }
|
||||
/* Trust */
|
||||
.trust { padding: 60px 0 40px; }
|
||||
.trust-grid { display: flex; gap: 40px; justify-content: center; flex-wrap: wrap; }
|
||||
.trust-item { text-align: center; flex: 1; min-width: 160px; max-width: 220px; }
|
||||
.trust-num { font-size: 2rem; font-weight: 800; color: var(--accent); letter-spacing: -1px; }
|
||||
.trust-label { font-size: 0.85rem; color: var(--muted); margin-top: 4px; }
|
||||
|
||||
/* EU Hosting */
|
||||
.eu-hosting { padding: 40px 0 80px; }
|
||||
.eu-badge { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 32px; max-width: 600px; margin: 0 auto; display: flex; align-items: center; gap: 20px; transition: border-color 0.2s, transform 0.2s; }
|
||||
.eu-badge:hover { border-color: rgba(52,211,153,0.3); transform: translateY(-2px); }
|
||||
.eu-icon { font-size: 3rem; flex-shrink: 0; }
|
||||
.eu-content h3 { font-size: 1.4rem; font-weight: 700; margin-bottom: 8px; color: var(--fg); }
|
||||
.eu-content p { color: var(--muted); font-size: 0.95rem; line-height: 1.6; margin: 0; }
|
||||
@media (max-width: 640px) {
|
||||
.eu-badge { flex-direction: column; text-align: center; gap: 16px; padding: 24px; }
|
||||
.eu-icon { font-size: 2.5rem; }
|
||||
}
|
||||
|
||||
/* Footer */
|
||||
footer { padding: 40px 0; text-align: center; color: var(--muted); font-size: 0.85rem; border-top: 1px solid var(--border); }
|
||||
footer { padding: 40px 0; border-top: 1px solid var(--border); }
|
||||
footer .container { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 16px; }
|
||||
.footer-left { color: var(--muted); font-size: 0.85rem; }
|
||||
.footer-links { display: flex; gap: 24px; flex-wrap: wrap; }
|
||||
.footer-links a { color: var(--muted); font-size: 0.85rem; }
|
||||
.footer-links a:hover { color: var(--fg); }
|
||||
|
||||
/* Modal */
|
||||
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.7); z-index: 100; align-items: center; justify-content: center; }
|
||||
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.75); backdrop-filter: blur(4px); z-index: 100; align-items: center; justify-content: center; }
|
||||
.modal-overlay.active { display: flex; }
|
||||
.modal { background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 40px; max-width: 440px; width: 90%; }
|
||||
.modal h2 { margin-bottom: 8px; font-size: 1.5rem; }
|
||||
.modal { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 40px; max-width: 460px; width: 90%; position: relative; }
|
||||
.modal h2 { margin-bottom: 8px; font-size: 1.4rem; font-weight: 700; }
|
||||
.modal p { color: var(--muted); margin-bottom: 24px; font-size: 0.95rem; }
|
||||
.modal input { width: 100%; padding: 14px 16px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg); color: var(--fg); font-size: 1rem; margin-bottom: 16px; outline: none; }
|
||||
.modal input:focus { border-color: var(--accent); }
|
||||
.modal .btn { width: 100%; text-align: center; }
|
||||
.modal .error { color: #f66; font-size: 0.85rem; margin-bottom: 12px; display: none; }
|
||||
.modal .close { position: absolute; top: 16px; right: 20px; color: var(--muted); font-size: 1.5rem; cursor: pointer; background: none; border: none; }
|
||||
.modal .close { position: absolute; top: 16px; right: 20px; color: var(--muted); font-size: 1.4rem; cursor: pointer; background: none; border: none; transition: color 0.2s; }
|
||||
.modal .close:hover { color: var(--fg); }
|
||||
|
||||
/* Key result */
|
||||
.key-result { display: none; }
|
||||
.key-result .key-box { background: var(--bg); border: 1px solid var(--accent); border-radius: 8px; padding: 16px; font-family: monospace; font-size: 0.85rem; word-break: break-all; margin: 16px 0; cursor: pointer; transition: background 0.2s; }
|
||||
.key-result .key-box:hover { background: #111; }
|
||||
.key-result .copy-hint { color: var(--muted); font-size: 0.8rem; text-align: center; }
|
||||
/* Signup states */
|
||||
#signupInitial, #signupLoading, #signupVerify, #signupResult { display: none; }
|
||||
#signupInitial.active { display: block; }
|
||||
#signupLoading.active { display: flex; flex-direction: column; align-items: center; padding: 40px 0; text-align: center; }
|
||||
#signupResult.active { display: block; }
|
||||
#signupVerify.active { display: block; }
|
||||
.spinner { width: 36px; height: 36px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.7s linear infinite; margin-bottom: 16px; }
|
||||
@keyframes spin { to { transform: rotate(360deg); } }
|
||||
|
||||
.key-box { background: var(--bg); border: 1px solid var(--accent); border-radius: 8px; padding: 16px; font-family: monospace; font-size: 0.82rem; word-break: break-all; margin: 16px 0 12px; position: relative; cursor: pointer; transition: background 0.2s; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
|
||||
.key-box:hover { background: #151922; }
|
||||
.key-text { flex: 1; }
|
||||
.copy-btn { background: rgba(52,211,153,0.1); border: 1px solid rgba(52,211,153,0.2); color: var(--accent); border-radius: 6px; padding: 6px 14px; font-size: 0.8rem; font-weight: 600; cursor: pointer; white-space: nowrap; transition: all 0.2s; }
|
||||
.copy-btn:hover { background: rgba(52,211,153,0.2); }
|
||||
.warning-box { background: rgba(251,191,36,0.06); border: 1px solid rgba(251,191,36,0.15); border-radius: 8px; padding: 12px 16px; font-size: 0.85rem; color: #fbbf24; display: flex; align-items: flex-start; gap: 10px; margin-bottom: 16px; }
|
||||
.warning-box .icon { font-size: 1.1rem; flex-shrink: 0; }
|
||||
.signup-error { color: #f87171; font-size: 0.85rem; margin-bottom: 16px; display: none; padding: 10px 14px; background: rgba(248,113,113,0.06); border: 1px solid rgba(248,113,113,0.15); border-radius: 8px; }
|
||||
|
||||
/* Responsive */
|
||||
@media (max-width: 640px) {
|
||||
.hero { padding: 72px 0 56px; }
|
||||
.nav-links { gap: 16px; }
|
||||
.code-block {
|
||||
font-size: 0.75rem;
|
||||
padding: 18px 16px;
|
||||
overflow-x: hidden;
|
||||
word-wrap: break-word;
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
.trust-grid { gap: 24px; }
|
||||
.footer-links { gap: 16px; }
|
||||
footer .container { flex-direction: column; text-align: center; }
|
||||
}
|
||||
|
||||
/* Fix mobile terminal gaps at 375px and smaller */
|
||||
@media (max-width: 375px) {
|
||||
.container {
|
||||
padding: 0 12px !important;
|
||||
}
|
||||
.code-section {
|
||||
margin: 32px auto 0;
|
||||
max-width: calc(100vw - 24px) !important;
|
||||
}
|
||||
.code-header {
|
||||
padding: 8px 12px;
|
||||
}
|
||||
.code-block {
|
||||
padding: 12px !important;
|
||||
font-size: 0.7rem;
|
||||
}
|
||||
.hero {
|
||||
padding: 56px 0 40px;
|
||||
}
|
||||
}
|
||||
|
||||
/* Additional mobile overflow fixes */
|
||||
html, body {
|
||||
overflow-x: hidden !important;
|
||||
max-width: 100vw !important;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
* {
|
||||
max-width: 100% !important;
|
||||
}
|
||||
body {
|
||||
overflow-x: hidden !important;
|
||||
}
|
||||
.container {
|
||||
overflow-x: hidden !important;
|
||||
max-width: 100vw !important;
|
||||
padding: 0 16px !important;
|
||||
}
|
||||
.code-section {
|
||||
max-width: calc(100vw - 32px) !important;
|
||||
overflow: hidden !important;
|
||||
display: flex !important;
|
||||
flex-direction: column !important;
|
||||
white-space: normal !important;
|
||||
}
|
||||
.code-block {
|
||||
overflow-x: hidden !important;
|
||||
white-space: pre-wrap !important;
|
||||
word-break: break-all !important;
|
||||
max-width: 100% !important;
|
||||
box-sizing: border-box !important;
|
||||
}
|
||||
.trust-grid {
|
||||
justify-content: center !important;
|
||||
overflow-x: hidden !important;
|
||||
max-width: 100% !important;
|
||||
}
|
||||
|
||||
/* Force any wide elements to fit */
|
||||
pre, code, .code-block {
|
||||
max-width: calc(100vw - 32px) !important;
|
||||
overflow-wrap: break-word !important;
|
||||
word-break: break-all !important;
|
||||
white-space: pre-wrap !important;
|
||||
overflow-x: hidden !important;
|
||||
}
|
||||
.code-section {
|
||||
max-width: calc(100vw - 32px) !important;
|
||||
overflow-x: hidden !important;
|
||||
white-space: normal !important;
|
||||
}
|
||||
}
|
||||
|
||||
/* Recovery modal states */
|
||||
#recoverInitial, #recoverLoading, #recoverVerify, #recoverResult { display: none; }
|
||||
#recoverInitial.active { display: block; }
|
||||
#recoverLoading.active { display: flex; flex-direction: column; align-items: center; padding: 40px 0; text-align: center; }
|
||||
#recoverResult.active { display: block; }
|
||||
#recoverVerify.active { display: block; }
|
||||
|
||||
/* Email change modal states */
|
||||
#emailChangeInitial, #emailChangeLoading, #emailChangeVerify, #emailChangeResult { display: none; }
|
||||
#emailChangeInitial.active { display: block; }
|
||||
#emailChangeLoading.active { display: flex; flex-direction: column; align-items: center; padding: 40px 0; text-align: center; }
|
||||
#emailChangeResult.active { display: block; }
|
||||
#emailChangeVerify.active { display: block; }
|
||||
|
||||
/* Focus-visible for accessibility */
|
||||
.btn:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
|
||||
</style>
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap" rel="stylesheet">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<section class="hero">
|
||||
<nav aria-label="Main navigation">
|
||||
<div class="container">
|
||||
<h1>HTML & Markdown to <span>PDF</span></h1>
|
||||
<p>One API call. Beautiful PDFs. Built-in invoice templates. No headless browser setup, no dependencies, no hassle.</p>
|
||||
<div class="hero-actions">
|
||||
<button class="btn btn-primary" onclick="openSignup()">Get Free API Key</button>
|
||||
<a href="/docs" class="btn btn-secondary">View Docs</a>
|
||||
<div class="logo">⚡ Doc<span>Fast</span></div>
|
||||
<div class="nav-links">
|
||||
<a href="#features">Features</a>
|
||||
<a href="#pricing">Pricing</a>
|
||||
<a href="/docs">Docs</a>
|
||||
</div>
|
||||
<div class="code-hero">
|
||||
<span class="comment">// Convert markdown to PDF in one call</span><br>
|
||||
<span class="key">curl</span> -X POST https://docfast.dev/v1/convert/markdown \<br>
|
||||
-H <span class="string">"Authorization: Bearer YOUR_KEY"</span> \<br>
|
||||
-H <span class="string">"Content-Type: application/json"</span> \<br>
|
||||
-d <span class="string">'{"markdown": "# Invoice\\n\\nAmount: $500"}'</span> \<br>
|
||||
-o invoice.pdf
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<main class="hero" role="main">
|
||||
<div class="container">
|
||||
<div class="badge">🚀 Simple PDF API for Developers</div>
|
||||
<h1>HTML to <span class="gradient">PDF</span><br>in one API call</h1>
|
||||
<p>Convert HTML, Markdown, or URLs to pixel-perfect PDFs. Built-in templates for invoices & receipts. No headless browser headaches.</p>
|
||||
<div class="hero-actions">
|
||||
<button class="btn btn-primary" id="btn-signup">Get Free API Key →</button>
|
||||
<a href="/docs" class="btn btn-secondary">Read the Docs</a>
|
||||
</div>
|
||||
<p style="margin-top:16px;color:var(--muted);font-size:0.9rem;">Already have an account? <a href="#" class="open-recover" style="color:var(--accent);">Lost your API key? Recover it →</a></p>
|
||||
|
||||
<div class="code-section">
|
||||
<div class="code-header">
|
||||
<div class="code-dots" aria-hidden="true"><span></span><span></span><span></span></div>
|
||||
<span class="code-label">terminal</span>
|
||||
</div>
|
||||
<div class="code-block">
|
||||
<span class="c"># Convert HTML to PDF — it's that simple</span>
|
||||
<span class="k">curl</span> <span class="f">-X POST</span> https://docfast.dev/v1/convert/html \
|
||||
-H <span class="s">"Authorization: Bearer YOUR_KEY"</span> \
|
||||
-H <span class="s">"Content-Type: application/json"</span> \
|
||||
-d <span class="s">'{"html": "<h1>Hello World</h1><p>Your first PDF</p>"}'</span> \
|
||||
-o <span class="f">output.pdf</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<section class="trust">
|
||||
<div class="container">
|
||||
<div class="trust-grid">
|
||||
<div class="trust-item">
|
||||
<div class="trust-num"><1s</div>
|
||||
<div class="trust-label">Avg. generation time</div>
|
||||
</div>
|
||||
<div class="trust-item">
|
||||
<div class="trust-num">99.5%</div>
|
||||
<div class="trust-label">Uptime SLA</div>
|
||||
</div>
|
||||
<div class="trust-item">
|
||||
<div class="trust-num">HTTPS</div>
|
||||
<div class="trust-label">Encrypted & secure</div>
|
||||
</div>
|
||||
<div class="trust-item">
|
||||
<div class="trust-num">0 bytes</div>
|
||||
<div class="trust-label">Data stored on disk</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="features">
|
||||
<section class="eu-hosting">
|
||||
<div class="container">
|
||||
<h2>Why DocFast?</h2>
|
||||
<div class="eu-badge">
|
||||
<div class="eu-icon">🇪🇺</div>
|
||||
<div class="eu-content">
|
||||
<h3>Hosted in the EU</h3>
|
||||
<p>Your data never leaves the EU • GDPR Compliant • Hetzner Germany (Nuremberg)</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="features" id="features">
|
||||
<div class="container">
|
||||
<h2 class="section-title">Everything you need</h2>
|
||||
<p class="section-sub">A complete PDF generation API. No SDKs, no dependencies, no setup.</p>
|
||||
<div class="features-grid">
|
||||
<div class="feature-card">
|
||||
<div class="feature-icon">⚡</div>
|
||||
<h3>Fast</h3>
|
||||
<p>Sub-second PDF generation. Persistent browser pool means no cold starts.</p>
|
||||
<div class="feature-icon" aria-hidden="true">⚡</div>
|
||||
<h3>Sub-second Speed</h3>
|
||||
<p>Persistent browser pool — no cold starts. Your PDFs are ready before your spinner shows.</p>
|
||||
</div>
|
||||
<div class="feature-card">
|
||||
<div class="feature-icon">🎨</div>
|
||||
<h3>Beautiful Output</h3>
|
||||
<p>Full CSS support. Custom fonts, colors, layouts. Your PDFs, your brand.</p>
|
||||
<div class="feature-icon" aria-hidden="true">🎨</div>
|
||||
<h3>Pixel-perfect Output</h3>
|
||||
<p>Full CSS support including flexbox, grid, and custom fonts. Your brand, your PDFs.</p>
|
||||
</div>
|
||||
<div class="feature-card">
|
||||
<div class="feature-icon">📄</div>
|
||||
<h3>Templates</h3>
|
||||
<p>Built-in invoice and receipt templates. Pass data, get PDF. No HTML needed.</p>
|
||||
<div class="feature-icon" aria-hidden="true">📄</div>
|
||||
<h3>Built-in Templates</h3>
|
||||
<p>Invoice and receipt templates out of the box. Pass JSON data, get beautiful PDFs.</p>
|
||||
</div>
|
||||
<div class="feature-card">
|
||||
<div class="feature-icon">🔧</div>
|
||||
<h3>Simple API</h3>
|
||||
<p>REST API with JSON in, PDF out. Works with any language. No SDKs required.</p>
|
||||
<div class="feature-icon" aria-hidden="true">🔧</div>
|
||||
<h3>Dead-simple API</h3>
|
||||
<p>REST API. JSON in, PDF out. Works with curl, Python, Node, Go — anything with HTTP.</p>
|
||||
</div>
|
||||
<div class="feature-card">
|
||||
<div class="feature-icon">📐</div>
|
||||
<h3>Flexible</h3>
|
||||
<p>A4, Letter, custom sizes. Portrait or landscape. Configurable margins.</p>
|
||||
<div class="feature-icon" aria-hidden="true">📐</div>
|
||||
<h3>Fully Configurable</h3>
|
||||
<p>A4, Letter, custom sizes. Portrait or landscape. Headers, footers, and margins.</p>
|
||||
</div>
|
||||
<div class="feature-card">
|
||||
<div class="feature-icon">🔒</div>
|
||||
<h3>Secure</h3>
|
||||
<p>Your data is never stored. PDFs are generated and streamed — nothing hits disk.</p>
|
||||
<div class="feature-icon" aria-hidden="true">🔒</div>
|
||||
<h3>Secure by Default</h3>
|
||||
<p>HTTPS only. Rate limiting. No data stored. PDFs stream directly — nothing touches disk.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="endpoints" id="endpoints">
|
||||
<div class="container">
|
||||
<h2>API Endpoints</h2>
|
||||
<div class="endpoint">
|
||||
<span class="endpoint-method">POST</span>
|
||||
<span class="endpoint-path">/v1/convert/html</span>
|
||||
<div class="endpoint-desc">Convert raw HTML (with optional CSS) to PDF.</div>
|
||||
</div>
|
||||
<div class="endpoint">
|
||||
<span class="endpoint-method">POST</span>
|
||||
<span class="endpoint-path">/v1/convert/markdown</span>
|
||||
<div class="endpoint-desc">Convert Markdown to styled PDF with syntax highlighting.</div>
|
||||
</div>
|
||||
<div class="endpoint">
|
||||
<span class="endpoint-method">POST</span>
|
||||
<span class="endpoint-path">/v1/convert/url</span>
|
||||
<div class="endpoint-desc">Navigate to a URL and convert the page to PDF.</div>
|
||||
</div>
|
||||
<div class="endpoint">
|
||||
<span class="endpoint-method">GET</span>
|
||||
<span class="endpoint-path">/v1/templates</span>
|
||||
<div class="endpoint-desc">List available document templates with field definitions.</div>
|
||||
</div>
|
||||
<div class="endpoint">
|
||||
<span class="endpoint-method">POST</span>
|
||||
<span class="endpoint-path">/v1/templates/:id/render</span>
|
||||
<div class="endpoint-desc">Render a template (invoice, receipt) with your data to PDF.</div>
|
||||
</div>
|
||||
<div class="endpoint">
|
||||
<span class="endpoint-method">GET</span>
|
||||
<span class="endpoint-path">/health</span>
|
||||
<div class="endpoint-desc">Health check — verify the API is running.</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="pricing" id="pricing">
|
||||
<div class="container">
|
||||
<h2>Simple Pricing</h2>
|
||||
<p class="subtitle">No per-page fees. No hidden limits. Pay for what you use.</p>
|
||||
<h2 class="section-title">Simple, transparent pricing</h2>
|
||||
<p class="section-sub">Start free. Upgrade when you're ready. No surprise charges.</p>
|
||||
<div class="pricing-grid">
|
||||
<div class="price-card">
|
||||
<h3>Free</h3>
|
||||
<div class="price-amount">$0<span>/mo</span></div>
|
||||
<div class="price-name">Free</div>
|
||||
<div class="price-amount">€0<span> /mo</span></div>
|
||||
<div class="price-desc">Perfect for side projects and testing</div>
|
||||
<ul class="price-features">
|
||||
<li>100 PDFs / month</li>
|
||||
<li>All endpoints</li>
|
||||
<li>All templates</li>
|
||||
<li>Community support</li>
|
||||
<li>100 PDFs per month</li>
|
||||
<li>All conversion endpoints</li>
|
||||
<li>All templates included</li>
|
||||
<li>Rate limiting: 10 req/min</li>
|
||||
</ul>
|
||||
<button class="btn btn-secondary" style="width:100%" onclick="openSignup()">Get Free Key</button>
|
||||
<button class="btn btn-secondary" style="width:100%" id="btn-signup-2">Get Free API Key</button>
|
||||
</div>
|
||||
<div class="price-card featured">
|
||||
<h3>Pro</h3>
|
||||
<div class="price-amount">$9<span>/mo</span></div>
|
||||
<div class="price-name">Pro</div>
|
||||
<div class="price-amount">€9<span> /mo</span></div>
|
||||
<div class="price-desc">For production apps and businesses</div>
|
||||
<ul class="price-features">
|
||||
<li>10,000 PDFs / month</li>
|
||||
<li>All endpoints</li>
|
||||
<li>All templates</li>
|
||||
<li>5,000 PDFs / month</li>
|
||||
<li>All conversion endpoints</li>
|
||||
<li>All templates included</li>
|
||||
<li>Priority support</li>
|
||||
<li>Custom templates</li>
|
||||
</ul>
|
||||
<button class="btn btn-primary" style="width:100%" onclick="checkout()">Get Started</button>
|
||||
<button class="btn btn-primary" style="width:100%" id="btn-checkout">Get Started →</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<footer>
|
||||
|
||||
<footer aria-label="Footer">
|
||||
<div class="container">
|
||||
<p>DocFast © 2026 — Fast PDF generation for developers</p>
|
||||
<div class="footer-left">© 2026 DocFast. Fast PDF generation for developers.</div>
|
||||
<div class="footer-links">
|
||||
<a href="/">Home</a>
|
||||
<a href="/docs">Docs</a>
|
||||
<a href="/health">API Status</a>
|
||||
<a href="/#change-email" class="open-email-change">Change Email</a>
|
||||
<a href="/impressum">Impressum</a>
|
||||
<a href="/privacy">Privacy Policy</a>
|
||||
<a href="/terms">Terms of Service</a>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
<!-- Signup Modal -->
|
||||
<div class="modal-overlay" id="signupModal">
|
||||
<div class="modal" style="position:relative">
|
||||
<button class="close" onclick="closeSignup()">×</button>
|
||||
<div id="signupForm">
|
||||
<h2>Get Your Free API Key</h2>
|
||||
<p>Enter your email and get an API key instantly. No credit card required.</p>
|
||||
<div class="error" id="signupError"></div>
|
||||
<input type="email" id="signupEmail" placeholder="you@example.com" autofocus>
|
||||
<button class="btn btn-primary" style="width:100%" onclick="submitSignup()" id="signupBtn">Get API Key</button>
|
||||
<div class="modal-overlay" id="signupModal" role="dialog" aria-label="Sign up for API key">
|
||||
<div class="modal">
|
||||
<button class="close" id="btn-close-signup">×</button>
|
||||
|
||||
<div id="signupInitial" class="active">
|
||||
<h2>Get your free API key</h2>
|
||||
<p>Enter your email to get started. No credit card required.</p>
|
||||
<div class="signup-error" id="signupError"></div>
|
||||
<input type="email" id="signupEmail" placeholder="your.email@example.com" style="width:100%;padding:12px;border:1px solid var(--border);background:var(--bg);color:var(--fg);border-radius:8px;font-size:0.9rem;margin-bottom:16px;" required>
|
||||
<button class="btn btn-primary" style="width:100%" id="signupBtn">Generate API Key →</button>
|
||||
<p style="margin-top:16px;color:var(--muted);font-size:0.8rem;text-align:center;">100 free PDFs/month • All endpoints included<br><a href="#" class="open-recover" style="color:var(--muted)">Lost your API key? Recover it →</a></p>
|
||||
</div>
|
||||
<div class="key-result" id="keyResult">
|
||||
<h2>🚀 You're in!</h2>
|
||||
<p>Here's your API key. <strong>Save it now</strong> — it won't be shown again.</p>
|
||||
<div class="key-box" id="apiKeyDisplay" onclick="copyKey()" title="Click to copy"></div>
|
||||
<div class="copy-hint">Click to copy</div>
|
||||
<p style="margin-top:24px;color:var(--muted);font-size:0.9rem;">100 free PDFs/month • All endpoints • <a href="/docs">View docs →</a></p>
|
||||
|
||||
<div id="signupLoading">
|
||||
<div class="spinner"></div>
|
||||
<p style="color:var(--muted);margin:0">Generating your API key…</p>
|
||||
</div>
|
||||
|
||||
<div id="signupVerify">
|
||||
<h2>Enter verification code</h2>
|
||||
<p>We sent a 6-digit code to <strong id="verifyEmailDisplay"></strong></p>
|
||||
<div class="signup-error" id="verifyError"></div>
|
||||
<input type="text" id="verifyCode" placeholder="123456" maxlength="6" pattern="[0-9]{6}" inputmode="numeric" style="width:100%;padding:14px;border:1px solid var(--border);background:var(--bg);color:var(--fg);border-radius:8px;font-size:1.4rem;letter-spacing:0.3em;text-align:center;margin-bottom:16px;font-family:monospace;" required>
|
||||
<button class="btn btn-primary" style="width:100%" id="verifyBtn">Verify →</button>
|
||||
<p style="margin-top:16px;color:var(--muted);font-size:0.8rem;text-align:center;">Code expires in 15 minutes</p>
|
||||
</div>
|
||||
|
||||
<div id="signupResult" aria-live="polite">
|
||||
<h2>🚀 Your API key is ready!</h2>
|
||||
<div class="warning-box">
|
||||
<span class="icon">⚠️</span>
|
||||
<span>Save your API key securely. Lost it? <a href="#" class="open-recover" style="color:#fbbf24">Recover via email</a></span>
|
||||
</div>
|
||||
<div style="background:var(--bg);border:1px solid var(--accent);border-radius:8px;padding:14px;font-family:monospace;font-size:0.82rem;word-break:break-all;margin:16px 0;position:relative;">
|
||||
<span id="apiKeyText"></span>
|
||||
<button onclick="copyKey()" id="copyBtn" style="position:absolute;top:8px;right:8px;background:var(--accent);color:var(--bg);border:none;border-radius:4px;padding:4px 12px;cursor:pointer;font-size:0.8rem;">Copy</button>
|
||||
</div>
|
||||
<p style="margin-top:20px;color:var(--muted);font-size:0.9rem;">100 free PDFs/month • <a href="/docs">Read the docs →</a></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function openSignup() {
|
||||
document.getElementById('signupModal').classList.add('active');
|
||||
document.getElementById('signupForm').style.display = 'block';
|
||||
document.getElementById('keyResult').style.display = 'none';
|
||||
document.getElementById('signupEmail').value = '';
|
||||
document.getElementById('signupError').style.display = 'none';
|
||||
setTimeout(() => document.getElementById('signupEmail').focus(), 100);
|
||||
}
|
||||
|
||||
function closeSignup() {
|
||||
document.getElementById('signupModal').classList.remove('active');
|
||||
}
|
||||
<!-- Recovery Modal -->
|
||||
<div class="modal-overlay" id="recoverModal" role="dialog" aria-label="Recover API key">
|
||||
<div class="modal">
|
||||
<button class="close" id="btn-close-recover">×</button>
|
||||
|
||||
// Close on overlay click
|
||||
document.getElementById('signupModal').addEventListener('click', function(e) {
|
||||
if (e.target === this) closeSignup();
|
||||
});
|
||||
<div id="recoverInitial" class="active">
|
||||
<h2>Recover your API key</h2>
|
||||
<p>Enter the email you signed up with. We'll send a verification code.</p>
|
||||
<div class="signup-error" id="recoverError"></div>
|
||||
<input type="email" id="recoverEmailInput" placeholder="your.email@example.com" style="width:100%;padding:12px;border:1px solid var(--border);background:var(--bg);color:var(--fg);border-radius:8px;font-size:0.9rem;margin-bottom:16px;" required>
|
||||
<button class="btn btn-primary" style="width:100%" id="recoverBtn">Send Verification Code →</button>
|
||||
<p style="margin-top:16px;color:var(--muted);font-size:0.8rem;text-align:center;">Your key will be shown here after verification — never sent via email</p>
|
||||
</div>
|
||||
|
||||
// Submit on Enter
|
||||
document.getElementById('signupEmail').addEventListener('keydown', function(e) {
|
||||
if (e.key === 'Enter') submitSignup();
|
||||
});
|
||||
<div id="recoverLoading">
|
||||
<div class="spinner"></div>
|
||||
<p style="color:var(--muted);margin:0">Sending verification code…</p>
|
||||
</div>
|
||||
|
||||
async function submitSignup() {
|
||||
const email = document.getElementById('signupEmail').value.trim();
|
||||
const errEl = document.getElementById('signupError');
|
||||
const btn = document.getElementById('signupBtn');
|
||||
<div id="recoverVerify">
|
||||
<h2>Enter verification code</h2>
|
||||
<p>We sent a 6-digit code to <strong id="recoverEmailDisplay"></strong></p>
|
||||
<div class="signup-error" id="recoverVerifyError"></div>
|
||||
<input type="text" id="recoverCode" placeholder="123456" maxlength="6" pattern="[0-9]{6}" inputmode="numeric" style="width:100%;padding:14px;border:1px solid var(--border);background:var(--bg);color:var(--fg);border-radius:8px;font-size:1.4rem;letter-spacing:0.3em;text-align:center;margin-bottom:16px;font-family:monospace;" required>
|
||||
<button class="btn btn-primary" style="width:100%" id="recoverVerifyBtn">Verify →</button>
|
||||
<p style="margin-top:16px;color:var(--muted);font-size:0.8rem;text-align:center;">Code expires in 15 minutes</p>
|
||||
</div>
|
||||
|
||||
if (!email) {
|
||||
errEl.textContent = 'Please enter your email.';
|
||||
errEl.style.display = 'block';
|
||||
return;
|
||||
}
|
||||
<div id="recoverResult" aria-live="polite">
|
||||
<h2>🔑 Your API key</h2>
|
||||
<div class="warning-box">
|
||||
<span class="icon">⚠️</span>
|
||||
<span>Save your API key securely. This is the only time it will be shown.</span>
|
||||
</div>
|
||||
<div style="background:var(--bg);border:1px solid var(--accent);border-radius:8px;padding:14px;font-family:monospace;font-size:0.82rem;word-break:break-all;margin:16px 0;position:relative;">
|
||||
<span id="recoveredKeyText"></span>
|
||||
<button onclick="copyRecoveredKey()" id="copyRecoveredBtn" style="position:absolute;top:8px;right:8px;background:var(--accent);color:var(--bg);border:none;border-radius:4px;padding:4px 12px;cursor:pointer;font-size:0.8rem;">Copy</button>
|
||||
</div>
|
||||
<p style="margin-top:20px;color:var(--muted);font-size:0.9rem;"><a href="/docs">Read the docs →</a></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
btn.textContent = 'Creating...';
|
||||
btn.disabled = true;
|
||||
|
||||
try {
|
||||
const res = await fetch('/v1/signup/free', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ email })
|
||||
});
|
||||
const data = await res.json();
|
||||
<!-- Email Change Modal -->
|
||||
<div class="modal-overlay" id="emailChangeModal" role="dialog" aria-label="Change email">
|
||||
<div class="modal">
|
||||
<button class="close" id="btn-close-email-change">×</button>
|
||||
|
||||
if (!res.ok) {
|
||||
errEl.textContent = data.error || 'Something went wrong.';
|
||||
errEl.style.display = 'block';
|
||||
btn.textContent = 'Get API Key';
|
||||
btn.disabled = false;
|
||||
return;
|
||||
}
|
||||
<div id="emailChangeInitial" class="active">
|
||||
<h2>Change your email</h2>
|
||||
<p>Enter your API key and new email address.</p>
|
||||
<div class="signup-error" id="emailChangeError"></div>
|
||||
<input type="text" id="emailChangeApiKey" placeholder="Your API key (df_free_... or df_pro_...)" style="width:100%;padding:12px;border:1px solid var(--border);background:var(--bg);color:var(--fg);border-radius:8px;font-size:0.9rem;margin-bottom:12px;font-family:monospace;" required>
|
||||
<input type="email" id="emailChangeNewEmail" placeholder="new.email@example.com" style="width:100%;padding:12px;border:1px solid var(--border);background:var(--bg);color:var(--fg);border-radius:8px;font-size:0.9rem;margin-bottom:16px;" required>
|
||||
<button class="btn btn-primary" style="width:100%" id="emailChangeBtn">Send Verification Code →</button>
|
||||
<p style="margin-top:16px;color:var(--muted);font-size:0.8rem;text-align:center;">A verification code will be sent to your new email</p>
|
||||
</div>
|
||||
|
||||
// Show key
|
||||
document.getElementById('signupForm').style.display = 'none';
|
||||
document.getElementById('keyResult').style.display = 'block';
|
||||
document.getElementById('apiKeyDisplay').textContent = data.apiKey;
|
||||
} catch (err) {
|
||||
errEl.textContent = 'Network error. Please try again.';
|
||||
errEl.style.display = 'block';
|
||||
btn.textContent = 'Get API Key';
|
||||
btn.disabled = false;
|
||||
}
|
||||
}
|
||||
<div id="emailChangeLoading">
|
||||
<div class="spinner"></div>
|
||||
<p style="color:var(--muted);margin:0">Sending verification code…</p>
|
||||
</div>
|
||||
|
||||
function copyKey() {
|
||||
const key = document.getElementById('apiKeyDisplay').textContent;
|
||||
navigator.clipboard.writeText(key).then(() => {
|
||||
document.querySelector('.copy-hint').textContent = '✓ Copied!';
|
||||
setTimeout(() => document.querySelector('.copy-hint').textContent = 'Click to copy', 2000);
|
||||
});
|
||||
}
|
||||
<div id="emailChangeVerify">
|
||||
<h2>Enter verification code</h2>
|
||||
<p>We sent a 6-digit code to <strong id="emailChangeEmailDisplay"></strong></p>
|
||||
<div class="signup-error" id="emailChangeVerifyError"></div>
|
||||
<input type="text" id="emailChangeCode" placeholder="123456" maxlength="6" pattern="[0-9]{6}" inputmode="numeric" style="width:100%;padding:14px;border:1px solid var(--border);background:var(--bg);color:var(--fg);border-radius:8px;font-size:1.4rem;letter-spacing:0.3em;text-align:center;margin-bottom:16px;font-family:monospace;" required>
|
||||
<button class="btn btn-primary" style="width:100%" id="emailChangeVerifyBtn">Verify →</button>
|
||||
<p style="margin-top:16px;color:var(--muted);font-size:0.8rem;text-align:center;">Code expires in 15 minutes</p>
|
||||
</div>
|
||||
|
||||
async function checkout() {
|
||||
try {
|
||||
const res = await fetch('/v1/billing/checkout', { method: 'POST' });
|
||||
const data = await res.json();
|
||||
if (data.url) window.location.href = data.url;
|
||||
else alert('Something went wrong. Please try again.');
|
||||
} catch (err) {
|
||||
alert('Something went wrong. Please try again.');
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<div id="emailChangeResult">
|
||||
<h2>✅ Email updated!</h2>
|
||||
<p>Your account email has been changed to <strong id="emailChangeNewDisplay"></strong></p>
|
||||
<p style="margin-top:20px;color:var(--muted);font-size:0.9rem;"><a href="/docs">Read the docs →</a></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="/app.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,325 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>DocFast — HTML & Markdown to PDF API</title>
|
||||
<meta name="description" content="Convert HTML and Markdown to beautiful PDFs with a simple API call. Built-in invoice templates. Fast, reliable, developer-friendly.">
|
||||
<link rel="icon" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><text y='.9em' font-size='90'>⚡</text></svg>">
|
||||
<style>
|
||||
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
|
||||
:root {
|
||||
--bg: #0b0d11; --bg2: #12151c; --fg: #e4e7ed; --muted: #7a8194;
|
||||
--accent: #34d399; --accent-hover: #5eead4; --accent-glow: rgba(52,211,153,0.12);
|
||||
--accent2: #60a5fa; --card: #151922; --border: #1e2433;
|
||||
--radius: 12px; --radius-lg: 16px;
|
||||
}
|
||||
body { font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: var(--bg); color: var(--fg); line-height: 1.65; -webkit-font-smoothing: antialiased; }
|
||||
a { color: var(--accent); text-decoration: none; transition: color 0.2s; }
|
||||
a:hover { color: var(--accent-hover); }
|
||||
.container { max-width: 1020px; margin: 0 auto; padding: 0 24px; }
|
||||
|
||||
/* Nav */
|
||||
nav { padding: 20px 0; border-bottom: 1px solid var(--border); }
|
||||
nav .container { display: flex; align-items: center; justify-content: space-between; }
|
||||
.logo { font-size: 1.25rem; font-weight: 700; letter-spacing: -0.5px; color: var(--fg); display: flex; align-items: center; gap: 8px; }
|
||||
.logo span { color: var(--accent); }
|
||||
.nav-links { display: flex; gap: 28px; align-items: center; }
|
||||
.nav-links a { color: var(--muted); font-size: 0.9rem; font-weight: 500; }
|
||||
.nav-links a:hover { color: var(--fg); }
|
||||
|
||||
/* Hero */
|
||||
.hero { padding: 100px 0 80px; text-align: center; position: relative; }
|
||||
.hero::before { content: ''; position: absolute; top: 0; left: 50%; transform: translateX(-50%); width: 600px; height: 400px; background: radial-gradient(ellipse, var(--accent-glow) 0%, transparent 70%); pointer-events: none; }
|
||||
.badge { display: inline-block; padding: 6px 16px; border-radius: 50px; font-size: 0.8rem; font-weight: 600; color: var(--accent); background: rgba(52,211,153,0.08); border: 1px solid rgba(52,211,153,0.15); margin-bottom: 24px; letter-spacing: 0.3px; }
|
||||
.hero h1 { font-size: clamp(2.2rem, 5vw, 3.5rem); font-weight: 800; margin-bottom: 20px; letter-spacing: -1.5px; line-height: 1.15; }
|
||||
.hero h1 .gradient { background: linear-gradient(135deg, var(--accent) 0%, var(--accent2) 100%); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
|
||||
.hero p { font-size: 1.2rem; color: var(--muted); max-width: 560px; margin: 0 auto 40px; line-height: 1.7; }
|
||||
.hero-actions { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }
|
||||
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 14px 28px; border-radius: 10px; font-size: 0.95rem; font-weight: 600; transition: all 0.2s; border: none; cursor: pointer; text-decoration: none; }
|
||||
.btn-primary { background: var(--accent); color: #0b0d11; }
|
||||
.btn-primary:hover { background: var(--accent-hover); text-decoration: none; transform: translateY(-1px); box-shadow: 0 8px 24px rgba(52,211,153,0.2); }
|
||||
.btn-secondary { border: 1px solid var(--border); color: var(--fg); background: transparent; }
|
||||
.btn-secondary:hover { border-color: var(--muted); text-decoration: none; background: rgba(255,255,255,0.03); }
|
||||
.btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }
|
||||
|
||||
/* Code block */
|
||||
.code-section { margin: 56px auto 0; max-width: 660px; text-align: left; }
|
||||
.code-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 20px; background: #1a1f2b; border: 1px solid var(--border); border-bottom: none; border-radius: var(--radius) var(--radius) 0 0; }
|
||||
.code-dots { display: flex; gap: 6px; }
|
||||
.code-dots span { width: 10px; height: 10px; border-radius: 50%; }
|
||||
.code-dots span:nth-child(1) { background: #f87171; }
|
||||
.code-dots span:nth-child(2) { background: #fbbf24; }
|
||||
.code-dots span:nth-child(3) { background: #34d399; }
|
||||
.code-label { font-size: 0.75rem; color: var(--muted); font-family: monospace; }
|
||||
.code-block { background: var(--card); border: 1px solid var(--border); border-radius: 0 0 var(--radius) var(--radius); padding: 24px 28px; font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace; font-size: 0.85rem; line-height: 1.85; overflow-x: auto; }
|
||||
.code-block .c { color: #4a5568; }
|
||||
.code-block .s { color: var(--accent); }
|
||||
.code-block .k { color: var(--accent2); }
|
||||
.code-block .f { color: #c084fc; }
|
||||
|
||||
/* Sections */
|
||||
section { position: relative; }
|
||||
.section-title { text-align: center; font-size: clamp(1.5rem, 3vw, 2.2rem); font-weight: 700; letter-spacing: -0.5px; margin-bottom: 12px; }
|
||||
.section-sub { text-align: center; color: var(--muted); margin-bottom: 48px; font-size: 1.05rem; }
|
||||
|
||||
/* Features */
|
||||
.features { padding: 80px 0; }
|
||||
.features-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
|
||||
@media (max-width: 768px) { .features-grid { grid-template-columns: 1fr; } }
|
||||
.feature-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 28px; transition: border-color 0.2s, transform 0.2s; }
|
||||
.feature-card:hover { border-color: rgba(52,211,153,0.3); transform: translateY(-2px); }
|
||||
.feature-icon { width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 1.2rem; margin-bottom: 16px; background: rgba(52,211,153,0.08); }
|
||||
.feature-card h3 { font-size: 1rem; font-weight: 600; margin-bottom: 8px; }
|
||||
.feature-card p { color: var(--muted); font-size: 0.9rem; line-height: 1.6; }
|
||||
|
||||
/* Pricing */
|
||||
.pricing { padding: 80px 0; }
|
||||
.pricing-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 24px; max-width: 700px; margin: 0 auto; }
|
||||
@media (max-width: 640px) { .pricing-grid { grid-template-columns: 1fr; } }
|
||||
.price-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 36px; position: relative; }
|
||||
.price-card.featured { border-color: var(--accent); }
|
||||
.price-card.featured::before { content: 'POPULAR'; position: absolute; top: -10px; right: 20px; background: var(--accent); color: #0b0d11; font-size: 0.65rem; font-weight: 700; padding: 3px 10px; border-radius: 50px; letter-spacing: 0.5px; }
|
||||
.price-name { font-size: 0.9rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px; }
|
||||
.price-amount { font-size: 3rem; font-weight: 800; letter-spacing: -2px; margin-bottom: 4px; }
|
||||
.price-amount span { font-size: 1rem; color: var(--muted); font-weight: 400; letter-spacing: 0; }
|
||||
.price-desc { color: var(--muted); font-size: 0.85rem; margin-bottom: 24px; padding-bottom: 24px; border-bottom: 1px solid var(--border); }
|
||||
.price-features { list-style: none; margin-bottom: 28px; }
|
||||
.price-features li { padding: 5px 0; color: var(--muted); font-size: 0.9rem; display: flex; align-items: center; gap: 10px; }
|
||||
.price-features li::before { content: "✓"; color: var(--accent); font-weight: 700; font-size: 0.85rem; flex-shrink: 0; }
|
||||
|
||||
/* Trust */
|
||||
.trust { padding: 60px 0 80px; }
|
||||
.trust-grid { display: flex; gap: 40px; justify-content: center; flex-wrap: wrap; }
|
||||
.trust-item { text-align: center; flex: 1; min-width: 160px; max-width: 220px; }
|
||||
.trust-num { font-size: 2rem; font-weight: 800; color: var(--accent); letter-spacing: -1px; }
|
||||
.trust-label { font-size: 0.85rem; color: var(--muted); margin-top: 4px; }
|
||||
|
||||
/* Footer */
|
||||
footer { padding: 40px 0; border-top: 1px solid var(--border); }
|
||||
footer .container { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 16px; }
|
||||
.footer-left { color: var(--muted); font-size: 0.85rem; }
|
||||
.footer-links { display: flex; gap: 24px; }
|
||||
.footer-links a { color: var(--muted); font-size: 0.85rem; }
|
||||
.footer-links a:hover { color: var(--fg); }
|
||||
|
||||
/* Modal */
|
||||
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.75); backdrop-filter: blur(4px); z-index: 100; align-items: center; justify-content: center; }
|
||||
.modal-overlay.active { display: flex; }
|
||||
.modal { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 40px; max-width: 460px; width: 90%; position: relative; }
|
||||
.modal h2 { margin-bottom: 8px; font-size: 1.4rem; font-weight: 700; }
|
||||
.modal p { color: var(--muted); margin-bottom: 24px; font-size: 0.95rem; }
|
||||
.modal .close { position: absolute; top: 16px; right: 20px; color: var(--muted); font-size: 1.4rem; cursor: pointer; background: none; border: none; transition: color 0.2s; }
|
||||
.modal .close:hover { color: var(--fg); }
|
||||
|
||||
/* Signup states */
|
||||
#signupInitial, #signupLoading, #signupResult { display: none; }
|
||||
#signupInitial.active { display: block; }
|
||||
#signupLoading.active { display: flex; flex-direction: column; align-items: center; padding: 40px 0; text-align: center; }
|
||||
#signupResult.active { display: block; }
|
||||
.spinner { width: 36px; height: 36px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.7s linear infinite; margin-bottom: 16px; }
|
||||
@keyframes spin { to { transform: rotate(360deg); } }
|
||||
|
||||
.key-box { background: var(--bg); border: 1px solid var(--accent); border-radius: 8px; padding: 16px; font-family: monospace; font-size: 0.82rem; word-break: break-all; margin: 16px 0 12px; position: relative; cursor: pointer; transition: background 0.2s; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
|
||||
.key-box:hover { background: #151922; }
|
||||
.key-text { flex: 1; }
|
||||
.copy-btn { background: rgba(52,211,153,0.1); border: 1px solid rgba(52,211,153,0.2); color: var(--accent); border-radius: 6px; padding: 6px 14px; font-size: 0.8rem; font-weight: 600; cursor: pointer; white-space: nowrap; transition: all 0.2s; }
|
||||
.copy-btn:hover { background: rgba(52,211,153,0.2); }
|
||||
.warning-box { background: rgba(251,191,36,0.06); border: 1px solid rgba(251,191,36,0.15); border-radius: 8px; padding: 12px 16px; font-size: 0.85rem; color: #fbbf24; display: flex; align-items: flex-start; gap: 10px; margin-bottom: 16px; }
|
||||
.warning-box .icon { font-size: 1.1rem; flex-shrink: 0; }
|
||||
.signup-error { color: #f87171; font-size: 0.85rem; margin-bottom: 16px; display: none; padding: 10px 14px; background: rgba(248,113,113,0.06); border: 1px solid rgba(248,113,113,0.15); border-radius: 8px; }
|
||||
|
||||
/* Responsive */
|
||||
@media (max-width: 640px) {
|
||||
.hero { padding: 72px 0 56px; }
|
||||
.nav-links { gap: 16px; }
|
||||
.code-block { font-size: 0.75rem; padding: 18px 16px; }
|
||||
.trust-grid { gap: 24px; }
|
||||
}
|
||||
</style>
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap" rel="stylesheet">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<nav>
|
||||
<div class="container">
|
||||
<div class="logo">⚡ Doc<span>Fast</span></div>
|
||||
<div class="nav-links">
|
||||
<a href="#features">Features</a>
|
||||
<a href="#pricing">Pricing</a>
|
||||
<a href="/docs">Docs</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<section class="hero">
|
||||
<div class="container">
|
||||
<div class="badge">🚀 Simple PDF API for Developers</div>
|
||||
<h1>HTML to <span class="gradient">PDF</span><br>in one API call</h1>
|
||||
<p>Convert HTML, Markdown, or URLs to pixel-perfect PDFs. Built-in templates for invoices & receipts. No headless browser headaches.</p>
|
||||
<div class="hero-actions">
|
||||
<button class="btn btn-primary" id="btn-signup">Get Free API Key →</button>
|
||||
<a href="/docs" class="btn btn-secondary">Read the Docs</a>
|
||||
</div>
|
||||
|
||||
<div class="code-section">
|
||||
<div class="code-header">
|
||||
<div class="code-dots"><span></span><span></span><span></span></div>
|
||||
<span class="code-label">terminal</span>
|
||||
</div>
|
||||
<div class="code-block">
|
||||
<span class="c"># Convert HTML to PDF — it's that simple</span>
|
||||
<span class="k">curl</span> <span class="f">-X POST</span> https://docfast.dev/v1/convert/html \
|
||||
-H <span class="s">"Authorization: Bearer YOUR_KEY"</span> \
|
||||
-H <span class="s">"Content-Type: application/json"</span> \
|
||||
-d <span class="s">'{"html": "<h1>Hello World</h1><p>Your first PDF</p>"}'</span> \
|
||||
-o <span class="f">output.pdf</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="trust">
|
||||
<div class="container">
|
||||
<div class="trust-grid">
|
||||
<div class="trust-item">
|
||||
<div class="trust-num"><1s</div>
|
||||
<div class="trust-label">Avg. generation time</div>
|
||||
</div>
|
||||
<div class="trust-item">
|
||||
<div class="trust-num">99.9%</div>
|
||||
<div class="trust-label">Uptime SLA</div>
|
||||
</div>
|
||||
<div class="trust-item">
|
||||
<div class="trust-num">HTTPS</div>
|
||||
<div class="trust-label">Encrypted & secure</div>
|
||||
</div>
|
||||
<div class="trust-item">
|
||||
<div class="trust-num">0 bytes</div>
|
||||
<div class="trust-label">Data stored on disk</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="features" id="features">
|
||||
<div class="container">
|
||||
<h2 class="section-title">Everything you need</h2>
|
||||
<p class="section-sub">A complete PDF generation API. No SDKs, no dependencies, no setup.</p>
|
||||
<div class="features-grid">
|
||||
<div class="feature-card">
|
||||
<div class="feature-icon">⚡</div>
|
||||
<h3>Sub-second Speed</h3>
|
||||
<p>Persistent browser pool — no cold starts. Your PDFs are ready before your spinner shows.</p>
|
||||
</div>
|
||||
<div class="feature-card">
|
||||
<div class="feature-icon">🎨</div>
|
||||
<h3>Pixel-perfect Output</h3>
|
||||
<p>Full CSS support including flexbox, grid, and custom fonts. Your brand, your PDFs.</p>
|
||||
</div>
|
||||
<div class="feature-card">
|
||||
<div class="feature-icon">📄</div>
|
||||
<h3>Built-in Templates</h3>
|
||||
<p>Invoice and receipt templates out of the box. Pass JSON data, get beautiful PDFs.</p>
|
||||
</div>
|
||||
<div class="feature-card">
|
||||
<div class="feature-icon">🔧</div>
|
||||
<h3>Dead-simple API</h3>
|
||||
<p>REST API. JSON in, PDF out. Works with curl, Python, Node, Go — anything with HTTP.</p>
|
||||
</div>
|
||||
<div class="feature-card">
|
||||
<div class="feature-icon">📐</div>
|
||||
<h3>Fully Configurable</h3>
|
||||
<p>A4, Letter, custom sizes. Portrait or landscape. Headers, footers, and margins.</p>
|
||||
</div>
|
||||
<div class="feature-card">
|
||||
<div class="feature-icon">🔒</div>
|
||||
<h3>Secure by Default</h3>
|
||||
<p>HTTPS only. Rate limiting. No data stored. PDFs stream directly — nothing touches disk.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="pricing" id="pricing">
|
||||
<div class="container">
|
||||
<h2 class="section-title">Simple, transparent pricing</h2>
|
||||
<p class="section-sub">Start free. Upgrade when you're ready. No surprise charges.</p>
|
||||
<div class="pricing-grid">
|
||||
<div class="price-card">
|
||||
<div class="price-name">Free</div>
|
||||
<div class="price-amount">$0<span> /mo</span></div>
|
||||
<div class="price-desc">Perfect for side projects and testing</div>
|
||||
<ul class="price-features">
|
||||
<li>100 PDFs per month</li>
|
||||
<li>All conversion endpoints</li>
|
||||
<li>All templates included</li>
|
||||
<li>Rate limiting: 10 req/min</li>
|
||||
</ul>
|
||||
<button class="btn btn-secondary" style="width:100%" id="btn-signup-2">Get Free API Key</button>
|
||||
</div>
|
||||
<div class="price-card featured">
|
||||
<div class="price-name">Pro</div>
|
||||
<div class="price-amount">$9<span> /mo</span></div>
|
||||
<div class="price-desc">For production apps and businesses</div>
|
||||
<ul class="price-features">
|
||||
<li>10,000 PDFs per month</li>
|
||||
<li>All conversion endpoints</li>
|
||||
<li>All templates included</li>
|
||||
<li>Priority support</li>
|
||||
</ul>
|
||||
<button class="btn btn-primary" style="width:100%" id="btn-checkout">Get Started →</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<footer>
|
||||
<div class="container">
|
||||
<div class="footer-left">© 2026 DocFast. Fast PDF generation for developers.</div>
|
||||
<div class="footer-links">
|
||||
<a href="/docs">Docs</a>
|
||||
<a href="/health">API Status</a>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
<!-- Signup Modal -->
|
||||
<div class="modal-overlay" id="signupModal">
|
||||
<div class="modal">
|
||||
<button class="close" id="btn-close-signup">×</button>
|
||||
|
||||
<div id="signupInitial" class="active">
|
||||
<h2>Get your free API key</h2>
|
||||
<p>Enter your email to get started. No credit card required.</p>
|
||||
<div class="signup-error" id="signupError"></div>
|
||||
<input type="email" id="signupEmail" placeholder="your.email@example.com" style="width:100%;padding:12px;border:1px solid var(--border);background:var(--bg);color:var(--fg);border-radius:8px;font-size:0.9rem;margin-bottom:16px;" required>
|
||||
<button class="btn btn-primary" style="width:100%" id="signupBtn">Generate API Key →</button>
|
||||
<p style="margin-top:16px;color:var(--muted);font-size:0.8rem;text-align:center;">100 free PDFs/month • All endpoints included</p>
|
||||
</div>
|
||||
|
||||
<div id="signupLoading">
|
||||
<div class="spinner"></div>
|
||||
<p style="color:var(--muted);margin:0">Generating your API key…</p>
|
||||
</div>
|
||||
|
||||
<div id="signupResult">
|
||||
<h2>🚀 You're in!</h2>
|
||||
<div class="warning-box">
|
||||
<span class="icon">⚠️</span>
|
||||
<span>Save your API key now — we can't recover it later.</span>
|
||||
</div>
|
||||
<div class="key-box" id="apiKeyDisplay">
|
||||
<span class="key-text" id="apiKeyText"></span>
|
||||
<button class="copy-btn" id="copyBtn">Copy</button>
|
||||
</div>
|
||||
<p style="margin-top:20px;color:var(--muted);font-size:0.9rem;">100 free PDFs/month • <a href="/docs">Read the docs →</a></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="/app.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
560
projects/business/src/pdf-api/public/index.html.server
Normal file
560
projects/business/src/pdf-api/public/index.html.server
Normal file
|
|
@ -0,0 +1,560 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>DocFast — HTML & Markdown to PDF API</title>
|
||||
<meta name="description" content="Convert HTML and Markdown to beautiful PDFs with a simple API call. Built-in invoice templates. Fast, reliable, developer-friendly.">
|
||||
<meta property="og:title" content="DocFast — HTML & Markdown to PDF API">
|
||||
<meta property="og:description" content="Convert HTML and Markdown to beautiful PDFs with a simple API call. Fast, reliable, developer-friendly.">
|
||||
<meta property="og:type" content="website">
|
||||
<meta property="og:url" content="https://docfast.dev">
|
||||
<meta property="og:image" content="https://docfast.dev/og-image.png">
|
||||
<meta name="twitter:card" content="summary_large_image">
|
||||
<meta name="twitter:title" content="DocFast — HTML & Markdown to PDF API">
|
||||
<meta name="twitter:description" content="Convert HTML and Markdown to beautiful PDFs with a simple API call.">
|
||||
<link rel="canonical" href="https://docfast.dev">
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<script type="application/ld+json">
|
||||
{"@context":"https://schema.org","@type":"SoftwareApplication","name":"DocFast","url":"https://docfast.dev","applicationCategory":"DeveloperApplication","operatingSystem":"Web","description":"Convert HTML and Markdown to beautiful PDFs with a simple API call. Fast, reliable, developer-friendly.","offers":[{"@type":"Offer","price":"0","priceCurrency":"EUR","name":"Free","description":"100 PDFs/month"},{"@type":"Offer","price":"9","priceCurrency":"EUR","name":"Pro","description":"5,000 PDFs per month","billingIncrement":"P1M"}]}
|
||||
</script>
|
||||
<link rel="icon" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><text y='.9em' font-size='90'>⚡</text></svg>">
|
||||
<style>
|
||||
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
|
||||
:root {
|
||||
--bg: #0b0d11; --bg2: #12151c; --fg: #e4e7ed; --muted: #7a8194;
|
||||
--accent: #34d399; --accent-hover: #5eead4; --accent-glow: rgba(52,211,153,0.12);
|
||||
--accent2: #60a5fa; --card: #151922; --border: #1e2433;
|
||||
--radius: 12px; --radius-lg: 16px;
|
||||
}
|
||||
body { font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: var(--bg); color: var(--fg); line-height: 1.65; -webkit-font-smoothing: antialiased; }
|
||||
a { color: var(--accent); text-decoration: none; transition: color 0.2s; }
|
||||
a:hover { color: var(--accent-hover); }
|
||||
.container { max-width: 1020px; margin: 0 auto; padding: 0 24px; }
|
||||
|
||||
/* Nav */
|
||||
nav { padding: 20px 0; border-bottom: 1px solid var(--border); }
|
||||
nav .container { display: flex; align-items: center; justify-content: space-between; }
|
||||
.logo { font-size: 1.25rem; font-weight: 700; letter-spacing: -0.5px; color: var(--fg); display: flex; align-items: center; gap: 8px; }
|
||||
.logo span { color: var(--accent); }
|
||||
.nav-links { display: flex; gap: 28px; align-items: center; }
|
||||
.nav-links a { color: var(--muted); font-size: 0.9rem; font-weight: 500; }
|
||||
.nav-links a:hover { color: var(--fg); }
|
||||
|
||||
/* Hero */
|
||||
.hero { padding: 100px 0 80px; text-align: center; position: relative; }
|
||||
.hero::before { content: ''; position: absolute; top: 0; left: 50%; transform: translateX(-50%); width: 600px; height: 400px; background: radial-gradient(ellipse, var(--accent-glow) 0%, transparent 70%); pointer-events: none; }
|
||||
.badge { display: inline-block; padding: 6px 16px; border-radius: 50px; font-size: 0.8rem; font-weight: 600; color: var(--accent); background: rgba(52,211,153,0.08); border: 1px solid rgba(52,211,153,0.15); margin-bottom: 24px; letter-spacing: 0.3px; }
|
||||
.hero h1 { font-size: clamp(2.2rem, 5vw, 3.5rem); font-weight: 800; margin-bottom: 20px; letter-spacing: -1.5px; line-height: 1.15; }
|
||||
.hero h1 .gradient { background: linear-gradient(135deg, var(--accent) 0%, var(--accent2) 100%); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
|
||||
.hero p { font-size: 1.2rem; color: var(--muted); max-width: 560px; margin: 0 auto 40px; line-height: 1.7; }
|
||||
.hero-actions { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }
|
||||
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 14px 28px; border-radius: 10px; font-size: 0.95rem; font-weight: 600; transition: all 0.2s; border: none; cursor: pointer; text-decoration: none; }
|
||||
.btn-primary { background: var(--accent); color: #0b0d11; }
|
||||
.btn-primary:hover { background: var(--accent-hover); text-decoration: none; transform: translateY(-1px); box-shadow: 0 8px 24px rgba(52,211,153,0.2); }
|
||||
.btn-secondary { border: 1px solid var(--border); color: var(--fg); background: transparent; }
|
||||
.btn-secondary:hover { border-color: var(--muted); text-decoration: none; background: rgba(255,255,255,0.03); }
|
||||
.btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }
|
||||
|
||||
/* Code block */
|
||||
.code-section { margin: 56px auto 0; max-width: 660px; text-align: left; display: flex; flex-direction: column; }
|
||||
.code-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 20px; background: #1a1f2b; border: 1px solid var(--border); border-bottom: none; border-radius: var(--radius) var(--radius) 0 0; }
|
||||
.code-dots { display: flex; gap: 6px; }
|
||||
.code-dots span { width: 10px; height: 10px; border-radius: 50%; }
|
||||
.code-dots span:nth-child(1) { background: #f87171; }
|
||||
.code-dots span:nth-child(2) { background: #fbbf24; }
|
||||
.code-dots span:nth-child(3) { background: #34d399; }
|
||||
.code-label { font-size: 0.75rem; color: var(--muted); font-family: monospace; }
|
||||
.code-block { background: var(--card); border: 1px solid var(--border); border-radius: 0 0 var(--radius) var(--radius); padding: 24px 28px; font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace; font-size: 0.85rem; line-height: 1.85; overflow-x: auto; }
|
||||
.code-block .c { color: #4a5568; }
|
||||
.code-block .s { color: var(--accent); }
|
||||
.code-block .k { color: var(--accent2); }
|
||||
.code-block .f { color: #c084fc; }
|
||||
|
||||
/* Sections */
|
||||
section { position: relative; }
|
||||
.section-title { text-align: center; font-size: clamp(1.5rem, 3vw, 2.2rem); font-weight: 700; letter-spacing: -0.5px; margin-bottom: 12px; }
|
||||
.section-sub { text-align: center; color: var(--muted); margin-bottom: 48px; font-size: 1.05rem; }
|
||||
|
||||
/* Features */
|
||||
.features { padding: 80px 0; }
|
||||
.features-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
|
||||
@media (max-width: 768px) { .features-grid { grid-template-columns: 1fr; } }
|
||||
.feature-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 28px; transition: border-color 0.2s, transform 0.2s; }
|
||||
.feature-card:hover { border-color: rgba(52,211,153,0.3); transform: translateY(-2px); }
|
||||
.feature-icon { width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 1.2rem; margin-bottom: 16px; background: rgba(52,211,153,0.08); }
|
||||
.feature-card h3 { font-size: 1rem; font-weight: 600; margin-bottom: 8px; }
|
||||
.feature-card p { color: var(--muted); font-size: 0.9rem; line-height: 1.6; }
|
||||
|
||||
/* Pricing */
|
||||
.pricing { padding: 80px 0; }
|
||||
.pricing-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 24px; max-width: 700px; margin: 0 auto; }
|
||||
@media (max-width: 640px) { .pricing-grid { grid-template-columns: 1fr; } }
|
||||
.price-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 36px; position: relative; }
|
||||
.price-card.featured { border-color: var(--accent); }
|
||||
.price-card.featured::before { content: 'POPULAR'; position: absolute; top: -10px; right: 20px; background: var(--accent); color: #0b0d11; font-size: 0.65rem; font-weight: 700; padding: 3px 10px; border-radius: 50px; letter-spacing: 0.5px; }
|
||||
.price-name { font-size: 0.9rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px; }
|
||||
.price-amount { font-size: 3rem; font-weight: 800; letter-spacing: -2px; margin-bottom: 4px; }
|
||||
.price-amount span { font-size: 1rem; color: var(--muted); font-weight: 400; letter-spacing: 0; }
|
||||
.price-desc { color: var(--muted); font-size: 0.85rem; margin-bottom: 24px; padding-bottom: 24px; border-bottom: 1px solid var(--border); }
|
||||
.price-features { list-style: none; margin-bottom: 28px; }
|
||||
.price-features li { padding: 5px 0; color: var(--muted); font-size: 0.9rem; display: flex; align-items: center; gap: 10px; }
|
||||
.price-features li::before { content: "✓"; color: var(--accent); font-weight: 700; font-size: 0.85rem; flex-shrink: 0; }
|
||||
|
||||
/* Trust */
|
||||
.trust { padding: 60px 0 40px; }
|
||||
.trust-grid { display: flex; gap: 40px; justify-content: center; flex-wrap: wrap; }
|
||||
.trust-item { text-align: center; flex: 1; min-width: 160px; max-width: 220px; }
|
||||
.trust-num { font-size: 2rem; font-weight: 800; color: var(--accent); letter-spacing: -1px; }
|
||||
.trust-label { font-size: 0.85rem; color: var(--muted); margin-top: 4px; }
|
||||
|
||||
/* EU Hosting */
|
||||
.eu-hosting { padding: 40px 0 80px; }
|
||||
.eu-badge { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 32px; max-width: 600px; margin: 0 auto; display: flex; align-items: center; gap: 20px; transition: border-color 0.2s, transform 0.2s; }
|
||||
.eu-badge:hover { border-color: rgba(52,211,153,0.3); transform: translateY(-2px); }
|
||||
.eu-icon { font-size: 3rem; flex-shrink: 0; }
|
||||
.eu-content h3 { font-size: 1.4rem; font-weight: 700; margin-bottom: 8px; color: var(--fg); }
|
||||
.eu-content p { color: var(--muted); font-size: 0.95rem; line-height: 1.6; margin: 0; }
|
||||
@media (max-width: 640px) {
|
||||
.eu-badge { flex-direction: column; text-align: center; gap: 16px; padding: 24px; }
|
||||
.eu-icon { font-size: 2.5rem; }
|
||||
}
|
||||
|
||||
/* Footer */
|
||||
footer { padding: 40px 0; border-top: 1px solid var(--border); }
|
||||
footer .container { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 16px; }
|
||||
.footer-left { color: var(--muted); font-size: 0.85rem; }
|
||||
.footer-links { display: flex; gap: 24px; flex-wrap: wrap; }
|
||||
.footer-links a { color: var(--muted); font-size: 0.85rem; }
|
||||
.footer-links a:hover { color: var(--fg); }
|
||||
|
||||
/* Modal */
|
||||
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.75); backdrop-filter: blur(4px); z-index: 100; align-items: center; justify-content: center; }
|
||||
.modal-overlay.active { display: flex; }
|
||||
.modal { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 40px; max-width: 460px; width: 90%; position: relative; }
|
||||
.modal h2 { margin-bottom: 8px; font-size: 1.4rem; font-weight: 700; }
|
||||
.modal p { color: var(--muted); margin-bottom: 24px; font-size: 0.95rem; }
|
||||
.modal .close { position: absolute; top: 16px; right: 20px; color: var(--muted); font-size: 1.4rem; cursor: pointer; background: none; border: none; transition: color 0.2s; }
|
||||
.modal .close:hover { color: var(--fg); }
|
||||
|
||||
/* Signup states */
|
||||
#signupInitial, #signupLoading, #signupVerify, #signupResult { display: none; }
|
||||
#signupInitial.active { display: block; }
|
||||
#signupLoading.active { display: flex; flex-direction: column; align-items: center; padding: 40px 0; text-align: center; }
|
||||
#signupResult.active { display: block; }
|
||||
#signupVerify.active { display: block; }
|
||||
.spinner { width: 36px; height: 36px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.7s linear infinite; margin-bottom: 16px; }
|
||||
@keyframes spin { to { transform: rotate(360deg); } }
|
||||
|
||||
.key-box { background: var(--bg); border: 1px solid var(--accent); border-radius: 8px; padding: 16px; font-family: monospace; font-size: 0.82rem; word-break: break-all; margin: 16px 0 12px; position: relative; cursor: pointer; transition: background 0.2s; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
|
||||
.key-box:hover { background: #151922; }
|
||||
.key-text { flex: 1; }
|
||||
.copy-btn { background: rgba(52,211,153,0.1); border: 1px solid rgba(52,211,153,0.2); color: var(--accent); border-radius: 6px; padding: 6px 14px; font-size: 0.8rem; font-weight: 600; cursor: pointer; white-space: nowrap; transition: all 0.2s; }
|
||||
.copy-btn:hover { background: rgba(52,211,153,0.2); }
|
||||
.warning-box { background: rgba(251,191,36,0.06); border: 1px solid rgba(251,191,36,0.15); border-radius: 8px; padding: 12px 16px; font-size: 0.85rem; color: #fbbf24; display: flex; align-items: flex-start; gap: 10px; margin-bottom: 16px; }
|
||||
.warning-box .icon { font-size: 1.1rem; flex-shrink: 0; }
|
||||
.signup-error { color: #f87171; font-size: 0.85rem; margin-bottom: 16px; display: none; padding: 10px 14px; background: rgba(248,113,113,0.06); border: 1px solid rgba(248,113,113,0.15); border-radius: 8px; }
|
||||
|
||||
/* Responsive */
|
||||
@media (max-width: 640px) {
|
||||
.hero { padding: 72px 0 56px; }
|
||||
.nav-links { gap: 16px; }
|
||||
.code-block {
|
||||
font-size: 0.75rem;
|
||||
padding: 18px 16px;
|
||||
overflow-x: hidden;
|
||||
word-wrap: break-word;
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
.trust-grid { gap: 24px; }
|
||||
.footer-links { gap: 16px; }
|
||||
footer .container { flex-direction: column; text-align: center; }
|
||||
}
|
||||
|
||||
/* Fix mobile terminal gaps at 375px and smaller */
|
||||
@media (max-width: 375px) {
|
||||
.container {
|
||||
padding: 0 12px !important;
|
||||
}
|
||||
.code-section {
|
||||
margin: 32px auto 0;
|
||||
max-width: calc(100vw - 24px) !important;
|
||||
}
|
||||
.code-header {
|
||||
padding: 8px 12px;
|
||||
}
|
||||
.code-block {
|
||||
padding: 12px !important;
|
||||
font-size: 0.7rem;
|
||||
}
|
||||
.hero {
|
||||
padding: 56px 0 40px;
|
||||
}
|
||||
}
|
||||
|
||||
/* Additional mobile overflow fixes */
|
||||
html, body {
|
||||
overflow-x: hidden !important;
|
||||
max-width: 100vw !important;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
* {
|
||||
max-width: 100% !important;
|
||||
}
|
||||
body {
|
||||
overflow-x: hidden !important;
|
||||
}
|
||||
.container {
|
||||
overflow-x: hidden !important;
|
||||
max-width: 100vw !important;
|
||||
padding: 0 16px !important;
|
||||
}
|
||||
.code-section {
|
||||
max-width: calc(100vw - 32px) !important;
|
||||
overflow: hidden !important;
|
||||
display: flex !important;
|
||||
flex-direction: column !important;
|
||||
white-space: normal !important;
|
||||
}
|
||||
.code-block {
|
||||
overflow-x: hidden !important;
|
||||
white-space: pre-wrap !important;
|
||||
word-break: break-all !important;
|
||||
max-width: 100% !important;
|
||||
box-sizing: border-box !important;
|
||||
}
|
||||
.trust-grid {
|
||||
justify-content: center !important;
|
||||
overflow-x: hidden !important;
|
||||
max-width: 100% !important;
|
||||
}
|
||||
|
||||
/* Force any wide elements to fit */
|
||||
pre, code, .code-block {
|
||||
max-width: calc(100vw - 32px) !important;
|
||||
overflow-wrap: break-word !important;
|
||||
word-break: break-all !important;
|
||||
white-space: pre-wrap !important;
|
||||
overflow-x: hidden !important;
|
||||
}
|
||||
.code-section {
|
||||
max-width: calc(100vw - 32px) !important;
|
||||
overflow-x: hidden !important;
|
||||
white-space: normal !important;
|
||||
}
|
||||
}
|
||||
|
||||
/* Recovery modal states */
|
||||
#recoverInitial, #recoverLoading, #recoverVerify, #recoverResult { display: none; }
|
||||
#recoverInitial.active { display: block; }
|
||||
#recoverLoading.active { display: flex; flex-direction: column; align-items: center; padding: 40px 0; text-align: center; }
|
||||
#recoverResult.active { display: block; }
|
||||
#recoverVerify.active { display: block; }
|
||||
|
||||
/* Email change modal states */
|
||||
#emailChangeInitial, #emailChangeLoading, #emailChangeVerify, #emailChangeResult { display: none; }
|
||||
#emailChangeInitial.active { display: block; }
|
||||
#emailChangeLoading.active { display: flex; flex-direction: column; align-items: center; padding: 40px 0; text-align: center; }
|
||||
#emailChangeResult.active { display: block; }
|
||||
#emailChangeVerify.active { display: block; }
|
||||
|
||||
/* Focus-visible for accessibility */
|
||||
.btn:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
|
||||
</style>
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap" rel="stylesheet">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<nav aria-label="Main navigation">
|
||||
<div class="container">
|
||||
<a href="/" class="logo">⚡ Doc<span>Fast</span></a>
|
||||
<div class="nav-links">
|
||||
<a href="#features">Features</a>
|
||||
<a href="#pricing">Pricing</a>
|
||||
<a href="/docs">Docs</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<main class="hero" role="main">
|
||||
<div class="container">
|
||||
<div class="badge">🚀 Simple PDF API for Developers</div>
|
||||
<h1>HTML to <span class="gradient">PDF</span><br>in one API call</h1>
|
||||
<p>Convert HTML, Markdown, or URLs to pixel-perfect PDFs. Built-in templates for invoices & receipts. No headless browser headaches.</p>
|
||||
<div class="hero-actions">
|
||||
<button class="btn btn-primary" id="btn-signup">Get Free API Key →</button>
|
||||
<a href="/docs" class="btn btn-secondary">Read the Docs</a>
|
||||
</div>
|
||||
<p style="margin-top:16px;color:var(--muted);font-size:0.9rem;">Already have an account? <a href="#" class="open-recover" style="color:var(--accent);">Lost your API key? Recover it →</a></p>
|
||||
|
||||
<div class="code-section">
|
||||
<div class="code-header">
|
||||
<div class="code-dots" aria-hidden="true"><span></span><span></span><span></span></div>
|
||||
<span class="code-label">terminal</span>
|
||||
</div>
|
||||
<div class="code-block">
|
||||
<span class="c"># Convert HTML to PDF — it's that simple</span>
|
||||
<span class="k">curl</span> <span class="f">-X POST</span> https://docfast.dev/v1/convert/html \
|
||||
-H <span class="s">"Authorization: Bearer YOUR_KEY"</span> \
|
||||
-H <span class="s">"Content-Type: application/json"</span> \
|
||||
-d <span class="s">'{"html": "<h1>Hello World</h1><p>Your first PDF</p>"}'</span> \
|
||||
-o <span class="f">output.pdf</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<section class="trust">
|
||||
<div class="container">
|
||||
<div class="trust-grid">
|
||||
<div class="trust-item">
|
||||
<div class="trust-num"><1s</div>
|
||||
<div class="trust-label">Avg. generation time</div>
|
||||
</div>
|
||||
<div class="trust-item">
|
||||
<div class="trust-num">99.5%</div>
|
||||
<div class="trust-label">Uptime SLA</div>
|
||||
</div>
|
||||
<div class="trust-item">
|
||||
<div class="trust-num">HTTPS</div>
|
||||
<div class="trust-label">Encrypted & secure</div>
|
||||
</div>
|
||||
<div class="trust-item">
|
||||
<div class="trust-num">0 bytes</div>
|
||||
<div class="trust-label">Data stored on disk</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="eu-hosting">
|
||||
<div class="container">
|
||||
<div class="eu-badge">
|
||||
<div class="eu-icon">🇪🇺</div>
|
||||
<div class="eu-content">
|
||||
<h3>Hosted in the EU</h3>
|
||||
<p>Your data never leaves the EU • GDPR Compliant • Hetzner Germany (Nuremberg)</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="features" id="features">
|
||||
<div class="container">
|
||||
<h2 class="section-title">Everything you need</h2>
|
||||
<p class="section-sub">A complete PDF generation API. No SDKs, no dependencies, no setup.</p>
|
||||
<div class="features-grid">
|
||||
<div class="feature-card">
|
||||
<div class="feature-icon" aria-hidden="true">⚡</div>
|
||||
<h3>Sub-second Speed</h3>
|
||||
<p>Persistent browser pool — no cold starts. Your PDFs are ready before your spinner shows.</p>
|
||||
</div>
|
||||
<div class="feature-card">
|
||||
<div class="feature-icon" aria-hidden="true">🎨</div>
|
||||
<h3>Pixel-perfect Output</h3>
|
||||
<p>Full CSS support including flexbox, grid, and custom fonts. Your brand, your PDFs.</p>
|
||||
</div>
|
||||
<div class="feature-card">
|
||||
<div class="feature-icon" aria-hidden="true">📄</div>
|
||||
<h3>Built-in Templates</h3>
|
||||
<p>Invoice and receipt templates out of the box. Pass JSON data, get beautiful PDFs.</p>
|
||||
</div>
|
||||
<div class="feature-card">
|
||||
<div class="feature-icon" aria-hidden="true">🔧</div>
|
||||
<h3>Dead-simple API</h3>
|
||||
<p>REST API. JSON in, PDF out. Works with curl, Python, Node, Go — anything with HTTP.</p>
|
||||
</div>
|
||||
<div class="feature-card">
|
||||
<div class="feature-icon" aria-hidden="true">📐</div>
|
||||
<h3>Fully Configurable</h3>
|
||||
<p>A4, Letter, custom sizes. Portrait or landscape. Headers, footers, and margins.</p>
|
||||
</div>
|
||||
<div class="feature-card">
|
||||
<div class="feature-icon" aria-hidden="true">🔒</div>
|
||||
<h3>Secure by Default</h3>
|
||||
<p>HTTPS only. Rate limiting. No data stored. PDFs stream directly — nothing touches disk.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="pricing" id="pricing">
|
||||
<div class="container">
|
||||
<h2 class="section-title">Simple, transparent pricing</h2>
|
||||
<p class="section-sub">Start free. Upgrade when you're ready. No surprise charges.</p>
|
||||
<div class="pricing-grid">
|
||||
<div class="price-card">
|
||||
<div class="price-name">Free</div>
|
||||
<div class="price-amount">€0<span> /mo</span></div>
|
||||
<div class="price-desc">Perfect for side projects and testing</div>
|
||||
<ul class="price-features">
|
||||
<li>100 PDFs per month</li>
|
||||
<li>All conversion endpoints</li>
|
||||
<li>All templates included</li>
|
||||
<li>Rate limiting: 10 req/min</li>
|
||||
</ul>
|
||||
<button class="btn btn-secondary" style="width:100%" id="btn-signup-2">Get Free API Key</button>
|
||||
</div>
|
||||
<div class="price-card featured">
|
||||
<div class="price-name">Pro</div>
|
||||
<div class="price-amount">€9<span> /mo</span></div>
|
||||
<div class="price-desc">For production apps and businesses</div>
|
||||
<ul class="price-features">
|
||||
<li>5,000 PDFs per month</li>
|
||||
<li>All conversion endpoints</li>
|
||||
<li>All templates included</li>
|
||||
<li>Priority support</li>
|
||||
</ul>
|
||||
<button class="btn btn-primary" style="width:100%" id="btn-checkout">Get Started →</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<footer aria-label="Footer">
|
||||
<div class="container">
|
||||
<div class="footer-left">© 2026 DocFast. Fast PDF generation for developers.</div>
|
||||
<div class="footer-links">
|
||||
<a href="/">Home</a>
|
||||
<a href="/docs">Docs</a>
|
||||
<a href="/health">API Status</a>
|
||||
<a href="/#change-email" class="open-email-change">Change Email</a>
|
||||
<a href="/impressum">Impressum</a>
|
||||
<a href="/privacy">Privacy Policy</a>
|
||||
<a href="/terms">Terms of Service</a>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
<!-- Signup Modal -->
|
||||
<div class="modal-overlay" id="signupModal" role="dialog" aria-label="Sign up for API key">
|
||||
<div class="modal">
|
||||
<button class="close" id="btn-close-signup">×</button>
|
||||
|
||||
<div id="signupInitial" class="active">
|
||||
<h2>Get your free API key</h2>
|
||||
<p>Enter your email to get started. No credit card required.</p>
|
||||
<div class="signup-error" id="signupError"></div>
|
||||
<input type="email" id="signupEmail" placeholder="your.email@example.com" style="width:100%;padding:12px;border:1px solid var(--border);background:var(--bg);color:var(--fg);border-radius:8px;font-size:0.9rem;margin-bottom:16px;" required>
|
||||
<button class="btn btn-primary" style="width:100%" id="signupBtn">Generate API Key →</button>
|
||||
<p style="margin-top:16px;color:var(--muted);font-size:0.8rem;text-align:center;">100 free PDFs/month • All endpoints included<br><a href="#" class="open-recover" style="color:var(--muted)">Lost your API key? Recover it →</a></p>
|
||||
</div>
|
||||
|
||||
<div id="signupLoading">
|
||||
<div class="spinner"></div>
|
||||
<p style="color:var(--muted);margin:0">Generating your API key…</p>
|
||||
</div>
|
||||
|
||||
<div id="signupVerify">
|
||||
<h2>Enter verification code</h2>
|
||||
<p>We sent a 6-digit code to <strong id="verifyEmailDisplay"></strong></p>
|
||||
<div class="signup-error" id="verifyError"></div>
|
||||
<input type="text" id="verifyCode" placeholder="123456" maxlength="6" pattern="[0-9]{6}" inputmode="numeric" style="width:100%;padding:14px;border:1px solid var(--border);background:var(--bg);color:var(--fg);border-radius:8px;font-size:1.4rem;letter-spacing:0.3em;text-align:center;margin-bottom:16px;font-family:monospace;" required>
|
||||
<button class="btn btn-primary" style="width:100%" id="verifyBtn">Verify →</button>
|
||||
<p style="margin-top:16px;color:var(--muted);font-size:0.8rem;text-align:center;">Code expires in 15 minutes</p>
|
||||
</div>
|
||||
|
||||
<div id="signupResult" aria-live="polite">
|
||||
<h2>🚀 Your API key is ready!</h2>
|
||||
<div class="warning-box">
|
||||
<span class="icon">⚠️</span>
|
||||
<span>Save your API key securely. Lost it? <a href="#" class="open-recover" style="color:#fbbf24">Recover via email</a></span>
|
||||
</div>
|
||||
<div style="background:var(--bg);border:1px solid var(--accent);border-radius:8px;padding:14px;font-family:monospace;font-size:0.82rem;word-break:break-all;margin:16px 0;position:relative;">
|
||||
<span id="apiKeyText"></span>
|
||||
<button onclick="copyKey()" id="copyBtn" style="position:absolute;top:8px;right:8px;background:var(--accent);color:var(--bg);border:none;border-radius:4px;padding:4px 12px;cursor:pointer;font-size:0.8rem;">Copy</button>
|
||||
</div>
|
||||
<p style="margin-top:20px;color:var(--muted);font-size:0.9rem;">100 free PDFs/month • <a href="/docs">Read the docs →</a></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- Recovery Modal -->
|
||||
<div class="modal-overlay" id="recoverModal" role="dialog" aria-label="Recover API key">
|
||||
<div class="modal">
|
||||
<button class="close" id="btn-close-recover">×</button>
|
||||
|
||||
<div id="recoverInitial" class="active">
|
||||
<h2>Recover your API key</h2>
|
||||
<p>Enter the email you signed up with. We'll send a verification code.</p>
|
||||
<div class="signup-error" id="recoverError"></div>
|
||||
<input type="email" id="recoverEmailInput" placeholder="your.email@example.com" style="width:100%;padding:12px;border:1px solid var(--border);background:var(--bg);color:var(--fg);border-radius:8px;font-size:0.9rem;margin-bottom:16px;" required>
|
||||
<button class="btn btn-primary" style="width:100%" id="recoverBtn">Send Verification Code →</button>
|
||||
<p style="margin-top:16px;color:var(--muted);font-size:0.8rem;text-align:center;">Your key will be shown here after verification — never sent via email</p>
|
||||
</div>
|
||||
|
||||
<div id="recoverLoading">
|
||||
<div class="spinner"></div>
|
||||
<p style="color:var(--muted);margin:0">Sending verification code…</p>
|
||||
</div>
|
||||
|
||||
<div id="recoverVerify">
|
||||
<h2>Enter verification code</h2>
|
||||
<p>We sent a 6-digit code to <strong id="recoverEmailDisplay"></strong></p>
|
||||
<div class="signup-error" id="recoverVerifyError"></div>
|
||||
<input type="text" id="recoverCode" placeholder="123456" maxlength="6" pattern="[0-9]{6}" inputmode="numeric" style="width:100%;padding:14px;border:1px solid var(--border);background:var(--bg);color:var(--fg);border-radius:8px;font-size:1.4rem;letter-spacing:0.3em;text-align:center;margin-bottom:16px;font-family:monospace;" required>
|
||||
<button class="btn btn-primary" style="width:100%" id="recoverVerifyBtn">Verify →</button>
|
||||
<p style="margin-top:16px;color:var(--muted);font-size:0.8rem;text-align:center;">Code expires in 15 minutes</p>
|
||||
</div>
|
||||
|
||||
<div id="recoverResult" aria-live="polite">
|
||||
<h2>🔑 Your API key</h2>
|
||||
<div class="warning-box">
|
||||
<span class="icon">⚠️</span>
|
||||
<span>Save your API key securely. This is the only time it will be shown.</span>
|
||||
</div>
|
||||
<div style="background:var(--bg);border:1px solid var(--accent);border-radius:8px;padding:14px;font-family:monospace;font-size:0.82rem;word-break:break-all;margin:16px 0;position:relative;">
|
||||
<span id="recoveredKeyText"></span>
|
||||
<button onclick="copyRecoveredKey()" id="copyRecoveredBtn" style="position:absolute;top:8px;right:8px;background:var(--accent);color:var(--bg);border:none;border-radius:4px;padding:4px 12px;cursor:pointer;font-size:0.8rem;">Copy</button>
|
||||
</div>
|
||||
<p style="margin-top:20px;color:var(--muted);font-size:0.9rem;"><a href="/docs">Read the docs →</a></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- Email Change Modal -->
|
||||
<div class="modal-overlay" id="emailChangeModal" role="dialog" aria-label="Change email">
|
||||
<div class="modal">
|
||||
<button class="close" id="btn-close-email-change">×</button>
|
||||
|
||||
<div id="emailChangeInitial" class="active">
|
||||
<h2>Change your email</h2>
|
||||
<p>Enter your API key and new email address.</p>
|
||||
<div class="signup-error" id="emailChangeError"></div>
|
||||
<input type="text" id="emailChangeApiKey" placeholder="Your API key (df_free_... or df_pro_...)" style="width:100%;padding:12px;border:1px solid var(--border);background:var(--bg);color:var(--fg);border-radius:8px;font-size:0.9rem;margin-bottom:12px;font-family:monospace;" required>
|
||||
<input type="email" id="emailChangeNewEmail" placeholder="new.email@example.com" style="width:100%;padding:12px;border:1px solid var(--border);background:var(--bg);color:var(--fg);border-radius:8px;font-size:0.9rem;margin-bottom:16px;" required>
|
||||
<button class="btn btn-primary" style="width:100%" id="emailChangeBtn">Send Verification Code →</button>
|
||||
<p style="margin-top:16px;color:var(--muted);font-size:0.8rem;text-align:center;">A verification code will be sent to your new email</p>
|
||||
</div>
|
||||
|
||||
<div id="emailChangeLoading">
|
||||
<div class="spinner"></div>
|
||||
<p style="color:var(--muted);margin:0">Sending verification code…</p>
|
||||
</div>
|
||||
|
||||
<div id="emailChangeVerify">
|
||||
<h2>Enter verification code</h2>
|
||||
<p>We sent a 6-digit code to <strong id="emailChangeEmailDisplay"></strong></p>
|
||||
<div class="signup-error" id="emailChangeVerifyError"></div>
|
||||
<input type="text" id="emailChangeCode" placeholder="123456" maxlength="6" pattern="[0-9]{6}" inputmode="numeric" style="width:100%;padding:14px;border:1px solid var(--border);background:var(--bg);color:var(--fg);border-radius:8px;font-size:1.4rem;letter-spacing:0.3em;text-align:center;margin-bottom:16px;font-family:monospace;" required>
|
||||
<button class="btn btn-primary" style="width:100%" id="emailChangeVerifyBtn">Verify →</button>
|
||||
<p style="margin-top:16px;color:var(--muted);font-size:0.8rem;text-align:center;">Code expires in 15 minutes</p>
|
||||
</div>
|
||||
|
||||
<div id="emailChangeResult">
|
||||
<h2>✅ Email updated!</h2>
|
||||
<p>Your account email has been changed to <strong id="emailChangeNewDisplay"></strong></p>
|
||||
<p style="margin-top:20px;color:var(--muted);font-size:0.9rem;"><a href="/docs">Read the docs →</a></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="/app.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
BIN
projects/business/src/pdf-api/public/og-image.png
Normal file
BIN
projects/business/src/pdf-api/public/og-image.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 39 KiB |
13
projects/business/src/pdf-api/public/og-image.svg
Normal file
13
projects/business/src/pdf-api/public/og-image.svg
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="1200" height="630" viewBox="0 0 1200 630">
|
||||
<rect width="1200" height="630" fill="#0b0d11"/>
|
||||
<rect x="0" y="0" width="1200" height="630" fill="url(#glow)" opacity="0.3"/>
|
||||
<defs>
|
||||
<radialGradient id="glow" cx="50%" cy="50%" r="50%">
|
||||
<stop offset="0%" stop-color="#34d399" stop-opacity="0.2"/>
|
||||
<stop offset="100%" stop-color="#0b0d11" stop-opacity="0"/>
|
||||
</radialGradient>
|
||||
</defs>
|
||||
<text x="600" y="270" text-anchor="middle" font-family="Inter, -apple-system, sans-serif" font-size="80" font-weight="800" fill="#e4e7ed">⚡ Doc<tspan fill="#34d399">Fast</tspan></text>
|
||||
<text x="600" y="370" text-anchor="middle" font-family="Inter, -apple-system, sans-serif" font-size="36" font-weight="400" fill="#7a8194">HTML & Markdown to PDF API</text>
|
||||
<rect x="400" y="420" width="400" height="4" rx="2" fill="#34d399" opacity="0.5"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 910 B |
422
projects/business/src/pdf-api/public/openapi.json
Normal file
422
projects/business/src/pdf-api/public/openapi.json
Normal file
|
|
@ -0,0 +1,422 @@
|
|||
{
|
||||
"openapi": "3.0.3",
|
||||
"info": {
|
||||
"title": "DocFast API",
|
||||
"version": "1.0.0",
|
||||
"description": "Convert HTML, Markdown, and URLs to pixel-perfect PDFs. Built-in invoice & receipt templates.\n\n## Authentication\nAll conversion and template endpoints require an API key via `Authorization: Bearer <key>` or `X-API-Key: <key>` header.\n\n## Rate Limits\n- Free tier: 100 PDFs/month, 10 req/min\n- Pro tier: 10,000 PDFs/month, 30 req/min\n\n## Getting Started\n1. Sign up at [docfast.dev](https://docfast.dev) or via `POST /v1/signup/free`\n2. Verify your email with the 6-digit code\n3. Use your API key to convert documents",
|
||||
"contact": { "name": "DocFast", "url": "https://docfast.dev" }
|
||||
},
|
||||
"servers": [{ "url": "https://docfast.dev", "description": "Production" }],
|
||||
"tags": [
|
||||
{ "name": "Conversion", "description": "Convert HTML, Markdown, or URLs to PDF" },
|
||||
{ "name": "Templates", "description": "Built-in document templates" },
|
||||
{ "name": "Account", "description": "Signup, key recovery, and email management" },
|
||||
{ "name": "Billing", "description": "Stripe-powered subscription management" },
|
||||
{ "name": "System", "description": "Health checks and usage stats" }
|
||||
],
|
||||
"components": {
|
||||
"securitySchemes": {
|
||||
"BearerAuth": { "type": "http", "scheme": "bearer", "description": "API key as Bearer token" },
|
||||
"ApiKeyHeader": { "type": "apiKey", "in": "header", "name": "X-API-Key", "description": "API key via X-API-Key header" }
|
||||
},
|
||||
"schemas": {
|
||||
"PdfOptions": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"format": { "type": "string", "enum": ["A4", "Letter", "Legal", "A3", "A5", "Tabloid"], "default": "A4", "description": "Page size" },
|
||||
"landscape": { "type": "boolean", "default": false, "description": "Landscape orientation" },
|
||||
"margin": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"top": { "type": "string", "example": "20mm" },
|
||||
"bottom": { "type": "string", "example": "20mm" },
|
||||
"left": { "type": "string", "example": "15mm" },
|
||||
"right": { "type": "string", "example": "15mm" }
|
||||
}
|
||||
},
|
||||
"printBackground": { "type": "boolean", "default": true, "description": "Print background graphics" },
|
||||
"filename": { "type": "string", "default": "document.pdf", "description": "Suggested filename for the PDF" }
|
||||
}
|
||||
},
|
||||
"Error": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"error": { "type": "string", "description": "Error message" }
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"paths": {
|
||||
"/v1/convert/html": {
|
||||
"post": {
|
||||
"tags": ["Conversion"],
|
||||
"summary": "Convert HTML to PDF",
|
||||
"description": "Renders HTML content as a PDF. Supports full CSS including flexbox, grid, and custom fonts. Bare HTML fragments are auto-wrapped.",
|
||||
"security": [{ "BearerAuth": [] }, { "ApiKeyHeader": [] }],
|
||||
"requestBody": {
|
||||
"required": true,
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"allOf": [
|
||||
{
|
||||
"type": "object",
|
||||
"required": ["html"],
|
||||
"properties": {
|
||||
"html": { "type": "string", "description": "HTML content to convert", "example": "<h1>Hello World</h1><p>Your first PDF</p>" },
|
||||
"css": { "type": "string", "description": "Optional CSS to inject (for HTML fragments)" }
|
||||
}
|
||||
},
|
||||
{ "$ref": "#/components/schemas/PdfOptions" }
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"responses": {
|
||||
"200": { "description": "PDF file", "content": { "application/pdf": { "schema": { "type": "string", "format": "binary" } } } },
|
||||
"400": { "description": "Invalid request", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
|
||||
"401": { "description": "Missing or invalid API key" },
|
||||
"415": { "description": "Unsupported Content-Type" },
|
||||
"429": { "description": "Rate limit exceeded or server busy" }
|
||||
}
|
||||
}
|
||||
},
|
||||
"/v1/convert/markdown": {
|
||||
"post": {
|
||||
"tags": ["Conversion"],
|
||||
"summary": "Convert Markdown to PDF",
|
||||
"description": "Converts Markdown content to a beautifully styled PDF with syntax highlighting.",
|
||||
"security": [{ "BearerAuth": [] }, { "ApiKeyHeader": [] }],
|
||||
"requestBody": {
|
||||
"required": true,
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"allOf": [
|
||||
{
|
||||
"type": "object",
|
||||
"required": ["markdown"],
|
||||
"properties": {
|
||||
"markdown": { "type": "string", "description": "Markdown content to convert", "example": "# Hello World\n\nThis is **bold** and this is *italic*.\n\n- Item 1\n- Item 2" },
|
||||
"css": { "type": "string", "description": "Optional custom CSS" }
|
||||
}
|
||||
},
|
||||
{ "$ref": "#/components/schemas/PdfOptions" }
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"responses": {
|
||||
"200": { "description": "PDF file", "content": { "application/pdf": { "schema": { "type": "string", "format": "binary" } } } },
|
||||
"400": { "description": "Invalid request" },
|
||||
"401": { "description": "Missing or invalid API key" },
|
||||
"429": { "description": "Rate limit exceeded" }
|
||||
}
|
||||
}
|
||||
},
|
||||
"/v1/convert/url": {
|
||||
"post": {
|
||||
"tags": ["Conversion"],
|
||||
"summary": "Convert URL to PDF",
|
||||
"description": "Fetches a URL and converts the rendered page to PDF. Only http/https URLs are supported. Private/reserved IPs are blocked (SSRF protection).",
|
||||
"security": [{ "BearerAuth": [] }, { "ApiKeyHeader": [] }],
|
||||
"requestBody": {
|
||||
"required": true,
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"allOf": [
|
||||
{
|
||||
"type": "object",
|
||||
"required": ["url"],
|
||||
"properties": {
|
||||
"url": { "type": "string", "format": "uri", "description": "URL to convert", "example": "https://example.com" },
|
||||
"waitUntil": { "type": "string", "enum": ["load", "domcontentloaded", "networkidle0", "networkidle2"], "default": "networkidle0", "description": "When to consider navigation complete" }
|
||||
}
|
||||
},
|
||||
{ "$ref": "#/components/schemas/PdfOptions" }
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"responses": {
|
||||
"200": { "description": "PDF file", "content": { "application/pdf": { "schema": { "type": "string", "format": "binary" } } } },
|
||||
"400": { "description": "Invalid URL or DNS failure" },
|
||||
"401": { "description": "Missing or invalid API key" },
|
||||
"429": { "description": "Rate limit exceeded" }
|
||||
}
|
||||
}
|
||||
},
|
||||
"/v1/templates": {
|
||||
"get": {
|
||||
"tags": ["Templates"],
|
||||
"summary": "List available templates",
|
||||
"description": "Returns all available document templates with their field definitions.",
|
||||
"security": [{ "BearerAuth": [] }, { "ApiKeyHeader": [] }],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Template list",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"templates": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": { "type": "string", "example": "invoice" },
|
||||
"name": { "type": "string", "example": "Invoice" },
|
||||
"description": { "type": "string" },
|
||||
"fields": { "type": "array", "items": { "type": "string" } }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/v1/templates/{id}/render": {
|
||||
"post": {
|
||||
"tags": ["Templates"],
|
||||
"summary": "Render a template to PDF",
|
||||
"description": "Renders a template with the provided data and returns a PDF.",
|
||||
"security": [{ "BearerAuth": [] }, { "ApiKeyHeader": [] }],
|
||||
"parameters": [
|
||||
{ "name": "id", "in": "path", "required": true, "schema": { "type": "string" }, "description": "Template ID (e.g., 'invoice', 'receipt')" }
|
||||
],
|
||||
"requestBody": {
|
||||
"required": true,
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"data": { "type": "object", "description": "Template data fields", "example": { "company": "Acme Corp", "items": [{ "description": "Widget", "quantity": 5, "price": 9.99 }] } }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"responses": {
|
||||
"200": { "description": "PDF file", "content": { "application/pdf": { "schema": { "type": "string", "format": "binary" } } } },
|
||||
"404": { "description": "Template not found" }
|
||||
}
|
||||
}
|
||||
},
|
||||
"/v1/signup/free": {
|
||||
"post": {
|
||||
"tags": ["Account"],
|
||||
"summary": "Request a free API key",
|
||||
"description": "Sends a 6-digit verification code to your email. Use `/v1/signup/verify` to complete signup.",
|
||||
"requestBody": {
|
||||
"required": true,
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"required": ["email"],
|
||||
"properties": {
|
||||
"email": { "type": "string", "format": "email", "example": "you@example.com" }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Verification code sent",
|
||||
"content": { "application/json": { "schema": { "type": "object", "properties": { "status": { "type": "string", "example": "verification_required" }, "message": { "type": "string" } } } } }
|
||||
},
|
||||
"409": { "description": "Email already registered" },
|
||||
"429": { "description": "Too many signup attempts" }
|
||||
}
|
||||
}
|
||||
},
|
||||
"/v1/signup/verify": {
|
||||
"post": {
|
||||
"tags": ["Account"],
|
||||
"summary": "Verify email and get API key",
|
||||
"description": "Verify your email with the 6-digit code to receive your API key.",
|
||||
"requestBody": {
|
||||
"required": true,
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"required": ["email", "code"],
|
||||
"properties": {
|
||||
"email": { "type": "string", "format": "email" },
|
||||
"code": { "type": "string", "example": "123456", "description": "6-digit verification code" }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "API key issued",
|
||||
"content": { "application/json": { "schema": { "type": "object", "properties": { "status": { "type": "string", "example": "verified" }, "apiKey": { "type": "string", "example": "df_free_abc123..." }, "tier": { "type": "string", "example": "free" } } } } }
|
||||
},
|
||||
"400": { "description": "Invalid code" },
|
||||
"410": { "description": "Code expired" },
|
||||
"429": { "description": "Too many attempts" }
|
||||
}
|
||||
}
|
||||
},
|
||||
"/v1/recover": {
|
||||
"post": {
|
||||
"tags": ["Account"],
|
||||
"summary": "Request API key recovery",
|
||||
"description": "Sends a verification code to your registered email. Returns the same response whether or not the email exists (prevents enumeration).",
|
||||
"requestBody": {
|
||||
"required": true,
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"required": ["email"],
|
||||
"properties": {
|
||||
"email": { "type": "string", "format": "email" }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"responses": {
|
||||
"200": { "description": "Recovery code sent (if account exists)" },
|
||||
"429": { "description": "Too many recovery attempts" }
|
||||
}
|
||||
}
|
||||
},
|
||||
"/v1/recover/verify": {
|
||||
"post": {
|
||||
"tags": ["Account"],
|
||||
"summary": "Verify recovery code and get API key",
|
||||
"description": "Verify the recovery code to retrieve your API key. The key is shown only in the response — never sent via email.",
|
||||
"requestBody": {
|
||||
"required": true,
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"required": ["email", "code"],
|
||||
"properties": {
|
||||
"email": { "type": "string", "format": "email" },
|
||||
"code": { "type": "string", "example": "123456" }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "API key recovered",
|
||||
"content": { "application/json": { "schema": { "type": "object", "properties": { "status": { "type": "string", "example": "recovered" }, "apiKey": { "type": "string" }, "tier": { "type": "string" } } } } }
|
||||
},
|
||||
"400": { "description": "Invalid code" },
|
||||
"410": { "description": "Code expired" },
|
||||
"429": { "description": "Too many attempts" }
|
||||
}
|
||||
}
|
||||
},
|
||||
"/v1/email-change": {
|
||||
"post": {
|
||||
"tags": ["Account"],
|
||||
"summary": "Request email change",
|
||||
"description": "Change the email associated with your API key. Sends a verification code to the new email address.",
|
||||
"requestBody": {
|
||||
"required": true,
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"required": ["apiKey", "newEmail"],
|
||||
"properties": {
|
||||
"apiKey": { "type": "string", "description": "Your current API key" },
|
||||
"newEmail": { "type": "string", "format": "email", "description": "New email address" }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"responses": {
|
||||
"200": { "description": "Verification code sent to new email" },
|
||||
"400": { "description": "Invalid input" },
|
||||
"401": { "description": "Invalid API key" },
|
||||
"409": { "description": "Email already in use" },
|
||||
"429": { "description": "Too many attempts" }
|
||||
}
|
||||
}
|
||||
},
|
||||
"/v1/email-change/verify": {
|
||||
"post": {
|
||||
"tags": ["Account"],
|
||||
"summary": "Verify email change",
|
||||
"description": "Verify the code sent to your new email to complete the change.",
|
||||
"requestBody": {
|
||||
"required": true,
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"required": ["apiKey", "newEmail", "code"],
|
||||
"properties": {
|
||||
"apiKey": { "type": "string" },
|
||||
"newEmail": { "type": "string", "format": "email" },
|
||||
"code": { "type": "string", "example": "123456" }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"responses": {
|
||||
"200": { "description": "Email updated", "content": { "application/json": { "schema": { "type": "object", "properties": { "status": { "type": "string", "example": "updated" }, "newEmail": { "type": "string" } } } } } },
|
||||
"400": { "description": "Invalid code" },
|
||||
"401": { "description": "Invalid API key" },
|
||||
"410": { "description": "Code expired" }
|
||||
}
|
||||
}
|
||||
},
|
||||
"/v1/billing/checkout": {
|
||||
"post": {
|
||||
"tags": ["Billing"],
|
||||
"summary": "Start Pro subscription checkout",
|
||||
"description": "Creates a Stripe Checkout session for the Pro plan ($9/mo). Returns a URL to redirect the user to.",
|
||||
"responses": {
|
||||
"200": { "description": "Checkout URL", "content": { "application/json": { "schema": { "type": "object", "properties": { "url": { "type": "string", "format": "uri" } } } } } },
|
||||
"500": { "description": "Checkout creation failed" }
|
||||
}
|
||||
}
|
||||
},
|
||||
"/v1/usage": {
|
||||
"get": {
|
||||
"tags": ["System"],
|
||||
"summary": "Get usage statistics",
|
||||
"description": "Returns your API usage statistics for the current billing period.",
|
||||
"security": [{ "BearerAuth": [] }, { "ApiKeyHeader": [] }],
|
||||
"responses": {
|
||||
"200": { "description": "Usage stats" }
|
||||
}
|
||||
}
|
||||
},
|
||||
"/health": {
|
||||
"get": {
|
||||
"tags": ["System"],
|
||||
"summary": "Health check",
|
||||
"description": "Returns service health status. No authentication required.",
|
||||
"responses": {
|
||||
"200": { "description": "Service is healthy" }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
222
projects/business/src/pdf-api/public/privacy.html
Normal file
222
projects/business/src/pdf-api/public/privacy.html
Normal file
|
|
@ -0,0 +1,222 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="icon" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><text y='.9em' font-size='90'>⚡</text></svg>">
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap" rel="stylesheet">
|
||||
<title>Privacy Policy — DocFast</title>
|
||||
<meta name="description" content="Privacy policy for DocFast API service - GDPR compliant data protection information.">
|
||||
<link rel="canonical" href="https://docfast.dev/privacy">
|
||||
<style>
|
||||
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
|
||||
:root {
|
||||
--bg: #0b0d11; --bg2: #12151c; --fg: #e4e7ed; --muted: #7a8194;
|
||||
--accent: #34d399; --accent-hover: #5eead4; --accent-glow: rgba(52,211,153,0.12);
|
||||
--accent2: #60a5fa; --card: #151922; --border: #1e2433;
|
||||
--radius: 12px; --radius-lg: 16px;
|
||||
}
|
||||
body { font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: var(--bg); color: var(--fg); line-height: 1.65; -webkit-font-smoothing: antialiased; }
|
||||
a { color: var(--accent); text-decoration: none; transition: color 0.2s; }
|
||||
a:hover { color: var(--accent-hover); }
|
||||
.container { max-width: 1020px; margin: 0 auto; padding: 0 24px; }
|
||||
|
||||
/* Nav */
|
||||
nav { padding: 20px 0; border-bottom: 1px solid var(--border); }
|
||||
nav .container { display: flex; align-items: center; justify-content: space-between; }
|
||||
.logo { font-size: 1.25rem; font-weight: 700; letter-spacing: -0.5px; color: var(--fg); display: flex; align-items: center; gap: 8px; text-decoration: none; }
|
||||
.logo:hover { color: var(--fg); }
|
||||
.logo span { color: var(--accent); }
|
||||
.nav-links { display: flex; gap: 28px; align-items: center; }
|
||||
.nav-links a { color: var(--muted); font-size: 0.9rem; font-weight: 500; }
|
||||
.nav-links a:hover { color: var(--fg); }
|
||||
|
||||
/* Footer */
|
||||
footer { padding: 40px 0; border-top: 1px solid var(--border); }
|
||||
footer .container { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 16px; }
|
||||
.footer-left { color: var(--muted); font-size: 0.85rem; }
|
||||
.footer-links { display: flex; gap: 24px; flex-wrap: wrap; }
|
||||
.footer-links a { color: var(--muted); font-size: 0.85rem; }
|
||||
.footer-links a:hover { color: var(--fg); }
|
||||
|
||||
/* Buttons */
|
||||
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 14px 28px; border-radius: 10px; font-size: 0.95rem; font-weight: 600; transition: all 0.2s; border: none; cursor: pointer; text-decoration: none; }
|
||||
.btn-primary { background: var(--accent); color: #0b0d11; }
|
||||
.btn-primary:hover { background: var(--accent-hover); text-decoration: none; transform: translateY(-1px); box-shadow: 0 8px 24px rgba(52,211,153,0.2); }
|
||||
.btn-secondary { border: 1px solid var(--border); color: var(--fg); background: transparent; }
|
||||
.btn-secondary:hover { border-color: var(--muted); text-decoration: none; background: rgba(255,255,255,0.03); }
|
||||
.btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }
|
||||
.btn:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
|
||||
|
||||
/* Responsive base */
|
||||
@media (max-width: 640px) {
|
||||
.nav-links { gap: 16px; }
|
||||
.footer-links { gap: 16px; }
|
||||
footer .container { flex-direction: column; text-align: center; }
|
||||
}
|
||||
.container { max-width: 800px; margin: 0 auto; padding: 0 24px; }
|
||||
|
||||
/* Legal page overrides */
|
||||
.container { max-width: 800px; }
|
||||
main { padding: 60px 0 80px; }
|
||||
h1 { font-size: 2.5rem; font-weight: 800; margin-bottom: 16px; letter-spacing: -1px; }
|
||||
h2 { font-size: 1.5rem; font-weight: 700; margin: 32px 0 16px; color: var(--accent); }
|
||||
h3 { font-size: 1.2rem; font-weight: 600; margin: 24px 0 12px; }
|
||||
p { margin-bottom: 16px; line-height: 1.7; }
|
||||
ul { margin-bottom: 16px; padding-left: 24px; }
|
||||
li { margin-bottom: 8px; line-height: 1.7; }
|
||||
.highlight { background: rgba(52,211,153,0.08); border: 1px solid rgba(52,211,153,0.15); border-radius: 8px; padding: 16px; margin: 24px 0; color: var(--accent); font-size: 0.9rem; }
|
||||
.info { background: rgba(96,165,250,0.08); border: 1px solid rgba(96,165,250,0.15); border-radius: 8px; padding: 16px; margin: 24px 0; color: #60a5fa; font-size: 0.9rem; }
|
||||
.warning { background: rgba(251,191,36,0.08); border: 1px solid rgba(251,191,36,0.15); border-radius: 8px; padding: 16px; margin: 24px 0; color: #fbbf24; font-size: 0.9rem; }
|
||||
|
||||
@media (max-width: 640px) {
|
||||
main { padding: 40px 0 60px; }
|
||||
h1 { font-size: 2rem; }
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<nav aria-label="Main navigation">
|
||||
<div class="container">
|
||||
<a href="/" class="logo">⚡ Doc<span>Fast</span></a>
|
||||
<div class="nav-links">
|
||||
<a href="/#features">Features</a>
|
||||
<a href="/#pricing">Pricing</a>
|
||||
<a href="/docs">Docs</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<main>
|
||||
<div class="container">
|
||||
<h1>Privacy Policy</h1>
|
||||
<p><em>Last updated: February 16, 2026</em></p>
|
||||
|
||||
<div class="info">
|
||||
This privacy policy is GDPR compliant and explains how we collect, use, and protect your personal data.
|
||||
</div>
|
||||
|
||||
<h2>1. Data Controller</h2>
|
||||
<p><strong>Cloonar Technologies GmbH</strong><br>
|
||||
Address: Vienna, Austria<br>
|
||||
Email: <a href="mailto:legal@docfast.dev">legal@docfast.dev</a><br>
|
||||
Data Protection Contact: <a href="mailto:privacy@docfast.dev">privacy@docfast.dev</a></p>
|
||||
|
||||
<h2>2. Data We Collect</h2>
|
||||
|
||||
<h3>2.1 Account Information</h3>
|
||||
<ul>
|
||||
<li><strong>Email address</strong> - Required for account creation and API key delivery</li>
|
||||
<li><strong>API key</strong> - Automatically generated unique identifier</li>
|
||||
</ul>
|
||||
|
||||
<h3>2.2 API Usage Data</h3>
|
||||
<ul>
|
||||
<li><strong>Request logs</strong> - API endpoint accessed, timestamp, response status</li>
|
||||
<li><strong>Usage metrics</strong> - Number of API calls, data volume processed</li>
|
||||
<li><strong>IP address</strong> - For rate limiting and abuse prevention</li>
|
||||
</ul>
|
||||
|
||||
<h3>2.3 Payment Information</h3>
|
||||
<ul>
|
||||
<li><strong>Stripe Customer ID</strong> - For Pro subscription billing</li>
|
||||
<li><strong>Payment metadata</strong> - Subscription status, billing period</li>
|
||||
</ul>
|
||||
|
||||
<div class="highlight">
|
||||
<strong>No PDF content stored:</strong> We process your HTML/Markdown input to generate PDFs, but do not store the content or resulting PDFs on our servers.
|
||||
</div>
|
||||
|
||||
<h2>3. Legal Basis for Processing</h2>
|
||||
<ul>
|
||||
<li><strong>Contract fulfillment</strong> (Art. 6(1)(b) GDPR) - Account creation, API service provision</li>
|
||||
<li><strong>Legitimate interest</strong> (Art. 6(1)(f) GDPR) - Service monitoring, abuse prevention, performance optimization</li>
|
||||
<li><strong>Legal obligation</strong> (Art. 6(1)(c) GDPR) - Tax records, payment processing compliance</li>
|
||||
</ul>
|
||||
|
||||
<h2>4. Data Retention</h2>
|
||||
<ul>
|
||||
<li><strong>Account data:</strong> Retained while account is active + 30 days after deletion request</li>
|
||||
<li><strong>API usage logs:</strong> 90 days for operational monitoring</li>
|
||||
<li><strong>Payment records:</strong> 7 years for tax compliance (Austrian law)</li>
|
||||
<li><strong>PDF processing data:</strong> Not stored (processed in memory only)</li>
|
||||
</ul>
|
||||
|
||||
<h2>5. Third-Party Processors</h2>
|
||||
|
||||
<h3>5.1 Stripe (Payment Processing)</h3>
|
||||
<p><strong>Purpose:</strong> Payment processing for Pro subscriptions<br>
|
||||
<strong>Data:</strong> Email, payment information<br>
|
||||
<strong>Location:</strong> EU (GDPR compliant)<br>
|
||||
<strong>Privacy Policy:</strong> <a href="https://stripe.com/privacy" target="_blank" rel="noopener">https://stripe.com/privacy</a></p>
|
||||
|
||||
<h3>5.2 Hetzner (Hosting)</h3>
|
||||
<p><strong>Purpose:</strong> Server hosting and infrastructure<br>
|
||||
<strong>Data:</strong> All data processed by DocFast<br>
|
||||
<strong>Location:</strong> Germany (Nuremberg)<br>
|
||||
<strong>Privacy Policy:</strong> <a href="https://www.hetzner.com/legal/privacy-policy" target="_blank" rel="noopener">https://www.hetzner.com/legal/privacy-policy</a></p>
|
||||
|
||||
<div class="highlight">
|
||||
<strong>EU Data Residency:</strong> All your data is processed and stored exclusively within the European Union.
|
||||
</div>
|
||||
|
||||
<h2>6. Your Rights Under GDPR</h2>
|
||||
<ul>
|
||||
<li><strong>Right of access</strong> - Request information about your personal data</li>
|
||||
<li><strong>Right to rectification</strong> - Correct inaccurate data (e.g., email changes)</li>
|
||||
<li><strong>Right to erasure</strong> - Delete your account and associated data</li>
|
||||
<li><strong>Right to data portability</strong> - Receive your data in machine-readable format</li>
|
||||
<li><strong>Right to object</strong> - Object to processing based on legitimate interest</li>
|
||||
<li><strong>Right to lodge a complaint</strong> - Contact your data protection authority</li>
|
||||
</ul>
|
||||
|
||||
<p><strong>To exercise your rights:</strong> Email <a href="mailto:privacy@docfast.dev">privacy@docfast.dev</a></p>
|
||||
|
||||
<h2>7. Cookies and Tracking</h2>
|
||||
<p>DocFast uses minimal technical cookies:</p>
|
||||
<ul>
|
||||
<li><strong>Session cookies</strong> - For login state (if applicable)</li>
|
||||
<li><strong>No tracking cookies</strong> - We do not use analytics, advertising, or third-party tracking</li>
|
||||
</ul>
|
||||
|
||||
<h2>8. Data Security</h2>
|
||||
<ul>
|
||||
<li><strong>Encryption:</strong> All data transmission via HTTPS/TLS</li>
|
||||
<li><strong>Access control:</strong> Limited employee access with logging</li>
|
||||
<li><strong>Infrastructure:</strong> EU-based servers with enterprise security</li>
|
||||
<li><strong>API keys:</strong> Securely hashed and stored</li>
|
||||
</ul>
|
||||
|
||||
<h2>9. International Transfers</h2>
|
||||
<p>Your personal data does not leave the European Union. Our infrastructure is hosted exclusively by Hetzner in Germany.</p>
|
||||
|
||||
<h2>10. Contact for Data Protection</h2>
|
||||
<p>For questions about data processing or to exercise your rights:</p>
|
||||
<p><strong>Email:</strong> <a href="mailto:privacy@docfast.dev">privacy@docfast.dev</a><br>
|
||||
<strong>Subject:</strong> Include "GDPR" in the subject line for priority handling</p>
|
||||
|
||||
<h2>11. Changes to This Policy</h2>
|
||||
<p>We will notify users of material changes via email. Continued use of the service constitutes acceptance of updated terms.</p>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<footer aria-label="Footer">
|
||||
<div class="container">
|
||||
<div class="footer-left">© 2026 DocFast. Fast PDF generation for developers.</div>
|
||||
<div class="footer-links">
|
||||
<a href="/">Home</a>
|
||||
<a href="/docs">Docs</a>
|
||||
<a href="/health">API Status</a>
|
||||
<a href="/#change-email" class="open-email-change">Change Email</a>
|
||||
<a href="/impressum">Impressum</a>
|
||||
<a href="/privacy">Privacy Policy</a>
|
||||
<a href="/terms">Terms of Service</a>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
191
projects/business/src/pdf-api/public/privacy.html.server
Normal file
191
projects/business/src/pdf-api/public/privacy.html.server
Normal file
|
|
@ -0,0 +1,191 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Privacy Policy — DocFast</title>
|
||||
<meta name="description" content="Privacy policy for DocFast API service - GDPR compliant data protection information.">
|
||||
<link rel="canonical" href="https://docfast.dev/privacy">
|
||||
<link rel="icon" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><text y='.9em' font-size='90'>⚡</text></svg>">
|
||||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap" rel="stylesheet">
|
||||
<style>
|
||||
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
|
||||
:root {
|
||||
--bg: #0b0d11; --bg2: #12151c; --fg: #e4e7ed; --muted: #7a8194;
|
||||
--accent: #34d399; --accent-hover: #5eead4; --accent-glow: rgba(52,211,153,0.12);
|
||||
--card: #151922; --border: #1e2433;
|
||||
--radius: 12px; --radius-lg: 16px;
|
||||
}
|
||||
body { font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: var(--bg); color: var(--fg); line-height: 1.65; -webkit-font-smoothing: antialiased; }
|
||||
a { color: var(--accent); text-decoration: none; transition: color 0.2s; }
|
||||
a:hover { color: var(--accent-hover); }
|
||||
.container { max-width: 800px; margin: 0 auto; padding: 0 24px; }
|
||||
nav { padding: 20px 0; border-bottom: 1px solid var(--border); }
|
||||
nav .container { display: flex; align-items: center; justify-content: space-between; }
|
||||
.logo { font-size: 1.25rem; font-weight: 700; letter-spacing: -0.5px; color: var(--fg); display: flex; align-items: center; gap: 8px; text-decoration: none; }
|
||||
.logo span { color: var(--accent); }
|
||||
.nav-links { display: flex; gap: 28px; align-items: center; }
|
||||
.nav-links a { color: var(--muted); font-size: 0.9rem; font-weight: 500; }
|
||||
.nav-links a:hover { color: var(--fg); }
|
||||
.content { padding: 60px 0; min-height: 60vh; }
|
||||
.content h1 { font-size: 2rem; font-weight: 800; margin-bottom: 32px; letter-spacing: -1px; }
|
||||
.content h2 { font-size: 1.3rem; font-weight: 700; margin: 32px 0 16px; color: var(--fg); }
|
||||
.content h3 { font-size: 1.1rem; font-weight: 600; margin: 24px 0 12px; color: var(--fg); }
|
||||
.content p, .content li { color: var(--muted); margin-bottom: 12px; }
|
||||
.content ul, .content ol { padding-left: 24px; }
|
||||
.content strong { color: var(--fg); }
|
||||
footer { padding: 32px 0; border-top: 1px solid var(--border); margin-top: 60px; }
|
||||
footer .container { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 16px; }
|
||||
.footer-left { color: var(--muted); font-size: 0.85rem; }
|
||||
.footer-links { display: flex; gap: 20px; flex-wrap: wrap; }
|
||||
.footer-links a { color: var(--muted); font-size: 0.85rem; }
|
||||
.footer-links a:hover { color: var(--fg); }
|
||||
@media (max-width: 768px) {
|
||||
footer .container { flex-direction: column; text-align: center; }
|
||||
.nav-links { gap: 16px; }
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<nav aria-label="Main navigation">
|
||||
<div class="container">
|
||||
<a href="/" class="logo">⚡ Doc<span>Fast</span></a>
|
||||
<div class="nav-links">
|
||||
<a href="/#features">Features</a>
|
||||
<a href="/#pricing">Pricing</a>
|
||||
<a href="/docs">Docs</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<main>
|
||||
<div class="container">
|
||||
<h1>Privacy Policy</h1>
|
||||
<p><em>Last updated: February 16, 2026</em></p>
|
||||
|
||||
<div class="info">
|
||||
This privacy policy is GDPR compliant and explains how we collect, use, and protect your personal data.
|
||||
</div>
|
||||
|
||||
<h2>1. Data Controller</h2>
|
||||
<p><strong>Cloonar Technologies GmbH</strong><br>
|
||||
Address: Vienna, Austria<br>
|
||||
Email: <a href="mailto:legal@docfast.dev">legal@docfast.dev</a><br>
|
||||
Data Protection Contact: <a href="mailto:privacy@docfast.dev">privacy@docfast.dev</a></p>
|
||||
|
||||
<h2>2. Data We Collect</h2>
|
||||
|
||||
<h3>2.1 Account Information</h3>
|
||||
<ul>
|
||||
<li><strong>Email address</strong> - Required for account creation and API key delivery</li>
|
||||
<li><strong>API key</strong> - Automatically generated unique identifier</li>
|
||||
</ul>
|
||||
|
||||
<h3>2.2 API Usage Data</h3>
|
||||
<ul>
|
||||
<li><strong>Request logs</strong> - API endpoint accessed, timestamp, response status</li>
|
||||
<li><strong>Usage metrics</strong> - Number of API calls, data volume processed</li>
|
||||
<li><strong>IP address</strong> - For rate limiting and abuse prevention</li>
|
||||
</ul>
|
||||
|
||||
<h3>2.3 Payment Information</h3>
|
||||
<ul>
|
||||
<li><strong>Stripe Customer ID</strong> - For Pro subscription billing</li>
|
||||
<li><strong>Payment metadata</strong> - Subscription status, billing period</li>
|
||||
</ul>
|
||||
|
||||
<div class="highlight">
|
||||
<strong>No PDF content stored:</strong> We process your HTML/Markdown input to generate PDFs, but do not store the content or resulting PDFs on our servers.
|
||||
</div>
|
||||
|
||||
<h2>3. Legal Basis for Processing</h2>
|
||||
<ul>
|
||||
<li><strong>Contract fulfillment</strong> (Art. 6(1)(b) GDPR) - Account creation, API service provision</li>
|
||||
<li><strong>Legitimate interest</strong> (Art. 6(1)(f) GDPR) - Service monitoring, abuse prevention, performance optimization</li>
|
||||
<li><strong>Legal obligation</strong> (Art. 6(1)(c) GDPR) - Tax records, payment processing compliance</li>
|
||||
</ul>
|
||||
|
||||
<h2>4. Data Retention</h2>
|
||||
<ul>
|
||||
<li><strong>Account data:</strong> Retained while account is active + 30 days after deletion request</li>
|
||||
<li><strong>API usage logs:</strong> 90 days for operational monitoring</li>
|
||||
<li><strong>Payment records:</strong> 7 years for tax compliance (Austrian law)</li>
|
||||
<li><strong>PDF processing data:</strong> Not stored (processed in memory only)</li>
|
||||
</ul>
|
||||
|
||||
<h2>5. Third-Party Processors</h2>
|
||||
|
||||
<h3>5.1 Stripe (Payment Processing)</h3>
|
||||
<p><strong>Purpose:</strong> Payment processing for Pro subscriptions<br>
|
||||
<strong>Data:</strong> Email, payment information<br>
|
||||
<strong>Location:</strong> EU (GDPR compliant)<br>
|
||||
<strong>Privacy Policy:</strong> <a href="https://stripe.com/privacy" target="_blank" rel="noopener">https://stripe.com/privacy</a></p>
|
||||
|
||||
<h3>5.2 Hetzner (Hosting)</h3>
|
||||
<p><strong>Purpose:</strong> Server hosting and infrastructure<br>
|
||||
<strong>Data:</strong> All data processed by DocFast<br>
|
||||
<strong>Location:</strong> Germany (Nuremberg)<br>
|
||||
<strong>Privacy Policy:</strong> <a href="https://www.hetzner.com/legal/privacy-policy" target="_blank" rel="noopener">https://www.hetzner.com/legal/privacy-policy</a></p>
|
||||
|
||||
<div class="highlight">
|
||||
<strong>EU Data Residency:</strong> All your data is processed and stored exclusively within the European Union.
|
||||
</div>
|
||||
|
||||
<h2>6. Your Rights Under GDPR</h2>
|
||||
<ul>
|
||||
<li><strong>Right of access</strong> - Request information about your personal data</li>
|
||||
<li><strong>Right to rectification</strong> - Correct inaccurate data (e.g., email changes)</li>
|
||||
<li><strong>Right to erasure</strong> - Delete your account and associated data</li>
|
||||
<li><strong>Right to data portability</strong> - Receive your data in machine-readable format</li>
|
||||
<li><strong>Right to object</strong> - Object to processing based on legitimate interest</li>
|
||||
<li><strong>Right to lodge a complaint</strong> - Contact your data protection authority</li>
|
||||
</ul>
|
||||
|
||||
<p><strong>To exercise your rights:</strong> Email <a href="mailto:privacy@docfast.dev">privacy@docfast.dev</a></p>
|
||||
|
||||
<h2>7. Cookies and Tracking</h2>
|
||||
<p>DocFast uses minimal technical cookies:</p>
|
||||
<ul>
|
||||
<li><strong>Session cookies</strong> - For login state (if applicable)</li>
|
||||
<li><strong>No tracking cookies</strong> - We do not use analytics, advertising, or third-party tracking</li>
|
||||
</ul>
|
||||
|
||||
<h2>8. Data Security</h2>
|
||||
<ul>
|
||||
<li><strong>Encryption:</strong> All data transmission via HTTPS/TLS</li>
|
||||
<li><strong>Access control:</strong> Limited employee access with logging</li>
|
||||
<li><strong>Infrastructure:</strong> EU-based servers with enterprise security</li>
|
||||
<li><strong>API keys:</strong> Securely hashed and stored</li>
|
||||
</ul>
|
||||
|
||||
<h2>9. International Transfers</h2>
|
||||
<p>Your personal data does not leave the European Union. Our infrastructure is hosted exclusively by Hetzner in Germany.</p>
|
||||
|
||||
<h2>10. Contact for Data Protection</h2>
|
||||
<p>For questions about data processing or to exercise your rights:</p>
|
||||
<p><strong>Email:</strong> <a href="mailto:privacy@docfast.dev">privacy@docfast.dev</a><br>
|
||||
<strong>Subject:</strong> Include "GDPR" in the subject line for priority handling</p>
|
||||
|
||||
<h2>11. Changes to This Policy</h2>
|
||||
<p>We will notify users of material changes via email. Continued use of the service constitutes acceptance of updated terms.</p>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<footer aria-label="Footer">
|
||||
<div class="container">
|
||||
<div class="footer-left">© 2026 DocFast. Fast PDF generation for developers.</div>
|
||||
<div class="footer-links">
|
||||
<a href="/">Home</a>
|
||||
<a href="/docs">Docs</a>
|
||||
<a href="/health">API Status</a>
|
||||
<a href="/#change-email" class="open-email-change">Change Email</a>
|
||||
<a href="/impressum">Impressum</a>
|
||||
<a href="/privacy">Privacy Policy</a>
|
||||
<a href="/terms">Terms of Service</a>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
6
projects/business/src/pdf-api/public/robots.txt
Normal file
6
projects/business/src/pdf-api/public/robots.txt
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
User-agent: *
|
||||
Allow: /
|
||||
Disallow: /v1/
|
||||
Disallow: /api
|
||||
Disallow: /health
|
||||
Sitemap: https://docfast.dev/sitemap.xml
|
||||
8
projects/business/src/pdf-api/public/sitemap.xml
Normal file
8
projects/business/src/pdf-api/public/sitemap.xml
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<urlset xmlns="http://www.sitemapns.org/schemas/sitemap/0.9">
|
||||
<url><loc>https://docfast.dev/</loc><lastmod>2026-02-16</lastmod><changefreq>weekly</changefreq><priority>1.0</priority></url>
|
||||
<url><loc>https://docfast.dev/docs</loc><lastmod>2026-02-16</lastmod><changefreq>weekly</changefreq><priority>0.8</priority></url>
|
||||
<url><loc>https://docfast.dev/impressum</loc><lastmod>2026-02-16</lastmod><changefreq>monthly</changefreq><priority>0.3</priority></url>
|
||||
<url><loc>https://docfast.dev/privacy</loc><lastmod>2026-02-16</lastmod><changefreq>monthly</changefreq><priority>0.3</priority></url>
|
||||
<url><loc>https://docfast.dev/terms</loc><lastmod>2026-02-16</lastmod><changefreq>monthly</changefreq><priority>0.3</priority></url>
|
||||
</urlset>
|
||||
18
projects/business/src/pdf-api/public/swagger-init.js
Normal file
18
projects/business/src/pdf-api/public/swagger-init.js
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
SwaggerUIBundle({
|
||||
url: "/openapi.json",
|
||||
dom_id: "#swagger-ui",
|
||||
deepLinking: true,
|
||||
presets: [
|
||||
SwaggerUIBundle.presets.apis,
|
||||
SwaggerUIBundle.SwaggerUIStandalonePreset
|
||||
],
|
||||
layout: "BaseLayout",
|
||||
defaultModelsExpandDepth: 1,
|
||||
defaultModelExpandDepth: 2,
|
||||
docExpansion: "list",
|
||||
filter: true,
|
||||
tryItOutEnabled: true,
|
||||
requestSnippetsEnabled: true,
|
||||
persistAuthorization: true,
|
||||
syntaxHighlight: { theme: "monokai" }
|
||||
});
|
||||
1
projects/business/src/pdf-api/public/swagger-ui
Symbolic link
1
projects/business/src/pdf-api/public/swagger-ui
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../node_modules/swagger-ui-dist
|
||||
294
projects/business/src/pdf-api/public/terms.html
Normal file
294
projects/business/src/pdf-api/public/terms.html
Normal file
|
|
@ -0,0 +1,294 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="icon" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><text y='.9em' font-size='90'>⚡</text></svg>">
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap" rel="stylesheet">
|
||||
<title>Terms of Service — DocFast</title>
|
||||
<meta name="description" content="Terms of service for DocFast API - legal terms and conditions for using our PDF generation service.">
|
||||
<link rel="canonical" href="https://docfast.dev/terms">
|
||||
<style>
|
||||
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
|
||||
:root {
|
||||
--bg: #0b0d11; --bg2: #12151c; --fg: #e4e7ed; --muted: #7a8194;
|
||||
--accent: #34d399; --accent-hover: #5eead4; --accent-glow: rgba(52,211,153,0.12);
|
||||
--accent2: #60a5fa; --card: #151922; --border: #1e2433;
|
||||
--radius: 12px; --radius-lg: 16px;
|
||||
}
|
||||
body { font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: var(--bg); color: var(--fg); line-height: 1.65; -webkit-font-smoothing: antialiased; }
|
||||
a { color: var(--accent); text-decoration: none; transition: color 0.2s; }
|
||||
a:hover { color: var(--accent-hover); }
|
||||
.container { max-width: 1020px; margin: 0 auto; padding: 0 24px; }
|
||||
|
||||
/* Nav */
|
||||
nav { padding: 20px 0; border-bottom: 1px solid var(--border); }
|
||||
nav .container { display: flex; align-items: center; justify-content: space-between; }
|
||||
.logo { font-size: 1.25rem; font-weight: 700; letter-spacing: -0.5px; color: var(--fg); display: flex; align-items: center; gap: 8px; text-decoration: none; }
|
||||
.logo:hover { color: var(--fg); }
|
||||
.logo span { color: var(--accent); }
|
||||
.nav-links { display: flex; gap: 28px; align-items: center; }
|
||||
.nav-links a { color: var(--muted); font-size: 0.9rem; font-weight: 500; }
|
||||
.nav-links a:hover { color: var(--fg); }
|
||||
|
||||
/* Footer */
|
||||
footer { padding: 40px 0; border-top: 1px solid var(--border); }
|
||||
footer .container { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 16px; }
|
||||
.footer-left { color: var(--muted); font-size: 0.85rem; }
|
||||
.footer-links { display: flex; gap: 24px; flex-wrap: wrap; }
|
||||
.footer-links a { color: var(--muted); font-size: 0.85rem; }
|
||||
.footer-links a:hover { color: var(--fg); }
|
||||
|
||||
/* Buttons */
|
||||
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 14px 28px; border-radius: 10px; font-size: 0.95rem; font-weight: 600; transition: all 0.2s; border: none; cursor: pointer; text-decoration: none; }
|
||||
.btn-primary { background: var(--accent); color: #0b0d11; }
|
||||
.btn-primary:hover { background: var(--accent-hover); text-decoration: none; transform: translateY(-1px); box-shadow: 0 8px 24px rgba(52,211,153,0.2); }
|
||||
.btn-secondary { border: 1px solid var(--border); color: var(--fg); background: transparent; }
|
||||
.btn-secondary:hover { border-color: var(--muted); text-decoration: none; background: rgba(255,255,255,0.03); }
|
||||
.btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }
|
||||
.btn:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
|
||||
|
||||
/* Responsive base */
|
||||
@media (max-width: 640px) {
|
||||
.nav-links { gap: 16px; }
|
||||
.footer-links { gap: 16px; }
|
||||
footer .container { flex-direction: column; text-align: center; }
|
||||
}
|
||||
.container { max-width: 800px; margin: 0 auto; padding: 0 24px; }
|
||||
|
||||
/* Legal page overrides */
|
||||
.container { max-width: 800px; }
|
||||
main { padding: 60px 0 80px; }
|
||||
h1 { font-size: 2.5rem; font-weight: 800; margin-bottom: 16px; letter-spacing: -1px; }
|
||||
h2 { font-size: 1.5rem; font-weight: 700; margin: 32px 0 16px; color: var(--accent); }
|
||||
h3 { font-size: 1.2rem; font-weight: 600; margin: 24px 0 12px; }
|
||||
p { margin-bottom: 16px; line-height: 1.7; }
|
||||
ul { margin-bottom: 16px; padding-left: 24px; }
|
||||
li { margin-bottom: 8px; line-height: 1.7; }
|
||||
.highlight { background: rgba(52,211,153,0.08); border: 1px solid rgba(52,211,153,0.15); border-radius: 8px; padding: 16px; margin: 24px 0; color: var(--accent); font-size: 0.9rem; }
|
||||
.info { background: rgba(96,165,250,0.08); border: 1px solid rgba(96,165,250,0.15); border-radius: 8px; padding: 16px; margin: 24px 0; color: #60a5fa; font-size: 0.9rem; }
|
||||
.warning { background: rgba(251,191,36,0.08); border: 1px solid rgba(251,191,36,0.15); border-radius: 8px; padding: 16px; margin: 24px 0; color: #fbbf24; font-size: 0.9rem; }
|
||||
|
||||
@media (max-width: 640px) {
|
||||
main { padding: 40px 0 60px; }
|
||||
h1 { font-size: 2rem; }
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<nav aria-label="Main navigation">
|
||||
<div class="container">
|
||||
<a href="/" class="logo">⚡ Doc<span>Fast</span></a>
|
||||
<div class="nav-links">
|
||||
<a href="/#features">Features</a>
|
||||
<a href="/#pricing">Pricing</a>
|
||||
<a href="/docs">Docs</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<main>
|
||||
<div class="container">
|
||||
<h1>Terms of Service</h1>
|
||||
<p><em>Last updated: February 16, 2026</em></p>
|
||||
|
||||
<div class="info">
|
||||
By using DocFast, you agree to these terms. Please read them carefully.
|
||||
</div>
|
||||
|
||||
<h2>1. Service Description</h2>
|
||||
<p>DocFast provides an API service for converting HTML, Markdown, and URLs to PDF documents. The service includes:</p>
|
||||
<ul>
|
||||
<li>HTML to PDF conversion</li>
|
||||
<li>Markdown to PDF conversion</li>
|
||||
<li>URL to PDF conversion</li>
|
||||
<li>Pre-built invoice and receipt templates</li>
|
||||
<li>Custom CSS styling support</li>
|
||||
</ul>
|
||||
|
||||
<h2>2. Service Plans</h2>
|
||||
|
||||
<h3>2.1 Free Tier</h3>
|
||||
<ul>
|
||||
<li><strong>Monthly limit:</strong> 100 PDF conversions</li>
|
||||
<li><strong>Rate limit:</strong> 10 requests per minute</li>
|
||||
<li><strong>Fair use policy:</strong> Personal and small business use</li>
|
||||
<li><strong>Support:</strong> Community documentation</li>
|
||||
</ul>
|
||||
|
||||
<h3>2.2 Pro Tier</h3>
|
||||
<ul>
|
||||
<li><strong>Price:</strong> €9 per month</li>
|
||||
<li><strong>Monthly limit:</strong> 10,000 PDF conversions</li>
|
||||
<li><strong>Rate limit:</strong> Higher limits based on fair use</li>
|
||||
<li><strong>Support:</strong> Priority email support</li>
|
||||
<li><strong>Billing:</strong> Monthly subscription via Stripe</li>
|
||||
</ul>
|
||||
|
||||
<div class="highlight">
|
||||
<strong>Overage:</strong> If you exceed your plan limits, API requests will return rate limiting errors. No automatic charges apply.
|
||||
</div>
|
||||
|
||||
<h2>3. Acceptable Use</h2>
|
||||
|
||||
<h3>3.1 Permitted Uses</h3>
|
||||
<ul>
|
||||
<li>Business documents (invoices, reports, receipts)</li>
|
||||
<li>Personal document generation</li>
|
||||
<li>Integration into web applications</li>
|
||||
<li>Educational and non-commercial projects</li>
|
||||
</ul>
|
||||
|
||||
<h3>3.2 Prohibited Uses</h3>
|
||||
<ul>
|
||||
<li><strong>Illegal content:</strong> No processing of copyrighted material without permission</li>
|
||||
<li><strong>Abuse:</strong> No attempts to overload or disrupt the service</li>
|
||||
<li><strong>Harmful content:</strong> No generation of malicious, threatening, or harmful documents</li>
|
||||
<li><strong>Reselling:</strong> No white-labeling or reselling of the raw API service</li>
|
||||
<li><strong>Reverse engineering:</strong> No attempts to extract proprietary algorithms</li>
|
||||
</ul>
|
||||
|
||||
<div class="warning">
|
||||
<strong>Violation consequences:</strong> Account termination, permanent ban, and legal action if necessary.
|
||||
</div>
|
||||
|
||||
<h2>4. API Key Security</h2>
|
||||
<ul>
|
||||
<li><strong>Responsibility:</strong> You are responsible for keeping your API key secure</li>
|
||||
<li><strong>Unauthorized use:</strong> You are liable for all usage under your API key</li>
|
||||
<li><strong>Recovery:</strong> Lost keys can be recovered via email verification</li>
|
||||
<li><strong>Sharing:</strong> Do not share API keys publicly or in client-side code</li>
|
||||
</ul>
|
||||
|
||||
<h2>5. Service Availability</h2>
|
||||
|
||||
<h3>5.1 Uptime</h3>
|
||||
<ul>
|
||||
<li><strong>Target:</strong> 99.5% uptime (best effort, no SLA for free tier)</li>
|
||||
<li><strong>Maintenance:</strong> Scheduled maintenance with advance notice</li>
|
||||
<li><strong>Status page:</strong> <a href="/health">https://docfast.dev/health</a></li>
|
||||
</ul>
|
||||
|
||||
<h3>5.2 Performance</h3>
|
||||
<ul>
|
||||
<li><strong>Processing time:</strong> Typically under 1 second per PDF</li>
|
||||
<li><strong>Rate limiting:</strong> Applied fairly to ensure service stability</li>
|
||||
<li><strong>File size limits:</strong> Input HTML/Markdown up to 2MB</li>
|
||||
</ul>
|
||||
|
||||
<h2>6. Data Processing</h2>
|
||||
<ul>
|
||||
<li><strong>No storage:</strong> PDF content is processed in memory only</li>
|
||||
<li><strong>Logs:</strong> API usage logs retained for 90 days</li>
|
||||
<li><strong>Privacy:</strong> See our <a href="/privacy">Privacy Policy</a> for details</li>
|
||||
<li><strong>EU hosting:</strong> All data processed in Germany (Hetzner)</li>
|
||||
</ul>
|
||||
|
||||
<h2>7. Payment Terms</h2>
|
||||
|
||||
<h3>7.1 Pro Subscription</h3>
|
||||
<ul>
|
||||
<li><strong>Billing cycle:</strong> Monthly, billed in advance</li>
|
||||
<li><strong>Payment method:</strong> Credit card via Stripe</li>
|
||||
<li><strong>Currency:</strong> EUR (Euro)</li>
|
||||
<li><strong>Auto-renewal:</strong> Subscription renews automatically</li>
|
||||
</ul>
|
||||
|
||||
<h3>7.2 Cancellation</h3>
|
||||
<ul>
|
||||
<li><strong>Anytime:</strong> Cancel your subscription at any time</li>
|
||||
<li><strong>Access:</strong> Service continues until end of billing period</li>
|
||||
<li><strong>Refunds:</strong> No partial refunds for unused portions</li>
|
||||
</ul>
|
||||
|
||||
<div class="info">
|
||||
<strong>EU Consumer Rights:</strong> 14-day right of withdrawal applies to digital services not yet delivered. Once you start using the Pro service, withdrawal right expires.
|
||||
</div>
|
||||
|
||||
<h2>8. Limitation of Liability</h2>
|
||||
<ul>
|
||||
<li><strong>Service provision:</strong> Best effort basis, no guarantees</li>
|
||||
<li><strong>Damages:</strong> Our liability is limited to the amount paid for the service</li>
|
||||
<li><strong>Indirect damages:</strong> We are not liable for lost profits, business interruption, or data loss</li>
|
||||
<li><strong>Force majeure:</strong> Not liable for events beyond our reasonable control</li>
|
||||
</ul>
|
||||
|
||||
<h2>9. Account Termination</h2>
|
||||
|
||||
<h3>9.1 By You</h3>
|
||||
<ul>
|
||||
<li>Delete your account by emailing <a href="mailto:legal@docfast.dev">legal@docfast.dev</a></li>
|
||||
<li>Cancel Pro subscription through your account or email</li>
|
||||
</ul>
|
||||
|
||||
<h3>9.2 By Us</h3>
|
||||
<p>We may terminate accounts for:</p>
|
||||
<ul>
|
||||
<li>Violation of these terms</li>
|
||||
<li>Non-payment (Pro accounts)</li>
|
||||
<li>Extended inactivity (12+ months)</li>
|
||||
<li>Technical abuse or security concerns</li>
|
||||
</ul>
|
||||
|
||||
<div class="warning">
|
||||
<strong>Termination notice:</strong> We will provide reasonable notice except for immediate security threats.
|
||||
</div>
|
||||
|
||||
<h2>10. Intellectual Property</h2>
|
||||
<ul>
|
||||
<li><strong>Service ownership:</strong> DocFast and its technology remain our property</li>
|
||||
<li><strong>Your content:</strong> You retain rights to content you process through our API</li>
|
||||
<li><strong>Generated PDFs:</strong> You own the PDFs generated from your content</li>
|
||||
<li><strong>Feedback:</strong> Any feedback provided may be used to improve the service</li>
|
||||
</ul>
|
||||
|
||||
<h2>11. Governing Law</h2>
|
||||
<ul>
|
||||
<li><strong>Jurisdiction:</strong> These terms are governed by Austrian law</li>
|
||||
<li><strong>Courts:</strong> Disputes resolved in Vienna, Austria</li>
|
||||
<li><strong>Language:</strong> German version prevails in case of translation conflicts</li>
|
||||
<li><strong>EU regulations:</strong> GDPR and other EU laws apply</li>
|
||||
</ul>
|
||||
|
||||
<h2>12. Changes to Terms</h2>
|
||||
<p>We may update these terms by:</p>
|
||||
<ul>
|
||||
<li><strong>Email notification:</strong> For material changes affecting your rights</li>
|
||||
<li><strong>Website posting:</strong> Updated version posted with revision date</li>
|
||||
<li><strong>Continued use:</strong> Using the service after changes constitutes acceptance</li>
|
||||
</ul>
|
||||
|
||||
<h2>13. Contact Information</h2>
|
||||
<p>Questions about these terms:</p>
|
||||
<ul>
|
||||
<li><strong>Email:</strong> <a href="mailto:legal@docfast.dev">legal@docfast.dev</a></li>
|
||||
<li><strong>Company:</strong> Cloonar Technologies GmbH, Vienna, Austria</li>
|
||||
<li><strong>Legal notice:</strong> See <a href="/impressum">Impressum</a> for full company details</li>
|
||||
</ul>
|
||||
|
||||
<div class="highlight">
|
||||
<strong>Effective Date:</strong> These terms are effective immediately upon posting. By using DocFast, you acknowledge reading and agreeing to these terms.
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<footer aria-label="Footer">
|
||||
<div class="container">
|
||||
<div class="footer-left">© 2026 DocFast. Fast PDF generation for developers.</div>
|
||||
<div class="footer-links">
|
||||
<a href="/">Home</a>
|
||||
<a href="/docs">Docs</a>
|
||||
<a href="/health">API Status</a>
|
||||
<a href="/#change-email" class="open-email-change">Change Email</a>
|
||||
<a href="/impressum">Impressum</a>
|
||||
<a href="/privacy">Privacy Policy</a>
|
||||
<a href="/terms">Terms of Service</a>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
263
projects/business/src/pdf-api/public/terms.html.server
Normal file
263
projects/business/src/pdf-api/public/terms.html.server
Normal file
|
|
@ -0,0 +1,263 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Terms of Service — DocFast</title>
|
||||
<meta name="description" content="Terms of service for DocFast API - legal terms and conditions for using our PDF generation service.">
|
||||
<link rel="canonical" href="https://docfast.dev/terms">
|
||||
<link rel="icon" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><text y='.9em' font-size='90'>⚡</text></svg>">
|
||||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap" rel="stylesheet">
|
||||
<style>
|
||||
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
|
||||
:root {
|
||||
--bg: #0b0d11; --bg2: #12151c; --fg: #e4e7ed; --muted: #7a8194;
|
||||
--accent: #34d399; --accent-hover: #5eead4; --accent-glow: rgba(52,211,153,0.12);
|
||||
--card: #151922; --border: #1e2433;
|
||||
--radius: 12px; --radius-lg: 16px;
|
||||
}
|
||||
body { font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: var(--bg); color: var(--fg); line-height: 1.65; -webkit-font-smoothing: antialiased; }
|
||||
a { color: var(--accent); text-decoration: none; transition: color 0.2s; }
|
||||
a:hover { color: var(--accent-hover); }
|
||||
.container { max-width: 800px; margin: 0 auto; padding: 0 24px; }
|
||||
nav { padding: 20px 0; border-bottom: 1px solid var(--border); }
|
||||
nav .container { display: flex; align-items: center; justify-content: space-between; }
|
||||
.logo { font-size: 1.25rem; font-weight: 700; letter-spacing: -0.5px; color: var(--fg); display: flex; align-items: center; gap: 8px; text-decoration: none; }
|
||||
.logo span { color: var(--accent); }
|
||||
.nav-links { display: flex; gap: 28px; align-items: center; }
|
||||
.nav-links a { color: var(--muted); font-size: 0.9rem; font-weight: 500; }
|
||||
.nav-links a:hover { color: var(--fg); }
|
||||
.content { padding: 60px 0; min-height: 60vh; }
|
||||
.content h1 { font-size: 2rem; font-weight: 800; margin-bottom: 32px; letter-spacing: -1px; }
|
||||
.content h2 { font-size: 1.3rem; font-weight: 700; margin: 32px 0 16px; color: var(--fg); }
|
||||
.content h3 { font-size: 1.1rem; font-weight: 600; margin: 24px 0 12px; color: var(--fg); }
|
||||
.content p, .content li { color: var(--muted); margin-bottom: 12px; }
|
||||
.content ul, .content ol { padding-left: 24px; }
|
||||
.content strong { color: var(--fg); }
|
||||
footer { padding: 32px 0; border-top: 1px solid var(--border); margin-top: 60px; }
|
||||
footer .container { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 16px; }
|
||||
.footer-left { color: var(--muted); font-size: 0.85rem; }
|
||||
.footer-links { display: flex; gap: 20px; flex-wrap: wrap; }
|
||||
.footer-links a { color: var(--muted); font-size: 0.85rem; }
|
||||
.footer-links a:hover { color: var(--fg); }
|
||||
@media (max-width: 768px) {
|
||||
footer .container { flex-direction: column; text-align: center; }
|
||||
.nav-links { gap: 16px; }
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<nav aria-label="Main navigation">
|
||||
<div class="container">
|
||||
<a href="/" class="logo">⚡ Doc<span>Fast</span></a>
|
||||
<div class="nav-links">
|
||||
<a href="/#features">Features</a>
|
||||
<a href="/#pricing">Pricing</a>
|
||||
<a href="/docs">Docs</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<main>
|
||||
<div class="container">
|
||||
<h1>Terms of Service</h1>
|
||||
<p><em>Last updated: February 16, 2026</em></p>
|
||||
|
||||
<div class="info">
|
||||
By using DocFast, you agree to these terms. Please read them carefully.
|
||||
</div>
|
||||
|
||||
<h2>1. Service Description</h2>
|
||||
<p>DocFast provides an API service for converting HTML, Markdown, and URLs to PDF documents. The service includes:</p>
|
||||
<ul>
|
||||
<li>HTML to PDF conversion</li>
|
||||
<li>Markdown to PDF conversion</li>
|
||||
<li>URL to PDF conversion</li>
|
||||
<li>Pre-built invoice and receipt templates</li>
|
||||
<li>Custom CSS styling support</li>
|
||||
</ul>
|
||||
|
||||
<h2>2. Service Plans</h2>
|
||||
|
||||
<h3>2.1 Free Tier</h3>
|
||||
<ul>
|
||||
<li><strong>Monthly limit:</strong> 100 PDF conversions</li>
|
||||
<li><strong>Rate limit:</strong> 10 requests per minute</li>
|
||||
<li><strong>Fair use policy:</strong> Personal and small business use</li>
|
||||
<li><strong>Support:</strong> Community documentation</li>
|
||||
</ul>
|
||||
|
||||
<h3>2.2 Pro Tier</h3>
|
||||
<ul>
|
||||
<li><strong>Price:</strong> €9 per month</li>
|
||||
<li><strong>Monthly limit:</strong> 10,000 PDF conversions</li>
|
||||
<li><strong>Rate limit:</strong> Higher limits based on fair use</li>
|
||||
<li><strong>Support:</strong> Priority email support</li>
|
||||
<li><strong>Billing:</strong> Monthly subscription via Stripe</li>
|
||||
</ul>
|
||||
|
||||
<div class="highlight">
|
||||
<strong>Overage:</strong> If you exceed your plan limits, API requests will return rate limiting errors. No automatic charges apply.
|
||||
</div>
|
||||
|
||||
<h2>3. Acceptable Use</h2>
|
||||
|
||||
<h3>3.1 Permitted Uses</h3>
|
||||
<ul>
|
||||
<li>Business documents (invoices, reports, receipts)</li>
|
||||
<li>Personal document generation</li>
|
||||
<li>Integration into web applications</li>
|
||||
<li>Educational and non-commercial projects</li>
|
||||
</ul>
|
||||
|
||||
<h3>3.2 Prohibited Uses</h3>
|
||||
<ul>
|
||||
<li><strong>Illegal content:</strong> No processing of copyrighted material without permission</li>
|
||||
<li><strong>Abuse:</strong> No attempts to overload or disrupt the service</li>
|
||||
<li><strong>Harmful content:</strong> No generation of malicious, threatening, or harmful documents</li>
|
||||
<li><strong>Reselling:</strong> No white-labeling or reselling of the raw API service</li>
|
||||
<li><strong>Reverse engineering:</strong> No attempts to extract proprietary algorithms</li>
|
||||
</ul>
|
||||
|
||||
<div class="warning">
|
||||
<strong>Violation consequences:</strong> Account termination, permanent ban, and legal action if necessary.
|
||||
</div>
|
||||
|
||||
<h2>4. API Key Security</h2>
|
||||
<ul>
|
||||
<li><strong>Responsibility:</strong> You are responsible for keeping your API key secure</li>
|
||||
<li><strong>Unauthorized use:</strong> You are liable for all usage under your API key</li>
|
||||
<li><strong>Recovery:</strong> Lost keys can be recovered via email verification</li>
|
||||
<li><strong>Sharing:</strong> Do not share API keys publicly or in client-side code</li>
|
||||
</ul>
|
||||
|
||||
<h2>5. Service Availability</h2>
|
||||
|
||||
<h3>5.1 Uptime</h3>
|
||||
<ul>
|
||||
<li><strong>Target:</strong> 99.5% uptime (best effort, no SLA for free tier)</li>
|
||||
<li><strong>Maintenance:</strong> Scheduled maintenance with advance notice</li>
|
||||
<li><strong>Status page:</strong> <a href="/health">https://docfast.dev/health</a></li>
|
||||
</ul>
|
||||
|
||||
<h3>5.2 Performance</h3>
|
||||
<ul>
|
||||
<li><strong>Processing time:</strong> Typically under 1 second per PDF</li>
|
||||
<li><strong>Rate limiting:</strong> Applied fairly to ensure service stability</li>
|
||||
<li><strong>File size limits:</strong> Input HTML/Markdown up to 2MB</li>
|
||||
</ul>
|
||||
|
||||
<h2>6. Data Processing</h2>
|
||||
<ul>
|
||||
<li><strong>No storage:</strong> PDF content is processed in memory only</li>
|
||||
<li><strong>Logs:</strong> API usage logs retained for 90 days</li>
|
||||
<li><strong>Privacy:</strong> See our <a href="/privacy">Privacy Policy</a> for details</li>
|
||||
<li><strong>EU hosting:</strong> All data processed in Germany (Hetzner)</li>
|
||||
</ul>
|
||||
|
||||
<h2>7. Payment Terms</h2>
|
||||
|
||||
<h3>7.1 Pro Subscription</h3>
|
||||
<ul>
|
||||
<li><strong>Billing cycle:</strong> Monthly, billed in advance</li>
|
||||
<li><strong>Payment method:</strong> Credit card via Stripe</li>
|
||||
<li><strong>Currency:</strong> EUR (Euro)</li>
|
||||
<li><strong>Auto-renewal:</strong> Subscription renews automatically</li>
|
||||
</ul>
|
||||
|
||||
<h3>7.2 Cancellation</h3>
|
||||
<ul>
|
||||
<li><strong>Anytime:</strong> Cancel your subscription at any time</li>
|
||||
<li><strong>Access:</strong> Service continues until end of billing period</li>
|
||||
<li><strong>Refunds:</strong> No partial refunds for unused portions</li>
|
||||
</ul>
|
||||
|
||||
<div class="info">
|
||||
<strong>EU Consumer Rights:</strong> 14-day right of withdrawal applies to digital services not yet delivered. Once you start using the Pro service, withdrawal right expires.
|
||||
</div>
|
||||
|
||||
<h2>8. Limitation of Liability</h2>
|
||||
<ul>
|
||||
<li><strong>Service provision:</strong> Best effort basis, no guarantees</li>
|
||||
<li><strong>Damages:</strong> Our liability is limited to the amount paid for the service</li>
|
||||
<li><strong>Indirect damages:</strong> We are not liable for lost profits, business interruption, or data loss</li>
|
||||
<li><strong>Force majeure:</strong> Not liable for events beyond our reasonable control</li>
|
||||
</ul>
|
||||
|
||||
<h2>9. Account Termination</h2>
|
||||
|
||||
<h3>9.1 By You</h3>
|
||||
<ul>
|
||||
<li>Delete your account by emailing <a href="mailto:legal@docfast.dev">legal@docfast.dev</a></li>
|
||||
<li>Cancel Pro subscription through your account or email</li>
|
||||
</ul>
|
||||
|
||||
<h3>9.2 By Us</h3>
|
||||
<p>We may terminate accounts for:</p>
|
||||
<ul>
|
||||
<li>Violation of these terms</li>
|
||||
<li>Non-payment (Pro accounts)</li>
|
||||
<li>Extended inactivity (12+ months)</li>
|
||||
<li>Technical abuse or security concerns</li>
|
||||
</ul>
|
||||
|
||||
<div class="warning">
|
||||
<strong>Termination notice:</strong> We will provide reasonable notice except for immediate security threats.
|
||||
</div>
|
||||
|
||||
<h2>10. Intellectual Property</h2>
|
||||
<ul>
|
||||
<li><strong>Service ownership:</strong> DocFast and its technology remain our property</li>
|
||||
<li><strong>Your content:</strong> You retain rights to content you process through our API</li>
|
||||
<li><strong>Generated PDFs:</strong> You own the PDFs generated from your content</li>
|
||||
<li><strong>Feedback:</strong> Any feedback provided may be used to improve the service</li>
|
||||
</ul>
|
||||
|
||||
<h2>11. Governing Law</h2>
|
||||
<ul>
|
||||
<li><strong>Jurisdiction:</strong> These terms are governed by Austrian law</li>
|
||||
<li><strong>Courts:</strong> Disputes resolved in Vienna, Austria</li>
|
||||
<li><strong>Language:</strong> German version prevails in case of translation conflicts</li>
|
||||
<li><strong>EU regulations:</strong> GDPR and other EU laws apply</li>
|
||||
</ul>
|
||||
|
||||
<h2>12. Changes to Terms</h2>
|
||||
<p>We may update these terms by:</p>
|
||||
<ul>
|
||||
<li><strong>Email notification:</strong> For material changes affecting your rights</li>
|
||||
<li><strong>Website posting:</strong> Updated version posted with revision date</li>
|
||||
<li><strong>Continued use:</strong> Using the service after changes constitutes acceptance</li>
|
||||
</ul>
|
||||
|
||||
<h2>13. Contact Information</h2>
|
||||
<p>Questions about these terms:</p>
|
||||
<ul>
|
||||
<li><strong>Email:</strong> <a href="mailto:legal@docfast.dev">legal@docfast.dev</a></li>
|
||||
<li><strong>Company:</strong> Cloonar Technologies GmbH, Vienna, Austria</li>
|
||||
<li><strong>Legal notice:</strong> See <a href="/impressum">Impressum</a> for full company details</li>
|
||||
</ul>
|
||||
|
||||
<div class="highlight">
|
||||
<strong>Effective Date:</strong> These terms are effective immediately upon posting. By using DocFast, you acknowledge reading and agreeing to these terms.
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<footer aria-label="Footer">
|
||||
<div class="container">
|
||||
<div class="footer-left">© 2026 DocFast. Fast PDF generation for developers.</div>
|
||||
<div class="footer-links">
|
||||
<a href="/">Home</a>
|
||||
<a href="/docs">Docs</a>
|
||||
<a href="/health">API Status</a>
|
||||
<a href="/#change-email" class="open-email-change">Change Email</a>
|
||||
<a href="/impressum">Impressum</a>
|
||||
<a href="/privacy">Privacy Policy</a>
|
||||
<a href="/terms">Terms of Service</a>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
162
projects/business/src/pdf-api/scripts/borg-backup.sh
Executable file
162
projects/business/src/pdf-api/scripts/borg-backup.sh
Executable file
|
|
@ -0,0 +1,162 @@
|
|||
#!/bin/bash
|
||||
# DocFast BorgBackup Script - Full Disaster Recovery
|
||||
# Backs up: PostgreSQL, Docker volumes, nginx config, SSL certs, crontabs, OpenDKIM keys
|
||||
# Schedule: daily at 03:00 UTC, keeps 7 daily + 4 weekly + 3 monthly
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
# Configuration
|
||||
BORG_REPO="/opt/borg-backups/docfast"
|
||||
BACKUP_NAME="docfast-$(date +%Y-%m-%d_%H%M)"
|
||||
TEMP_DIR="/tmp/docfast-backup-$$"
|
||||
LOG_FILE="/var/log/docfast-backup.log"
|
||||
|
||||
# Database configuration
|
||||
DB_NAME="docfast"
|
||||
DB_USER="docfast"
|
||||
DB_HOST="localhost"
|
||||
DB_PORT="5432"
|
||||
|
||||
# Logging function
|
||||
log() {
|
||||
echo "$(date '+%Y-%m-%d %H:%M:%S') - $1" | tee -a "$LOG_FILE"
|
||||
}
|
||||
|
||||
# Error handler
|
||||
error_exit() {
|
||||
log "ERROR: $1"
|
||||
cleanup
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Cleanup function
|
||||
cleanup() {
|
||||
if [[ -d "$TEMP_DIR" ]]; then
|
||||
rm -rf "$TEMP_DIR"
|
||||
fi
|
||||
}
|
||||
|
||||
# Trap cleanup on exit
|
||||
trap cleanup EXIT
|
||||
|
||||
log "Starting DocFast backup: $BACKUP_NAME"
|
||||
|
||||
# Create temporary directory
|
||||
mkdir -p "$TEMP_DIR"
|
||||
mkdir -p "$(dirname "$LOG_FILE")"
|
||||
|
||||
# 1. PostgreSQL dump
|
||||
log "Creating PostgreSQL dump..."
|
||||
export PGPASSFILE="/root/.pgpass"
|
||||
pg_dump -h "$DB_HOST" -p "$DB_PORT" -U "$DB_USER" -d "$DB_NAME" \
|
||||
--no-password --verbose --clean --if-exists --format=custom \
|
||||
> "$TEMP_DIR/docfast-db.dump" 2>>"$LOG_FILE" || error_exit "PostgreSQL dump failed"
|
||||
|
||||
# Verify dump is valid
|
||||
if ! pg_restore --list "$TEMP_DIR/docfast-db.dump" >/dev/null 2>&1; then
|
||||
error_exit "PostgreSQL dump verification failed"
|
||||
fi
|
||||
log "PostgreSQL dump completed: $(stat -c%s "$TEMP_DIR/docfast-db.dump") bytes"
|
||||
|
||||
# 2. Docker volumes
|
||||
log "Backing up Docker volumes..."
|
||||
mkdir -p "$TEMP_DIR/docker-volumes"
|
||||
if [[ -d "/var/lib/docker/volumes" ]]; then
|
||||
cp -r /var/lib/docker/volumes/* "$TEMP_DIR/docker-volumes/" || error_exit "Docker volumes backup failed"
|
||||
log "Docker volumes backed up"
|
||||
else
|
||||
log "WARNING: No Docker volumes found"
|
||||
fi
|
||||
|
||||
# 3. Nginx configuration
|
||||
log "Backing up nginx configuration..."
|
||||
mkdir -p "$TEMP_DIR/nginx"
|
||||
cp -r /etc/nginx/* "$TEMP_DIR/nginx/" || error_exit "Nginx backup failed"
|
||||
log "Nginx configuration backed up"
|
||||
|
||||
# 4. SSL certificates
|
||||
log "Backing up SSL certificates..."
|
||||
mkdir -p "$TEMP_DIR/letsencrypt"
|
||||
cp -r /etc/letsencrypt/* "$TEMP_DIR/letsencrypt/" || error_exit "SSL certificates backup failed"
|
||||
log "SSL certificates backed up"
|
||||
|
||||
# 5. Crontabs
|
||||
log "Backing up crontabs..."
|
||||
mkdir -p "$TEMP_DIR/crontabs"
|
||||
if [[ -d "/var/spool/cron/crontabs" ]]; then
|
||||
cp -r /var/spool/cron/crontabs/* "$TEMP_DIR/crontabs/" 2>/dev/null || log "No crontabs found"
|
||||
fi
|
||||
# Also backup user crontabs
|
||||
crontab -l > "$TEMP_DIR/crontabs/root-crontab.txt" 2>/dev/null || echo "# No root crontab" > "$TEMP_DIR/crontabs/root-crontab.txt"
|
||||
log "Crontabs backed up"
|
||||
|
||||
# 6. OpenDKIM keys
|
||||
log "Backing up OpenDKIM keys..."
|
||||
mkdir -p "$TEMP_DIR/opendkim"
|
||||
cp -r /etc/opendkim/* "$TEMP_DIR/opendkim/" || error_exit "OpenDKIM backup failed"
|
||||
log "OpenDKIM keys backed up"
|
||||
|
||||
# 7. DocFast application files (docker-compose, env, scripts)
|
||||
log "Backing up DocFast application files..."
|
||||
mkdir -p "$TEMP_DIR/docfast-app"
|
||||
if [[ -d "/opt/docfast" ]]; then
|
||||
cp /opt/docfast/docker-compose.yml "$TEMP_DIR/docfast-app/" 2>/dev/null || true
|
||||
cp /opt/docfast/.env "$TEMP_DIR/docfast-app/" 2>/dev/null || true
|
||||
cp -r /opt/docfast/scripts "$TEMP_DIR/docfast-app/" 2>/dev/null || true
|
||||
cp -r /opt/docfast/deploy "$TEMP_DIR/docfast-app/" 2>/dev/null || true
|
||||
log "DocFast application files backed up"
|
||||
fi
|
||||
|
||||
# 8. System information
|
||||
log "Creating system information backup..."
|
||||
mkdir -p "$TEMP_DIR/system"
|
||||
systemctl list-unit-files --state=enabled > "$TEMP_DIR/system/enabled-services.txt"
|
||||
dpkg -l > "$TEMP_DIR/system/installed-packages.txt"
|
||||
uname -a > "$TEMP_DIR/system/system-info.txt"
|
||||
df -h > "$TEMP_DIR/system/disk-usage.txt"
|
||||
log "System information backed up"
|
||||
|
||||
# 9. Create Borg backup
|
||||
log "Creating Borg backup..."
|
||||
export BORG_PASSPHRASE="docfast-backup-$(date +%Y)"
|
||||
export BORG_RELOCATED_REPO_ACCESS_IS_OK=yes
|
||||
|
||||
# Initialize repository if it doesn't exist
|
||||
if [[ ! -d "$BORG_REPO" ]]; then
|
||||
log "Initializing new Borg repository..."
|
||||
borg init --encryption=repokey "$BORG_REPO" || error_exit "Failed to initialize Borg repository"
|
||||
fi
|
||||
|
||||
# Create backup
|
||||
log "Creating Borg archive: $BACKUP_NAME"
|
||||
borg create \
|
||||
--verbose \
|
||||
--filter AME \
|
||||
--list \
|
||||
--stats \
|
||||
--show-rc \
|
||||
--compression lz4 \
|
||||
--exclude-caches \
|
||||
"$BORG_REPO::$BACKUP_NAME" \
|
||||
"$TEMP_DIR" 2>>"$LOG_FILE" || error_exit "Borg backup creation failed"
|
||||
|
||||
# 10. Prune old backups (7 daily, 4 weekly, 3 monthly)
|
||||
log "Pruning old backups..."
|
||||
borg prune \
|
||||
--list \
|
||||
--prefix 'docfast-' \
|
||||
--show-rc \
|
||||
--keep-daily 7 \
|
||||
--keep-weekly 4 \
|
||||
--keep-monthly 3 \
|
||||
"$BORG_REPO" 2>>"$LOG_FILE" || error_exit "Borg pruning failed"
|
||||
|
||||
# 11. Compact repository
|
||||
log "Compacting repository..."
|
||||
borg compact "$BORG_REPO" 2>>"$LOG_FILE" || log "WARNING: Repository compaction failed (non-fatal)"
|
||||
|
||||
# 12. Repository info
|
||||
log "Backup completed successfully!"
|
||||
borg info "$BORG_REPO" 2>>"$LOG_FILE"
|
||||
|
||||
log "DocFast backup completed: $BACKUP_NAME"
|
||||
90
projects/business/src/pdf-api/scripts/borg-offsite.sh
Executable file
90
projects/business/src/pdf-api/scripts/borg-offsite.sh
Executable file
|
|
@ -0,0 +1,90 @@
|
|||
#!/bin/bash
|
||||
# DocFast Off-site BorgBackup to Hetzner Storage Box
|
||||
# Runs AFTER local backup completes (cron: 03:30 UTC)
|
||||
# Same data & retention as local: 7 daily + 4 weekly + 3 monthly
|
||||
|
||||
set -uo pipefail
|
||||
|
||||
REMOTE_REPO="ssh://u149513-sub11@u149513-sub11.your-backup.de:23/./docfast-1"
|
||||
BACKUP_NAME="docfast-$(date +%Y-%m-%d_%H%M)"
|
||||
LOG_FILE="/var/log/docfast-backup.log"
|
||||
|
||||
log() {
|
||||
echo "$(date '+%Y-%m-%d %H:%M:%S') - [OFFSITE] $1" | tee -a "$LOG_FILE"
|
||||
}
|
||||
|
||||
export BORG_PASSPHRASE="docfast-backup-$(date +%Y)"
|
||||
export BORG_RELOCATED_REPO_ACCESS_IS_OK=yes
|
||||
export BORG_RSH="ssh -o StrictHostKeyChecking=no"
|
||||
|
||||
# Prepare data (same as local backup script)
|
||||
TEMP_DIR="/tmp/docfast-backup-offsite-$$"
|
||||
mkdir -p "$TEMP_DIR"
|
||||
trap "rm -rf $TEMP_DIR" EXIT
|
||||
|
||||
# PostgreSQL dump
|
||||
log "Dumping PostgreSQL..."
|
||||
export PGPASSFILE="/root/.pgpass"
|
||||
pg_dump -h localhost -p 5432 -U docfast -d docfast \
|
||||
--no-password --clean --if-exists --format=custom \
|
||||
> "$TEMP_DIR/docfast-db.dump" 2>>"$LOG_FILE" || log "WARNING: PostgreSQL dump failed"
|
||||
|
||||
# Docker volumes
|
||||
mkdir -p "$TEMP_DIR/docker-volumes"
|
||||
cp -r /var/lib/docker/volumes/* "$TEMP_DIR/docker-volumes/" 2>/dev/null || true
|
||||
|
||||
# Nginx
|
||||
mkdir -p "$TEMP_DIR/nginx"
|
||||
cp -r /etc/nginx/* "$TEMP_DIR/nginx/" 2>/dev/null || true
|
||||
|
||||
# SSL
|
||||
mkdir -p "$TEMP_DIR/letsencrypt"
|
||||
cp -r /etc/letsencrypt/* "$TEMP_DIR/letsencrypt/" 2>/dev/null || true
|
||||
|
||||
# Crontabs
|
||||
mkdir -p "$TEMP_DIR/crontabs"
|
||||
cp -r /var/spool/cron/crontabs/* "$TEMP_DIR/crontabs/" 2>/dev/null || true
|
||||
crontab -l > "$TEMP_DIR/crontabs/root-crontab.txt" 2>/dev/null || true
|
||||
|
||||
# OpenDKIM
|
||||
mkdir -p "$TEMP_DIR/opendkim"
|
||||
cp -r /etc/opendkim/* "$TEMP_DIR/opendkim/" 2>/dev/null || true
|
||||
|
||||
# App files
|
||||
mkdir -p "$TEMP_DIR/docfast-app"
|
||||
cp /opt/docfast/docker-compose.yml "$TEMP_DIR/docfast-app/" 2>/dev/null || true
|
||||
cp /opt/docfast/.env "$TEMP_DIR/docfast-app/" 2>/dev/null || true
|
||||
cp -r /opt/docfast/scripts "$TEMP_DIR/docfast-app/" 2>/dev/null || true
|
||||
cp -r /opt/docfast/deploy "$TEMP_DIR/docfast-app/" 2>/dev/null || true
|
||||
|
||||
# System info
|
||||
mkdir -p "$TEMP_DIR/system"
|
||||
systemctl list-unit-files --state=enabled > "$TEMP_DIR/system/enabled-services.txt" 2>/dev/null || true
|
||||
dpkg -l > "$TEMP_DIR/system/installed-packages.txt" 2>/dev/null || true
|
||||
|
||||
log "Starting off-site backup: $BACKUP_NAME"
|
||||
|
||||
# Create remote backup
|
||||
borg create \
|
||||
--stats \
|
||||
--compression lz4 \
|
||||
--exclude-caches \
|
||||
"$REMOTE_REPO::$BACKUP_NAME" \
|
||||
"$TEMP_DIR" 2>>"$LOG_FILE" || { log "ERROR: Off-site backup creation failed"; exit 1; }
|
||||
|
||||
log "Off-site backup created, pruning..."
|
||||
|
||||
# Prune (same retention as local)
|
||||
borg prune \
|
||||
--list \
|
||||
--prefix 'docfast-' \
|
||||
--keep-daily 7 \
|
||||
--keep-weekly 4 \
|
||||
--keep-monthly 3 \
|
||||
"$REMOTE_REPO" 2>>"$LOG_FILE" || log "WARNING: Off-site prune failed"
|
||||
|
||||
# Compact
|
||||
borg compact "$REMOTE_REPO" 2>>"$LOG_FILE" || true
|
||||
|
||||
log "Off-site backup completed: $BACKUP_NAME"
|
||||
borg info "$REMOTE_REPO" 2>>"$LOG_FILE"
|
||||
150
projects/business/src/pdf-api/scripts/borg-restore.sh
Executable file
150
projects/business/src/pdf-api/scripts/borg-restore.sh
Executable file
|
|
@ -0,0 +1,150 @@
|
|||
#!/bin/bash
|
||||
# DocFast BorgBackup Restore Script
|
||||
# Restores from Borg backup for disaster recovery
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
# Configuration
|
||||
BORG_REPO="/opt/borg-backups/docfast"
|
||||
RESTORE_DIR="/tmp/docfast-restore-$$"
|
||||
LOG_FILE="/var/log/docfast-restore.log"
|
||||
|
||||
# Usage function
|
||||
usage() {
|
||||
echo "Usage: $0 [list|restore] [archive-name]"
|
||||
echo " list - List available archives"
|
||||
echo " restore <archive-name> - Restore specific archive"
|
||||
echo " restore latest - Restore latest archive"
|
||||
echo ""
|
||||
echo "Examples:"
|
||||
echo " $0 list"
|
||||
echo " $0 restore docfast-2026-02-15_0300"
|
||||
echo " $0 restore latest"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Logging function
|
||||
log() {
|
||||
echo "$(date '+%Y-%m-%d %H:%M:%S') - $1" | tee -a "$LOG_FILE"
|
||||
}
|
||||
|
||||
# Error handler
|
||||
error_exit() {
|
||||
log "ERROR: $1"
|
||||
cleanup
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Cleanup function
|
||||
cleanup() {
|
||||
if [[ -d "$RESTORE_DIR" ]]; then
|
||||
log "Cleaning up temporary directory: $RESTORE_DIR"
|
||||
rm -rf "$RESTORE_DIR"
|
||||
fi
|
||||
}
|
||||
|
||||
# Trap cleanup on exit
|
||||
trap cleanup EXIT
|
||||
|
||||
# Check if repository exists
|
||||
if [[ ! -d "$BORG_REPO" ]]; then
|
||||
error_exit "Borg repository not found: $BORG_REPO"
|
||||
fi
|
||||
|
||||
# Set up environment
|
||||
export BORG_PASSPHRASE="docfast-backup-$(date +%Y)"
|
||||
export BORG_RELOCATED_REPO_ACCESS_IS_OK=yes
|
||||
mkdir -p "$(dirname "$LOG_FILE")"
|
||||
|
||||
# Parse command line
|
||||
case "${1:-}" in
|
||||
"list")
|
||||
log "Listing available archives..."
|
||||
borg list "$BORG_REPO"
|
||||
exit 0
|
||||
;;
|
||||
"restore")
|
||||
ARCHIVE_NAME="${2:-}"
|
||||
if [[ -z "$ARCHIVE_NAME" ]]; then
|
||||
usage
|
||||
fi
|
||||
|
||||
if [[ "$ARCHIVE_NAME" == "latest" ]]; then
|
||||
log "Finding latest archive..."
|
||||
ARCHIVE_NAME=$(borg list --short "$BORG_REPO" | grep "^docfast-" | tail -1)
|
||||
if [[ -z "$ARCHIVE_NAME" ]]; then
|
||||
error_exit "No archives found in repository"
|
||||
fi
|
||||
log "Latest archive found: $ARCHIVE_NAME"
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
usage
|
||||
;;
|
||||
esac
|
||||
|
||||
log "Starting restore of archive: $ARCHIVE_NAME"
|
||||
|
||||
# Verify archive exists
|
||||
if ! borg list "$BORG_REPO::$ARCHIVE_NAME" >/dev/null 2>&1; then
|
||||
error_exit "Archive not found: $ARCHIVE_NAME"
|
||||
fi
|
||||
|
||||
# Create restore directory
|
||||
mkdir -p "$RESTORE_DIR"
|
||||
log "Restoring to temporary directory: $RESTORE_DIR"
|
||||
|
||||
# Extract archive
|
||||
log "Extracting archive..."
|
||||
cd "$RESTORE_DIR"
|
||||
borg extract --verbose --list "$BORG_REPO::$ARCHIVE_NAME"
|
||||
|
||||
log "Archive extracted successfully. Restore data available at: $RESTORE_DIR"
|
||||
echo ""
|
||||
echo "RESTORE LOCATIONS:"
|
||||
echo "=================="
|
||||
echo "PostgreSQL dump: $RESTORE_DIR/tmp/docfast-backup-*/docfast-db.dump"
|
||||
echo "Docker volumes: $RESTORE_DIR/tmp/docfast-backup-*/docker-volumes/"
|
||||
echo "Nginx config: $RESTORE_DIR/tmp/docfast-backup-*/nginx/"
|
||||
echo "SSL certificates: $RESTORE_DIR/tmp/docfast-backup-*/letsencrypt/"
|
||||
echo "Crontabs: $RESTORE_DIR/tmp/docfast-backup-*/crontabs/"
|
||||
echo "OpenDKIM keys: $RESTORE_DIR/tmp/docfast-backup-*/opendkim/"
|
||||
echo "DocFast app files: $RESTORE_DIR/tmp/docfast-backup-*/docfast-app/"
|
||||
echo "System info: $RESTORE_DIR/tmp/docfast-backup-*/system/"
|
||||
echo ""
|
||||
echo "MANUAL RESTORE STEPS:"
|
||||
echo "====================="
|
||||
echo "1. Stop DocFast service:"
|
||||
echo " systemctl stop docker"
|
||||
echo ""
|
||||
echo "2. Restore PostgreSQL database:"
|
||||
echo " sudo -u postgres dropdb docfast"
|
||||
echo " sudo -u postgres createdb -O docfast docfast"
|
||||
echo " sudo -u postgres pg_restore -d docfast $RESTORE_DIR/tmp/docfast-backup-*/docfast-db.dump"
|
||||
echo ""
|
||||
echo "3. Restore Docker volumes:"
|
||||
echo " cp -r $RESTORE_DIR/tmp/docfast-backup-*/docker-volumes/* /var/lib/docker/volumes/"
|
||||
echo ""
|
||||
echo "4. Restore configuration files:"
|
||||
echo " cp -r $RESTORE_DIR/tmp/docfast-backup-*/nginx/* /etc/nginx/"
|
||||
echo " cp -r $RESTORE_DIR/tmp/docfast-backup-*/letsencrypt/* /etc/letsencrypt/"
|
||||
echo " cp -r $RESTORE_DIR/tmp/docfast-backup-*/opendkim/* /etc/opendkim/"
|
||||
echo " cp -r $RESTORE_DIR/tmp/docfast-backup-*/docfast-app/* /opt/docfast/"
|
||||
echo ""
|
||||
echo "5. Restore crontabs:"
|
||||
echo " cp $RESTORE_DIR/tmp/docfast-backup-*/crontabs/root /var/spool/cron/crontabs/root"
|
||||
echo " chmod 600 /var/spool/cron/crontabs/root"
|
||||
echo ""
|
||||
echo "6. Set correct permissions:"
|
||||
echo " chown -R opendkim:opendkim /etc/opendkim/keys"
|
||||
echo " chown -R postgres:postgres /var/lib/postgresql"
|
||||
echo ""
|
||||
echo "7. Start services:"
|
||||
echo " systemctl start postgresql"
|
||||
echo " systemctl start docker"
|
||||
echo " cd /opt/docfast && docker-compose up -d"
|
||||
echo ""
|
||||
echo "WARNING: This script does NOT automatically restore files to prevent"
|
||||
echo "accidental overwrites. Follow the manual steps above carefully."
|
||||
|
||||
log "Restore extraction completed. Follow manual steps to complete restoration."
|
||||
70
projects/business/src/pdf-api/scripts/build-pages.js
Normal file
70
projects/business/src/pdf-api/scripts/build-pages.js
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
#!/usr/bin/env node
|
||||
/**
|
||||
* Build-time HTML templating system for DocFast.
|
||||
* No dependencies — uses only Node.js built-ins.
|
||||
*
|
||||
* - Reads page sources from templates/pages/*.html
|
||||
* - Reads partials from templates/partials/*.html
|
||||
* - Replaces {{> partial_name}} with partial content
|
||||
* - Supports {{title}} variable (set via <!-- title: Page Title --> comment at top)
|
||||
* - Writes output to public/
|
||||
*/
|
||||
|
||||
import { readFileSync, writeFileSync, readdirSync, mkdirSync } from 'node:fs';
|
||||
import { join, basename } from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
const __dirname = fileURLToPath(new URL('.', import.meta.url));
|
||||
const ROOT = join(__dirname, '..');
|
||||
const PAGES_DIR = join(ROOT, 'templates', 'pages');
|
||||
const PARTIALS_DIR = join(ROOT, 'templates', 'partials');
|
||||
const OUTPUT_DIR = join(ROOT, 'public');
|
||||
|
||||
// Load all partials
|
||||
const partials = {};
|
||||
for (const file of readdirSync(PARTIALS_DIR)) {
|
||||
if (!file.endsWith('.html')) continue;
|
||||
const name = file.replace('.html', '');
|
||||
partials[name] = readFileSync(join(PARTIALS_DIR, file), 'utf-8');
|
||||
}
|
||||
|
||||
console.log(`Loaded ${Object.keys(partials).length} partials: ${Object.keys(partials).join(', ')}`);
|
||||
|
||||
// Process each page
|
||||
const pages = readdirSync(PAGES_DIR).filter(f => f.endsWith('.html'));
|
||||
console.log(`Processing ${pages.length} pages...`);
|
||||
|
||||
for (const file of pages) {
|
||||
let content = readFileSync(join(PAGES_DIR, file), 'utf-8');
|
||||
|
||||
// Extract title from <!-- title: ... --> comment
|
||||
let title = '';
|
||||
const titleMatch = content.match(/^<!--\s*title:\s*(.+?)\s*-->/);
|
||||
if (titleMatch) {
|
||||
title = titleMatch[1];
|
||||
// Remove the title comment from output
|
||||
content = content.replace(/^<!--\s*title:.+?-->\n?/, '');
|
||||
}
|
||||
|
||||
// Replace {{> partial_name}} with partial content (support nested partials)
|
||||
let maxDepth = 5;
|
||||
while (maxDepth-- > 0 && content.includes('{{>')) {
|
||||
content = content.replace(/\{\{>\s*([a-zA-Z0-9_-]+)\s*\}\}/g, (match, name) => {
|
||||
if (!(name in partials)) {
|
||||
console.warn(` Warning: partial "${name}" not found in ${file}`);
|
||||
return match;
|
||||
}
|
||||
return partials[name];
|
||||
});
|
||||
}
|
||||
|
||||
// Replace {{title}} variable
|
||||
content = content.replace(/\{\{title\}\}/g, title);
|
||||
|
||||
// Write output
|
||||
const outPath = join(OUTPUT_DIR, file);
|
||||
writeFileSync(outPath, content);
|
||||
console.log(` ✓ ${file} (${(content.length / 1024).toFixed(1)}KB)`);
|
||||
}
|
||||
|
||||
console.log('Done!');
|
||||
49
projects/business/src/pdf-api/scripts/docfast-backup.sh
Executable file
49
projects/business/src/pdf-api/scripts/docfast-backup.sh
Executable file
|
|
@ -0,0 +1,49 @@
|
|||
#!/bin/bash
|
||||
# DocFast SQLite Backup Script
|
||||
# Runs every 6 hours via cron. Keeps 7 daily + 4 weekly backups.
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
BACKUP_DIR="/opt/docfast-backups"
|
||||
DB_PATH="/var/lib/docker/volumes/docfast_docfast-data/_data/docfast.db"
|
||||
DATE=$(date +%Y-%m-%d_%H%M)
|
||||
DAY_OF_WEEK=$(date +%u) # 1=Monday, 7=Sunday
|
||||
|
||||
mkdir -p "$BACKUP_DIR"
|
||||
|
||||
# Check if database exists
|
||||
if [[ ! -f "$DB_PATH" ]]; then
|
||||
echo "ERROR: Database not found at $DB_PATH" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Safe hot backup using sqlite3 .backup
|
||||
DAILY_FILE="$BACKUP_DIR/docfast-daily-${DATE}.db"
|
||||
sqlite3 "$DB_PATH" ".backup '$DAILY_FILE'"
|
||||
|
||||
# Verify backup is valid
|
||||
if ! sqlite3 "$DAILY_FILE" "PRAGMA integrity_check;" | grep -q "^ok$"; then
|
||||
echo "ERROR: Backup integrity check failed!" >&2
|
||||
rm -f "$DAILY_FILE"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Created backup: $DAILY_FILE ($(stat -c%s "$DAILY_FILE") bytes)"
|
||||
|
||||
# On Sundays, also keep a weekly copy
|
||||
if [ "$DAY_OF_WEEK" -eq 7 ]; then
|
||||
WEEKLY_FILE="$BACKUP_DIR/docfast-weekly-$(date +%Y-%m-%d).db"
|
||||
cp "$DAILY_FILE" "$WEEKLY_FILE"
|
||||
echo "Created weekly backup: $WEEKLY_FILE"
|
||||
fi
|
||||
|
||||
# Rotate: keep last 7 daily backups (28 files at 6h intervals = ~7 days)
|
||||
find "$BACKUP_DIR" -name "docfast-daily-*.db" -type f | sort -r | tail -n +29 | xargs -r rm -f
|
||||
|
||||
# Rotate: keep last 4 weekly backups
|
||||
find "$BACKUP_DIR" -name "docfast-weekly-*.db" -type f | sort -r | tail -n +5 | xargs -r rm -f || true
|
||||
|
||||
# Show current backup status
|
||||
DAILY_COUNT=$(find "$BACKUP_DIR" -name "docfast-daily-*.db" -type f | wc -l)
|
||||
WEEKLY_COUNT=$(find "$BACKUP_DIR" -name "docfast-weekly-*.db" -type f | wc -l)
|
||||
echo "Backup rotation complete. Daily: $DAILY_COUNT, Weekly: $WEEKLY_COUNT"
|
||||
143
projects/business/src/pdf-api/scripts/migrate-to-postgres.mjs
Normal file
143
projects/business/src/pdf-api/scripts/migrate-to-postgres.mjs
Normal file
|
|
@ -0,0 +1,143 @@
|
|||
#!/usr/bin/env node
|
||||
/**
|
||||
* Migration script: JSON files → PostgreSQL
|
||||
* Run on the server where JSON data files exist.
|
||||
* Usage: DATABASE_PASSWORD=docfast node scripts/migrate-to-postgres.mjs
|
||||
*/
|
||||
import pg from "pg";
|
||||
import { readFileSync, existsSync } from "fs";
|
||||
|
||||
const { Pool } = pg;
|
||||
|
||||
const pool = new Pool({
|
||||
host: process.env.DATABASE_HOST || "127.0.0.1",
|
||||
port: parseInt(process.env.DATABASE_PORT || "5432", 10),
|
||||
database: process.env.DATABASE_NAME || "docfast",
|
||||
user: process.env.DATABASE_USER || "docfast",
|
||||
password: process.env.DATABASE_PASSWORD || "docfast",
|
||||
});
|
||||
|
||||
async function migrate() {
|
||||
const client = await pool.connect();
|
||||
try {
|
||||
// Create tables
|
||||
await client.query(`
|
||||
CREATE TABLE IF NOT EXISTS api_keys (
|
||||
key TEXT PRIMARY KEY,
|
||||
tier TEXT NOT NULL DEFAULT 'free',
|
||||
email TEXT NOT NULL DEFAULT '',
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
stripe_customer_id TEXT
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS idx_api_keys_email ON api_keys(email);
|
||||
CREATE INDEX IF NOT EXISTS idx_api_keys_stripe ON api_keys(stripe_customer_id);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS verifications (
|
||||
id SERIAL PRIMARY KEY,
|
||||
email TEXT NOT NULL,
|
||||
token TEXT NOT NULL UNIQUE,
|
||||
api_key TEXT NOT NULL,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
verified_at TIMESTAMPTZ
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS idx_verifications_email ON verifications(email);
|
||||
CREATE INDEX IF NOT EXISTS idx_verifications_token ON verifications(token);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS pending_verifications (
|
||||
email TEXT PRIMARY KEY,
|
||||
code TEXT NOT NULL,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
expires_at TIMESTAMPTZ NOT NULL,
|
||||
attempts INT NOT NULL DEFAULT 0
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS usage (
|
||||
key TEXT PRIMARY KEY,
|
||||
count INT NOT NULL DEFAULT 0,
|
||||
month_key TEXT NOT NULL
|
||||
);
|
||||
`);
|
||||
console.log("✅ Tables created");
|
||||
|
||||
// Migrate keys.json
|
||||
const keysPath = "/opt/docfast/data/keys.json";
|
||||
if (existsSync(keysPath)) {
|
||||
const keysData = JSON.parse(readFileSync(keysPath, "utf-8"));
|
||||
const keys = keysData.keys || [];
|
||||
let keyCount = 0;
|
||||
for (const k of keys) {
|
||||
await client.query(
|
||||
`INSERT INTO api_keys (key, tier, email, created_at, stripe_customer_id)
|
||||
VALUES ($1, $2, $3, $4, $5) ON CONFLICT (key) DO NOTHING`,
|
||||
[k.key, k.tier, k.email || "", k.createdAt, k.stripeCustomerId || null]
|
||||
);
|
||||
keyCount++;
|
||||
}
|
||||
console.log(`✅ Migrated ${keyCount} API keys`);
|
||||
} else {
|
||||
// Try docker volume path
|
||||
console.log("⚠️ keys.json not found at", keysPath);
|
||||
}
|
||||
|
||||
// Migrate verifications.json
|
||||
const verifPath = "/opt/docfast/data/verifications.json";
|
||||
if (existsSync(verifPath)) {
|
||||
const data = JSON.parse(readFileSync(verifPath, "utf-8"));
|
||||
const verifications = Array.isArray(data) ? data : (data.verifications || []);
|
||||
const pending = data.pendingVerifications || [];
|
||||
|
||||
let vCount = 0;
|
||||
for (const v of verifications) {
|
||||
await client.query(
|
||||
`INSERT INTO verifications (email, token, api_key, created_at, verified_at)
|
||||
VALUES ($1, $2, $3, $4, $5) ON CONFLICT (token) DO NOTHING`,
|
||||
[v.email, v.token, v.apiKey, v.createdAt, v.verifiedAt || null]
|
||||
);
|
||||
vCount++;
|
||||
}
|
||||
console.log(`✅ Migrated ${vCount} verifications`);
|
||||
|
||||
let pCount = 0;
|
||||
for (const p of pending) {
|
||||
await client.query(
|
||||
`INSERT INTO pending_verifications (email, code, created_at, expires_at, attempts)
|
||||
VALUES ($1, $2, $3, $4, $5) ON CONFLICT (email) DO NOTHING`,
|
||||
[p.email, p.code, p.createdAt, p.expiresAt, p.attempts]
|
||||
);
|
||||
pCount++;
|
||||
}
|
||||
console.log(`✅ Migrated ${pCount} pending verifications`);
|
||||
} else {
|
||||
console.log("⚠️ verifications.json not found at", verifPath);
|
||||
}
|
||||
|
||||
// Migrate usage.json
|
||||
const usagePath = "/opt/docfast/data/usage.json";
|
||||
if (existsSync(usagePath)) {
|
||||
const usageData = JSON.parse(readFileSync(usagePath, "utf-8"));
|
||||
let uCount = 0;
|
||||
for (const [key, record] of Object.entries(usageData)) {
|
||||
const r = /** @type {any} */ (record);
|
||||
await client.query(
|
||||
`INSERT INTO usage (key, count, month_key)
|
||||
VALUES ($1, $2, $3) ON CONFLICT (key) DO UPDATE SET count = $2, month_key = $3`,
|
||||
[key, r.count, r.monthKey]
|
||||
);
|
||||
uCount++;
|
||||
}
|
||||
console.log(`✅ Migrated ${uCount} usage records`);
|
||||
} else {
|
||||
console.log("⚠️ usage.json not found at", usagePath);
|
||||
}
|
||||
|
||||
console.log("\n🎉 Migration complete!");
|
||||
} finally {
|
||||
client.release();
|
||||
await pool.end();
|
||||
}
|
||||
}
|
||||
|
||||
migrate().catch((err) => {
|
||||
console.error("Migration failed:", err);
|
||||
process.exit(1);
|
||||
});
|
||||
72
projects/business/src/pdf-api/scripts/rollback.sh
Executable file
72
projects/business/src/pdf-api/scripts/rollback.sh
Executable file
|
|
@ -0,0 +1,72 @@
|
|||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
echo "🔄 DocFast Rollback Script"
|
||||
echo "=========================="
|
||||
|
||||
# Check if we're on the server
|
||||
if [ ! -d "/root/docfast" ]; then
|
||||
echo "❌ This script should be run on the production server"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cd /root/docfast
|
||||
|
||||
# List available rollback images
|
||||
echo "📋 Available rollback images:"
|
||||
ROLLBACK_IMAGES=$(docker images --format "table {{.Repository}}:{{.Tag}}\t{{.CreatedAt}}" | grep "docfast-docfast:rollback-" | head -10)
|
||||
|
||||
if [ -z "$ROLLBACK_IMAGES" ]; then
|
||||
echo "❌ No rollback images available"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "$ROLLBACK_IMAGES"
|
||||
echo ""
|
||||
|
||||
# Get the most recent rollback image
|
||||
LATEST_ROLLBACK=$(docker images --format "{{.Repository}}:{{.Tag}}" | grep "docfast-docfast:rollback-" | head -n1)
|
||||
|
||||
if [ -z "$LATEST_ROLLBACK" ]; then
|
||||
echo "❌ No rollback image found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "🎯 Will rollback to: $LATEST_ROLLBACK"
|
||||
echo ""
|
||||
|
||||
# Confirm rollback
|
||||
read -p "⚠️ Are you sure you want to rollback? (y/N): " -n 1 -r
|
||||
echo
|
||||
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
|
||||
echo "❌ Rollback cancelled"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "🛑 Stopping current services..."
|
||||
docker compose down --timeout 30
|
||||
|
||||
echo "🔄 Rolling back to $LATEST_ROLLBACK..."
|
||||
docker tag $LATEST_ROLLBACK docfast-docfast:latest
|
||||
|
||||
echo "▶️ Starting services..."
|
||||
docker compose up -d
|
||||
|
||||
echo "⏱️ Waiting for service to be ready..."
|
||||
for i in {1..20}; do
|
||||
if curl -f -s http://127.0.0.1:3100/health > /dev/null; then
|
||||
echo "✅ Rollback successful! Service is healthy."
|
||||
break
|
||||
fi
|
||||
if [ $i -eq 20 ]; then
|
||||
echo "❌ Rollback failed - service is not responding"
|
||||
exit 1
|
||||
fi
|
||||
echo "⏳ Attempt $i/20 - waiting 3 seconds..."
|
||||
sleep 3
|
||||
done
|
||||
|
||||
echo "📊 Service status:"
|
||||
docker compose ps
|
||||
|
||||
echo "🎉 Rollback completed successfully!"
|
||||
41
projects/business/src/pdf-api/scripts/setup-secrets.sh
Executable file
41
projects/business/src/pdf-api/scripts/setup-secrets.sh
Executable file
|
|
@ -0,0 +1,41 @@
|
|||
#!/bin/bash
|
||||
|
||||
echo "🔐 Forgejo Repository Secrets Setup"
|
||||
echo "===================================="
|
||||
|
||||
# Source credentials to get Forgejo token
|
||||
source /home/openclaw/.openclaw/workspace/.credentials/docfast.env
|
||||
|
||||
# Repository secrets to set up
|
||||
REPO_URL="https://git.cloonar.com/api/v1/repos/openclawd/docfast/actions/secrets"
|
||||
|
||||
echo "Setting up repository secrets for CI/CD..."
|
||||
|
||||
# Server host
|
||||
echo "📡 Setting SERVER_HOST..."
|
||||
curl -X PUT "$REPO_URL/SERVER_HOST" \
|
||||
-H "Authorization: token $FORGEJO_TOKEN" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"data":"167.235.156.214"}' \
|
||||
--silent
|
||||
|
||||
# Server user
|
||||
echo "👤 Setting SERVER_USER..."
|
||||
curl -X PUT "$REPO_URL/SERVER_USER" \
|
||||
-H "Authorization: token $FORGEJO_TOKEN" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"data":"root"}' \
|
||||
--silent
|
||||
|
||||
# SSH Private Key
|
||||
echo "🔑 Setting SSH_PRIVATE_KEY..."
|
||||
SSH_KEY_CONTENT=$(cat /home/openclaw/.ssh/docfast | jq -Rs .)
|
||||
curl -X PUT "$REPO_URL/SSH_PRIVATE_KEY" \
|
||||
-H "Authorization: token $FORGEJO_TOKEN" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{\"data\":$SSH_KEY_CONTENT}" \
|
||||
--silent
|
||||
|
||||
echo "✅ Repository secrets have been configured!"
|
||||
echo ""
|
||||
echo "🔍 To verify, check: https://git.cloonar.com/openclawd/docfast/settings/actions/secrets"
|
||||
37
projects/business/src/pdf-api/sessions.md
Normal file
37
projects/business/src/pdf-api/sessions.md
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
# DocFast Sessions Log
|
||||
|
||||
## 2026-02-14 22:14 UTC — Deployment + QA Session
|
||||
|
||||
**Trigger:** Latest code changes (Swagger UI, key recovery UI, email change) were not deployed despite being in the working tree.
|
||||
|
||||
**Actions:**
|
||||
1. SSH'd into server (167.235.156.214)
|
||||
2. Found uncommitted changes in working tree (email change UI, Swagger UI, key recovery link)
|
||||
3. Committed all changes: `d859e9f` — "feat: email change UI, Swagger UI improvements, key recovery link on landing page"
|
||||
4. Pushed to Forgejo (openclawd/docfast)
|
||||
5. Rebuilt container with `docker compose build --no-cache`
|
||||
6. Restarted: `docker compose up -d`
|
||||
7. Verified server healthy: 15-page browser pool, version 0.2.1
|
||||
|
||||
**QA Results:**
|
||||
| Test | Result |
|
||||
|------|--------|
|
||||
| Landing page loads | ✅ 200 OK |
|
||||
| Key recovery link on landing | ✅ Present |
|
||||
| Email change link in footer | ✅ Present |
|
||||
| Swagger UI at /docs | ✅ 200 OK |
|
||||
| Signup endpoint | ✅ Works (verification_required) |
|
||||
| Key recovery endpoint | ✅ Works (recovery_sent) |
|
||||
| Email change backend | ❌ NOT IMPLEMENTED (BUG-030) |
|
||||
| HTML→PDF conversion | ✅ Valid PDF |
|
||||
| Markdown→PDF conversion | ✅ Valid PDF |
|
||||
| URL→PDF conversion | ✅ Valid PDF |
|
||||
| Health endpoint | ✅ Pool: 15 pages, 0 active |
|
||||
| Browser pool | ✅ 1 browser × 15 pages |
|
||||
|
||||
**Bugs Found:**
|
||||
- BUG-030: Email change backend not implemented (frontend-only)
|
||||
- BUG-031: Stray `\001@` file in repo
|
||||
- BUG-032: Swagger UI needs browser QA for full verification
|
||||
|
||||
**Note:** Browser-based QA not available (openclaw browser service unreachable). Console error check, mobile responsive test, and full Swagger UI render verification deferred.
|
||||
|
|
@ -1,4 +1,7 @@
|
|||
import express from "express";
|
||||
import { randomUUID } from "crypto";
|
||||
import compression from "compression";
|
||||
import logger from "./services/logger.js";
|
||||
import helmet from "helmet";
|
||||
import path from "path";
|
||||
import { fileURLToPath } from "url";
|
||||
|
|
@ -7,37 +10,71 @@ import { convertRouter } from "./routes/convert.js";
|
|||
import { templatesRouter } from "./routes/templates.js";
|
||||
import { healthRouter } from "./routes/health.js";
|
||||
import { signupRouter } from "./routes/signup.js";
|
||||
import { recoverRouter } from "./routes/recover.js";
|
||||
import { billingRouter } from "./routes/billing.js";
|
||||
import { emailChangeRouter } from "./routes/email-change.js";
|
||||
import { authMiddleware } from "./middleware/auth.js";
|
||||
import { usageMiddleware } from "./middleware/usage.js";
|
||||
import { usageMiddleware, loadUsageData } from "./middleware/usage.js";
|
||||
import { getUsageStats } from "./middleware/usage.js";
|
||||
import { pdfRateLimitMiddleware, getConcurrencyStats } from "./middleware/pdfRateLimit.js";
|
||||
import { initBrowser, closeBrowser } from "./services/browser.js";
|
||||
import { loadKeys, getAllKeys } from "./services/keys.js";
|
||||
import { verifyToken, loadVerifications } from "./services/verification.js";
|
||||
import { initDatabase, pool } from "./services/db.js";
|
||||
|
||||
const app = express();
|
||||
const PORT = parseInt(process.env.PORT || "3100", 10);
|
||||
|
||||
// Load API keys from persistent store
|
||||
loadKeys();
|
||||
app.use(helmet({ crossOriginResourcePolicy: { policy: "cross-origin" } }));
|
||||
|
||||
app.use(helmet());
|
||||
|
||||
// CORS — allow browser requests from the landing page
|
||||
// Request ID + request logging middleware
|
||||
app.use((req, res, next) => {
|
||||
const origin = req.headers.origin;
|
||||
const allowed = ["https://docfast.dev", "http://localhost:3100"];
|
||||
if (origin && allowed.includes(origin)) {
|
||||
res.setHeader("Access-Control-Allow-Origin", origin);
|
||||
const requestId = (req.headers["x-request-id"] as string) || randomUUID();
|
||||
(req as any).requestId = requestId;
|
||||
res.setHeader("X-Request-Id", requestId);
|
||||
const start = Date.now();
|
||||
res.on("finish", () => {
|
||||
const ms = Date.now() - start;
|
||||
if (req.path !== "/health") {
|
||||
logger.info({ method: req.method, path: req.path, status: res.statusCode, ms, requestId }, "request");
|
||||
}
|
||||
});
|
||||
next();
|
||||
});
|
||||
|
||||
// Permissions-Policy header
|
||||
app.use((_req, res, next) => {
|
||||
res.setHeader("Permissions-Policy", "camera=(), microphone=(), geolocation=(), payment=(self)");
|
||||
next();
|
||||
});
|
||||
|
||||
// Compression
|
||||
app.use(compression());
|
||||
|
||||
// Differentiated CORS middleware
|
||||
app.use((req, res, next) => {
|
||||
const isAuthBillingRoute = req.path.startsWith('/v1/signup') ||
|
||||
req.path.startsWith('/v1/recover') ||
|
||||
req.path.startsWith('/v1/billing') ||
|
||||
req.path.startsWith('/v1/email-change');
|
||||
|
||||
if (isAuthBillingRoute) {
|
||||
res.setHeader("Access-Control-Allow-Origin", "https://docfast.dev");
|
||||
} else {
|
||||
res.setHeader("Access-Control-Allow-Origin", "*");
|
||||
}
|
||||
|
||||
res.setHeader("Access-Control-Allow-Methods", "GET, POST, OPTIONS");
|
||||
res.setHeader("Access-Control-Allow-Headers", "Content-Type, Authorization, X-API-Key");
|
||||
res.setHeader("Access-Control-Max-Age", "86400");
|
||||
|
||||
if (req.method === "OPTIONS") {
|
||||
res.status(204).end();
|
||||
return;
|
||||
}
|
||||
next();
|
||||
});
|
||||
|
||||
// Raw body for Stripe webhook signature verification
|
||||
app.use("/v1/billing/webhook", express.raw({ type: "application/json" }));
|
||||
app.use(express.json({ limit: "2mb" }));
|
||||
|
|
@ -46,7 +83,7 @@ app.use(express.text({ limit: "2mb", type: "text/*" }));
|
|||
// Trust nginx proxy
|
||||
app.set("trust proxy", 1);
|
||||
|
||||
// Rate limiting
|
||||
// Global rate limiting - reduced from 10,000 to reasonable limit
|
||||
const limiter = rateLimit({
|
||||
windowMs: 60_000,
|
||||
max: 100,
|
||||
|
|
@ -58,31 +95,126 @@ app.use(limiter);
|
|||
// Public routes
|
||||
app.use("/health", healthRouter);
|
||||
app.use("/v1/signup", signupRouter);
|
||||
app.use("/v1/recover", recoverRouter);
|
||||
app.use("/v1/billing", billingRouter);
|
||||
app.use("/v1/email-change", emailChangeRouter);
|
||||
|
||||
// Authenticated routes
|
||||
app.use("/v1/convert", authMiddleware, usageMiddleware, convertRouter);
|
||||
app.use("/v1/convert", authMiddleware, usageMiddleware, pdfRateLimitMiddleware, convertRouter);
|
||||
app.use("/v1/templates", authMiddleware, usageMiddleware, templatesRouter);
|
||||
|
||||
// Admin: usage stats
|
||||
app.get("/v1/usage", authMiddleware, (_req, res) => {
|
||||
res.json(getUsageStats());
|
||||
app.get("/v1/usage", authMiddleware, (req: any, res) => {
|
||||
res.json(getUsageStats(req.apiKeyInfo?.key));
|
||||
});
|
||||
|
||||
// Admin: concurrency stats
|
||||
app.get("/v1/concurrency", authMiddleware, (_req, res) => {
|
||||
res.json(getConcurrencyStats());
|
||||
});
|
||||
|
||||
// Email verification endpoint
|
||||
app.get("/verify", (req, res) => {
|
||||
const token = req.query.token as string;
|
||||
if (!token) {
|
||||
res.status(400).send(verifyPage("Invalid Link", "No verification token provided.", null));
|
||||
return;
|
||||
}
|
||||
|
||||
const result = verifyToken(token);
|
||||
|
||||
switch (result.status) {
|
||||
case "ok":
|
||||
res.send(verifyPage("Email Verified! 🚀", "Your DocFast API key is ready:", result.verification!.apiKey));
|
||||
break;
|
||||
case "already_verified":
|
||||
res.send(verifyPage("Already Verified", "This email was already verified. Here's your API key:", result.verification!.apiKey));
|
||||
break;
|
||||
case "expired":
|
||||
res.status(410).send(verifyPage("Link Expired", "This verification link has expired (24h). Please sign up again.", null));
|
||||
break;
|
||||
case "invalid":
|
||||
res.status(404).send(verifyPage("Invalid Link", "This verification link is not valid.", null));
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
function verifyPage(title: string, message: string, apiKey: string | null): string {
|
||||
return `<!DOCTYPE html>
|
||||
<html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<title>${title} — DocFast</title>
|
||||
<link rel="icon" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><text y='.9em' font-size='90'>⚡</text></svg>">
|
||||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700;800&display=swap" rel="stylesheet">
|
||||
<style>
|
||||
*{box-sizing:border-box;margin:0;padding:0}
|
||||
body{font-family:'Inter',sans-serif;background:#0b0d11;color:#e4e7ed;min-height:100vh;display:flex;align-items:center;justify-content:center;padding:24px}
|
||||
.card{background:#151922;border:1px solid #1e2433;border-radius:16px;padding:48px;max-width:520px;width:100%;text-align:center}
|
||||
h1{font-size:1.8rem;margin-bottom:12px;font-weight:800}
|
||||
p{color:#7a8194;margin-bottom:24px;line-height:1.6}
|
||||
.key-box{background:#0b0d11;border:1px solid #34d399;border-radius:8px;padding:16px;font-family:monospace;font-size:0.82rem;word-break:break-all;margin:16px 0;cursor:pointer;transition:background 0.2s;position:relative}
|
||||
.key-box:hover{background:#12151c}
|
||||
.key-box::after{content:'Click to copy';position:absolute;top:-24px;right:0;font-size:0.7rem;color:#7a8194;font-family:'Inter',sans-serif}
|
||||
.warning{background:rgba(251,191,36,0.06);border:1px solid rgba(251,191,36,0.15);border-radius:8px;padding:12px 16px;font-size:0.85rem;color:#fbbf24;margin-bottom:16px;text-align:left}
|
||||
.links{margin-top:24px;color:#7a8194;font-size:0.9rem}
|
||||
.links a{color:#34d399;text-decoration:none}
|
||||
.links a:hover{color:#5eead4}
|
||||
</style></head><body>
|
||||
<div class="card">
|
||||
<h1>${title}</h1>
|
||||
<p>${message}</p>
|
||||
${apiKey ? `
|
||||
<div class="warning">⚠️ Save your API key securely. You can recover it via email if needed.</div>
|
||||
<div class="key-box" onclick="navigator.clipboard.writeText('${apiKey}');this.style.borderColor='#5eead4';setTimeout(()=>this.style.borderColor='#34d399',1500)">${apiKey}</div>
|
||||
<div class="links">100 free PDFs/month · <a href="/docs">Read the docs →</a></div>
|
||||
` : `<div class="links"><a href="/">← Back to DocFast</a></div>`}
|
||||
</div></body></html>`;
|
||||
}
|
||||
|
||||
// Landing page
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
app.use(express.static(path.join(__dirname, "../public")));
|
||||
|
||||
// Favicon route
|
||||
app.get("/favicon.ico", (_req, res) => {
|
||||
res.setHeader('Content-Type', 'image/svg+xml');
|
||||
res.setHeader('Cache-Control', 'public, max-age=604800');
|
||||
res.sendFile(path.join(__dirname, "../public/favicon.svg"));
|
||||
});
|
||||
|
||||
app.use(express.static(path.join(__dirname, "../public"), {
|
||||
maxAge: "1d",
|
||||
etag: true,
|
||||
setHeaders: (res) => {
|
||||
res.setHeader('Cache-Control', 'public, max-age=86400');
|
||||
}
|
||||
}));
|
||||
|
||||
// Docs page (clean URL)
|
||||
app.get("/docs", (_req, res) => {
|
||||
res.setHeader('Cache-Control', 'public, max-age=86400');
|
||||
res.sendFile(path.join(__dirname, "../public/docs.html"));
|
||||
});
|
||||
|
||||
// Legal pages (clean URLs)
|
||||
app.get("/impressum", (_req, res) => {
|
||||
res.setHeader('Cache-Control', 'public, max-age=86400');
|
||||
res.sendFile(path.join(__dirname, "../public/impressum.html"));
|
||||
});
|
||||
|
||||
app.get("/privacy", (_req, res) => {
|
||||
res.setHeader('Cache-Control', 'public, max-age=86400');
|
||||
res.sendFile(path.join(__dirname, "../public/privacy.html"));
|
||||
});
|
||||
|
||||
app.get("/terms", (_req, res) => {
|
||||
res.setHeader('Cache-Control', 'public, max-age=86400');
|
||||
res.sendFile(path.join(__dirname, "../public/terms.html"));
|
||||
});
|
||||
|
||||
// API root
|
||||
app.get("/api", (_req, res) => {
|
||||
res.json({
|
||||
name: "DocFast API",
|
||||
version: "0.2.0",
|
||||
version: "0.2.1",
|
||||
endpoints: [
|
||||
"POST /v1/signup/free — Get a free API key",
|
||||
"POST /v1/convert/html",
|
||||
|
|
@ -95,22 +227,131 @@ app.get("/api", (_req, res) => {
|
|||
});
|
||||
});
|
||||
|
||||
async function start() {
|
||||
await initBrowser();
|
||||
console.log(`Loaded ${getAllKeys().length} API keys`);
|
||||
app.listen(PORT, () => console.log(`DocFast API running on :${PORT}`));
|
||||
// 404 handler - must be after all routes
|
||||
app.use((req, res) => {
|
||||
// Check if it's an API request
|
||||
const isApiRequest = req.path.startsWith('/v1/') || req.path.startsWith('/api') || req.path.startsWith('/health');
|
||||
|
||||
if (isApiRequest) {
|
||||
// JSON 404 for API paths
|
||||
res.status(404).json({
|
||||
error: "Not Found",
|
||||
message: `The requested endpoint ${req.method} ${req.path} does not exist`,
|
||||
statusCode: 404,
|
||||
timestamp: new Date().toISOString()
|
||||
});
|
||||
} else {
|
||||
// HTML 404 for browser paths
|
||||
res.status(404).send(`<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>404 - Page Not Found | DocFast</title>
|
||||
<link rel="icon" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><text y='.9em' font-size='90'>⚡</text></svg>">
|
||||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&display=swap" rel="stylesheet">
|
||||
<style>
|
||||
* { box-sizing: border-box; margin: 0; padding: 0; }
|
||||
body { font-family: 'Inter', sans-serif; background: #0b0d11; color: #e4e7ed; min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
|
||||
.container { background: #151922; border: 1px solid #1e2433; border-radius: 16px; padding: 48px; max-width: 520px; width: 100%; text-align: center; }
|
||||
h1 { font-size: 3rem; margin-bottom: 12px; font-weight: 700; color: #34d399; }
|
||||
h2 { font-size: 1.5rem; margin-bottom: 16px; font-weight: 600; }
|
||||
p { color: #7a8194; margin-bottom: 24px; line-height: 1.6; }
|
||||
a { color: #34d399; text-decoration: none; font-weight: 600; }
|
||||
a:hover { color: #5eead4; }
|
||||
.emoji { font-size: 4rem; margin-bottom: 24px; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="emoji">⚡</div>
|
||||
<h1>404</h1>
|
||||
<h2>Page Not Found</h2>
|
||||
<p>The page you're looking for doesn't exist or has been moved.</p>
|
||||
<p><a href="/">← Back to DocFast</a> | <a href="/docs">Read the docs</a></p>
|
||||
</div>
|
||||
</body>
|
||||
</html>`);
|
||||
}
|
||||
});
|
||||
|
||||
const shutdown = async () => {
|
||||
console.log("Shutting down...");
|
||||
await closeBrowser();
|
||||
// 404 handler — must be after all routes
|
||||
app.use((req, res) => {
|
||||
if (req.path.startsWith("/v1/")) {
|
||||
res.status(404).json({ error: "Not found" });
|
||||
} else {
|
||||
const accepts = req.headers.accept || "";
|
||||
if (accepts.includes("text/html")) {
|
||||
res.status(404).send(`<!DOCTYPE html>
|
||||
<html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<title>404 — DocFast</title>
|
||||
<link rel="icon" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><text y='.9em' font-size='90'>⚡</text></svg>">
|
||||
<style>*{margin:0;padding:0;box-sizing:border-box}body{font-family:'Inter',-apple-system,sans-serif;background:#0b0d11;color:#e4e7ed;min-height:100vh;display:flex;align-items:center;justify-content:center}
|
||||
.c{text-align:center}.c h1{font-size:4rem;font-weight:800;color:#34d399;margin-bottom:12px}.c p{color:#7a8194;margin-bottom:24px}.c a{color:#34d399;text-decoration:none}.c a:hover{color:#5eead4}</style>
|
||||
</head><body><div class="c"><h1>404</h1><p>Page not found.</p><p><a href="/">← Back to DocFast</a> · <a href="/docs">API Docs</a></p></div></body></html>`);
|
||||
} else {
|
||||
res.status(404).json({ error: "Not found" });
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
async function start() {
|
||||
// Initialize PostgreSQL
|
||||
await initDatabase();
|
||||
|
||||
// Load data from PostgreSQL
|
||||
await loadKeys();
|
||||
await loadVerifications();
|
||||
await loadUsageData();
|
||||
|
||||
await initBrowser();
|
||||
logger.info(`Loaded ${getAllKeys().length} API keys`);
|
||||
const server = app.listen(PORT, () => logger.info(`DocFast API running on :${PORT}`));
|
||||
|
||||
let shuttingDown = false;
|
||||
const shutdown = async (signal: string) => {
|
||||
if (shuttingDown) return;
|
||||
shuttingDown = true;
|
||||
logger.info(`Received ${signal}, starting graceful shutdown...`);
|
||||
|
||||
// 1. Stop accepting new connections, wait for in-flight requests (max 10s)
|
||||
await new Promise<void>((resolve) => {
|
||||
const forceTimeout = setTimeout(() => {
|
||||
logger.warn("Forcing server close after 10s timeout");
|
||||
resolve();
|
||||
}, 10_000);
|
||||
server.close(() => {
|
||||
clearTimeout(forceTimeout);
|
||||
logger.info("HTTP server closed (all in-flight requests completed)");
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
|
||||
// 2. Close Puppeteer browser pool
|
||||
try {
|
||||
await closeBrowser();
|
||||
logger.info("Browser pool closed");
|
||||
} catch (err) {
|
||||
logger.error({ err }, "Error closing browser pool");
|
||||
}
|
||||
|
||||
// 3. Close PostgreSQL connection pool
|
||||
try {
|
||||
await pool.end();
|
||||
logger.info("PostgreSQL pool closed");
|
||||
} catch (err) {
|
||||
logger.error({ err }, "Error closing PostgreSQL pool");
|
||||
}
|
||||
|
||||
logger.info("Graceful shutdown complete");
|
||||
process.exit(0);
|
||||
};
|
||||
process.on("SIGTERM", shutdown);
|
||||
process.on("SIGINT", shutdown);
|
||||
process.on("SIGTERM", () => shutdown("SIGTERM"));
|
||||
process.on("SIGINT", () => shutdown("SIGINT"));
|
||||
}
|
||||
|
||||
start().catch((err) => {
|
||||
console.error("Failed to start:", err);
|
||||
logger.error({ err }, "Failed to start");
|
||||
process.exit(1);
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -7,11 +7,19 @@ export function authMiddleware(
|
|||
next: NextFunction
|
||||
): void {
|
||||
const header = req.headers.authorization;
|
||||
if (!header?.startsWith("Bearer ")) {
|
||||
res.status(401).json({ error: "Missing API key. Use: Authorization: Bearer <key>" });
|
||||
const xApiKey = req.headers["x-api-key"] as string | undefined;
|
||||
let key: string | undefined;
|
||||
|
||||
if (header?.startsWith("Bearer ")) {
|
||||
key = header.slice(7);
|
||||
} else if (xApiKey) {
|
||||
key = xApiKey;
|
||||
}
|
||||
|
||||
if (!key) {
|
||||
res.status(401).json({ error: "Missing API key. Use: Authorization: Bearer <key> or X-API-Key: <key>" });
|
||||
return;
|
||||
}
|
||||
const key = header.slice(7);
|
||||
if (!isValidKey(key)) {
|
||||
res.status(403).json({ error: "Invalid API key" });
|
||||
return;
|
||||
|
|
|
|||
118
projects/business/src/pdf-api/src/middleware/pdfRateLimit.ts
Normal file
118
projects/business/src/pdf-api/src/middleware/pdfRateLimit.ts
Normal file
|
|
@ -0,0 +1,118 @@
|
|||
import { Request, Response, NextFunction } from "express";
|
||||
import { isProKey } from "../services/keys.js";
|
||||
|
||||
interface RateLimitEntry {
|
||||
count: number;
|
||||
resetTime: number;
|
||||
}
|
||||
|
||||
// Per-key rate limits (requests per minute)
|
||||
const FREE_RATE_LIMIT = 10;
|
||||
const PRO_RATE_LIMIT = 30;
|
||||
const RATE_WINDOW_MS = 60_000; // 1 minute
|
||||
|
||||
// Concurrency limits
|
||||
const MAX_CONCURRENT_PDFS = 3;
|
||||
const MAX_QUEUE_SIZE = 10;
|
||||
|
||||
const rateLimitStore = new Map<string, RateLimitEntry>();
|
||||
let activePdfCount = 0;
|
||||
const pdfQueue: Array<{ resolve: () => void; reject: (error: Error) => void }> = [];
|
||||
|
||||
function cleanupExpiredEntries(): void {
|
||||
const now = Date.now();
|
||||
for (const [key, entry] of rateLimitStore.entries()) {
|
||||
if (now >= entry.resetTime) {
|
||||
rateLimitStore.delete(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getRateLimit(apiKey: string): number {
|
||||
return isProKey(apiKey) ? PRO_RATE_LIMIT : FREE_RATE_LIMIT;
|
||||
}
|
||||
|
||||
function checkRateLimit(apiKey: string): boolean {
|
||||
cleanupExpiredEntries();
|
||||
|
||||
const now = Date.now();
|
||||
const limit = getRateLimit(apiKey);
|
||||
const entry = rateLimitStore.get(apiKey);
|
||||
|
||||
if (!entry || now >= entry.resetTime) {
|
||||
// Create new window
|
||||
rateLimitStore.set(apiKey, {
|
||||
count: 1,
|
||||
resetTime: now + RATE_WINDOW_MS
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
if (entry.count >= limit) {
|
||||
return false;
|
||||
}
|
||||
|
||||
entry.count++;
|
||||
return true;
|
||||
}
|
||||
|
||||
async function acquireConcurrencySlot(): Promise<void> {
|
||||
if (activePdfCount < MAX_CONCURRENT_PDFS) {
|
||||
activePdfCount++;
|
||||
return;
|
||||
}
|
||||
|
||||
if (pdfQueue.length >= MAX_QUEUE_SIZE) {
|
||||
throw new Error("QUEUE_FULL");
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
pdfQueue.push({ resolve, reject });
|
||||
});
|
||||
}
|
||||
|
||||
function releaseConcurrencySlot(): void {
|
||||
activePdfCount--;
|
||||
|
||||
const waiter = pdfQueue.shift();
|
||||
if (waiter) {
|
||||
activePdfCount++;
|
||||
waiter.resolve();
|
||||
}
|
||||
}
|
||||
|
||||
export function pdfRateLimitMiddleware(req: Request & { apiKeyInfo?: any }, res: Response, next: NextFunction): void {
|
||||
const keyInfo = req.apiKeyInfo;
|
||||
const apiKey = keyInfo?.key || "unknown";
|
||||
|
||||
// Check rate limit first
|
||||
if (!checkRateLimit(apiKey)) {
|
||||
const limit = getRateLimit(apiKey);
|
||||
const tier = isProKey(apiKey) ? "pro" : "free";
|
||||
res.status(429).json({
|
||||
error: "Rate limit exceeded",
|
||||
limit: `${limit} PDFs per minute`,
|
||||
tier,
|
||||
retryAfter: "60 seconds"
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
// Add concurrency control to the request
|
||||
(req as any).acquirePdfSlot = acquireConcurrencySlot;
|
||||
(req as any).releasePdfSlot = releaseConcurrencySlot;
|
||||
|
||||
next();
|
||||
}
|
||||
|
||||
export function getConcurrencyStats() {
|
||||
return {
|
||||
activePdfCount,
|
||||
queueSize: pdfQueue.length,
|
||||
maxConcurrent: MAX_CONCURRENT_PDFS,
|
||||
maxQueue: MAX_QUEUE_SIZE
|
||||
};
|
||||
}
|
||||
|
||||
// Proactive cleanup every 60s
|
||||
setInterval(cleanupExpiredEntries, 60_000);
|
||||
|
|
@ -1,42 +1,71 @@
|
|||
import { Request, Response, NextFunction } from "express";
|
||||
import { isProKey } from "../services/keys.js";
|
||||
import logger from "../services/logger.js";
|
||||
import pool from "../services/db.js";
|
||||
|
||||
interface UsageRecord {
|
||||
count: number;
|
||||
monthKey: string;
|
||||
}
|
||||
|
||||
const usage = new Map<string, UsageRecord>();
|
||||
const FREE_TIER_LIMIT = 100;
|
||||
const PRO_TIER_LIMIT = 2500;
|
||||
|
||||
// In-memory cache, periodically synced to PostgreSQL
|
||||
let usage = new Map<string, { count: number; monthKey: string }>();
|
||||
|
||||
function getMonthKey(): string {
|
||||
const d = new Date();
|
||||
return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, "0")}`;
|
||||
}
|
||||
|
||||
export function usageMiddleware(
|
||||
req: Request,
|
||||
res: Response,
|
||||
next: NextFunction
|
||||
): void {
|
||||
const key = req.headers.authorization?.slice(7) || "unknown";
|
||||
export async function loadUsageData(): Promise<void> {
|
||||
try {
|
||||
const result = await pool.query("SELECT key, count, month_key FROM usage");
|
||||
usage = new Map();
|
||||
for (const row of result.rows) {
|
||||
usage.set(row.key, { count: row.count, monthKey: row.month_key });
|
||||
}
|
||||
logger.info(`Loaded usage data for ${usage.size} keys from PostgreSQL`);
|
||||
} catch (error) {
|
||||
logger.info("No existing usage data found, starting fresh");
|
||||
usage = new Map();
|
||||
}
|
||||
}
|
||||
|
||||
async function saveUsageEntry(key: string, record: { count: number; monthKey: string }): Promise<void> {
|
||||
try {
|
||||
await pool.query(
|
||||
`INSERT INTO usage (key, count, month_key) VALUES ($1, $2, $3)
|
||||
ON CONFLICT (key) DO UPDATE SET count = $2, month_key = $3`,
|
||||
[key, record.count, record.monthKey]
|
||||
);
|
||||
} catch (error) {
|
||||
logger.error({ err: error }, "Failed to save usage data");
|
||||
}
|
||||
}
|
||||
|
||||
export function usageMiddleware(req: any, res: any, next: any): void {
|
||||
const keyInfo = req.apiKeyInfo;
|
||||
const key = keyInfo?.key || "unknown";
|
||||
const monthKey = getMonthKey();
|
||||
|
||||
// Pro keys have no limit
|
||||
if (isProKey(key)) {
|
||||
const record = usage.get(key);
|
||||
if (record && record.monthKey === monthKey && record.count >= PRO_TIER_LIMIT) {
|
||||
res.status(429).json({
|
||||
error: "Pro tier limit reached (2,500/month). Contact support for higher limits.",
|
||||
limit: PRO_TIER_LIMIT,
|
||||
used: record.count,
|
||||
});
|
||||
return;
|
||||
}
|
||||
trackUsage(key, monthKey);
|
||||
next();
|
||||
return;
|
||||
}
|
||||
|
||||
// Free tier limit check
|
||||
const record = usage.get(key);
|
||||
if (record && record.monthKey === monthKey && record.count >= FREE_TIER_LIMIT) {
|
||||
res.status(429).json({
|
||||
error: "Free tier limit reached",
|
||||
limit: FREE_TIER_LIMIT,
|
||||
used: record.count,
|
||||
upgrade: "Upgrade to Pro for unlimited conversions: https://docfast.dev/pricing",
|
||||
upgrade: "Upgrade to Pro for 2,500 PDFs/month: https://docfast.dev/pricing",
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
|
@ -48,17 +77,23 @@ export function usageMiddleware(
|
|||
function trackUsage(key: string, monthKey: string): void {
|
||||
const record = usage.get(key);
|
||||
if (!record || record.monthKey !== monthKey) {
|
||||
usage.set(key, { count: 1, monthKey });
|
||||
const newRecord = { count: 1, monthKey };
|
||||
usage.set(key, newRecord);
|
||||
saveUsageEntry(key, newRecord).catch((err) => logger.error({ err }, "Failed to save usage entry"));
|
||||
} else {
|
||||
record.count++;
|
||||
saveUsageEntry(key, record).catch((err) => logger.error({ err }, "Failed to save usage entry"));
|
||||
}
|
||||
}
|
||||
|
||||
export function getUsageStats(): Record<string, { count: number; month: string }> {
|
||||
export function getUsageStats(apiKey?: string): Record<string, { count: number; month: string }> {
|
||||
const stats: Record<string, { count: number; month: string }> = {};
|
||||
for (const [key, record] of usage) {
|
||||
const masked = key.slice(0, 8) + "...";
|
||||
stats[masked] = { count: record.count, month: record.monthKey };
|
||||
if (apiKey) {
|
||||
const record = usage.get(apiKey);
|
||||
if (record) {
|
||||
const masked = apiKey.slice(0, 8) + "...";
|
||||
stats[masked] = { count: record.count, month: record.monthKey };
|
||||
}
|
||||
}
|
||||
return stats;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,11 @@
|
|||
import { Router, Request, Response } from "express";
|
||||
import Stripe from "stripe";
|
||||
import { createProKey, revokeByCustomer } from "../services/keys.js";
|
||||
import logger from "../services/logger.js";
|
||||
|
||||
function escapeHtml(s: string): string {
|
||||
return s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
||||
}
|
||||
|
||||
let _stripe: Stripe | null = null;
|
||||
function getStripe(): Stripe {
|
||||
|
|
@ -29,7 +34,7 @@ router.post("/checkout", async (_req: Request, res: Response) => {
|
|||
|
||||
res.json({ url: session.url });
|
||||
} catch (err: any) {
|
||||
console.error("Checkout error:", err.message);
|
||||
logger.error({ err }, "Checkout error");
|
||||
res.status(500).json({ error: "Failed to create checkout session" });
|
||||
}
|
||||
});
|
||||
|
|
@ -52,7 +57,7 @@ router.get("/success", async (req: Request, res: Response) => {
|
|||
return;
|
||||
}
|
||||
|
||||
const keyInfo = createProKey(email, customerId);
|
||||
const keyInfo = await createProKey(email, customerId);
|
||||
|
||||
// Return a nice HTML page instead of raw JSON
|
||||
res.send(`<!DOCTYPE html>
|
||||
|
|
@ -69,13 +74,13 @@ a { color: #4f9; }
|
|||
<div class="card">
|
||||
<h1>🎉 Welcome to Pro!</h1>
|
||||
<p>Your API key:</p>
|
||||
<div class="key" onclick="navigator.clipboard.writeText('${keyInfo.key}')" title="Click to copy">${keyInfo.key}</div>
|
||||
<div class="key" style="position:relative">${escapeHtml(keyInfo.key)}<button onclick="navigator.clipboard.writeText('${escapeHtml(keyInfo.key)}');this.textContent='Copied!';setTimeout(()=>this.textContent='Copy',1500)" style="position:absolute;top:8px;right:8px;background:#4f9;color:#0a0a0a;border:none;border-radius:4px;padding:4px 12px;cursor:pointer;font-size:0.8rem;font-family:system-ui">Copy</button></div>
|
||||
<p><strong>Save this key!</strong> It won't be shown again.</p>
|
||||
<p>10,000 PDFs/month • All endpoints • Priority support</p>
|
||||
<p>5,000 PDFs/month • All endpoints • Priority support</p>
|
||||
<p><a href="/docs">View API docs →</a></p>
|
||||
</div></body></html>`);
|
||||
} catch (err: any) {
|
||||
console.error("Success page error:", err.message);
|
||||
logger.error({ err }, "Success page error");
|
||||
res.status(500).json({ error: "Failed to retrieve session" });
|
||||
}
|
||||
});
|
||||
|
|
@ -87,24 +92,70 @@ router.post("/webhook", async (req: Request, res: Response) => {
|
|||
|
||||
let event: Stripe.Event;
|
||||
|
||||
if (webhookSecret && sig) {
|
||||
if (!webhookSecret) {
|
||||
console.warn("⚠️ STRIPE_WEBHOOK_SECRET is not configured — webhook signature verification skipped. Set this in production!");
|
||||
// Parse the body as a raw event without verification
|
||||
try {
|
||||
event = JSON.parse(typeof req.body === "string" ? req.body : req.body.toString()) as Stripe.Event;
|
||||
} catch (err: any) {
|
||||
logger.error({ err }, "Failed to parse webhook body");
|
||||
res.status(400).json({ error: "Invalid payload" });
|
||||
return;
|
||||
}
|
||||
} else if (!sig) {
|
||||
res.status(400).json({ error: "Missing stripe-signature header" });
|
||||
return;
|
||||
} else {
|
||||
try {
|
||||
event = getStripe().webhooks.constructEvent(req.body, sig, webhookSecret);
|
||||
} catch (err: any) {
|
||||
console.error("Webhook signature verification failed:", err.message);
|
||||
logger.error({ err }, "Webhook signature verification failed");
|
||||
res.status(400).json({ error: "Invalid signature" });
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
event = req.body as Stripe.Event;
|
||||
}
|
||||
|
||||
switch (event.type) {
|
||||
case "checkout.session.completed": {
|
||||
const session = event.data.object as Stripe.Checkout.Session;
|
||||
const customerId = session.customer as string;
|
||||
const email = session.customer_details?.email;
|
||||
|
||||
// Filter by product — this Stripe account is shared with other projects
|
||||
const DOCFAST_PRODUCT_ID = "prod_TygeG8tQPtEAdE";
|
||||
try {
|
||||
const fullSession = await getStripe().checkout.sessions.retrieve(session.id, {
|
||||
expand: ["line_items"],
|
||||
});
|
||||
const lineItems = fullSession.line_items?.data || [];
|
||||
const hasDocfastProduct = lineItems.some((item) => {
|
||||
const price = item.price as Stripe.Price | null;
|
||||
const productId = typeof price?.product === "string" ? price.product : (price?.product as Stripe.Product)?.id;
|
||||
return productId === DOCFAST_PRODUCT_ID;
|
||||
});
|
||||
if (!hasDocfastProduct) {
|
||||
logger.info({ sessionId: session.id }, "Ignoring event for different product");
|
||||
break;
|
||||
}
|
||||
} catch (err: any) {
|
||||
logger.error({ err, sessionId: session.id }, "Failed to retrieve session line_items");
|
||||
break;
|
||||
}
|
||||
|
||||
if (!customerId || !email) {
|
||||
console.warn("checkout.session.completed: missing customerId or email, skipping key provisioning");
|
||||
break;
|
||||
}
|
||||
|
||||
const keyInfo = await createProKey(email, customerId);
|
||||
logger.info({ email, customerId }, "checkout.session.completed: provisioned pro key");
|
||||
break;
|
||||
}
|
||||
case "customer.subscription.deleted": {
|
||||
const sub = event.data.object as Stripe.Subscription;
|
||||
const customerId = sub.customer as string;
|
||||
revokeByCustomer(customerId);
|
||||
console.log(`Subscription cancelled for ${customerId}, key revoked`);
|
||||
await revokeByCustomer(customerId);
|
||||
logger.info({ customerId }, "Subscription cancelled, key revoked");
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
|
@ -133,7 +184,7 @@ async function getOrCreateProPrice(): Promise<string> {
|
|||
} else {
|
||||
const product = await getStripe().products.create({
|
||||
name: "DocFast Pro",
|
||||
description: "Unlimited PDF conversions via API. HTML, Markdown, and URL to PDF.",
|
||||
description: "5,000 PDFs / month via API. HTML, Markdown, and URL to PDF.",
|
||||
});
|
||||
productId = product.id;
|
||||
}
|
||||
|
|
@ -141,7 +192,7 @@ async function getOrCreateProPrice(): Promise<string> {
|
|||
const price = await getStripe().prices.create({
|
||||
product: productId,
|
||||
unit_amount: 900,
|
||||
currency: "usd",
|
||||
currency: "eur",
|
||||
recurring: { interval: "month" },
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,31 @@
|
|||
import { Router, Request, Response } from "express";
|
||||
import { renderPdf, renderUrlPdf } from "../services/browser.js";
|
||||
import { renderPdf, renderUrlPdf, getPoolStats } from "../services/browser.js";
|
||||
import { markdownToHtml, wrapHtml } from "../services/markdown.js";
|
||||
import dns from "node:dns/promises";
|
||||
import logger from "../services/logger.js";
|
||||
import net from "node:net";
|
||||
|
||||
function isPrivateIP(ip: string): boolean {
|
||||
// IPv6 loopback/unspecified
|
||||
if (ip === "::1" || ip === "::") return true;
|
||||
|
||||
// IPv6 link-local (fe80::/10)
|
||||
if (ip.toLowerCase().startsWith("fe8") || ip.toLowerCase().startsWith("fe9") ||
|
||||
ip.toLowerCase().startsWith("fea") || ip.toLowerCase().startsWith("feb")) return true;
|
||||
|
||||
// IPv4-mapped IPv6
|
||||
if (ip.startsWith("::ffff:")) ip = ip.slice(7);
|
||||
if (!net.isIPv4(ip)) return false;
|
||||
|
||||
const parts = ip.split(".").map(Number);
|
||||
if (parts[0] === 0) return true; // 0.0.0.0/8
|
||||
if (parts[0] === 10) return true; // 10.0.0.0/8
|
||||
if (parts[0] === 127) return true; // 127.0.0.0/8
|
||||
if (parts[0] === 169 && parts[1] === 254) return true; // 169.254.0.0/16
|
||||
if (parts[0] === 172 && parts[1] >= 16 && parts[1] <= 31) return true; // 172.16.0.0/12
|
||||
if (parts[0] === 192 && parts[1] === 168) return true; // 192.168.0.0/16
|
||||
return false;
|
||||
}
|
||||
|
||||
export const convertRouter = Router();
|
||||
|
||||
|
|
@ -16,8 +41,15 @@ interface ConvertBody {
|
|||
}
|
||||
|
||||
// POST /v1/convert/html
|
||||
convertRouter.post("/html", async (req: Request, res: Response) => {
|
||||
convertRouter.post("/html", async (req: Request & { acquirePdfSlot?: () => Promise<void>; releasePdfSlot?: () => void }, res: Response) => {
|
||||
let slotAcquired = false;
|
||||
try {
|
||||
// Reject non-JSON content types
|
||||
const ct = req.headers["content-type"] || "";
|
||||
if (!ct.includes("application/json")) {
|
||||
res.status(415).json({ error: "Unsupported Content-Type. Use application/json." });
|
||||
return;
|
||||
}
|
||||
const body: ConvertBody =
|
||||
typeof req.body === "string" ? { html: req.body } : req.body;
|
||||
|
||||
|
|
@ -26,6 +58,12 @@ convertRouter.post("/html", async (req: Request, res: Response) => {
|
|||
return;
|
||||
}
|
||||
|
||||
// Acquire concurrency slot
|
||||
if (req.acquirePdfSlot) {
|
||||
await req.acquirePdfSlot();
|
||||
slotAcquired = true;
|
||||
}
|
||||
|
||||
// Wrap bare HTML fragments
|
||||
const fullHtml = body.html.includes("<html")
|
||||
? body.html
|
||||
|
|
@ -43,13 +81,22 @@ convertRouter.post("/html", async (req: Request, res: Response) => {
|
|||
res.setHeader("Content-Disposition", `inline; filename="${filename}"`);
|
||||
res.send(pdf);
|
||||
} catch (err: any) {
|
||||
console.error("Convert HTML error:", err);
|
||||
logger.error({ err }, "Convert HTML error");
|
||||
if (err.message === "QUEUE_FULL") {
|
||||
res.status(429).json({ error: "Server busy - too many concurrent PDF generations. Please try again in a few seconds." });
|
||||
return;
|
||||
}
|
||||
res.status(500).json({ error: "PDF generation failed", detail: err.message });
|
||||
} finally {
|
||||
if (slotAcquired && req.releasePdfSlot) {
|
||||
req.releasePdfSlot();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// POST /v1/convert/markdown
|
||||
convertRouter.post("/markdown", async (req: Request, res: Response) => {
|
||||
convertRouter.post("/markdown", async (req: Request & { acquirePdfSlot?: () => Promise<void>; releasePdfSlot?: () => void }, res: Response) => {
|
||||
let slotAcquired = false;
|
||||
try {
|
||||
const body: ConvertBody =
|
||||
typeof req.body === "string" ? { markdown: req.body } : req.body;
|
||||
|
|
@ -59,6 +106,12 @@ convertRouter.post("/markdown", async (req: Request, res: Response) => {
|
|||
return;
|
||||
}
|
||||
|
||||
// Acquire concurrency slot
|
||||
if (req.acquirePdfSlot) {
|
||||
await req.acquirePdfSlot();
|
||||
slotAcquired = true;
|
||||
}
|
||||
|
||||
const html = markdownToHtml(body.markdown, body.css);
|
||||
const pdf = await renderPdf(html, {
|
||||
format: body.format,
|
||||
|
|
@ -72,13 +125,22 @@ convertRouter.post("/markdown", async (req: Request, res: Response) => {
|
|||
res.setHeader("Content-Disposition", `inline; filename="${filename}"`);
|
||||
res.send(pdf);
|
||||
} catch (err: any) {
|
||||
console.error("Convert MD error:", err);
|
||||
logger.error({ err }, "Convert MD error");
|
||||
if (err.message === "QUEUE_FULL") {
|
||||
res.status(429).json({ error: "Server busy - too many concurrent PDF generations. Please try again in a few seconds." });
|
||||
return;
|
||||
}
|
||||
res.status(500).json({ error: "PDF generation failed", detail: err.message });
|
||||
} finally {
|
||||
if (slotAcquired && req.releasePdfSlot) {
|
||||
req.releasePdfSlot();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// POST /v1/convert/url
|
||||
convertRouter.post("/url", async (req: Request, res: Response) => {
|
||||
convertRouter.post("/url", async (req: Request & { acquirePdfSlot?: () => Promise<void>; releasePdfSlot?: () => void }, res: Response) => {
|
||||
let slotAcquired = false;
|
||||
try {
|
||||
const body = req.body as { url?: string; format?: string; landscape?: boolean; margin?: any; printBackground?: boolean; waitUntil?: string; filename?: string };
|
||||
|
||||
|
|
@ -87,9 +149,10 @@ convertRouter.post("/url", async (req: Request, res: Response) => {
|
|||
return;
|
||||
}
|
||||
|
||||
// Basic URL validation
|
||||
// URL validation + SSRF protection
|
||||
let parsed: URL;
|
||||
try {
|
||||
const parsed = new URL(body.url);
|
||||
parsed = new URL(body.url);
|
||||
if (!["http:", "https:"].includes(parsed.protocol)) {
|
||||
res.status(400).json({ error: "Only http/https URLs are supported" });
|
||||
return;
|
||||
|
|
@ -99,6 +162,24 @@ convertRouter.post("/url", async (req: Request, res: Response) => {
|
|||
return;
|
||||
}
|
||||
|
||||
// DNS lookup to block private/reserved IPs
|
||||
try {
|
||||
const { address } = await dns.lookup(parsed.hostname);
|
||||
if (isPrivateIP(address)) {
|
||||
res.status(400).json({ error: "URL resolves to a private/internal IP address" });
|
||||
return;
|
||||
}
|
||||
} catch {
|
||||
res.status(400).json({ error: "DNS lookup failed for URL hostname" });
|
||||
return;
|
||||
}
|
||||
|
||||
// Acquire concurrency slot
|
||||
if (req.acquirePdfSlot) {
|
||||
await req.acquirePdfSlot();
|
||||
slotAcquired = true;
|
||||
}
|
||||
|
||||
const pdf = await renderUrlPdf(body.url, {
|
||||
format: body.format,
|
||||
landscape: body.landscape,
|
||||
|
|
@ -112,7 +193,15 @@ convertRouter.post("/url", async (req: Request, res: Response) => {
|
|||
res.setHeader("Content-Disposition", `inline; filename="${filename}"`);
|
||||
res.send(pdf);
|
||||
} catch (err: any) {
|
||||
console.error("Convert URL error:", err);
|
||||
logger.error({ err }, "Convert URL error");
|
||||
if (err.message === "QUEUE_FULL") {
|
||||
res.status(429).json({ error: "Server busy - too many concurrent PDF generations. Please try again in a few seconds." });
|
||||
return;
|
||||
}
|
||||
res.status(500).json({ error: "PDF generation failed", detail: err.message });
|
||||
} finally {
|
||||
if (slotAcquired && req.releasePdfSlot) {
|
||||
req.releasePdfSlot();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
|||
99
projects/business/src/pdf-api/src/routes/email-change.ts
Normal file
99
projects/business/src/pdf-api/src/routes/email-change.ts
Normal file
|
|
@ -0,0 +1,99 @@
|
|||
import { Router } from "express";
|
||||
import type { Request, Response } from "express";
|
||||
import rateLimit from "express-rate-limit";
|
||||
import { createPendingVerification, verifyCode } from "../services/verification.js";
|
||||
import { sendVerificationEmail } from "../services/email.js";
|
||||
import { getAllKeys, updateKeyEmail } from "../services/keys.js";
|
||||
import logger from "../services/logger.js";
|
||||
|
||||
const router = Router();
|
||||
|
||||
const changeLimiter = rateLimit({
|
||||
windowMs: 60 * 60 * 1000,
|
||||
max: 3,
|
||||
message: { error: "Too many attempts. Please try again in 1 hour." },
|
||||
standardHeaders: true,
|
||||
legacyHeaders: false,
|
||||
});
|
||||
|
||||
router.post("/", changeLimiter, async (req: Request, res: Response) => {
|
||||
const apiKey = req.headers.authorization?.replace(/^Bearer\s+/i, "") || req.body?.apiKey;
|
||||
const newEmail = req.body?.newEmail;
|
||||
|
||||
if (!apiKey || typeof apiKey !== "string") {
|
||||
res.status(400).json({ error: "API key is required (Authorization header or body)." });
|
||||
return;
|
||||
}
|
||||
if (!newEmail || typeof newEmail !== "string" || !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(newEmail)) {
|
||||
res.status(400).json({ error: "A valid new email address is required." });
|
||||
return;
|
||||
}
|
||||
|
||||
const cleanEmail = newEmail.trim().toLowerCase();
|
||||
const keys = getAllKeys();
|
||||
const userKey = keys.find((k: any) => k.key === apiKey);
|
||||
|
||||
if (!userKey) {
|
||||
res.status(401).json({ error: "Invalid API key." });
|
||||
return;
|
||||
}
|
||||
|
||||
const existing = keys.find((k: any) => k.email === cleanEmail);
|
||||
if (existing) {
|
||||
res.status(409).json({ error: "This email is already associated with another account." });
|
||||
return;
|
||||
}
|
||||
|
||||
const pending = await createPendingVerification(cleanEmail);
|
||||
|
||||
sendVerificationEmail(cleanEmail, (pending as any).code).catch((err: Error) => {
|
||||
logger.error({ err, email: cleanEmail }, "Failed to send email change verification");
|
||||
});
|
||||
|
||||
res.json({ status: "verification_sent", message: "Verification code sent to your new email address." });
|
||||
});
|
||||
|
||||
router.post("/verify", changeLimiter, async (req: Request, res: Response) => {
|
||||
const apiKey = req.headers.authorization?.replace(/^Bearer\s+/i, "") || req.body?.apiKey;
|
||||
const { newEmail, code } = req.body || {};
|
||||
|
||||
if (!apiKey || !newEmail || !code) {
|
||||
res.status(400).json({ error: "API key, new email, and code are required." });
|
||||
return;
|
||||
}
|
||||
|
||||
const cleanEmail = newEmail.trim().toLowerCase();
|
||||
const cleanCode = String(code).trim();
|
||||
|
||||
const keys = getAllKeys();
|
||||
const userKey = keys.find((k: any) => k.key === apiKey);
|
||||
if (!userKey) {
|
||||
res.status(401).json({ error: "Invalid API key." });
|
||||
return;
|
||||
}
|
||||
|
||||
const result = await verifyCode(cleanEmail, cleanCode);
|
||||
|
||||
switch (result.status) {
|
||||
case "ok": {
|
||||
const updated = await updateKeyEmail(apiKey, cleanEmail);
|
||||
if (updated) {
|
||||
res.json({ status: "updated", message: "Email address updated successfully.", newEmail: cleanEmail });
|
||||
} else {
|
||||
res.status(500).json({ error: "Failed to update email." });
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "expired":
|
||||
res.status(410).json({ error: "Verification code has expired. Please request a new one." });
|
||||
break;
|
||||
case "max_attempts":
|
||||
res.status(429).json({ error: "Too many failed attempts. Please request a new code." });
|
||||
break;
|
||||
case "invalid":
|
||||
res.status(400).json({ error: "Invalid verification code." });
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
export { router as emailChangeRouter };
|
||||
|
|
@ -1,7 +1,59 @@
|
|||
import { Router } from "express";
|
||||
import { createRequire } from "module";
|
||||
import { getPoolStats } from "../services/browser.js";
|
||||
import { pool } from "../services/db.js";
|
||||
|
||||
const require = createRequire(import.meta.url);
|
||||
const { version: APP_VERSION } = require("../../package.json");
|
||||
|
||||
export const healthRouter = Router();
|
||||
|
||||
healthRouter.get("/", (_req, res) => {
|
||||
res.json({ status: "ok", version: "0.1.0" });
|
||||
});
|
||||
healthRouter.get("/", async (_req, res) => {
|
||||
const poolStats = getPoolStats();
|
||||
let databaseStatus: any;
|
||||
let overallStatus = "ok";
|
||||
let httpStatus = 200;
|
||||
|
||||
// Check database connectivity
|
||||
try {
|
||||
const client = await pool.connect();
|
||||
try {
|
||||
const result = await client.query('SELECT version()');
|
||||
const version = result.rows[0]?.version || 'Unknown';
|
||||
// Extract just the PostgreSQL version number (e.g., "PostgreSQL 15.4")
|
||||
const versionMatch = version.match(/PostgreSQL ([\d.]+)/);
|
||||
const shortVersion = versionMatch ? `PostgreSQL ${versionMatch[1]}` : 'PostgreSQL';
|
||||
|
||||
databaseStatus = {
|
||||
status: "ok",
|
||||
version: shortVersion
|
||||
};
|
||||
} finally {
|
||||
client.release();
|
||||
}
|
||||
} catch (error: any) {
|
||||
databaseStatus = {
|
||||
status: "error",
|
||||
message: error.message || "Database connection failed"
|
||||
};
|
||||
overallStatus = "degraded";
|
||||
httpStatus = 503;
|
||||
}
|
||||
|
||||
const response = {
|
||||
status: overallStatus,
|
||||
version: APP_VERSION,
|
||||
database: databaseStatus,
|
||||
pool: {
|
||||
size: poolStats.poolSize,
|
||||
active: poolStats.totalPages - poolStats.availablePages,
|
||||
available: poolStats.availablePages,
|
||||
queueDepth: poolStats.queueDepth,
|
||||
pdfCount: poolStats.pdfCount,
|
||||
restarting: poolStats.restarting,
|
||||
uptimeSeconds: Math.round(poolStats.uptimeMs / 1000),
|
||||
},
|
||||
};
|
||||
|
||||
res.status(httpStatus).json(response);
|
||||
});
|
||||
21
projects/business/src/pdf-api/src/routes/health.ts.backup
Normal file
21
projects/business/src/pdf-api/src/routes/health.ts.backup
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
import { Router } from "express";
|
||||
import { getPoolStats } from "../services/browser.js";
|
||||
|
||||
export const healthRouter = Router();
|
||||
|
||||
healthRouter.get("/", (_req, res) => {
|
||||
const pool = getPoolStats();
|
||||
res.json({
|
||||
status: "ok",
|
||||
version: "0.2.1",
|
||||
pool: {
|
||||
size: pool.poolSize,
|
||||
active: pool.totalPages - pool.availablePages,
|
||||
available: pool.availablePages,
|
||||
queueDepth: pool.queueDepth,
|
||||
pdfCount: pool.pdfCount,
|
||||
restarting: pool.restarting,
|
||||
uptimeSeconds: Math.round(pool.uptimeMs / 1000),
|
||||
},
|
||||
});
|
||||
});
|
||||
89
projects/business/src/pdf-api/src/routes/recover.ts
Normal file
89
projects/business/src/pdf-api/src/routes/recover.ts
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
import { Router, Request, Response } from "express";
|
||||
import rateLimit from "express-rate-limit";
|
||||
import { createPendingVerification, verifyCode } from "../services/verification.js";
|
||||
import { sendVerificationEmail } from "../services/email.js";
|
||||
import { getAllKeys } from "../services/keys.js";
|
||||
import logger from "../services/logger.js";
|
||||
|
||||
const router = Router();
|
||||
|
||||
const recoverLimiter = rateLimit({
|
||||
windowMs: 60 * 60 * 1000,
|
||||
max: 3,
|
||||
message: { error: "Too many recovery attempts. Please try again in 1 hour." },
|
||||
standardHeaders: true,
|
||||
legacyHeaders: false,
|
||||
});
|
||||
|
||||
router.post("/", recoverLimiter, async (req: Request, res: Response) => {
|
||||
const { email } = req.body || {};
|
||||
|
||||
if (!email || typeof email !== "string" || !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email)) {
|
||||
res.status(400).json({ error: "A valid email address is required." });
|
||||
return;
|
||||
}
|
||||
|
||||
const cleanEmail = email.trim().toLowerCase();
|
||||
const keys = getAllKeys();
|
||||
const userKey = keys.find(k => k.email === cleanEmail);
|
||||
|
||||
if (!userKey) {
|
||||
res.json({ status: "recovery_sent", message: "If an account exists for this email, a verification code has been sent." });
|
||||
return;
|
||||
}
|
||||
|
||||
const pending = await createPendingVerification(cleanEmail);
|
||||
|
||||
sendVerificationEmail(cleanEmail, pending.code).catch(err => {
|
||||
logger.error({ err, email: cleanEmail }, "Failed to send recovery email");
|
||||
});
|
||||
|
||||
res.json({ status: "recovery_sent", message: "If an account exists for this email, a verification code has been sent." });
|
||||
});
|
||||
|
||||
router.post("/verify", recoverLimiter, async (req: Request, res: Response) => {
|
||||
const { email, code } = req.body || {};
|
||||
|
||||
if (!email || !code) {
|
||||
res.status(400).json({ error: "Email and code are required." });
|
||||
return;
|
||||
}
|
||||
|
||||
const cleanEmail = email.trim().toLowerCase();
|
||||
const cleanCode = String(code).trim();
|
||||
|
||||
const result = await verifyCode(cleanEmail, cleanCode);
|
||||
|
||||
switch (result.status) {
|
||||
case "ok": {
|
||||
const keys = getAllKeys();
|
||||
const userKey = keys.find(k => k.email === cleanEmail);
|
||||
|
||||
if (userKey) {
|
||||
res.json({
|
||||
status: "recovered",
|
||||
apiKey: userKey.key,
|
||||
tier: userKey.tier,
|
||||
message: "Your API key has been recovered. Save it securely — it is shown only once.",
|
||||
});
|
||||
} else {
|
||||
res.json({
|
||||
status: "recovered",
|
||||
message: "No API key found for this email.",
|
||||
});
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "expired":
|
||||
res.status(410).json({ error: "Verification code has expired. Please request a new one." });
|
||||
break;
|
||||
case "max_attempts":
|
||||
res.status(429).json({ error: "Too many failed attempts. Please request a new code." });
|
||||
break;
|
||||
case "invalid":
|
||||
res.status(400).json({ error: "Invalid verification code." });
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
export { router as recoverRouter };
|
||||
|
|
@ -1,33 +1,111 @@
|
|||
import { Router, Request, Response } from "express";
|
||||
import rateLimit from "express-rate-limit";
|
||||
import { createFreeKey } from "../services/keys.js";
|
||||
import { createVerification, createPendingVerification, verifyCode, isEmailVerified, getVerifiedApiKey } from "../services/verification.js";
|
||||
import { sendVerificationEmail } from "../services/email.js";
|
||||
import logger from "../services/logger.js";
|
||||
|
||||
const router = Router();
|
||||
|
||||
// Self-service free API key signup
|
||||
router.post("/free", (req: Request, res: Response) => {
|
||||
const { email } = req.body;
|
||||
const signupLimiter = rateLimit({
|
||||
windowMs: 60 * 60 * 1000,
|
||||
max: 5,
|
||||
message: { error: "Too many signup attempts. Please try again in 1 hour.", retryAfter: "1 hour" },
|
||||
standardHeaders: true,
|
||||
legacyHeaders: false,
|
||||
});
|
||||
|
||||
if (!email || typeof email !== "string") {
|
||||
res.status(400).json({ error: "Email is required" });
|
||||
const verifyLimiter = rateLimit({
|
||||
windowMs: 15 * 60 * 1000,
|
||||
max: 15,
|
||||
message: { error: "Too many verification attempts. Please try again later." },
|
||||
standardHeaders: true,
|
||||
legacyHeaders: false,
|
||||
});
|
||||
|
||||
async function rejectDuplicateEmail(req: Request, res: Response, next: Function) {
|
||||
const { email } = req.body || {};
|
||||
if (email && typeof email === "string") {
|
||||
const cleanEmail = email.trim().toLowerCase();
|
||||
if (await isEmailVerified(cleanEmail)) {
|
||||
res.status(409).json({ error: "Email already registered" });
|
||||
return;
|
||||
}
|
||||
}
|
||||
next();
|
||||
}
|
||||
|
||||
// Step 1: Request signup — generates 6-digit code, sends via email
|
||||
router.post("/free", rejectDuplicateEmail, signupLimiter, async (req: Request, res: Response) => {
|
||||
const { email } = req.body || {};
|
||||
|
||||
if (!email || typeof email !== "string" || !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email)) {
|
||||
res.status(400).json({ error: "A valid email address is required." });
|
||||
return;
|
||||
}
|
||||
|
||||
// Basic email validation
|
||||
if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email)) {
|
||||
res.status(400).json({ error: "Invalid email address" });
|
||||
const cleanEmail = email.trim().toLowerCase();
|
||||
|
||||
if (await isEmailVerified(cleanEmail)) {
|
||||
res.status(409).json({ error: "This email is already registered. Contact support if you need help." });
|
||||
return;
|
||||
}
|
||||
|
||||
const keyInfo = createFreeKey(email.trim().toLowerCase());
|
||||
const pending = await createPendingVerification(cleanEmail);
|
||||
|
||||
sendVerificationEmail(cleanEmail, pending.code).catch(err => {
|
||||
logger.error({ err, email: cleanEmail }, "Failed to send verification email");
|
||||
});
|
||||
|
||||
res.json({
|
||||
message: "Welcome to DocFast! 🚀",
|
||||
apiKey: keyInfo.key,
|
||||
tier: "free",
|
||||
limit: "100 PDFs/month",
|
||||
docs: "https://docfast.dev/docs",
|
||||
note: "Save this API key — it won't be shown again.",
|
||||
status: "verification_required",
|
||||
message: "Check your email for the verification code.",
|
||||
});
|
||||
});
|
||||
|
||||
// Step 2: Verify code — creates API key
|
||||
router.post("/verify", verifyLimiter, async (req: Request, res: Response) => {
|
||||
const { email, code } = req.body || {};
|
||||
|
||||
if (!email || !code) {
|
||||
res.status(400).json({ error: "Email and code are required." });
|
||||
return;
|
||||
}
|
||||
|
||||
const cleanEmail = email.trim().toLowerCase();
|
||||
const cleanCode = String(code).trim();
|
||||
|
||||
if (await isEmailVerified(cleanEmail)) {
|
||||
res.status(409).json({ error: "This email is already verified." });
|
||||
return;
|
||||
}
|
||||
|
||||
const result = await verifyCode(cleanEmail, cleanCode);
|
||||
|
||||
switch (result.status) {
|
||||
case "ok": {
|
||||
const keyInfo = await createFreeKey(cleanEmail);
|
||||
const verification = await createVerification(cleanEmail, keyInfo.key);
|
||||
verification.verifiedAt = new Date().toISOString();
|
||||
|
||||
res.json({
|
||||
status: "verified",
|
||||
message: "Email verified! Here's your API key.",
|
||||
apiKey: keyInfo.key,
|
||||
tier: keyInfo.tier,
|
||||
});
|
||||
break;
|
||||
}
|
||||
case "expired":
|
||||
res.status(410).json({ error: "Verification code has expired. Please sign up again." });
|
||||
break;
|
||||
case "max_attempts":
|
||||
res.status(429).json({ error: "Too many failed attempts. Please sign up again to get a new code." });
|
||||
break;
|
||||
case "invalid":
|
||||
res.status(400).json({ error: "Invalid verification code." });
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
export { router as signupRouter };
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import { Router, Request, Response } from "express";
|
||||
import { renderPdf } from "../services/browser.js";
|
||||
import logger from "../services/logger.js";
|
||||
import { templates, renderTemplate } from "../services/templates.js";
|
||||
|
||||
export const templatesRouter = Router();
|
||||
|
|
@ -25,7 +26,7 @@ templatesRouter.post("/:id/render", async (req: Request, res: Response) => {
|
|||
return;
|
||||
}
|
||||
|
||||
const data = req.body;
|
||||
const data = req.body.data || req.body;
|
||||
const html = renderTemplate(id, data);
|
||||
const pdf = await renderPdf(html, {
|
||||
format: data._format || "A4",
|
||||
|
|
@ -37,7 +38,7 @@ templatesRouter.post("/:id/render", async (req: Request, res: Response) => {
|
|||
res.setHeader("Content-Disposition", `inline; filename="${filename}"`);
|
||||
res.send(pdf);
|
||||
} catch (err: any) {
|
||||
console.error("Template render error:", err);
|
||||
logger.error({ err }, "Template render error");
|
||||
res.status(500).json({ error: "Template rendering failed", detail: err.message });
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,19 +1,221 @@
|
|||
import puppeteer, { Browser, Page } from "puppeteer";
|
||||
import logger from "./logger.js";
|
||||
|
||||
let browser: Browser | null = null;
|
||||
const BROWSER_COUNT = parseInt(process.env.BROWSER_COUNT || "2", 10);
|
||||
const PAGES_PER_BROWSER = parseInt(process.env.PAGES_PER_BROWSER || "8", 10);
|
||||
const RESTART_AFTER_PDFS = 1000;
|
||||
const RESTART_AFTER_MS = 60 * 60 * 1000; // 1 hour
|
||||
|
||||
interface BrowserInstance {
|
||||
browser: Browser;
|
||||
availablePages: Page[];
|
||||
pdfCount: number;
|
||||
lastRestartTime: number;
|
||||
restarting: boolean;
|
||||
id: number;
|
||||
}
|
||||
|
||||
const instances: BrowserInstance[] = [];
|
||||
const waitingQueue: Array<{ resolve: (v: { page: Page; instance: BrowserInstance }) => void }> = [];
|
||||
let roundRobinIndex = 0;
|
||||
|
||||
export function getPoolStats() {
|
||||
const totalAvailable = instances.reduce((s, i) => s + i.availablePages.length, 0);
|
||||
const totalPages = instances.length * PAGES_PER_BROWSER;
|
||||
const totalPdfs = instances.reduce((s, i) => s + i.pdfCount, 0);
|
||||
return {
|
||||
poolSize: totalPages,
|
||||
totalPages,
|
||||
availablePages: totalAvailable,
|
||||
queueDepth: waitingQueue.length,
|
||||
pdfCount: totalPdfs,
|
||||
restarting: instances.some((i) => i.restarting),
|
||||
uptimeMs: Date.now() - (instances[0]?.lastRestartTime || Date.now()),
|
||||
browsers: instances.map((i) => ({
|
||||
id: i.id,
|
||||
available: i.availablePages.length,
|
||||
pdfCount: i.pdfCount,
|
||||
restarting: i.restarting,
|
||||
})),
|
||||
};
|
||||
}
|
||||
|
||||
async function recyclePage(page: Page): Promise<void> {
|
||||
try {
|
||||
const client = await page.createCDPSession();
|
||||
await client.send("Network.clearBrowserCache").catch(() => {});
|
||||
await client.detach().catch(() => {});
|
||||
const cookies = await page.cookies();
|
||||
if (cookies.length > 0) {
|
||||
await page.deleteCookie(...cookies);
|
||||
}
|
||||
await page.goto("about:blank", { timeout: 5000 }).catch(() => {});
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
|
||||
async function createPages(b: Browser, count: number): Promise<Page[]> {
|
||||
const pages: Page[] = [];
|
||||
for (let i = 0; i < count; i++) {
|
||||
const page = await b.newPage();
|
||||
pages.push(page);
|
||||
}
|
||||
return pages;
|
||||
}
|
||||
|
||||
function pickInstance(): BrowserInstance | null {
|
||||
// Round-robin among instances that have available pages
|
||||
for (let i = 0; i < instances.length; i++) {
|
||||
const idx = (roundRobinIndex + i) % instances.length;
|
||||
const inst = instances[idx];
|
||||
if (inst.availablePages.length > 0 && !inst.restarting) {
|
||||
roundRobinIndex = (idx + 1) % instances.length;
|
||||
return inst;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
async function acquirePage(): Promise<{ page: Page; instance: BrowserInstance }> {
|
||||
// Check restarts
|
||||
for (const inst of instances) {
|
||||
if (!inst.restarting && (inst.pdfCount >= RESTART_AFTER_PDFS || Date.now() - inst.lastRestartTime >= RESTART_AFTER_MS)) {
|
||||
scheduleRestart(inst);
|
||||
}
|
||||
}
|
||||
|
||||
const inst = pickInstance();
|
||||
if (inst) {
|
||||
const page = inst.availablePages.pop()!;
|
||||
return { page, instance: inst };
|
||||
}
|
||||
|
||||
// All pages busy, queue with 30s timeout
|
||||
return new Promise((resolve, reject) => {
|
||||
const timer = setTimeout(() => {
|
||||
const idx = waitingQueue.findIndex((w) => w.resolve === resolve);
|
||||
if (idx >= 0) waitingQueue.splice(idx, 1);
|
||||
reject(new Error("QUEUE_FULL"));
|
||||
}, 30_000);
|
||||
waitingQueue.push({
|
||||
resolve: (v) => {
|
||||
clearTimeout(timer);
|
||||
resolve(v);
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function releasePage(page: Page, inst: BrowserInstance): void {
|
||||
inst.pdfCount++;
|
||||
|
||||
const waiter = waitingQueue.shift();
|
||||
if (waiter) {
|
||||
recyclePage(page).then(() => waiter.resolve({ page, instance: inst })).catch(() => {
|
||||
if (inst.browser && !inst.restarting) {
|
||||
inst.browser.newPage().then((p) => waiter.resolve({ page: p, instance: inst })).catch(() => {
|
||||
waitingQueue.unshift(waiter);
|
||||
});
|
||||
} else {
|
||||
waitingQueue.unshift(waiter);
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
recyclePage(page).then(() => {
|
||||
inst.availablePages.push(page);
|
||||
}).catch(() => {
|
||||
if (inst.browser && !inst.restarting) {
|
||||
inst.browser.newPage().then((p) => inst.availablePages.push(p)).catch(() => {});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async function scheduleRestart(inst: BrowserInstance): Promise<void> {
|
||||
if (inst.restarting) return;
|
||||
inst.restarting = true;
|
||||
logger.info(`Scheduling browser ${inst.id} restart (pdfs=${inst.pdfCount}, uptime=${Math.round((Date.now() - inst.lastRestartTime) / 1000)}s)`);
|
||||
|
||||
const drainCheck = () => new Promise<void>((resolve) => {
|
||||
const check = () => {
|
||||
if (inst.availablePages.length === PAGES_PER_BROWSER && waitingQueue.length === 0) {
|
||||
resolve();
|
||||
} else {
|
||||
setTimeout(check, 100);
|
||||
}
|
||||
};
|
||||
check();
|
||||
});
|
||||
await Promise.race([drainCheck(), new Promise<void>(r => setTimeout(r, 30000))]);
|
||||
|
||||
for (const page of inst.availablePages) {
|
||||
await page.close().catch(() => {});
|
||||
}
|
||||
inst.availablePages.length = 0;
|
||||
|
||||
try { await inst.browser.close().catch(() => {}); } catch {}
|
||||
|
||||
export async function initBrowser(): Promise<void> {
|
||||
const execPath = process.env.PUPPETEER_EXECUTABLE_PATH || undefined;
|
||||
browser = await puppeteer.launch({
|
||||
inst.browser = await puppeteer.launch({
|
||||
headless: true,
|
||||
executablePath: execPath,
|
||||
args: ["--no-sandbox", "--disable-setuid-sandbox", "--disable-gpu", "--disable-dev-shm-usage"],
|
||||
});
|
||||
console.log("Browser pool ready");
|
||||
|
||||
const pages = await createPages(inst.browser, PAGES_PER_BROWSER);
|
||||
inst.availablePages.push(...pages);
|
||||
|
||||
inst.pdfCount = 0;
|
||||
inst.lastRestartTime = Date.now();
|
||||
inst.restarting = false;
|
||||
logger.info(`Browser ${inst.id} restarted successfully`);
|
||||
|
||||
while (waitingQueue.length > 0 && inst.availablePages.length > 0) {
|
||||
const waiter = waitingQueue.shift();
|
||||
const p = inst.availablePages.pop();
|
||||
if (waiter && p) waiter.resolve({ page: p, instance: inst });
|
||||
}
|
||||
}
|
||||
|
||||
async function launchInstance(id: number): Promise<BrowserInstance> {
|
||||
const execPath = process.env.PUPPETEER_EXECUTABLE_PATH || undefined;
|
||||
const browser = await puppeteer.launch({
|
||||
headless: true,
|
||||
executablePath: execPath,
|
||||
args: ["--no-sandbox", "--disable-setuid-sandbox", "--disable-gpu", "--disable-dev-shm-usage"],
|
||||
});
|
||||
|
||||
const pages = await createPages(browser, PAGES_PER_BROWSER);
|
||||
const inst: BrowserInstance = {
|
||||
browser,
|
||||
availablePages: pages,
|
||||
pdfCount: 0,
|
||||
lastRestartTime: Date.now(),
|
||||
restarting: false,
|
||||
id,
|
||||
};
|
||||
return inst;
|
||||
}
|
||||
|
||||
export async function initBrowser(): Promise<void> {
|
||||
for (let i = 0; i < BROWSER_COUNT; i++) {
|
||||
const inst = await launchInstance(i);
|
||||
instances.push(inst);
|
||||
}
|
||||
logger.info(`Browser pool ready (${BROWSER_COUNT} browsers × ${PAGES_PER_BROWSER} pages = ${BROWSER_COUNT * PAGES_PER_BROWSER} total)`);
|
||||
}
|
||||
|
||||
export async function closeBrowser(): Promise<void> {
|
||||
if (browser) await browser.close();
|
||||
for (const inst of instances) {
|
||||
for (const page of inst.availablePages) {
|
||||
await page.close().catch(() => {});
|
||||
}
|
||||
inst.availablePages.length = 0;
|
||||
await inst.browser.close().catch(() => {});
|
||||
}
|
||||
instances.length = 0;
|
||||
}
|
||||
|
||||
export async function renderPdf(
|
||||
|
|
@ -28,30 +230,31 @@ export async function renderPdf(
|
|||
displayHeaderFooter?: boolean;
|
||||
} = {}
|
||||
): Promise<Buffer> {
|
||||
if (!browser) throw new Error("Browser not initialized");
|
||||
|
||||
const page: Page = await browser.newPage();
|
||||
const { page, instance } = await acquirePage();
|
||||
try {
|
||||
await page.setContent(html, { waitUntil: "networkidle0", timeout: 15_000 });
|
||||
|
||||
const pdf = await page.pdf({
|
||||
format: (options.format as any) || "A4",
|
||||
landscape: options.landscape || false,
|
||||
printBackground: options.printBackground !== false,
|
||||
margin: options.margin || {
|
||||
top: "20mm",
|
||||
right: "15mm",
|
||||
bottom: "20mm",
|
||||
left: "15mm",
|
||||
},
|
||||
headerTemplate: options.headerTemplate,
|
||||
footerTemplate: options.footerTemplate,
|
||||
displayHeaderFooter: options.displayHeaderFooter || false,
|
||||
});
|
||||
|
||||
return Buffer.from(pdf);
|
||||
await page.setJavaScriptEnabled(false);
|
||||
const result = await Promise.race([
|
||||
(async () => {
|
||||
await page.setContent(html, { waitUntil: "domcontentloaded", timeout: 15_000 });
|
||||
await page.addStyleTag({ content: "* { margin: 0; padding: 0; } body { margin: 0; }" });
|
||||
const pdf = await page.pdf({
|
||||
format: (options.format as any) || "A4",
|
||||
landscape: options.landscape || false,
|
||||
printBackground: options.printBackground !== false,
|
||||
margin: options.margin || { top: "0", right: "0", bottom: "0", left: "0" },
|
||||
headerTemplate: options.headerTemplate,
|
||||
footerTemplate: options.footerTemplate,
|
||||
displayHeaderFooter: options.displayHeaderFooter || false,
|
||||
});
|
||||
return Buffer.from(pdf);
|
||||
})(),
|
||||
new Promise<never>((_, reject) =>
|
||||
setTimeout(() => reject(new Error("PDF_TIMEOUT")), 30_000)
|
||||
),
|
||||
]);
|
||||
return result;
|
||||
} finally {
|
||||
await page.close();
|
||||
releasePage(page, instance);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -65,29 +268,29 @@ export async function renderUrlPdf(
|
|||
waitUntil?: string;
|
||||
} = {}
|
||||
): Promise<Buffer> {
|
||||
if (!browser) throw new Error("Browser not initialized");
|
||||
|
||||
const page: Page = await browser.newPage();
|
||||
const { page, instance } = await acquirePage();
|
||||
try {
|
||||
await page.goto(url, {
|
||||
waitUntil: (options.waitUntil as any) || "networkidle0",
|
||||
timeout: 30_000,
|
||||
});
|
||||
|
||||
const pdf = await page.pdf({
|
||||
format: (options.format as any) || "A4",
|
||||
landscape: options.landscape || false,
|
||||
printBackground: options.printBackground !== false,
|
||||
margin: options.margin || {
|
||||
top: "20mm",
|
||||
right: "15mm",
|
||||
bottom: "20mm",
|
||||
left: "15mm",
|
||||
},
|
||||
});
|
||||
|
||||
return Buffer.from(pdf);
|
||||
await page.setJavaScriptEnabled(false);
|
||||
const result = await Promise.race([
|
||||
(async () => {
|
||||
await page.goto(url, {
|
||||
waitUntil: (options.waitUntil as any) || "networkidle0",
|
||||
timeout: 30_000,
|
||||
});
|
||||
const pdf = await page.pdf({
|
||||
format: (options.format as any) || "A4",
|
||||
landscape: options.landscape || false,
|
||||
printBackground: options.printBackground !== false,
|
||||
margin: options.margin || { top: "0", right: "0", bottom: "0", left: "0" },
|
||||
});
|
||||
return Buffer.from(pdf);
|
||||
})(),
|
||||
new Promise<never>((_, reject) =>
|
||||
setTimeout(() => reject(new Error("PDF_TIMEOUT")), 30_000)
|
||||
),
|
||||
]);
|
||||
return result;
|
||||
} finally {
|
||||
await page.close();
|
||||
releasePage(page, instance);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
66
projects/business/src/pdf-api/src/services/db.ts
Normal file
66
projects/business/src/pdf-api/src/services/db.ts
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
import pg from "pg";
|
||||
|
||||
import logger from "./logger.js";
|
||||
const { Pool } = pg;
|
||||
|
||||
const pool = new Pool({
|
||||
host: process.env.DATABASE_HOST || "172.17.0.1",
|
||||
port: parseInt(process.env.DATABASE_PORT || "5432", 10),
|
||||
database: process.env.DATABASE_NAME || "docfast",
|
||||
user: process.env.DATABASE_USER || "docfast",
|
||||
password: process.env.DATABASE_PASSWORD || "docfast",
|
||||
max: 10,
|
||||
idleTimeoutMillis: 30000,
|
||||
});
|
||||
|
||||
pool.on("error", (err) => {
|
||||
logger.error({ err }, "Unexpected PostgreSQL pool error");
|
||||
});
|
||||
|
||||
export async function initDatabase(): Promise<void> {
|
||||
const client = await pool.connect();
|
||||
try {
|
||||
await client.query(`
|
||||
CREATE TABLE IF NOT EXISTS api_keys (
|
||||
key TEXT PRIMARY KEY,
|
||||
tier TEXT NOT NULL DEFAULT 'free',
|
||||
email TEXT NOT NULL DEFAULT '',
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
stripe_customer_id TEXT
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS idx_api_keys_email ON api_keys(email);
|
||||
CREATE INDEX IF NOT EXISTS idx_api_keys_stripe ON api_keys(stripe_customer_id);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS verifications (
|
||||
id SERIAL PRIMARY KEY,
|
||||
email TEXT NOT NULL,
|
||||
token TEXT NOT NULL UNIQUE,
|
||||
api_key TEXT NOT NULL,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
verified_at TIMESTAMPTZ
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS idx_verifications_email ON verifications(email);
|
||||
CREATE INDEX IF NOT EXISTS idx_verifications_token ON verifications(token);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS pending_verifications (
|
||||
email TEXT PRIMARY KEY,
|
||||
code TEXT NOT NULL,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
expires_at TIMESTAMPTZ NOT NULL,
|
||||
attempts INT NOT NULL DEFAULT 0
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS usage (
|
||||
key TEXT PRIMARY KEY,
|
||||
count INT NOT NULL DEFAULT 0,
|
||||
month_key TEXT NOT NULL
|
||||
);
|
||||
`);
|
||||
logger.info("PostgreSQL tables initialized");
|
||||
} finally {
|
||||
client.release();
|
||||
}
|
||||
}
|
||||
|
||||
export { pool };
|
||||
export default pool;
|
||||
31
projects/business/src/pdf-api/src/services/email.ts
Normal file
31
projects/business/src/pdf-api/src/services/email.ts
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
import nodemailer from "nodemailer";
|
||||
import logger from "./logger.js";
|
||||
|
||||
const transporter = nodemailer.createTransport({
|
||||
host: process.env.SMTP_HOST || "host.docker.internal",
|
||||
port: Number(process.env.SMTP_PORT || 25),
|
||||
secure: false,
|
||||
connectionTimeout: 5000,
|
||||
greetingTimeout: 5000,
|
||||
socketTimeout: 10000,
|
||||
tls: { rejectUnauthorized: false },
|
||||
});
|
||||
|
||||
export async function sendVerificationEmail(email: string, code: string): Promise<boolean> {
|
||||
try {
|
||||
const info = await transporter.sendMail({
|
||||
from: "DocFast <noreply@docfast.dev>",
|
||||
to: email,
|
||||
subject: "DocFast - Verify your email",
|
||||
text: `Your DocFast verification code is: ${code}\n\nThis code expires in 15 minutes.\n\nIf you didn't request this, ignore this email.`,
|
||||
});
|
||||
logger.info({ email, messageId: info.messageId }, "Verification email sent");
|
||||
return true;
|
||||
} catch (err) {
|
||||
logger.error({ err, email }, "Failed to send verification email");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE: sendRecoveryEmail removed — API keys must NEVER be sent via email.
|
||||
// Key recovery now shows the key in the browser after code verification.
|
||||
|
|
@ -1,11 +1,6 @@
|
|||
import { randomBytes } from "crypto";
|
||||
import { readFileSync, writeFileSync, existsSync, mkdirSync } from "fs";
|
||||
import path from "path";
|
||||
import { fileURLToPath } from "url";
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
const DATA_DIR = path.join(__dirname, "../../data");
|
||||
const KEYS_FILE = path.join(DATA_DIR, "keys.json");
|
||||
import logger from "./logger.js";
|
||||
import pool from "./db.js";
|
||||
|
||||
export interface ApiKey {
|
||||
key: string;
|
||||
|
|
@ -15,47 +10,48 @@ export interface ApiKey {
|
|||
stripeCustomerId?: string;
|
||||
}
|
||||
|
||||
interface KeyStore {
|
||||
keys: ApiKey[];
|
||||
}
|
||||
// In-memory cache for fast lookups, synced with PostgreSQL
|
||||
let keysCache: ApiKey[] = [];
|
||||
|
||||
let store: KeyStore = { keys: [] };
|
||||
|
||||
function ensureDataDir(): void {
|
||||
if (!existsSync(DATA_DIR)) {
|
||||
mkdirSync(DATA_DIR, { recursive: true });
|
||||
export async function loadKeys(): Promise<void> {
|
||||
try {
|
||||
const result = await pool.query(
|
||||
"SELECT key, tier, email, created_at, stripe_customer_id FROM api_keys"
|
||||
);
|
||||
keysCache = result.rows.map((r) => ({
|
||||
key: r.key,
|
||||
tier: r.tier as "free" | "pro",
|
||||
email: r.email,
|
||||
createdAt: r.created_at instanceof Date ? r.created_at.toISOString() : r.created_at,
|
||||
stripeCustomerId: r.stripe_customer_id || undefined,
|
||||
}));
|
||||
} catch (err) {
|
||||
logger.error({ err }, "Failed to load keys from PostgreSQL");
|
||||
keysCache = [];
|
||||
}
|
||||
}
|
||||
|
||||
export function loadKeys(): void {
|
||||
ensureDataDir();
|
||||
if (existsSync(KEYS_FILE)) {
|
||||
try {
|
||||
store = JSON.parse(readFileSync(KEYS_FILE, "utf-8"));
|
||||
} catch {
|
||||
store = { keys: [] };
|
||||
}
|
||||
}
|
||||
// Also load seed keys from env
|
||||
const envKeys = process.env.API_KEYS?.split(",").map((k) => k.trim()).filter(Boolean) || [];
|
||||
for (const k of envKeys) {
|
||||
if (!store.keys.find((e) => e.key === k)) {
|
||||
store.keys.push({ key: k, tier: "pro", email: "seed@docfast.dev", createdAt: new Date().toISOString() });
|
||||
if (!keysCache.find((e) => e.key === k)) {
|
||||
const entry: ApiKey = { key: k, tier: "pro", email: "seed@docfast.dev", createdAt: new Date().toISOString() };
|
||||
keysCache.push(entry);
|
||||
// Upsert into DB
|
||||
await pool.query(
|
||||
`INSERT INTO api_keys (key, tier, email, created_at) VALUES ($1, $2, $3, $4)
|
||||
ON CONFLICT (key) DO NOTHING`,
|
||||
[k, "pro", "seed@docfast.dev", new Date().toISOString()]
|
||||
).catch(() => {});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function save(): void {
|
||||
ensureDataDir();
|
||||
writeFileSync(KEYS_FILE, JSON.stringify(store, null, 2));
|
||||
}
|
||||
|
||||
export function isValidKey(key: string): boolean {
|
||||
return store.keys.some((k) => k.key === key);
|
||||
return keysCache.some((k) => k.key === key);
|
||||
}
|
||||
|
||||
export function getKeyInfo(key: string): ApiKey | undefined {
|
||||
return store.keys.find((k) => k.key === key);
|
||||
return keysCache.find((k) => k.key === key);
|
||||
}
|
||||
|
||||
export function isProKey(key: string): boolean {
|
||||
|
|
@ -67,27 +63,32 @@ function generateKey(prefix: string): string {
|
|||
return `${prefix}_${randomBytes(24).toString("hex")}`;
|
||||
}
|
||||
|
||||
export function createFreeKey(email: string): ApiKey {
|
||||
// Check if email already has a free key
|
||||
const existing = store.keys.find((k) => k.email === email && k.tier === "free");
|
||||
if (existing) return existing;
|
||||
export async function createFreeKey(email?: string): Promise<ApiKey> {
|
||||
if (email) {
|
||||
const existing = keysCache.find((k) => k.email === email && k.tier === "free");
|
||||
if (existing) return existing;
|
||||
}
|
||||
|
||||
const entry: ApiKey = {
|
||||
key: generateKey("df_free"),
|
||||
tier: "free",
|
||||
email,
|
||||
email: email || "",
|
||||
createdAt: new Date().toISOString(),
|
||||
};
|
||||
store.keys.push(entry);
|
||||
save();
|
||||
|
||||
await pool.query(
|
||||
"INSERT INTO api_keys (key, tier, email, created_at) VALUES ($1, $2, $3, $4)",
|
||||
[entry.key, entry.tier, entry.email, entry.createdAt]
|
||||
);
|
||||
keysCache.push(entry);
|
||||
return entry;
|
||||
}
|
||||
|
||||
export function createProKey(email: string, stripeCustomerId: string): ApiKey {
|
||||
const existing = store.keys.find((k) => k.stripeCustomerId === stripeCustomerId);
|
||||
export async function createProKey(email: string, stripeCustomerId: string): Promise<ApiKey> {
|
||||
const existing = keysCache.find((k) => k.stripeCustomerId === stripeCustomerId);
|
||||
if (existing) {
|
||||
existing.tier = "pro";
|
||||
save();
|
||||
await pool.query("UPDATE api_keys SET tier = 'pro' WHERE key = $1", [existing.key]);
|
||||
return existing;
|
||||
}
|
||||
|
||||
|
|
@ -98,21 +99,34 @@ export function createProKey(email: string, stripeCustomerId: string): ApiKey {
|
|||
createdAt: new Date().toISOString(),
|
||||
stripeCustomerId,
|
||||
};
|
||||
store.keys.push(entry);
|
||||
save();
|
||||
|
||||
await pool.query(
|
||||
"INSERT INTO api_keys (key, tier, email, created_at, stripe_customer_id) VALUES ($1, $2, $3, $4, $5)",
|
||||
[entry.key, entry.tier, entry.email, entry.createdAt, entry.stripeCustomerId]
|
||||
);
|
||||
keysCache.push(entry);
|
||||
return entry;
|
||||
}
|
||||
|
||||
export function revokeByCustomer(stripeCustomerId: string): boolean {
|
||||
const idx = store.keys.findIndex((k) => k.stripeCustomerId === stripeCustomerId);
|
||||
export async function revokeByCustomer(stripeCustomerId: string): Promise<boolean> {
|
||||
const idx = keysCache.findIndex((k) => k.stripeCustomerId === stripeCustomerId);
|
||||
if (idx >= 0) {
|
||||
store.keys.splice(idx, 1);
|
||||
save();
|
||||
const key = keysCache[idx].key;
|
||||
keysCache.splice(idx, 1);
|
||||
await pool.query("DELETE FROM api_keys WHERE key = $1", [key]);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
export function getAllKeys(): ApiKey[] {
|
||||
return [...store.keys];
|
||||
return [...keysCache];
|
||||
}
|
||||
|
||||
export async function updateKeyEmail(apiKey: string, newEmail: string): Promise<boolean> {
|
||||
const entry = keysCache.find((k) => k.key === apiKey);
|
||||
if (!entry) return false;
|
||||
entry.email = newEmail;
|
||||
await pool.query("UPDATE api_keys SET email = $1 WHERE key = $2", [newEmail, apiKey]);
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
10
projects/business/src/pdf-api/src/services/logger.ts
Normal file
10
projects/business/src/pdf-api/src/services/logger.ts
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
import pino from "pino";
|
||||
|
||||
const logger = pino({
|
||||
level: process.env.LOG_LEVEL || "info",
|
||||
...(process.env.NODE_ENV !== "production" && {
|
||||
transport: { target: "pino/file", options: { destination: 1 } },
|
||||
}),
|
||||
});
|
||||
|
||||
export default logger;
|
||||
|
|
@ -47,7 +47,7 @@ function esc(s: string): string {
|
|||
}
|
||||
|
||||
function renderInvoice(d: any): string {
|
||||
const cur = d.currency || "€";
|
||||
const cur = esc(d.currency || "€");
|
||||
const items = d.items || [];
|
||||
let subtotal = 0;
|
||||
let totalTax = 0;
|
||||
|
|
@ -133,7 +133,7 @@ function renderInvoice(d: any): string {
|
|||
}
|
||||
|
||||
function renderReceipt(d: any): string {
|
||||
const cur = d.currency || "€";
|
||||
const cur = esc(d.currency || "€");
|
||||
const items = d.items || [];
|
||||
let total = 0;
|
||||
|
||||
|
|
|
|||
152
projects/business/src/pdf-api/src/services/verification.ts
Normal file
152
projects/business/src/pdf-api/src/services/verification.ts
Normal file
|
|
@ -0,0 +1,152 @@
|
|||
import { randomBytes, randomInt } from "crypto";
|
||||
import logger from "./logger.js";
|
||||
import pool from "./db.js";
|
||||
|
||||
export interface Verification {
|
||||
email: string;
|
||||
token: string;
|
||||
apiKey: string;
|
||||
createdAt: string;
|
||||
verifiedAt: string | null;
|
||||
}
|
||||
|
||||
export interface PendingVerification {
|
||||
email: string;
|
||||
code: string;
|
||||
createdAt: string;
|
||||
expiresAt: string;
|
||||
attempts: number;
|
||||
}
|
||||
|
||||
const TOKEN_EXPIRY_MS = 24 * 60 * 60 * 1000;
|
||||
const CODE_EXPIRY_MS = 15 * 60 * 1000;
|
||||
const MAX_ATTEMPTS = 3;
|
||||
|
||||
export async function createVerification(email: string, apiKey: string): Promise<Verification> {
|
||||
// Check for existing unexpired, unverified
|
||||
const existing = await pool.query(
|
||||
"SELECT * FROM verifications WHERE email = $1 AND verified_at IS NULL AND created_at > NOW() - INTERVAL '24 hours' LIMIT 1",
|
||||
[email]
|
||||
);
|
||||
if (existing.rows.length > 0) {
|
||||
const r = existing.rows[0];
|
||||
return { email: r.email, token: r.token, apiKey: r.api_key, createdAt: r.created_at.toISOString(), verifiedAt: null };
|
||||
}
|
||||
|
||||
// Remove old unverified
|
||||
await pool.query("DELETE FROM verifications WHERE email = $1 AND verified_at IS NULL", [email]);
|
||||
|
||||
const token = randomBytes(32).toString("hex");
|
||||
const now = new Date().toISOString();
|
||||
await pool.query(
|
||||
"INSERT INTO verifications (email, token, api_key, created_at) VALUES ($1, $2, $3, $4)",
|
||||
[email, token, apiKey, now]
|
||||
);
|
||||
return { email, token, apiKey, createdAt: now, verifiedAt: null };
|
||||
}
|
||||
|
||||
export function verifyToken(token: string): { status: "ok"; verification: Verification } | { status: "invalid" | "expired" | "already_verified"; verification?: Verification } {
|
||||
// Synchronous wrapper — we'll make it async-compatible
|
||||
// Actually need to keep sync for the GET /verify route. Use sync query workaround or refactor.
|
||||
// For simplicity, we'll cache verifications in memory too.
|
||||
return verifyTokenSync(token);
|
||||
}
|
||||
|
||||
// In-memory cache for verifications (loaded on startup, updated on changes)
|
||||
let verificationsCache: Verification[] = [];
|
||||
|
||||
export async function loadVerifications(): Promise<void> {
|
||||
const result = await pool.query("SELECT * FROM verifications");
|
||||
verificationsCache = result.rows.map((r) => ({
|
||||
email: r.email,
|
||||
token: r.token,
|
||||
apiKey: r.api_key,
|
||||
createdAt: r.created_at instanceof Date ? r.created_at.toISOString() : r.created_at,
|
||||
verifiedAt: r.verified_at ? (r.verified_at instanceof Date ? r.verified_at.toISOString() : r.verified_at) : null,
|
||||
}));
|
||||
|
||||
// Cleanup expired entries every 15 minutes
|
||||
setInterval(() => {
|
||||
const cutoff = Date.now() - 24 * 60 * 60 * 1000;
|
||||
const before = verificationsCache.length;
|
||||
verificationsCache = verificationsCache.filter(
|
||||
(v) => v.verifiedAt || new Date(v.createdAt).getTime() > cutoff
|
||||
);
|
||||
const removed = before - verificationsCache.length;
|
||||
if (removed > 0) logger.info({ removed }, "Cleaned expired verification cache entries");
|
||||
}, 15 * 60 * 1000);
|
||||
}
|
||||
|
||||
function verifyTokenSync(token: string): { status: "ok"; verification: Verification } | { status: "invalid" | "expired" | "already_verified"; verification?: Verification } {
|
||||
const v = verificationsCache.find((v) => v.token === token);
|
||||
if (!v) return { status: "invalid" };
|
||||
if (v.verifiedAt) return { status: "already_verified", verification: v };
|
||||
const age = Date.now() - new Date(v.createdAt).getTime();
|
||||
if (age > TOKEN_EXPIRY_MS) return { status: "expired" };
|
||||
v.verifiedAt = new Date().toISOString();
|
||||
// Update DB async
|
||||
pool.query("UPDATE verifications SET verified_at = $1 WHERE token = $2", [v.verifiedAt, token]).catch((err) => logger.error({ err }, "Failed to update verification"));
|
||||
return { status: "ok", verification: v };
|
||||
}
|
||||
|
||||
export async function createPendingVerification(email: string): Promise<PendingVerification> {
|
||||
await pool.query("DELETE FROM pending_verifications WHERE email = $1", [email]);
|
||||
|
||||
const now = new Date();
|
||||
const pending: PendingVerification = {
|
||||
email,
|
||||
code: String(randomInt(100000, 999999)),
|
||||
createdAt: now.toISOString(),
|
||||
expiresAt: new Date(now.getTime() + CODE_EXPIRY_MS).toISOString(),
|
||||
attempts: 0,
|
||||
};
|
||||
|
||||
await pool.query(
|
||||
"INSERT INTO pending_verifications (email, code, created_at, expires_at, attempts) VALUES ($1, $2, $3, $4, $5)",
|
||||
[pending.email, pending.code, pending.createdAt, pending.expiresAt, pending.attempts]
|
||||
);
|
||||
return pending;
|
||||
}
|
||||
|
||||
export async function verifyCode(email: string, code: string): Promise<{ status: "ok" | "invalid" | "expired" | "max_attempts" }> {
|
||||
const cleanEmail = email.trim().toLowerCase();
|
||||
const result = await pool.query("SELECT * FROM pending_verifications WHERE email = $1", [cleanEmail]);
|
||||
const pending = result.rows[0];
|
||||
|
||||
if (!pending) return { status: "invalid" };
|
||||
|
||||
if (new Date() > new Date(pending.expires_at)) {
|
||||
await pool.query("DELETE FROM pending_verifications WHERE email = $1", [cleanEmail]);
|
||||
return { status: "expired" };
|
||||
}
|
||||
|
||||
if (pending.attempts >= MAX_ATTEMPTS) {
|
||||
await pool.query("DELETE FROM pending_verifications WHERE email = $1", [cleanEmail]);
|
||||
return { status: "max_attempts" };
|
||||
}
|
||||
|
||||
await pool.query("UPDATE pending_verifications SET attempts = attempts + 1 WHERE email = $1", [cleanEmail]);
|
||||
|
||||
if (pending.code !== code) {
|
||||
return { status: "invalid" };
|
||||
}
|
||||
|
||||
await pool.query("DELETE FROM pending_verifications WHERE email = $1", [cleanEmail]);
|
||||
return { status: "ok" };
|
||||
}
|
||||
|
||||
export async function isEmailVerified(email: string): Promise<boolean> {
|
||||
const result = await pool.query(
|
||||
"SELECT 1 FROM verifications WHERE email = $1 AND verified_at IS NOT NULL LIMIT 1",
|
||||
[email]
|
||||
);
|
||||
return result.rows.length > 0;
|
||||
}
|
||||
|
||||
export async function getVerifiedApiKey(email: string): Promise<string | null> {
|
||||
const result = await pool.query(
|
||||
"SELECT api_key FROM verifications WHERE email = $1 AND verified_at IS NOT NULL LIMIT 1",
|
||||
[email]
|
||||
);
|
||||
return result.rows[0]?.api_key ?? null;
|
||||
}
|
||||
35
projects/business/src/pdf-api/state.json
Normal file
35
projects/business/src/pdf-api/state.json
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
{
|
||||
"project": "DocFast",
|
||||
"domain": "docfast.dev",
|
||||
"server": "167.235.156.214",
|
||||
"sshKey": "/home/openclaw/.ssh/docfast",
|
||||
"repo": "openclawd/docfast",
|
||||
"status": "live",
|
||||
"version": "0.2.1",
|
||||
"lastDeployment": "2026-02-14T22:17:00Z",
|
||||
"lastQA": "2026-02-14T22:18:00Z",
|
||||
"features": {
|
||||
"htmlToPdf": true,
|
||||
"markdownToPdf": true,
|
||||
"urlToPdf": true,
|
||||
"templates": true,
|
||||
"signup": true,
|
||||
"emailVerification": true,
|
||||
"keyRecovery": true,
|
||||
"emailChange": "frontend-only",
|
||||
"swaggerDocs": true,
|
||||
"browserPool": "1 browser × 15 pages",
|
||||
"stripeIntegration": true
|
||||
},
|
||||
"infrastructure": {
|
||||
"webServer": "nginx",
|
||||
"ssl": "letsencrypt",
|
||||
"container": "docker-compose",
|
||||
"email": "postfix + opendkim"
|
||||
},
|
||||
"todos": [
|
||||
"Implement email change backend route (/v1/email-change + /v1/email-change/verify)",
|
||||
"Set up staging environment for pre-production testing",
|
||||
"Remove obsolete \\001@ file from repo"
|
||||
]
|
||||
}
|
||||
110
projects/business/src/pdf-api/templates/pages/docs.html
Normal file
110
projects/business/src/pdf-api/templates/pages/docs.html
Normal file
|
|
@ -0,0 +1,110 @@
|
|||
<!-- title: DocFast API Documentation -->
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>DocFast API Documentation</title>
|
||||
<link rel="icon" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><text y='.9em' font-size='90'>⚡</text></svg>">
|
||||
<link rel="stylesheet" href="/swagger-ui/swagger-ui.css">
|
||||
<style>
|
||||
html { box-sizing: border-box; overflow-y: scroll; }
|
||||
*, *:before, *:after { box-sizing: inherit; }
|
||||
body { margin: 0; background: #1a1a2e; font-family: 'Inter', -apple-system, system-ui, sans-serif; }
|
||||
|
||||
/* Top bar */
|
||||
.topbar-wrapper { display: flex; align-items: center; }
|
||||
.swagger-ui .topbar { background: #0b0d11; border-bottom: 1px solid #1e2433; padding: 12px 0; }
|
||||
.swagger-ui .topbar .topbar-wrapper { max-width: 1200px; margin: 0 auto; padding: 0 24px; }
|
||||
.swagger-ui .topbar a { font-size: 0; }
|
||||
.swagger-ui .topbar .topbar-wrapper::before {
|
||||
content: '⚡ DocFast API';
|
||||
font-size: 1.25rem;
|
||||
font-weight: 700;
|
||||
color: #e4e7ed;
|
||||
font-family: 'Inter', system-ui, sans-serif;
|
||||
}
|
||||
.swagger-ui .topbar .topbar-wrapper::after {
|
||||
content: '← Back to docfast.dev';
|
||||
margin-left: auto;
|
||||
font-size: 0.85rem;
|
||||
color: #34d399;
|
||||
cursor: pointer;
|
||||
font-family: 'Inter', system-ui, sans-serif;
|
||||
}
|
||||
.swagger-ui .topbar .topbar-wrapper { cursor: default; }
|
||||
|
||||
/* Dark theme overrides */
|
||||
.swagger-ui { color: #c8ccd4; }
|
||||
.swagger-ui .wrapper { max-width: 1200px; padding: 0 24px; }
|
||||
.swagger-ui .scheme-container { background: #151922; border: 1px solid #1e2433; border-radius: 8px; margin: 16px 0; box-shadow: none; }
|
||||
.swagger-ui .opblock-tag { color: #e4e7ed !important; border-bottom: 1px solid #1e2433; }
|
||||
.swagger-ui .opblock-tag:hover { background: rgba(52,211,153,0.04); }
|
||||
.swagger-ui .opblock { background: #151922; border: 1px solid #1e2433 !important; border-radius: 8px !important; margin-bottom: 12px; box-shadow: none !important; }
|
||||
.swagger-ui .opblock .opblock-summary { border: none; }
|
||||
.swagger-ui .opblock .opblock-summary-method { border-radius: 6px; font-size: 0.75rem; min-width: 70px; }
|
||||
.swagger-ui .opblock.opblock-post .opblock-summary-method { background: #34d399; }
|
||||
.swagger-ui .opblock.opblock-get .opblock-summary-method { background: #60a5fa; }
|
||||
.swagger-ui .opblock.opblock-post { border-color: rgba(52,211,153,0.3) !important; background: rgba(52,211,153,0.03); }
|
||||
.swagger-ui .opblock.opblock-get { border-color: rgba(96,165,250,0.3) !important; background: rgba(96,165,250,0.03); }
|
||||
.swagger-ui .opblock .opblock-summary-path { color: #e4e7ed; }
|
||||
.swagger-ui .opblock .opblock-summary-description { color: #7a8194; }
|
||||
.swagger-ui .opblock-body { background: #0b0d11; }
|
||||
.swagger-ui .opblock-description-wrapper p,
|
||||
.swagger-ui .opblock-external-docs-wrapper p { color: #9ca3af; }
|
||||
.swagger-ui table thead tr th { color: #7a8194; border-bottom: 1px solid #1e2433; }
|
||||
.swagger-ui table tbody tr td { color: #c8ccd4; border-bottom: 1px solid #1e2433; }
|
||||
.swagger-ui .parameter__name { color: #e4e7ed; }
|
||||
.swagger-ui .parameter__type { color: #60a5fa; }
|
||||
.swagger-ui .parameter__name.required::after { color: #f87171; }
|
||||
.swagger-ui input[type=text], .swagger-ui textarea, .swagger-ui select {
|
||||
background: #0b0d11; color: #e4e7ed; border: 1px solid #1e2433; border-radius: 6px;
|
||||
}
|
||||
.swagger-ui .btn { border-radius: 6px; }
|
||||
.swagger-ui .btn.execute { background: #34d399; color: #0b0d11; border: none; }
|
||||
.swagger-ui .btn.execute:hover { background: #5eead4; }
|
||||
.swagger-ui .responses-inner { background: transparent; }
|
||||
.swagger-ui .response-col_status { color: #34d399; }
|
||||
.swagger-ui .response-col_description { color: #9ca3af; }
|
||||
.swagger-ui .model-box, .swagger-ui section.models { background: #151922; border: 1px solid #1e2433; border-radius: 8px; }
|
||||
.swagger-ui section.models h4 { color: #e4e7ed; border-bottom: 1px solid #1e2433; }
|
||||
.swagger-ui .model { color: #c8ccd4; }
|
||||
.swagger-ui .model-title { color: #e4e7ed; }
|
||||
.swagger-ui .prop-type { color: #60a5fa; }
|
||||
.swagger-ui .info .title { color: #e4e7ed; font-family: 'Inter', system-ui, sans-serif; }
|
||||
.swagger-ui .info .description p { color: #9ca3af; }
|
||||
.swagger-ui .info a { color: #34d399; }
|
||||
.swagger-ui .info h1, .swagger-ui .info h2, .swagger-ui .info h3 { color: #e4e7ed; }
|
||||
.swagger-ui .info .base-url { color: #7a8194; }
|
||||
.swagger-ui .scheme-container .schemes > label { color: #7a8194; }
|
||||
.swagger-ui .loading-container .loading::after { color: #7a8194; }
|
||||
.swagger-ui .highlight-code, .swagger-ui .microlight { background: #0b0d11 !important; color: #c8ccd4 !important; border-radius: 6px; }
|
||||
.swagger-ui .copy-to-clipboard { right: 10px; top: 10px; }
|
||||
.swagger-ui .auth-wrapper .authorize { color: #34d399; border-color: #34d399; }
|
||||
.swagger-ui .auth-wrapper .authorize svg { fill: #34d399; }
|
||||
.swagger-ui .dialog-ux .modal-ux { background: #151922; border: 1px solid #1e2433; }
|
||||
.swagger-ui .dialog-ux .modal-ux-header h3 { color: #e4e7ed; }
|
||||
.swagger-ui .dialog-ux .modal-ux-content p { color: #9ca3af; }
|
||||
.swagger-ui .model-box-control:focus, .swagger-ui .models-control:focus { outline: none; }
|
||||
.swagger-ui .servers > label select { background: #0b0d11; color: #e4e7ed; border: 1px solid #1e2433; }
|
||||
.swagger-ui .markdown code, .swagger-ui .renderedMarkdown code { background: rgba(52,211,153,0.1); color: #34d399; padding: 2px 6px; border-radius: 4px; }
|
||||
.swagger-ui .markdown p, .swagger-ui .renderedMarkdown p { color: #9ca3af; }
|
||||
.swagger-ui .opblock-tag small { color: #7a8194; }
|
||||
|
||||
/* Hide validator */
|
||||
.swagger-ui .errors-wrapper { display: none; }
|
||||
|
||||
/* Link back */
|
||||
.back-link { position: fixed; top: 14px; right: 24px; z-index: 100; color: #34d399; text-decoration: none; font-size: 0.85rem; font-family: 'Inter', system-ui, sans-serif; }
|
||||
.back-link:hover { color: #5eead4; }
|
||||
</style>
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap" rel="stylesheet">
|
||||
</head>
|
||||
<body>
|
||||
<a href="/" class="back-link">← Back to docfast.dev</a>
|
||||
<div id="swagger-ui"></div>
|
||||
<script src="/swagger-ui/swagger-ui-bundle.js"></script>
|
||||
<script src="/swagger-init.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
55
projects/business/src/pdf-api/templates/pages/impressum.html
Normal file
55
projects/business/src/pdf-api/templates/pages/impressum.html
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
<!-- title: Impressum — DocFast -->
|
||||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
{{> head-common}}
|
||||
<title>{{title}}</title>
|
||||
<meta name="description" content="Legal notice and company information for DocFast API service.">
|
||||
<link rel="canonical" href="https://docfast.dev/impressum">
|
||||
<link rel="icon" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><text y='.9em' font-size='90'>⚡</text></svg>">
|
||||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap" rel="stylesheet">
|
||||
<style>
|
||||
{{> styles-base}}
|
||||
.container { max-width: 800px; margin: 0 auto; padding: 0 24px; }
|
||||
|
||||
{{> styles-legal}}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
{{> nav}}
|
||||
|
||||
<main>
|
||||
<div class="container">
|
||||
<h1>Impressum</h1>
|
||||
<p><em>Legal notice according to § 5 ECG and § 25 MedienG (Austrian law)</em></p>
|
||||
|
||||
<h2>Company Information</h2>
|
||||
<p><strong>Company:</strong> Cloonar Technologies GmbH</p>
|
||||
<p><strong>Address:</strong> Linzer Straße 192/1/2, 1140 Wien, Austria</p>
|
||||
<p><strong>Email:</strong> <a href="mailto:legal@docfast.dev">legal@docfast.dev</a></p>
|
||||
|
||||
<h2>Legal Registration</h2>
|
||||
<p><strong>Commercial Register:</strong> FN 631089y</p>
|
||||
<p><strong>Court:</strong> Handelsgericht Wien</p>
|
||||
<p><strong>VAT ID:</strong> ATU81280034</p>
|
||||
<p><strong>GLN:</strong> 9110036145697</p>
|
||||
|
||||
<h2>Responsible for Content</h2>
|
||||
<p>Cloonar Technologies GmbH<br>
|
||||
Legal contact: <a href="mailto:legal@docfast.dev">legal@docfast.dev</a></p>
|
||||
|
||||
<h2>Disclaimer</h2>
|
||||
<p>Despite careful content control, we assume no liability for the content of external links. The operators of the linked pages are solely responsible for their content.</p>
|
||||
|
||||
<p>The content of our website has been created with the greatest possible care. However, we cannot guarantee that the content is current, reliable or complete.</p>
|
||||
|
||||
<h2>EU Online Dispute Resolution</h2>
|
||||
<p>Platform of the European Commission for Online Dispute Resolution (ODR): <a href="https://ec.europa.eu/consumers/odr" target="_blank" rel="noopener">https://ec.europa.eu/consumers/odr</a></p>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
{{> footer}}
|
||||
|
||||
</body>
|
||||
</html>
|
||||
493
projects/business/src/pdf-api/templates/pages/index.html
Normal file
493
projects/business/src/pdf-api/templates/pages/index.html
Normal file
|
|
@ -0,0 +1,493 @@
|
|||
<!-- title: DocFast — HTML & Markdown to PDF API -->
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
{{head}}
|
||||
<title>{{title}}</title>
|
||||
<meta name="description" content="Convert HTML and Markdown to beautiful PDFs with a simple API call. Built-in invoice templates. Fast, reliable, developer-friendly.">
|
||||
<meta property="og:title" content="DocFast — HTML & Markdown to PDF API">
|
||||
<meta property="og:description" content="Convert HTML and Markdown to beautiful PDFs with a simple API call. Fast, reliable, developer-friendly.">
|
||||
<meta property="og:type" content="website">
|
||||
<meta property="og:url" content="https://docfast.dev">
|
||||
<meta property="og:image" content="https://docfast.dev/og-image.png">
|
||||
<meta name="twitter:card" content="summary_large_image">
|
||||
<meta name="twitter:title" content="DocFast — HTML & Markdown to PDF API">
|
||||
<meta name="twitter:description" content="Convert HTML and Markdown to beautiful PDFs with a simple API call.">
|
||||
<link rel="canonical" href="https://docfast.dev">
|
||||
<script type="application/ld+json">
|
||||
{"@context":"https://schema.org","@type":"SoftwareApplication","name":"DocFast","url":"https://docfast.dev","applicationCategory":"DeveloperApplication","operatingSystem":"Web","description":"Convert HTML and Markdown to beautiful PDFs with a simple API call. Fast, reliable, developer-friendly.","offers":[{"@type":"Offer","price":"0","priceCurrency":"EUR","name":"Free","description":"100 PDFs/month"},{"@type":"Offer","price":"9","priceCurrency":"EUR","name":"Pro","description":"5,000 PDFs / month","billingIncrement":"P1M"}]}
|
||||
</script>
|
||||
<style>
|
||||
{{styles_base}}
|
||||
|
||||
/* Hero */
|
||||
.hero { padding: 100px 0 80px; text-align: center; position: relative; }
|
||||
.hero::before { content: ''; position: absolute; top: 0; left: 50%; transform: translateX(-50%); width: 600px; height: 400px; background: radial-gradient(ellipse, var(--accent-glow) 0%, transparent 70%); pointer-events: none; }
|
||||
.badge { display: inline-block; padding: 6px 16px; border-radius: 50px; font-size: 0.8rem; font-weight: 600; color: var(--accent); background: rgba(52,211,153,0.08); border: 1px solid rgba(52,211,153,0.15); margin-bottom: 24px; letter-spacing: 0.3px; }
|
||||
.hero h1 { font-size: clamp(2.2rem, 5vw, 3.5rem); font-weight: 800; margin-bottom: 20px; letter-spacing: -1.5px; line-height: 1.15; }
|
||||
.hero h1 .gradient { background: linear-gradient(135deg, var(--accent) 0%, var(--accent2) 100%); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
|
||||
.hero p { font-size: 1.2rem; color: var(--muted); max-width: 560px; margin: 0 auto 40px; line-height: 1.7; }
|
||||
.hero-actions { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }
|
||||
|
||||
/* Code block */
|
||||
.code-section { margin: 56px auto 0; max-width: 660px; text-align: left; display: flex; flex-direction: column; }
|
||||
.code-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 20px; background: #1a1f2b; border: 1px solid var(--border); border-bottom: none; border-radius: var(--radius) var(--radius) 0 0; }
|
||||
.code-dots { display: flex; gap: 6px; }
|
||||
.code-dots span { width: 10px; height: 10px; border-radius: 50%; }
|
||||
.code-dots span:nth-child(1) { background: #f87171; }
|
||||
.code-dots span:nth-child(2) { background: #fbbf24; }
|
||||
.code-dots span:nth-child(3) { background: #34d399; }
|
||||
.code-label { font-size: 0.75rem; color: var(--muted); font-family: monospace; }
|
||||
.code-block { background: var(--card); border: 1px solid var(--border); border-radius: 0 0 var(--radius) var(--radius); padding: 24px 28px; font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace; font-size: 0.85rem; line-height: 1.85; overflow-x: auto; }
|
||||
.code-block .c { color: #4a5568; }
|
||||
.code-block .s { color: var(--accent); }
|
||||
.code-block .k { color: var(--accent2); }
|
||||
.code-block .f { color: #c084fc; }
|
||||
|
||||
/* Sections */
|
||||
section { position: relative; }
|
||||
.section-title { text-align: center; font-size: clamp(1.5rem, 3vw, 2.2rem); font-weight: 700; letter-spacing: -0.5px; margin-bottom: 12px; }
|
||||
.section-sub { text-align: center; color: var(--muted); margin-bottom: 48px; font-size: 1.05rem; }
|
||||
|
||||
/* Features */
|
||||
.features { padding: 80px 0; }
|
||||
.features-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
|
||||
@media (max-width: 768px) { .features-grid { grid-template-columns: 1fr; } }
|
||||
.feature-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 28px; transition: border-color 0.2s, transform 0.2s; }
|
||||
.feature-card:hover { border-color: rgba(52,211,153,0.3); transform: translateY(-2px); }
|
||||
.feature-icon { width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 1.2rem; margin-bottom: 16px; background: rgba(52,211,153,0.08); }
|
||||
.feature-card h3 { font-size: 1rem; font-weight: 600; margin-bottom: 8px; }
|
||||
.feature-card p { color: var(--muted); font-size: 0.9rem; line-height: 1.6; }
|
||||
|
||||
/* Pricing */
|
||||
.pricing { padding: 80px 0; }
|
||||
.pricing-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 24px; max-width: 700px; margin: 0 auto; }
|
||||
@media (max-width: 640px) { .pricing-grid { grid-template-columns: 1fr; } }
|
||||
.price-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 36px; position: relative; }
|
||||
.price-card.featured { border-color: var(--accent); }
|
||||
.price-card.featured::before { content: 'POPULAR'; position: absolute; top: -10px; right: 20px; background: var(--accent); color: #0b0d11; font-size: 0.65rem; font-weight: 700; padding: 3px 10px; border-radius: 50px; letter-spacing: 0.5px; }
|
||||
.price-name { font-size: 0.9rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px; }
|
||||
.price-amount { font-size: 3rem; font-weight: 800; letter-spacing: -2px; margin-bottom: 4px; }
|
||||
.price-amount span { font-size: 1rem; color: var(--muted); font-weight: 400; letter-spacing: 0; }
|
||||
.price-desc { color: var(--muted); font-size: 0.85rem; margin-bottom: 24px; padding-bottom: 24px; border-bottom: 1px solid var(--border); }
|
||||
.price-features { list-style: none; margin-bottom: 28px; }
|
||||
.price-features li { padding: 5px 0; color: var(--muted); font-size: 0.9rem; display: flex; align-items: center; gap: 10px; }
|
||||
.price-features li::before { content: "✓"; color: var(--accent); font-weight: 700; font-size: 0.85rem; flex-shrink: 0; }
|
||||
|
||||
/* Trust */
|
||||
.trust { padding: 60px 0 40px; }
|
||||
.trust-grid { display: flex; gap: 40px; justify-content: center; flex-wrap: wrap; }
|
||||
.trust-item { text-align: center; flex: 1; min-width: 160px; max-width: 220px; }
|
||||
.trust-num { font-size: 2rem; font-weight: 800; color: var(--accent); letter-spacing: -1px; }
|
||||
.trust-label { font-size: 0.85rem; color: var(--muted); margin-top: 4px; }
|
||||
|
||||
/* EU Hosting */
|
||||
.eu-hosting { padding: 40px 0 80px; }
|
||||
.eu-badge { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 32px; max-width: 600px; margin: 0 auto; display: flex; align-items: center; gap: 20px; transition: border-color 0.2s, transform 0.2s; }
|
||||
.eu-badge:hover { border-color: rgba(52,211,153,0.3); transform: translateY(-2px); }
|
||||
.eu-icon { font-size: 3rem; flex-shrink: 0; }
|
||||
.eu-content h3 { font-size: 1.4rem; font-weight: 700; margin-bottom: 8px; color: var(--fg); }
|
||||
.eu-content p { color: var(--muted); font-size: 0.95rem; line-height: 1.6; margin: 0; }
|
||||
@media (max-width: 640px) {
|
||||
.eu-badge { flex-direction: column; text-align: center; gap: 16px; padding: 24px; }
|
||||
.eu-icon { font-size: 2.5rem; }
|
||||
}
|
||||
|
||||
/* Modal */
|
||||
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.75); backdrop-filter: blur(4px); z-index: 100; align-items: center; justify-content: center; }
|
||||
.modal-overlay.active { display: flex; }
|
||||
.modal { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 40px; max-width: 460px; width: 90%; position: relative; }
|
||||
.modal h2 { margin-bottom: 8px; font-size: 1.4rem; font-weight: 700; }
|
||||
.modal p { color: var(--muted); margin-bottom: 24px; font-size: 0.95rem; }
|
||||
.modal .close { position: absolute; top: 16px; right: 20px; color: var(--muted); font-size: 1.4rem; cursor: pointer; background: none; border: none; transition: color 0.2s; }
|
||||
.modal .close:hover { color: var(--fg); }
|
||||
|
||||
/* Signup states */
|
||||
#signupInitial, #signupLoading, #signupVerify, #signupResult { display: none; }
|
||||
#signupInitial.active { display: block; }
|
||||
#signupLoading.active { display: flex; flex-direction: column; align-items: center; padding: 40px 0; text-align: center; }
|
||||
#signupResult.active { display: block; }
|
||||
#signupVerify.active { display: block; }
|
||||
.spinner { width: 36px; height: 36px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.7s linear infinite; margin-bottom: 16px; }
|
||||
@keyframes spin { to { transform: rotate(360deg); } }
|
||||
|
||||
.key-box { background: var(--bg); border: 1px solid var(--accent); border-radius: 8px; padding: 16px; font-family: monospace; font-size: 0.82rem; word-break: break-all; margin: 16px 0 12px; position: relative; cursor: pointer; transition: background 0.2s; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
|
||||
.key-box:hover { background: #151922; }
|
||||
.key-text { flex: 1; }
|
||||
.copy-btn { background: rgba(52,211,153,0.1); border: 1px solid rgba(52,211,153,0.2); color: var(--accent); border-radius: 6px; padding: 6px 14px; font-size: 0.8rem; font-weight: 600; cursor: pointer; white-space: nowrap; transition: all 0.2s; }
|
||||
.copy-btn:hover { background: rgba(52,211,153,0.2); }
|
||||
.warning-box { background: rgba(251,191,36,0.06); border: 1px solid rgba(251,191,36,0.15); border-radius: 8px; padding: 12px 16px; font-size: 0.85rem; color: #fbbf24; display: flex; align-items: flex-start; gap: 10px; margin-bottom: 16px; }
|
||||
.warning-box .icon { font-size: 1.1rem; flex-shrink: 0; }
|
||||
.signup-error { color: #f87171; font-size: 0.85rem; margin-bottom: 16px; display: none; padding: 10px 14px; background: rgba(248,113,113,0.06); border: 1px solid rgba(248,113,113,0.15); border-radius: 8px; }
|
||||
|
||||
/* Recovery modal states */
|
||||
#recoverInitial, #recoverLoading, #recoverVerify, #recoverResult { display: none; }
|
||||
#recoverInitial.active { display: block; }
|
||||
#recoverLoading.active { display: flex; flex-direction: column; align-items: center; padding: 40px 0; text-align: center; }
|
||||
#recoverResult.active { display: block; }
|
||||
#recoverVerify.active { display: block; }
|
||||
|
||||
/* Email change modal states */
|
||||
#emailChangeInitial, #emailChangeLoading, #emailChangeVerify, #emailChangeResult { display: none; }
|
||||
#emailChangeInitial.active { display: block; }
|
||||
#emailChangeLoading.active { display: flex; flex-direction: column; align-items: center; padding: 40px 0; text-align: center; }
|
||||
#emailChangeResult.active { display: block; }
|
||||
#emailChangeVerify.active { display: block; }
|
||||
|
||||
/* Responsive */
|
||||
@media (max-width: 640px) {
|
||||
.hero { padding: 72px 0 56px; }
|
||||
.code-block {
|
||||
font-size: 0.75rem;
|
||||
padding: 18px 16px;
|
||||
overflow-x: hidden;
|
||||
word-wrap: break-word;
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
.trust-grid { gap: 24px; }
|
||||
}
|
||||
|
||||
/* Fix mobile terminal gaps at 375px and smaller */
|
||||
@media (max-width: 375px) {
|
||||
.container {
|
||||
padding: 0 12px !important;
|
||||
}
|
||||
.code-section {
|
||||
margin: 32px auto 0;
|
||||
max-width: calc(100vw - 24px) !important;
|
||||
}
|
||||
.code-header {
|
||||
padding: 8px 12px;
|
||||
}
|
||||
.code-block {
|
||||
padding: 12px !important;
|
||||
font-size: 0.7rem;
|
||||
}
|
||||
.hero {
|
||||
padding: 56px 0 40px;
|
||||
}
|
||||
}
|
||||
|
||||
/* Additional mobile overflow fixes */
|
||||
html, body {
|
||||
overflow-x: hidden !important;
|
||||
max-width: 100vw !important;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
* {
|
||||
max-width: 100% !important;
|
||||
}
|
||||
body {
|
||||
overflow-x: hidden !important;
|
||||
}
|
||||
.container {
|
||||
overflow-x: hidden !important;
|
||||
max-width: 100vw !important;
|
||||
padding: 0 16px !important;
|
||||
}
|
||||
.code-section {
|
||||
max-width: calc(100vw - 32px) !important;
|
||||
overflow: hidden !important;
|
||||
display: flex !important;
|
||||
flex-direction: column !important;
|
||||
white-space: normal !important;
|
||||
}
|
||||
.code-block {
|
||||
overflow-x: hidden !important;
|
||||
white-space: pre-wrap !important;
|
||||
word-break: break-all !important;
|
||||
max-width: 100% !important;
|
||||
box-sizing: border-box !important;
|
||||
}
|
||||
.trust-grid {
|
||||
justify-content: center !important;
|
||||
overflow-x: hidden !important;
|
||||
max-width: 100% !important;
|
||||
}
|
||||
|
||||
/* Force any wide elements to fit */
|
||||
pre, code, .code-block {
|
||||
max-width: calc(100vw - 32px) !important;
|
||||
overflow-wrap: break-word !important;
|
||||
word-break: break-all !important;
|
||||
white-space: pre-wrap !important;
|
||||
overflow-x: hidden !important;
|
||||
}
|
||||
.code-section {
|
||||
max-width: calc(100vw - 32px) !important;
|
||||
overflow-x: hidden !important;
|
||||
white-space: normal !important;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
{{nav}}
|
||||
|
||||
<main class="hero" role="main">
|
||||
<div class="container">
|
||||
<div class="badge">🚀 Simple PDF API for Developers</div>
|
||||
<h1>HTML to <span class="gradient">PDF</span><br>in one API call</h1>
|
||||
<p>Convert HTML, Markdown, or URLs to pixel-perfect PDFs. Built-in templates for invoices & receipts. No headless browser headaches.</p>
|
||||
<div class="hero-actions">
|
||||
<button class="btn btn-primary" id="btn-signup">Get Free API Key →</button>
|
||||
<a href="/docs" class="btn btn-secondary">Read the Docs</a>
|
||||
</div>
|
||||
<p style="margin-top:16px;color:var(--muted);font-size:0.9rem;">Already have an account? <a href="#" class="open-recover" style="color:var(--accent);">Lost your API key? Recover it →</a></p>
|
||||
|
||||
<div class="code-section">
|
||||
<div class="code-header">
|
||||
<div class="code-dots" aria-hidden="true"><span></span><span></span><span></span></div>
|
||||
<span class="code-label">terminal</span>
|
||||
</div>
|
||||
<div class="code-block">
|
||||
<span class="c"># Convert HTML to PDF — it's that simple</span>
|
||||
<span class="k">curl</span> <span class="f">-X POST</span> https://docfast.dev/v1/convert/html \
|
||||
-H <span class="s">"Authorization: Bearer YOUR_KEY"</span> \
|
||||
-H <span class="s">"Content-Type: application/json"</span> \
|
||||
-d <span class="s">'{"html": "<h1>Hello World</h1><p>Your first PDF</p>"}'</span> \
|
||||
-o <span class="f">output.pdf</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<section class="trust">
|
||||
<div class="container">
|
||||
<div class="trust-grid">
|
||||
<div class="trust-item">
|
||||
<div class="trust-num"><1s</div>
|
||||
<div class="trust-label">Avg. generation time</div>
|
||||
</div>
|
||||
<div class="trust-item">
|
||||
<div class="trust-num">99.5%</div>
|
||||
<div class="trust-label">Uptime SLA</div>
|
||||
</div>
|
||||
<div class="trust-item">
|
||||
<div class="trust-num">HTTPS</div>
|
||||
<div class="trust-label">Encrypted & secure</div>
|
||||
</div>
|
||||
<div class="trust-item">
|
||||
<div class="trust-num">0 bytes</div>
|
||||
<div class="trust-label">Data stored on disk</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="eu-hosting">
|
||||
<div class="container">
|
||||
<div class="eu-badge">
|
||||
<div class="eu-icon">🇪🇺</div>
|
||||
<div class="eu-content">
|
||||
<h3>Hosted in the EU</h3>
|
||||
<p>Your data never leaves the EU • GDPR Compliant • Hetzner Germany (Nuremberg)</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="features" id="features">
|
||||
<div class="container">
|
||||
<h2 class="section-title">Everything you need</h2>
|
||||
<p class="section-sub">A complete PDF generation API. No SDKs, no dependencies, no setup.</p>
|
||||
<div class="features-grid">
|
||||
<div class="feature-card">
|
||||
<div class="feature-icon" aria-hidden="true">⚡</div>
|
||||
<h3>Sub-second Speed</h3>
|
||||
<p>Persistent browser pool — no cold starts. Your PDFs are ready before your spinner shows.</p>
|
||||
</div>
|
||||
<div class="feature-card">
|
||||
<div class="feature-icon" aria-hidden="true">🎨</div>
|
||||
<h3>Pixel-perfect Output</h3>
|
||||
<p>Full CSS support including flexbox, grid, and custom fonts. Your brand, your PDFs.</p>
|
||||
</div>
|
||||
<div class="feature-card">
|
||||
<div class="feature-icon" aria-hidden="true">📄</div>
|
||||
<h3>Built-in Templates</h3>
|
||||
<p>Invoice and receipt templates out of the box. Pass JSON data, get beautiful PDFs.</p>
|
||||
</div>
|
||||
<div class="feature-card">
|
||||
<div class="feature-icon" aria-hidden="true">🔧</div>
|
||||
<h3>Dead-simple API</h3>
|
||||
<p>REST API. JSON in, PDF out. Works with curl, Python, Node, Go — anything with HTTP.</p>
|
||||
</div>
|
||||
<div class="feature-card">
|
||||
<div class="feature-icon" aria-hidden="true">📐</div>
|
||||
<h3>Fully Configurable</h3>
|
||||
<p>A4, Letter, custom sizes. Portrait or landscape. Headers, footers, and margins.</p>
|
||||
</div>
|
||||
<div class="feature-card">
|
||||
<div class="feature-icon" aria-hidden="true">🔒</div>
|
||||
<h3>Secure by Default</h3>
|
||||
<p>HTTPS only. Rate limiting. No data stored. PDFs stream directly — nothing touches disk.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="pricing" id="pricing">
|
||||
<div class="container">
|
||||
<h2 class="section-title">Simple, transparent pricing</h2>
|
||||
<p class="section-sub">Start free. Upgrade when you're ready. No surprise charges.</p>
|
||||
<div class="pricing-grid">
|
||||
<div class="price-card">
|
||||
<div class="price-name">Free</div>
|
||||
<div class="price-amount">€0<span> /mo</span></div>
|
||||
<div class="price-desc">Perfect for side projects and testing</div>
|
||||
<ul class="price-features">
|
||||
<li>100 PDFs per month</li>
|
||||
<li>All conversion endpoints</li>
|
||||
<li>All templates included</li>
|
||||
<li>Rate limiting: 10 req/min</li>
|
||||
</ul>
|
||||
<button class="btn btn-secondary" style="width:100%" id="btn-signup-2">Get Free API Key</button>
|
||||
</div>
|
||||
<div class="price-card featured">
|
||||
<div class="price-name">Pro</div>
|
||||
<div class="price-amount">€9<span> /mo</span></div>
|
||||
<div class="price-desc">For production apps and businesses</div>
|
||||
<ul class="price-features">
|
||||
<li>5,000 PDFs / month</li>
|
||||
<li>All conversion endpoints</li>
|
||||
<li>All templates included</li>
|
||||
<li>Priority support</li>
|
||||
</ul>
|
||||
<button class="btn btn-primary" style="width:100%" id="btn-checkout">Get Started →</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{{footer}}
|
||||
|
||||
<!-- Signup Modal -->
|
||||
<div class="modal-overlay" id="signupModal" role="dialog" aria-label="Sign up for API key">
|
||||
<div class="modal">
|
||||
<button class="close" id="btn-close-signup">×</button>
|
||||
|
||||
<div id="signupInitial" class="active">
|
||||
<h2>Get your free API key</h2>
|
||||
<p>Enter your email to get started. No credit card required.</p>
|
||||
<div class="signup-error" id="signupError"></div>
|
||||
<input type="email" id="signupEmail" placeholder="your.email@example.com" style="width:100%;padding:12px;border:1px solid var(--border);background:var(--bg);color:var(--fg);border-radius:8px;font-size:0.9rem;margin-bottom:16px;" required>
|
||||
<button class="btn btn-primary" style="width:100%" id="signupBtn">Generate API Key →</button>
|
||||
<p style="margin-top:16px;color:var(--muted);font-size:0.8rem;text-align:center;">100 free PDFs/month • All endpoints included<br><a href="#" class="open-recover" style="color:var(--muted)">Lost your API key? Recover it →</a></p>
|
||||
</div>
|
||||
|
||||
<div id="signupLoading">
|
||||
<div class="spinner"></div>
|
||||
<p style="color:var(--muted);margin:0">Generating your API key…</p>
|
||||
</div>
|
||||
|
||||
<div id="signupVerify">
|
||||
<h2>Enter verification code</h2>
|
||||
<p>We sent a 6-digit code to <strong id="verifyEmailDisplay"></strong></p>
|
||||
<div class="signup-error" id="verifyError"></div>
|
||||
<input type="text" id="verifyCode" placeholder="123456" maxlength="6" pattern="[0-9]{6}" inputmode="numeric" style="width:100%;padding:14px;border:1px solid var(--border);background:var(--bg);color:var(--fg);border-radius:8px;font-size:1.4rem;letter-spacing:0.3em;text-align:center;margin-bottom:16px;font-family:monospace;" required>
|
||||
<button class="btn btn-primary" style="width:100%" id="verifyBtn">Verify →</button>
|
||||
<p style="margin-top:16px;color:var(--muted);font-size:0.8rem;text-align:center;">Code expires in 15 minutes</p>
|
||||
</div>
|
||||
|
||||
<div id="signupResult" aria-live="polite">
|
||||
<h2>🚀 Your API key is ready!</h2>
|
||||
<div class="warning-box">
|
||||
<span class="icon">⚠️</span>
|
||||
<span>Save your API key securely. Lost it? <a href="#" class="open-recover" style="color:#fbbf24">Recover via email</a></span>
|
||||
</div>
|
||||
<div style="background:var(--bg);border:1px solid var(--accent);border-radius:8px;padding:14px;font-family:monospace;font-size:0.82rem;word-break:break-all;margin:16px 0;position:relative;">
|
||||
<span id="apiKeyText"></span>
|
||||
<button onclick="copyKey()" id="copyBtn" style="position:absolute;top:8px;right:8px;background:var(--accent);color:var(--bg);border:none;border-radius:4px;padding:4px 12px;cursor:pointer;font-size:0.8rem;">Copy</button>
|
||||
</div>
|
||||
<p style="margin-top:20px;color:var(--muted);font-size:0.9rem;">100 free PDFs/month • <a href="/docs">Read the docs →</a></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- Recovery Modal -->
|
||||
<div class="modal-overlay" id="recoverModal" role="dialog" aria-label="Recover API key">
|
||||
<div class="modal">
|
||||
<button class="close" id="btn-close-recover">×</button>
|
||||
|
||||
<div id="recoverInitial" class="active">
|
||||
<h2>Recover your API key</h2>
|
||||
<p>Enter the email you signed up with. We'll send a verification code.</p>
|
||||
<div class="signup-error" id="recoverError"></div>
|
||||
<input type="email" id="recoverEmailInput" placeholder="your.email@example.com" style="width:100%;padding:12px;border:1px solid var(--border);background:var(--bg);color:var(--fg);border-radius:8px;font-size:0.9rem;margin-bottom:16px;" required>
|
||||
<button class="btn btn-primary" style="width:100%" id="recoverBtn">Send Verification Code →</button>
|
||||
<p style="margin-top:16px;color:var(--muted);font-size:0.8rem;text-align:center;">Your key will be shown here after verification — never sent via email</p>
|
||||
</div>
|
||||
|
||||
<div id="recoverLoading">
|
||||
<div class="spinner"></div>
|
||||
<p style="color:var(--muted);margin:0">Sending verification code…</p>
|
||||
</div>
|
||||
|
||||
<div id="recoverVerify">
|
||||
<h2>Enter verification code</h2>
|
||||
<p>We sent a 6-digit code to <strong id="recoverEmailDisplay"></strong></p>
|
||||
<div class="signup-error" id="recoverVerifyError"></div>
|
||||
<input type="text" id="recoverCode" placeholder="123456" maxlength="6" pattern="[0-9]{6}" inputmode="numeric" style="width:100%;padding:14px;border:1px solid var(--border);background:var(--bg);color:var(--fg);border-radius:8px;font-size:1.4rem;letter-spacing:0.3em;text-align:center;margin-bottom:16px;font-family:monospace;" required>
|
||||
<button class="btn btn-primary" style="width:100%" id="recoverVerifyBtn">Verify →</button>
|
||||
<p style="margin-top:16px;color:var(--muted);font-size:0.8rem;text-align:center;">Code expires in 15 minutes</p>
|
||||
</div>
|
||||
|
||||
<div id="recoverResult" aria-live="polite">
|
||||
<h2>🔑 Your API key</h2>
|
||||
<div class="warning-box">
|
||||
<span class="icon">⚠️</span>
|
||||
<span>Save your API key securely. This is the only time it will be shown.</span>
|
||||
</div>
|
||||
<div style="background:var(--bg);border:1px solid var(--accent);border-radius:8px;padding:14px;font-family:monospace;font-size:0.82rem;word-break:break-all;margin:16px 0;position:relative;">
|
||||
<span id="recoveredKeyText"></span>
|
||||
<button onclick="copyRecoveredKey()" id="copyRecoveredBtn" style="position:absolute;top:8px;right:8px;background:var(--accent);color:var(--bg);border:none;border-radius:4px;padding:4px 12px;cursor:pointer;font-size:0.8rem;">Copy</button>
|
||||
</div>
|
||||
<p style="margin-top:20px;color:var(--muted);font-size:0.9rem;"><a href="/docs">Read the docs →</a></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- Email Change Modal -->
|
||||
<div class="modal-overlay" id="emailChangeModal" role="dialog" aria-label="Change email">
|
||||
<div class="modal">
|
||||
<button class="close" id="btn-close-email-change">×</button>
|
||||
|
||||
<div id="emailChangeInitial" class="active">
|
||||
<h2>Change your email</h2>
|
||||
<p>Enter your API key and new email address.</p>
|
||||
<div class="signup-error" id="emailChangeError"></div>
|
||||
<input type="text" id="emailChangeApiKey" placeholder="Your API key (df_free_... or df_pro_...)" style="width:100%;padding:12px;border:1px solid var(--border);background:var(--bg);color:var(--fg);border-radius:8px;font-size:0.9rem;margin-bottom:12px;font-family:monospace;" required>
|
||||
<input type="email" id="emailChangeNewEmail" placeholder="new.email@example.com" style="width:100%;padding:12px;border:1px solid var(--border);background:var(--bg);color:var(--fg);border-radius:8px;font-size:0.9rem;margin-bottom:16px;" required>
|
||||
<button class="btn btn-primary" style="width:100%" id="emailChangeBtn">Send Verification Code →</button>
|
||||
<p style="margin-top:16px;color:var(--muted);font-size:0.8rem;text-align:center;">A verification code will be sent to your new email</p>
|
||||
</div>
|
||||
|
||||
<div id="emailChangeLoading">
|
||||
<div class="spinner"></div>
|
||||
<p style="color:var(--muted);margin:0">Sending verification code…</p>
|
||||
</div>
|
||||
|
||||
<div id="emailChangeVerify">
|
||||
<h2>Enter verification code</h2>
|
||||
<p>We sent a 6-digit code to <strong id="emailChangeEmailDisplay"></strong></p>
|
||||
<div class="signup-error" id="emailChangeVerifyError"></div>
|
||||
<input type="text" id="emailChangeCode" placeholder="123456" maxlength="6" pattern="[0-9]{6}" inputmode="numeric" style="width:100%;padding:14px;border:1px solid var(--border);background:var(--bg);color:var(--fg);border-radius:8px;font-size:1.4rem;letter-spacing:0.3em;text-align:center;margin-bottom:16px;font-family:monospace;" required>
|
||||
<button class="btn btn-primary" style="width:100%" id="emailChangeVerifyBtn">Verify →</button>
|
||||
<p style="margin-top:16px;color:var(--muted);font-size:0.8rem;text-align:center;">Code expires in 15 minutes</p>
|
||||
</div>
|
||||
|
||||
<div id="emailChangeResult">
|
||||
<h2>✅ Email updated!</h2>
|
||||
<p>Your account email has been changed to <strong id="emailChangeNewDisplay"></strong></p>
|
||||
<p style="margin-top:20px;color:var(--muted);font-size:0.9rem;"><a href="/docs">Read the docs →</a></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="/app.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
138
projects/business/src/pdf-api/templates/pages/privacy.html
Normal file
138
projects/business/src/pdf-api/templates/pages/privacy.html
Normal file
|
|
@ -0,0 +1,138 @@
|
|||
<!-- title: Privacy Policy — DocFast -->
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
{{> head-common}}
|
||||
<title>{{title}}</title>
|
||||
<meta name="description" content="Privacy policy for DocFast API service - GDPR compliant data protection information.">
|
||||
<link rel="canonical" href="https://docfast.dev/privacy">
|
||||
<link rel="icon" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><text y='.9em' font-size='90'>⚡</text></svg>">
|
||||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap" rel="stylesheet">
|
||||
<style>
|
||||
{{> styles-base}}
|
||||
.container { max-width: 800px; margin: 0 auto; padding: 0 24px; }
|
||||
|
||||
{{> styles-legal}}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
{{> nav}}
|
||||
|
||||
<main>
|
||||
<div class="container">
|
||||
<h1>Privacy Policy</h1>
|
||||
<p><em>Last updated: February 16, 2026</em></p>
|
||||
|
||||
<div class="info">
|
||||
This privacy policy is GDPR compliant and explains how we collect, use, and protect your personal data.
|
||||
</div>
|
||||
|
||||
<h2>1. Data Controller</h2>
|
||||
<p><strong>Cloonar Technologies GmbH</strong><br>
|
||||
Address: Vienna, Austria<br>
|
||||
Email: <a href="mailto:legal@docfast.dev">legal@docfast.dev</a><br>
|
||||
Data Protection Contact: <a href="mailto:privacy@docfast.dev">privacy@docfast.dev</a></p>
|
||||
|
||||
<h2>2. Data We Collect</h2>
|
||||
|
||||
<h3>2.1 Account Information</h3>
|
||||
<ul>
|
||||
<li><strong>Email address</strong> - Required for account creation and API key delivery</li>
|
||||
<li><strong>API key</strong> - Automatically generated unique identifier</li>
|
||||
</ul>
|
||||
|
||||
<h3>2.2 API Usage Data</h3>
|
||||
<ul>
|
||||
<li><strong>Request logs</strong> - API endpoint accessed, timestamp, response status</li>
|
||||
<li><strong>Usage metrics</strong> - Number of API calls, data volume processed</li>
|
||||
<li><strong>IP address</strong> - For rate limiting and abuse prevention</li>
|
||||
</ul>
|
||||
|
||||
<h3>2.3 Payment Information</h3>
|
||||
<ul>
|
||||
<li><strong>Stripe Customer ID</strong> - For Pro subscription billing</li>
|
||||
<li><strong>Payment metadata</strong> - Subscription status, billing period</li>
|
||||
</ul>
|
||||
|
||||
<div class="highlight">
|
||||
<strong>No PDF content stored:</strong> We process your HTML/Markdown input to generate PDFs, but do not store the content or resulting PDFs on our servers.
|
||||
</div>
|
||||
|
||||
<h2>3. Legal Basis for Processing</h2>
|
||||
<ul>
|
||||
<li><strong>Contract fulfillment</strong> (Art. 6(1)(b) GDPR) - Account creation, API service provision</li>
|
||||
<li><strong>Legitimate interest</strong> (Art. 6(1)(f) GDPR) - Service monitoring, abuse prevention, performance optimization</li>
|
||||
<li><strong>Legal obligation</strong> (Art. 6(1)(c) GDPR) - Tax records, payment processing compliance</li>
|
||||
</ul>
|
||||
|
||||
<h2>4. Data Retention</h2>
|
||||
<ul>
|
||||
<li><strong>Account data:</strong> Retained while account is active + 30 days after deletion request</li>
|
||||
<li><strong>API usage logs:</strong> 90 days for operational monitoring</li>
|
||||
<li><strong>Payment records:</strong> 7 years for tax compliance (Austrian law)</li>
|
||||
<li><strong>PDF processing data:</strong> Not stored (processed in memory only)</li>
|
||||
</ul>
|
||||
|
||||
<h2>5. Third-Party Processors</h2>
|
||||
|
||||
<h3>5.1 Stripe (Payment Processing)</h3>
|
||||
<p><strong>Purpose:</strong> Payment processing for Pro subscriptions<br>
|
||||
<strong>Data:</strong> Email, payment information<br>
|
||||
<strong>Location:</strong> EU (GDPR compliant)<br>
|
||||
<strong>Privacy Policy:</strong> <a href="https://stripe.com/privacy" target="_blank" rel="noopener">https://stripe.com/privacy</a></p>
|
||||
|
||||
<h3>5.2 Hetzner (Hosting)</h3>
|
||||
<p><strong>Purpose:</strong> Server hosting and infrastructure<br>
|
||||
<strong>Data:</strong> All data processed by DocFast<br>
|
||||
<strong>Location:</strong> Germany (Nuremberg)<br>
|
||||
<strong>Privacy Policy:</strong> <a href="https://www.hetzner.com/legal/privacy-policy" target="_blank" rel="noopener">https://www.hetzner.com/legal/privacy-policy</a></p>
|
||||
|
||||
<div class="highlight">
|
||||
<strong>EU Data Residency:</strong> All your data is processed and stored exclusively within the European Union.
|
||||
</div>
|
||||
|
||||
<h2>6. Your Rights Under GDPR</h2>
|
||||
<ul>
|
||||
<li><strong>Right of access</strong> - Request information about your personal data</li>
|
||||
<li><strong>Right to rectification</strong> - Correct inaccurate data (e.g., email changes)</li>
|
||||
<li><strong>Right to erasure</strong> - Delete your account and associated data</li>
|
||||
<li><strong>Right to data portability</strong> - Receive your data in machine-readable format</li>
|
||||
<li><strong>Right to object</strong> - Object to processing based on legitimate interest</li>
|
||||
<li><strong>Right to lodge a complaint</strong> - Contact your data protection authority</li>
|
||||
</ul>
|
||||
|
||||
<p><strong>To exercise your rights:</strong> Email <a href="mailto:privacy@docfast.dev">privacy@docfast.dev</a></p>
|
||||
|
||||
<h2>7. Cookies and Tracking</h2>
|
||||
<p>DocFast uses minimal technical cookies:</p>
|
||||
<ul>
|
||||
<li><strong>Session cookies</strong> - For login state (if applicable)</li>
|
||||
<li><strong>No tracking cookies</strong> - We do not use analytics, advertising, or third-party tracking</li>
|
||||
</ul>
|
||||
|
||||
<h2>8. Data Security</h2>
|
||||
<ul>
|
||||
<li><strong>Encryption:</strong> All data transmission via HTTPS/TLS</li>
|
||||
<li><strong>Access control:</strong> Limited employee access with logging</li>
|
||||
<li><strong>Infrastructure:</strong> EU-based servers with enterprise security</li>
|
||||
<li><strong>API keys:</strong> Securely hashed and stored</li>
|
||||
</ul>
|
||||
|
||||
<h2>9. International Transfers</h2>
|
||||
<p>Your personal data does not leave the European Union. Our infrastructure is hosted exclusively by Hetzner in Germany.</p>
|
||||
|
||||
<h2>10. Contact for Data Protection</h2>
|
||||
<p>For questions about data processing or to exercise your rights:</p>
|
||||
<p><strong>Email:</strong> <a href="mailto:privacy@docfast.dev">privacy@docfast.dev</a><br>
|
||||
<strong>Subject:</strong> Include "GDPR" in the subject line for priority handling</p>
|
||||
|
||||
<h2>11. Changes to This Policy</h2>
|
||||
<p>We will notify users of material changes via email. Continued use of the service constitutes acceptance of updated terms.</p>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
{{> footer}}
|
||||
|
||||
</body>
|
||||
</html>
|
||||
208
projects/business/src/pdf-api/templates/pages/terms.html
Normal file
208
projects/business/src/pdf-api/templates/pages/terms.html
Normal file
|
|
@ -0,0 +1,208 @@
|
|||
<!-- title: Terms of Service — DocFast -->
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
{{> head-common}}
|
||||
<title>{{title}}</title>
|
||||
<meta name="description" content="Terms of service for DocFast API - legal terms and conditions for using our PDF generation service.">
|
||||
<link rel="canonical" href="https://docfast.dev/terms">
|
||||
<style>
|
||||
{{> styles-base}}
|
||||
.container { max-width: 800px; margin: 0 auto; padding: 0 24px; }
|
||||
|
||||
{{> styles-legal}}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
{{> nav}}
|
||||
|
||||
<main>
|
||||
<div class="container">
|
||||
<h1>Terms of Service</h1>
|
||||
<p><em>Last updated: February 16, 2026</em></p>
|
||||
|
||||
<div class="info">
|
||||
By using DocFast, you agree to these terms. Please read them carefully.
|
||||
</div>
|
||||
|
||||
<h2>1. Service Description</h2>
|
||||
<p>DocFast provides an API service for converting HTML, Markdown, and URLs to PDF documents. The service includes:</p>
|
||||
<ul>
|
||||
<li>HTML to PDF conversion</li>
|
||||
<li>Markdown to PDF conversion</li>
|
||||
<li>URL to PDF conversion</li>
|
||||
<li>Pre-built invoice and receipt templates</li>
|
||||
<li>Custom CSS styling support</li>
|
||||
</ul>
|
||||
|
||||
<h2>2. Service Plans</h2>
|
||||
|
||||
<h3>2.1 Free Tier</h3>
|
||||
<ul>
|
||||
<li><strong>Monthly limit:</strong> 100 PDF conversions</li>
|
||||
<li><strong>Rate limit:</strong> 10 requests per minute</li>
|
||||
<li><strong>Fair use policy:</strong> Personal and small business use</li>
|
||||
<li><strong>Support:</strong> Community documentation</li>
|
||||
</ul>
|
||||
|
||||
<h3>2.2 Pro Tier</h3>
|
||||
<ul>
|
||||
<li><strong>Price:</strong> €9 per month</li>
|
||||
<li><strong>Monthly limit:</strong> 10,000 PDF conversions</li>
|
||||
<li><strong>Rate limit:</strong> Higher limits based on fair use</li>
|
||||
<li><strong>Support:</strong> Priority email support</li>
|
||||
<li><strong>Billing:</strong> Monthly subscription via Stripe</li>
|
||||
</ul>
|
||||
|
||||
<div class="highlight">
|
||||
<strong>Overage:</strong> If you exceed your plan limits, API requests will return rate limiting errors. No automatic charges apply.
|
||||
</div>
|
||||
|
||||
<h2>3. Acceptable Use</h2>
|
||||
|
||||
<h3>3.1 Permitted Uses</h3>
|
||||
<ul>
|
||||
<li>Business documents (invoices, reports, receipts)</li>
|
||||
<li>Personal document generation</li>
|
||||
<li>Integration into web applications</li>
|
||||
<li>Educational and non-commercial projects</li>
|
||||
</ul>
|
||||
|
||||
<h3>3.2 Prohibited Uses</h3>
|
||||
<ul>
|
||||
<li><strong>Illegal content:</strong> No processing of copyrighted material without permission</li>
|
||||
<li><strong>Abuse:</strong> No attempts to overload or disrupt the service</li>
|
||||
<li><strong>Harmful content:</strong> No generation of malicious, threatening, or harmful documents</li>
|
||||
<li><strong>Reselling:</strong> No white-labeling or reselling of the raw API service</li>
|
||||
<li><strong>Reverse engineering:</strong> No attempts to extract proprietary algorithms</li>
|
||||
</ul>
|
||||
|
||||
<div class="warning">
|
||||
<strong>Violation consequences:</strong> Account termination, permanent ban, and legal action if necessary.
|
||||
</div>
|
||||
|
||||
<h2>4. API Key Security</h2>
|
||||
<ul>
|
||||
<li><strong>Responsibility:</strong> You are responsible for keeping your API key secure</li>
|
||||
<li><strong>Unauthorized use:</strong> You are liable for all usage under your API key</li>
|
||||
<li><strong>Recovery:</strong> Lost keys can be recovered via email verification</li>
|
||||
<li><strong>Sharing:</strong> Do not share API keys publicly or in client-side code</li>
|
||||
</ul>
|
||||
|
||||
<h2>5. Service Availability</h2>
|
||||
|
||||
<h3>5.1 Uptime</h3>
|
||||
<ul>
|
||||
<li><strong>Target:</strong> 99.5% uptime (best effort, no SLA for free tier)</li>
|
||||
<li><strong>Maintenance:</strong> Scheduled maintenance with advance notice</li>
|
||||
<li><strong>Status page:</strong> <a href="/health">https://docfast.dev/health</a></li>
|
||||
</ul>
|
||||
|
||||
<h3>5.2 Performance</h3>
|
||||
<ul>
|
||||
<li><strong>Processing time:</strong> Typically under 1 second per PDF</li>
|
||||
<li><strong>Rate limiting:</strong> Applied fairly to ensure service stability</li>
|
||||
<li><strong>File size limits:</strong> Input HTML/Markdown up to 2MB</li>
|
||||
</ul>
|
||||
|
||||
<h2>6. Data Processing</h2>
|
||||
<ul>
|
||||
<li><strong>No storage:</strong> PDF content is processed in memory only</li>
|
||||
<li><strong>Logs:</strong> API usage logs retained for 90 days</li>
|
||||
<li><strong>Privacy:</strong> See our <a href="/privacy">Privacy Policy</a> for details</li>
|
||||
<li><strong>EU hosting:</strong> All data processed in Germany (Hetzner)</li>
|
||||
</ul>
|
||||
|
||||
<h2>7. Payment Terms</h2>
|
||||
|
||||
<h3>7.1 Pro Subscription</h3>
|
||||
<ul>
|
||||
<li><strong>Billing cycle:</strong> Monthly, billed in advance</li>
|
||||
<li><strong>Payment method:</strong> Credit card via Stripe</li>
|
||||
<li><strong>Currency:</strong> EUR (Euro)</li>
|
||||
<li><strong>Auto-renewal:</strong> Subscription renews automatically</li>
|
||||
</ul>
|
||||
|
||||
<h3>7.2 Cancellation</h3>
|
||||
<ul>
|
||||
<li><strong>Anytime:</strong> Cancel your subscription at any time</li>
|
||||
<li><strong>Access:</strong> Service continues until end of billing period</li>
|
||||
<li><strong>Refunds:</strong> No partial refunds for unused portions</li>
|
||||
</ul>
|
||||
|
||||
<div class="info">
|
||||
<strong>EU Consumer Rights:</strong> 14-day right of withdrawal applies to digital services not yet delivered. Once you start using the Pro service, withdrawal right expires.
|
||||
</div>
|
||||
|
||||
<h2>8. Limitation of Liability</h2>
|
||||
<ul>
|
||||
<li><strong>Service provision:</strong> Best effort basis, no guarantees</li>
|
||||
<li><strong>Damages:</strong> Our liability is limited to the amount paid for the service</li>
|
||||
<li><strong>Indirect damages:</strong> We are not liable for lost profits, business interruption, or data loss</li>
|
||||
<li><strong>Force majeure:</strong> Not liable for events beyond our reasonable control</li>
|
||||
</ul>
|
||||
|
||||
<h2>9. Account Termination</h2>
|
||||
|
||||
<h3>9.1 By You</h3>
|
||||
<ul>
|
||||
<li>Delete your account by emailing <a href="mailto:legal@docfast.dev">legal@docfast.dev</a></li>
|
||||
<li>Cancel Pro subscription through your account or email</li>
|
||||
</ul>
|
||||
|
||||
<h3>9.2 By Us</h3>
|
||||
<p>We may terminate accounts for:</p>
|
||||
<ul>
|
||||
<li>Violation of these terms</li>
|
||||
<li>Non-payment (Pro accounts)</li>
|
||||
<li>Extended inactivity (12+ months)</li>
|
||||
<li>Technical abuse or security concerns</li>
|
||||
</ul>
|
||||
|
||||
<div class="warning">
|
||||
<strong>Termination notice:</strong> We will provide reasonable notice except for immediate security threats.
|
||||
</div>
|
||||
|
||||
<h2>10. Intellectual Property</h2>
|
||||
<ul>
|
||||
<li><strong>Service ownership:</strong> DocFast and its technology remain our property</li>
|
||||
<li><strong>Your content:</strong> You retain rights to content you process through our API</li>
|
||||
<li><strong>Generated PDFs:</strong> You own the PDFs generated from your content</li>
|
||||
<li><strong>Feedback:</strong> Any feedback provided may be used to improve the service</li>
|
||||
</ul>
|
||||
|
||||
<h2>11. Governing Law</h2>
|
||||
<ul>
|
||||
<li><strong>Jurisdiction:</strong> These terms are governed by Austrian law</li>
|
||||
<li><strong>Courts:</strong> Disputes resolved in Vienna, Austria</li>
|
||||
<li><strong>Language:</strong> German version prevails in case of translation conflicts</li>
|
||||
<li><strong>EU regulations:</strong> GDPR and other EU laws apply</li>
|
||||
</ul>
|
||||
|
||||
<h2>12. Changes to Terms</h2>
|
||||
<p>We may update these terms by:</p>
|
||||
<ul>
|
||||
<li><strong>Email notification:</strong> For material changes affecting your rights</li>
|
||||
<li><strong>Website posting:</strong> Updated version posted with revision date</li>
|
||||
<li><strong>Continued use:</strong> Using the service after changes constitutes acceptance</li>
|
||||
</ul>
|
||||
|
||||
<h2>13. Contact Information</h2>
|
||||
<p>Questions about these terms:</p>
|
||||
<ul>
|
||||
<li><strong>Email:</strong> <a href="mailto:legal@docfast.dev">legal@docfast.dev</a></li>
|
||||
<li><strong>Company:</strong> Cloonar Technologies GmbH, Vienna, Austria</li>
|
||||
<li><strong>Legal notice:</strong> See <a href="/impressum">Impressum</a> for full company details</li>
|
||||
</ul>
|
||||
|
||||
<div class="highlight">
|
||||
<strong>Effective Date:</strong> These terms are effective immediately upon posting. By using DocFast, you acknowledge reading and agreeing to these terms.
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
{{> footer}}
|
||||
|
||||
</body>
|
||||
</html>
|
||||
14
projects/business/src/pdf-api/templates/partials/footer.html
Normal file
14
projects/business/src/pdf-api/templates/partials/footer.html
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
<footer aria-label="Footer">
|
||||
<div class="container">
|
||||
<div class="footer-left">© 2026 DocFast. Fast PDF generation for developers.</div>
|
||||
<div class="footer-links">
|
||||
<a href="/">Home</a>
|
||||
<a href="/docs">Docs</a>
|
||||
<a href="/health">API Status</a>
|
||||
<a href="/#change-email" class="open-email-change">Change Email</a>
|
||||
<a href="/impressum">Impressum</a>
|
||||
<a href="/privacy">Privacy Policy</a>
|
||||
<a href="/terms">Terms of Service</a>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
<nav aria-label="Main navigation">
|
||||
<div class="container">
|
||||
<div class="logo">⚡ Doc<span>Fast</span></div>
|
||||
<div class="nav-links">
|
||||
<a href="#features">Features</a>
|
||||
<a href="#pricing">Pricing</a>
|
||||
<a href="/docs">Docs</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
10
projects/business/src/pdf-api/templates/partials/nav.html
Normal file
10
projects/business/src/pdf-api/templates/partials/nav.html
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<nav aria-label="Main navigation">
|
||||
<div class="container">
|
||||
<a href="/" class="logo">⚡ Doc<span>Fast</span></a>
|
||||
<div class="nav-links">
|
||||
<a href="/#features">Features</a>
|
||||
<a href="/#pricing">Pricing</a>
|
||||
<a href="/docs">Docs</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
|
||||
:root {
|
||||
--bg: #0b0d11; --bg2: #12151c; --fg: #e4e7ed; --muted: #7a8194;
|
||||
--accent: #34d399; --accent-hover: #5eead4; --accent-glow: rgba(52,211,153,0.12);
|
||||
--card: #151922; --border: #1e2433;
|
||||
--radius: 12px; --radius-lg: 16px;
|
||||
}
|
||||
body { font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: var(--bg); color: var(--fg); line-height: 1.65; -webkit-font-smoothing: antialiased; }
|
||||
a { color: var(--accent); text-decoration: none; transition: color 0.2s; }
|
||||
a:hover { color: var(--accent-hover); }
|
||||
|
||||
/* Nav */
|
||||
nav { padding: 20px 0; border-bottom: 1px solid var(--border); }
|
||||
nav .container { display: flex; align-items: center; justify-content: space-between; }
|
||||
.logo { font-size: 1.25rem; font-weight: 700; letter-spacing: -0.5px; color: var(--fg); display: flex; align-items: center; gap: 8px; }
|
||||
.logo span { color: var(--accent); }
|
||||
.nav-links { display: flex; gap: 28px; align-items: center; }
|
||||
.nav-links a { color: var(--muted); font-size: 0.9rem; font-weight: 500; }
|
||||
.nav-links a:hover { color: var(--fg); }
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
/* Content */
|
||||
main { padding: 60px 0 80px; }
|
||||
h1 { font-size: 2.5rem; font-weight: 800; margin-bottom: 16px; letter-spacing: -1px; }
|
||||
h2 { font-size: 1.5rem; font-weight: 700; margin: 32px 0 16px; color: var(--accent); }
|
||||
h3 { font-size: 1.2rem; font-weight: 600; margin: 24px 0 12px; }
|
||||
p { margin-bottom: 16px; line-height: 1.7; }
|
||||
ul { margin-bottom: 16px; padding-left: 24px; }
|
||||
li { margin-bottom: 8px; line-height: 1.7; }
|
||||
.highlight { background: rgba(52,211,153,0.08); border: 1px solid rgba(52,211,153,0.15); border-radius: 8px; padding: 16px; margin: 24px 0; color: var(--accent); font-size: 0.9rem; }
|
||||
.info { background: rgba(96,165,250,0.08); border: 1px solid rgba(96,165,250,0.15); border-radius: 8px; padding: 16px; margin: 24px 0; color: #60a5fa; font-size: 0.9rem; }
|
||||
.warning { background: rgba(251,191,36,0.08); border: 1px solid rgba(251,191,36,0.15); border-radius: 8px; padding: 16px; margin: 24px 0; color: #fbbf24; font-size: 0.9rem; }
|
||||
|
||||
/* Footer */
|
||||
footer { padding: 40px 0; border-top: 1px solid var(--border); }
|
||||
footer .container { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 16px; }
|
||||
.footer-left { color: var(--muted); font-size: 0.85rem; }
|
||||
.footer-links { display: flex; gap: 24px; flex-wrap: wrap; }
|
||||
.footer-links a { color: var(--muted); font-size: 0.85rem; }
|
||||
.footer-links a:hover { color: var(--fg); }
|
||||
|
||||
/* Responsive */
|
||||
@media (max-width: 640px) {
|
||||
main { padding: 40px 0 60px; }
|
||||
h1 { font-size: 2rem; }
|
||||
.footer-links { gap: 16px; }
|
||||
footer .container { flex-direction: column; text-align: center; }
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue