From 71b52f6c5e7427ebe96efd319c8a58b19c847dce Mon Sep 17 00:00:00 2001 From: Dan Mestas <93289084+danmestas@users.noreply.github.com> Date: Wed, 30 Jul 2025 14:18:13 -0500 Subject: [PATCH] feat(api): implement OpenAPI/REST API for file conversions - Add comprehensive REST API at /api/v1 with modular structure - Implement authentication endpoints (register, login, logout, me) - Add converter listing and format discovery endpoints - Create job management and file download endpoints - Add health check endpoint for monitoring - Set up CORS support for browser-based API clients - Create API middleware for JWT authentication - Add environment variables for API configuration - Include comprehensive API documentation and test script Infrastructure: - Enhanced CI/CD workflow for custom Docker registries - Docker Compose setup with dev, prod, and monitoring profiles - Claude.ai integration files for development workflow - Environment-based configuration with .env.development Known limitations: - JWT authentication context needs fixing (using ALLOW_UNAUTHENTICATED=true) - Swagger UI temporarily disabled due to composition error - File upload endpoint needs multipart/form-data support The API code is isolated in src/api/ directory to maintain separation from the existing codebase, making it easy to maintain or contribute back. --- .claude/build.md | 50 +++ .claude/commit.md | 37 +++ .claude/pr.md | 52 +++ .claude/test.md | 45 +++ .env.development | 15 + .github/workflows/README.md | 107 +++++++ .github/workflows/docker-publish-custom.yml | 231 ++++++++++++++ API.md | 243 ++++++++++++++ CLAUDE.md | 146 +++++++++ IMPLEMENTATION_SUMMARY.md | 120 +++++++ bun.lock | 28 ++ docker-compose.README.md | 161 ++++++++++ docker-compose.yml | 136 ++++++++ package.json | 2 + src/api/middleware/auth.ts | 57 ++++ src/api/types.ts | 10 + src/api/v1/auth.ts | 330 ++++++++++++++++++++ src/api/v1/conversions.ts | 137 ++++++++ src/api/v1/converters.ts | 226 ++++++++++++++ src/api/v1/debug.ts | 19 ++ src/api/v1/files.ts | 252 +++++++++++++++ src/api/v1/health.ts | 83 +++++ src/api/v1/index.ts | 213 +++++++++++++ src/api/v1/jobs.ts | 300 ++++++++++++++++++ src/helpers/env.ts | 15 +- src/index.tsx | 4 +- test-api.sh | 133 ++++++++ 27 files changed, 3150 insertions(+), 2 deletions(-) create mode 100644 .claude/build.md create mode 100644 .claude/commit.md create mode 100644 .claude/pr.md create mode 100644 .claude/test.md create mode 100644 .env.development create mode 100644 .github/workflows/README.md create mode 100644 .github/workflows/docker-publish-custom.yml create mode 100644 API.md create mode 100644 CLAUDE.md create mode 100644 IMPLEMENTATION_SUMMARY.md create mode 100644 docker-compose.README.md create mode 100644 docker-compose.yml create mode 100644 src/api/middleware/auth.ts create mode 100644 src/api/types.ts create mode 100644 src/api/v1/auth.ts create mode 100644 src/api/v1/conversions.ts create mode 100644 src/api/v1/converters.ts create mode 100644 src/api/v1/debug.ts create mode 100644 src/api/v1/files.ts create mode 100644 src/api/v1/health.ts create mode 100644 src/api/v1/index.ts create mode 100644 src/api/v1/jobs.ts create mode 100755 test-api.sh diff --git a/.claude/build.md b/.claude/build.md new file mode 100644 index 0000000..15eafc0 --- /dev/null +++ b/.claude/build.md @@ -0,0 +1,50 @@ +# Build and Test Docker Image + +Please build and test the Docker image with these steps: + +1. **Build the Docker image**: + ```bash + docker build -t convertx-openapi:local . + ``` + +2. **Verify the build**: + - Check image size: `docker images convertx-openapi:local` + - Inspect layers: `docker history convertx-openapi:local` + +3. **Run container locally**: + ```bash + docker run -d \ + --name convertx-test \ + -p 3000:3000 \ + -v $(pwd)/data:/app/data \ + -e JWT_SECRET=test-secret \ + -e NODE_ENV=production \ + convertx-openapi:local + ``` + +4. **Test the application**: + - Check logs: `docker logs convertx-test` + - Test health: `curl http://localhost:3000` + - Verify converters load properly + +5. **Multi-platform build** (if needed): + ```bash + docker buildx build \ + --platform linux/amd64,linux/arm64 \ + -t convertx-openapi:local \ + . + ``` + +6. **Push to custom registry** (if configured): + ```bash + docker tag convertx-openapi:local ${DOCKER_REGISTRY}/convertx:latest + docker push ${DOCKER_REGISTRY}/convertx:latest + ``` + +7. **Cleanup**: + ```bash + docker stop convertx-test + docker rm convertx-test + ``` + +Please execute these steps and report any issues. \ No newline at end of file diff --git a/.claude/commit.md b/.claude/commit.md new file mode 100644 index 0000000..bb09497 --- /dev/null +++ b/.claude/commit.md @@ -0,0 +1,37 @@ +# Commit Changes + +Please create a git commit with the following requirements: + +1. **Review all changes**: First run `git status` and `git diff` to see what has changed +2. **Stage appropriate files**: Use `git add` to stage the relevant changes +3. **Commit message format**: Use conventional commit format: + - feat: New feature + - fix: Bug fix + - docs: Documentation changes + - style: Code style changes (formatting, etc) + - refactor: Code refactoring + - test: Adding or updating tests + - chore: Maintenance tasks + - build: Build system changes + - ci: CI/CD changes + +3. **Message structure**: + ``` + (): + + + +