feat(backend): 🚧 [WIP] TUSD implementation#9
Merged
Conversation
…t upload functionality
… handling for multipart/form-data
…er.org/goleak to v1.3.0
…d integrate caching in auth
…e S3 client configuration
… and backend URL integration
- Cleaned up imports and improved formatting for better readability in route files. - Enhanced error handling and response parsing in API service functions. - Introduced new subscription and usage services for better API interaction. - Added tests for API contracts and established UI paths to ensure functionality. - Removed outdated sample test file to streamline test suite.
There was a problem hiding this comment.
Pull request overview
This PR expands the S3ase backend/frontend to support resumable uploads and richer “app management” capabilities (API key credentials, members, usage/subscription endpoints, domain verification), alongside a broad set of frontend contract/path updates and UI wiring.
Changes:
- Adds backend authorization/helpers, CRUD services (apps/files/members/webhooks/api keys/folders), usage + subscription endpoints, and protocol/SSE/pubsub enhancements.
- Updates frontend models/services/routes to consume new backend response envelopes and adds file download/resource routes.
- Introduces caching + API key auth support and tightens validation (e.g., webhook URL/event validation, domain verification checks).
Reviewed changes
Copilot reviewed 236 out of 243 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| frontend/tests/sample.test.ts | Removes placeholder Vitest sample suite. |
| frontend/tests/models-and-paths.test.ts | Adds contract/path tests for schemas and routing helpers. |
| frontend/tailwind.config.ts | Switches Tailwind plugins to ESM imports and adds typed plugin API. |
| frontend/package.json | Adds pnpm packageManager pin and dependency updates; adjusts lint script. |
| frontend/Dockerfile | Pins pnpm via corepack prepare across build stages. |
| frontend/app/types/tailwind.d.ts | Adds TS module declaration for Tailwind internal util import. |
| frontend/app/services/webhook.server.ts | Import reordering; keeps webhook API service wiring. |
| frontend/app/services/user.server.ts | Switches to GetUserSchema envelope and updates logout usage. |
| frontend/app/services/usage.server.ts | Adds UI usage fetch service. |
| frontend/app/services/subscription.server.ts | Adds UI subscription fetch service. |
| frontend/app/services/member.server.ts | Adds create/remove member service calls. |
| frontend/app/services/folder.server.ts | Import reordering for folder service. |
| frontend/app/services/file.server.ts | Introduces uploadFile wrapper and adjusts file service layout. |
| frontend/app/services/feature.server.ts | Removes unused type imports; uses GetFeatureSchema. |
| frontend/app/services/domain.server.ts | Adds verifyDomain call and tweaks imports. |
| frontend/app/services/auth.server.ts | Changes logout signature and session storage exports. |
| frontend/app/services/app.server.ts | Refactors imports/session storage exports and adds deleteApp. |
| frontend/app/services/api_key.server.ts | Import reordering and schema usage. |
| frontend/app/routes/resources.$appSlug.files.ts | Adds action endpoint for file creation/upload initiation. |
| frontend/app/routes/resources.$appSlug.files.$fileId.ts | Adds loader to stream file content from backend with auth headers. |
| frontend/app/routes/logout.tsx | Adjusts logout loader imports/usage. |
| frontend/app/routes/login._index/route.tsx | Uses public backend URL and tidies loader/component imports. |
| frontend/app/routes/auth.callback.tsx | Refactors loader definition and headers const usage. |
| frontend/app/routes/_app/route.tsx | Ensures user is required; import formatting adjustments. |
| frontend/app/routes/_app.apps/route.tsx | Refactors action/loader wiring and headers const usage. |
| frontend/app/routes/_app.app.$appSlug.webhooks/route.tsx | Refactors webhook UI route; updates error handling and removes unused app hook. |
| frontend/app/routes/_app.app.$appSlug.setting/route.tsx | Refactors settings route loader signature and imports. |
| frontend/app/routes/_app.app.$appSlug.setting.usage/route.tsx | Refactors usage settings route loader signature/imports. |
| frontend/app/routes/_app.app.$appSlug.setting.usage.billing/route.tsx | Loads subscription and passes currentPlan into plan cards. |
| frontend/app/routes/_app.app.$appSlug.setting.usage._index/route.tsx | Loads usage data and passes it into UsageChart. |
| frontend/app/routes/_app.app.$appSlug.setting.members/route.tsx | Adds member create/remove action handling and improves table keys/forms. |
| frontend/app/routes/_app.app.$appSlug.folder.$folderId/route.tsx | Parallelizes folder/files fetch and wires folderId into dropzone. |
| frontend/app/routes/_app.app.$appSlug.file.$fileId/route.tsx | Adds file details page with download + delete action. |
| frontend/app/routes/_app.app.$appSlug.api-keys/route.tsx | Refactors API key route; returns secret on create and displays prefix/last4. |
| frontend/app/routes/_app._index/route.tsx | Minor import formatting updates. |
| frontend/app/root.tsx | Loads backendUrl/accessToken/appId into root loader data for hooks. |
| frontend/app/models/webhook.ts | Allows nullable description + default metadata events. |
| frontend/app/models/user.ts | Adds GetUserSchema response envelope. |
| frontend/app/models/usage.ts | Adds usage schemas and GetUsageSchema envelope. |
| frontend/app/models/subscription.ts | Adds subscription schemas and GetSubscriptionSchema envelope. |
| frontend/app/models/member.ts | Tightens invite role to member-only; adds remove-member form schema. |
| frontend/app/models/folder.ts | Allows nullable description; makes url optional. |
| frontend/app/models/file.ts | Expands FileSchema fields/status and adds optional folder_id on form schema. |
| frontend/app/models/domain.ts | Removes unused ServerResponse type import. |
| frontend/app/models/app.ts | Makes domain optional; handles nullable description; adds DeleteAppFormSchema. |
| frontend/app/models/api_key.ts | Adds key fields and adjusts nullable/typed fields. |
| frontend/app/lib/utils.ts | Import formatting tweak. |
| frontend/app/lib/path.ts | Adds filePath + fileDownloadPath helpers. |
| frontend/app/hooks/use-user.ts | Adds hooks for auth token/appId/backendUrl from root loader data. |
| frontend/app/hooks/use-typed-match.ts | Improves match selection and tightens default AppData type. |
| frontend/app/hooks/use-sse.ts | Adds SSE hook based on event-source-polyfill with auth headers. |
| frontend/app/hooks/use-feature.tsx | Import reordering for Feature type. |
| frontend/app/hooks/use-apps.tsx | Import ordering cleanup. |
| frontend/app/env.server.ts | Adds PUBLIC_BACKEND_URL override for publicBackendUrl. |
| frontend/app/entry.server.tsx | Import reorder (isbot) and formatting updates. |
| frontend/app/entry.client.tsx | Import formatting updates. |
| frontend/app/components/usage/plan-card.tsx | Adds current-plan awareness and updates button messaging/props. |
| frontend/app/components/ui/tooltip.tsx | Export ordering and import ordering changes. |
| frontend/app/components/ui/tabs.tsx | Export ordering and import ordering changes. |
| frontend/app/components/ui/table.tsx | Collapses export list formatting. |
| frontend/app/components/ui/switch.tsx | Import ordering change. |
| frontend/app/components/ui/sheet.tsx | Import ordering and export list formatting. |
| frontend/app/components/ui/separator.tsx | Import ordering change. |
| frontend/app/components/ui/select.tsx | Import ordering and export list formatting. |
| frontend/app/components/ui/progress.tsx | Adds Radix progress UI component. |
| frontend/app/components/ui/popover.tsx | Export ordering and import ordering changes. |
| frontend/app/components/ui/label.tsx | Import ordering change. |
| frontend/app/components/ui/input.tsx | Export formatting change. |
| frontend/app/components/ui/hover-card.tsx | Export ordering and import ordering changes. |
| frontend/app/components/ui/dropdown-menu.tsx | Export list formatting and import ordering. |
| frontend/app/components/ui/drawer.tsx | Export list formatting. |
| frontend/app/components/ui/dialog.tsx | Export list formatting and import ordering. |
| frontend/app/components/ui/context-menu.tsx | Export list formatting and import ordering. |
| frontend/app/components/ui/command.tsx | Updates wrapper attribute to data-* and export formatting. |
| frontend/app/components/ui/combo-box.tsx | Import ordering cleanup. |
| frontend/app/components/ui/checkbox.tsx | Import ordering change. |
| frontend/app/components/ui/chart.tsx | Removes unused Recharts tooltip types and tweaks destructuring. |
| frontend/app/components/ui/card.tsx | Fixes Card/CardTitle to render children instead of self-closing. |
| frontend/app/components/ui/button.tsx | Export formatting and import ordering change. |
| frontend/app/components/ui/badge.tsx | Import ordering and export formatting. |
| frontend/app/components/ui/avatar.tsx | Export ordering and import ordering changes. |
| frontend/app/components/member/invite-member-dialog.tsx | Updates copy/flow for adding members; adds hidden role/intent. |
| frontend/app/components/login-bg-boxes.tsx | Import ordering change. |
| frontend/app/components/layout/user-menu.tsx | Import ordering and formatting changes. |
| frontend/app/components/layout/side-menu.tsx | Fixes logo link to use Remix Link and tidies imports. |
| frontend/app/components/file/folder-card.tsx | Import ordering change. |
| frontend/app/components/file/files-page-context.tsx | Import formatting change. |
| frontend/app/components/file/file-layout.tsx | Import formatting change. |
| frontend/app/components/file/file-card.tsx | Makes file cards link to file detail route; adds truncation. |
| frontend/app/components/file/drag-and-drop-area.tsx | Implements drop handler via upload manager and supports folderId. |
| frontend/app/components/file/create-folder-dropdown.tsx | Import ordering and formatting changes. |
| frontend/app/components/file/create-folder-dialog.tsx | Removes unused UI complexity; streamlines create/update folder dialog. |
| frontend/app/components/app/delete-app-dialog.tsx | Adds delete-app confirmation form and validation schema usage. |
| frontend/app/components/app/create-app-dialog.tsx | Refactors imports and improves copy; keeps region selection UI. |
| frontend/app/components/app/app-domain-form.tsx | Fixes memo deps; adds TXT record UI and makes domain hidden input read-only. |
| frontend/.eslintrc.cjs | Disables react/prop-types rule for TS code. |
| backend/services/verify_domain_test.go | Adds VerifyDomainService test with fake DNS resolver. |
| backend/services/update_webhook.go | Enforces owner/app checks and uses UpdateWebhook instead of CreateWebhook. |
| backend/services/update_webhook_test.go | Updates tests for new authorization + UpdateWebhook call. |
| backend/services/update_folder.go | Adds same-app check and preserves ParentID on update. |
| backend/services/update_folder_test.go | Updates tests to include AppID for same-app checks. |
| backend/services/update_api_key.go | Enforces owner/app checks before updating API keys. |
| backend/services/update_api_key_test.go | Updates tests to include member repo checks and AppID validation. |
| backend/services/find_usage.go | Adds service computing 30-day usage summary from file records. |
| backend/services/find_usage_test.go | Tests usage aggregation behavior and daily series shape. |
| backend/services/find_folder.go | Adds same-app check to folder lookup. |
| backend/services/find_folder_test.go | Updates tests to include AppID and expected folder struct changes. |
| backend/services/find_file.go | Adds same-app check to file lookup. |
| backend/services/delete_webhook.go | Adds owner/app checks before deleting webhooks. |
| backend/services/delete_webhook_test.go | Updates tests for auth and same-app checks. |
| backend/services/delete_member.go | Adds service to remove members with owner + owner-protection constraints. |
| backend/services/delete_folder.go | Adds same-app check and blocks deletion of non-empty folders. |
| backend/services/delete_folder_test.go | Updates tests to include file repo calls for emptiness check. |
| backend/services/delete_file.go | Adds file deletion service including S3 object deletion and DB removal. |
| backend/services/delete_file_test.go | Tests file deletion uses ObjectKey and calls S3 + repo delete. |
| backend/services/delete_app.go | Adds app deletion service with confirm-name check + bucket deletion. |
| backend/services/delete_app_test.go | Tests delete app flow with fake bucket store. |
| backend/services/delete_api_key.go | Adds owner/app checks before deleting API keys. |
| backend/services/delete_api_key_test.go | Updates tests to include member repo and AppID validation. |
| backend/services/create_webhook.go | Adds owner check + webhook validation (HTTPS, events allowlist, private IP block). |
| backend/services/create_webhook_test.go | Updates tests for owner authorization checks. |
| backend/services/create_or_link_user.go | Hardens auth user email selection/verification handling. |
| backend/services/create_member.go | Adds service to add an existing user as a member with conflict checks. |
| backend/services/create_file_test.go | Adds tests for file creation, name safety, and client-provided file_id handling. |
| backend/services/create_app_test.go | Updates metadata type usage and adds slugify tests + bucket store stub. |
| backend/services/create_api_key.go | Generates one-time API key secret, stores hash/prefix/last4, validates input. |
| backend/services/create_api_key_test.go | Adds assertions for generated secret/hash. |
| backend/services/authorization.go | Adds requireSameApp and requireAppOwner helpers. |
| backend/mocks/repository.go | Extends ApiKeyRepository mock with FindApiKeyByHash and TouchApiKey. |
| backend/job/type.go | Removes unused job constants; keeps webhook job name. |
| backend/job/job.go | Removes registration of the removed app sync job handler. |
| backend/job/handlers/handle_webhook_test.go | Adds test for webhook event subscription metadata matching. |
| backend/job/handlers/handle_sync.go | Removes unused store sync handler implementation. |
| backend/job/executor.go | Uses context.Background for asynq BaseContext. |
| backend/job/client.go | Removes inspector dedupe logic; renames monitoring root path. |
| backend/internal/redis/redis.go | Adds Redis DB selection from config. |
| backend/internal/protocol/tus_test.go | Adds tests for extracting TUS file IDs from paths. |
| backend/internal/protocol/ietf_draft.go | Implements IETF resumable upload draft helpers for upload length/limits. |
| backend/internal/protocol/http.go | Adds internal HTTP request/response helpers and merge logic for tusd interop. |
| backend/internal/protocol/hooks.go | Adds HookEvent type (with commented constructor). |
| backend/internal/protocol/errors.go | Adds protocol Error type with HTTPResponse payload. |
| backend/internal/pkg/sse/type.go | Expands SSE event types and adds UploadProgress payload schema. |
| backend/internal/pkg/sse/sse.go | Adds publish/subscribe namespace support and adjusts buffering/cleanup. |
| backend/internal/pkg/response/response.go | Adds centralized response.Error mapping + expands response helpers and redirect behavior. |
| backend/internal/pkg/pubsub/redis.go | Adds debug logging timer branch in redis subscriber loop. |
| backend/internal/pkg/pubsub/pubsub.go | Fixes Kafka constructor naming, adds AMQP/InMemory cases, and errors on unsupported provider. |
| backend/internal/pkg/pubsub/option.go | Adds namespace helpers for publish/subscribe. |
| backend/internal/pkg/auth/google.go | Populates Emails list from Google user info. |
| backend/internal/pkg/auth/auth.go | Adds provider configuration validation for Google/GitHub auth. |
| backend/go.mod | Adds indirect dependencies (CORS, redis cache, AMQP, etc.). |
| backend/errors/errors.go | Adds ErrInvalidInput and ErrConflict. |
| backend/engine/handler.go | Adds empty engine package file. |
| backend/Dockerfile | Improves module caching, simplifies final image, installs ca-certificates/tzdata. |
| backend/database/store/webhook.go | Ensures webhook metadata is persisted on update. |
| backend/database/store/user.go | COALESCE display_name/avatar_url in select columns for stable JSON output. |
| backend/database/store/store.go | Adds AppSubscriptionRepo and maps PG unique violations to ErrConflict. |
| backend/database/store/repository.go | Adds AppSubscriptionRepository and expands ApiKeyRepository interface. |
| backend/database/store/app.go | Returns apps for any member (join app_members) rather than only owners. |
| backend/database/store/app_subscription.go | Adds app subscription repository implementation. |
| backend/database/store/app_member.go | Fixes error message for FindAppMemberByAppIDAndUserId. |
| backend/database/store/api_key.go | Stores/selects key credential fields and adds FindApiKeyByHash + TouchApiKey. |
| backend/database/models/webhook.go | Changes Webhook.Metadata type to models.Metadata. |
| backend/database/models/user.go | Fixes missing db tag on User.Metadata. |
| backend/database/models/model.go | Implements Metadata Scan/Value and legacy decoding support. |
| backend/database/models/model_test.go | Tests Metadata JSON + DB round-trip and legacy base64 scanning. |
| backend/database/models/folder.go | Changes Folder.Metadata type to models.Metadata. |
| backend/database/models/file.go | Adds FileStatus, makes folder_id nullable, adds ObjectKey and typed Metadata. |
| backend/database/models/domain.go | Changes Domain.Metadata type to models.Metadata. |
| backend/database/models/app.go | Changes App.Metadata type to models.Metadata. |
| backend/database/models/app_subscription.go | Adds AppSubscription model. |
| backend/database/models/app_member.go | Changes AppMember.Metadata type to models.Metadata. |
| backend/database/models/api_key.go | Adds key hash/prefix/last4/secret fields and typed Metadata. |
| backend/database/migrate/postgres/1728298030-normalize-metadata.up.sql | Normalizes metadata columns to JSON objects. |
| backend/database/migrate/postgres/1728298030-normalize-metadata.down.sql | Notes metadata normalization is irreversible. |
| backend/database/migrate/postgres/1728298020-subscription-plans.up.sql | Adds plan/status columns and unique active subscription index. |
| backend/database/migrate/postgres/1728298020-subscription-plans.down.sql | Drops subscription plan/status additions. |
| backend/database/migrate/postgres/1728298010-api-key-credentials.up.sql | Adds key credential columns and unique hash index. |
| backend/database/migrate/postgres/1728298010-api-key-credentials.down.sql | Drops API key credential additions. |
| backend/database/migrate/postgres/1728298000-harden_core_schema.up.sql | Hardens FK/index constraints and adds supporting indexes. |
| backend/database/migrate/postgres/1728298000-harden_core_schema.down.sql | Reverts hardened constraints/indexes. |
| backend/database/migrate/postgres/1727282334-create_file_table.up.sql | Adds file status column default. |
| backend/database/migrate/postgres/1727022060-create_init_table.up.sql | Adds file_status and domain_verification_type enums. |
| backend/database/database.go | Fixes sqlx.NewDb driver name argument. |
| backend/cmd/server/server.go | Wires cache + protocol into API initialization. |
| backend/cache/redis.go | Adds Redis-backed cache implementation. |
| backend/cache/cache.go | Adds cache interface and provider factory. |
| backend/auth/jwt.go | Adds signing-method validation and caches tokens on issuance. |
| backend/api/middleware/request_id.go | Refactors request-id context key to a unique struct type. |
| backend/api/middleware/member.go | Refactors app member middleware and stores member in context. |
| backend/api/middleware/cors.go | Adds configurable CORS middleware using chi/cors. |
| backend/api/middleware/auth.go | Threads cache into JWT auth middleware and uses typed context key. |
| backend/api/middleware/app_id.go | Refactors app context key to a unique struct type. |
| backend/api/middleware/api_key.go | Adds API key auth + access control middleware. |
| backend/api/handler/webhook.go | Uses response.Error and adds owner repo to webhook services. |
| backend/api/handler/util.go | Raises PerPageDefault to 100. |
| backend/api/handler/usage.go | Adds usage endpoint handler. |
| backend/api/handler/subscription.go | Adds subscription endpoint handler (creates default if missing). |
| backend/api/handler/member.go | Adds create/delete member handlers and ID decoding helper. |
| backend/api/handler/handler.go | Wires cache + protocol into Handler struct. |
| backend/api/handler/folder.go | Switches to response.Error for folder handler errors. |
| backend/api/handler/domain.go | Adds verify domain endpoint and owner checks on create/update. |
| backend/api/handler/auth.go | Improves auth error handling; updates Redirect signature usage; uses cache in JWT auth. |
| backend/api/handler/app.go | Wires subscription repo + S3 into create app; adds delete app endpoint. |
| backend/api/handler/api_key.go | Fixes param ID constant usage and wires owner repo into update/delete services. |
| backend/api/dto/member.go | Adds CreateMemberRequestDto. |
| backend/api/dto/file.go | Adds search query and CreateFileRequestDto. |
| backend/api/dto/app.go | Adds DeleteAppRequestDto. |
Files not reviewed (1)
- frontend/pnpm-lock.yaml: Generated file
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…es for API key, folder, file, webhook, and feature services
- Improved error handling in the authentication request by ensuring proper closure of response body and handling read errors. - Updated AES encryption to use GCM mode for authenticated encryption, including legacy decryption support for backward compatibility. - Added unit tests for AES encryption and decryption, including tests for tampered ciphertext and legacy CFB payloads. - Enhanced error handling in AMQP and Kafka connection management to ensure proper resource cleanup and error reporting. - Improved error handling in protocol body reader and webhook notification handling to log errors when closing resources fails.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
[Provide a brief description of the changes in this pull request]
Related Issue
[If applicable, link to the issue this PR addresses]
Type of Change
Checklist
Additional Notes
[Add any additional information or context about the PR here]