Skip to content

Add drawing share links/grants, API base path support, and DX improvements#64

Open
tototomate123 wants to merge 62 commits intoZimengXiong:pre-releasefrom
tototomate123:pre-release
Open

Add drawing share links/grants, API base path support, and DX improvements#64
tototomate123 wants to merge 62 commits intoZimengXiong:pre-releasefrom
tototomate123:pre-release

Conversation

@tototomate123
Copy link

@tototomate123 tototomate123 commented Feb 14, 2026

This pull request introduces significant backend enhancements, most notably adding database support for drawing sharing via share links and grants, improving API routing flexibility, and increasing robustness in environment configuration and error logging. It also includes various code quality and developer experience improvements.

Database and Sharing Features:

  • Added new models DrawingShareLink and DrawingShareGrant to the Prisma schema and created corresponding migration scripts, enabling per-drawing share links and granular sharing permissions. [1] [2] [3]
  • Updated the User and Drawing models to support the new sharing relationships. [1] [2]

API Routing and Configuration:

  • Introduced API_BASE_PATH environment variable and related parsing logic, allowing the backend API to be served under a configurable base path (e.g., /api). Updated CORS, socket, health check, and route registrations to respect this path. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]

Developer Experience and Robustness:

  • Improved the database migration script to fall back to pnpm exec if npx is unavailable, increasing reliability in different development environments. [1] [2]
  • Enhanced validation error logging for user registration and admin user creation, providing more detailed and structured information for debugging. [1] [2]

Security and Utilities:

  • Centralized client IP resolution logic for rate limiting and logging, improving consistency and future extensibility. [1] [2] [3]
  • Updated CORS headers to allow the x-share-token header, supporting new sharing features.

Minor and Documentation Updates:

  • Added a reference to the original repository in the README.md.
  • Various minor code cleanups and utility improvements (e.g., route parameter parsing, import updates). [1] [2] [3] [4] [5] [6] [7]

These changes collectively lay the groundwork for advanced sharing capabilities, improve backend flexibility, and enhance developer and user experience.

I am working on this on gitea (thats the reason for that README edit, can be removed for this repo obv), and thought i'd port back my changes to you. If you don't need them / think this goes into the wrong direction just close this PR, but i thought it might be helpful :)

dependabot bot and others added 30 commits January 20, 2026 20:46
Bumps [diff](https://github.com/kpdecker/jsdiff) from 5.2.0 to 5.2.2.
- [Changelog](https://github.com/kpdecker/jsdiff/blob/master/release-notes.md)
- [Commits](kpdecker/jsdiff@v5.2.0...v5.2.2)

---
updated-dependencies:
- dependency-name: diff
  dependency-version: 5.2.2
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [lodash-es](https://github.com/lodash/lodash) from 4.17.21 to 4.17.23.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](lodash/lodash@4.17.21...4.17.23)

---
updated-dependencies:
- dependency-name: lodash-es
  dependency-version: 4.17.23
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [lodash](https://github.com/lodash/lodash) from 4.17.21 to 4.17.23.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](lodash/lodash@4.17.21...4.17.23)

---
updated-dependencies:
- dependency-name: lodash
  dependency-version: 4.17.23
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [lodash](https://github.com/lodash/lodash) from 4.17.21 to 4.17.23.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](lodash/lodash@4.17.21...4.17.23)

---
updated-dependencies:
- dependency-name: lodash
  dependency-version: 4.17.23
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Security fixes:
1. Drawings cache now includes userId in cache key to prevent data leakage
   between users making identical queries.
2. Socket.io connections now require JWT authentication when auth is enabled.
3. Socket.io join-room verifies drawing ownership before allowing access.
4. Frontend passes auth token when connecting to Socket.io.

Co-authored-by: ZimengXiong <83783148+ZimengXiong@users.noreply.github.com>
Co-authored-by: ZimengXiong <83783148+ZimengXiong@users.noreply.github.com>
… style

Co-authored-by: ZimengXiong <83783148+ZimengXiong@users.noreply.github.com>
@tototomate123 tototomate123 marked this pull request as ready for review February 14, 2026 15:48
@ZimengXiong
Copy link
Owner

thanks for your effort, @tototomate123, what does this implement? the description is not too clear (most are not about the sharing part), sharing of drawings via links? are they scoped? asking because #56 is now merged with multi-user authentication and scoped sharing.

@tototomate123
Copy link
Author

This PR bundled a few things, but the main feature was share-link based scoped access on top of auth: DrawingShareLink/DrawingShareGrant, viewer/editor links per drawing, token redemption into per-user grants, role enforcement in API + socket, and a "Shared with me" flow in the UI. So links are scoped (drawing + role) and still require login; not public anonymous links.

It also included some collaboration/realtime hardening (role-aware socket permissions + sync reliability improvements), plus infra/DX changes (API_BASE_PATH, socket path alignment, x- share-token CORS header, migration fallback, logging/IP utility, minor cleanup).

That said, I'm not fully sure how valuable all of this is now after #56 merged. I originally started this because prerelease v0.4.6 wasn't really ready for multi-user + collaboration yet, so this was meant to close that gap. If useful, you can try it and evaluate how it behaves with the current merged system, but I agree some parts may now be less necessary.

@ZimengXiong
Copy link
Owner

Yeah sure, I'll take a look at them, thanks for your effort! Sorry I had a lot of the work done locally and didn't keep the Github in sync.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants