Skip to Content
πŸ”Œ API Documentation

API Documentation

Backend API Endpoints

The Sitepins application communicates with a centralized Node.js backend for core business logic, user management, and organization control.

πŸ‘€ User Management (/user)

  • GET /user/:id - Fetch profile for a specific user.
  • PATCH /user/set-password - Set or update account password.
  • POST /user/check-limits - Validate project/organization creation limits for a user.
  • PATCH /user/update-country/:id - Update user’s country for billing/localization.
  • PATCH /user/update-newsletter/:id - Toggle newsletter subscription.
  • DELETE /user/delete/:id - Self-deletion for users.

🏒 Organization Control (/organization)

  • GET /organization/user - List organizations for the currently authenticated user.
  • POST /organization - Create a new organization.
  • GET /organization/:org_id - Get detailed organization information.
  • PATCH /organization/:org_id - Update organization profile.
  • PATCH /organization/member/:org_id - Invite/Add a new member.
  • PATCH /organization/update-role/:org_id - Update a member’s role within the org.
  • PATCH /organization/remove-member/:org_id - Remove a member from the org.
  • DELETE /organization/:org_id - Permanently delete an organization.

πŸ“ Project Management (/project)

  • GET /project/orgs/:orgId - List all projects within a specific organization.
  • POST /project/create - Create a new project linked to a Git repository.
  • GET /project/:projectId - Get project configuration and connection details.
  • PATCH /project/:projectId - Update basic project settings.
  • PATCH /project/status/:projectId - Archive or activate a project.
  • PATCH /project/visibility/:projectId - Toggle project privacy (Public/Private).
  • PATCH /project/move/:orgId/:projectId - Transfer a project to a different organization.
  • DELETE /project/:projectId - Remove a project.

πŸ’³ Subscriptions & Billing (/order)

  • GET /order/:userId - Fetch order history and active subscriptions for a user.
  • POST /order/cancel - Cancel an active user subscription.
  • GET /order/update-payment-method/:subscriptionId - Retrieve a transaction for updating payment info.
  • POST /order/pre-order - Log abandoned checkouts or pre-order interest.
  • GET /order/summary - (Admin) Get platform-wide revenue and subscription metrics.

πŸ™ Git Provider Linking (/provider)

  • POST /provider/create - Connect a new GitHub or GitLab integration to a user account.
  • GET /provider/:userId - List all connected Git providers for a user.

Git Provider Integrations

Sitepins interacts directly with Git providers using their respective REST APIs via RTK Query on the frontend.

GitHub API

  • Tree Retrieval: GET /repos/{owner}/{repo}/git/trees/{tree_sha}?recursive=1
  • Content Operations: GET /repos/{owner}/{repo}/contents/{path}
  • Multi-file Commit Workflow:
    1. Create blobs for each file.
    2. Construct a new tree from blobs.
    3. Create a commit based on the tree.
    4. Update the branch reference.

GitLab API

  • Tree Retrieval: GET /projects/{id}/repository/tree
  • Content Operations: GET /projects/{id}/repository/files/{path}
  • Commit API: Handles multi-file updates in a single POST request to /projects/{id}/repository/commits.

Git Utilities (src/lib/utils/git-utils.ts)

Standardized functions used across the application to maintain Git integrity:

  • runWithConcurrency(tasks, limit): Prevents API rate limiting by capping parallel operations.
  • retry(fn, options): Automatically retries failed network requests with exponential backoff.
  • createGitCommitMessage(msg, trailers): Ensures consistent commit formatting with co-author attribution.
Last updated on