feat: public end-user API (/api/public/v1) for native/portal clients#2
Closed
apple-techie wants to merge 18 commits into
Closed
feat: public end-user API (/api/public/v1) for native/portal clients#2apple-techie wants to merge 18 commits into
apple-techie wants to merge 18 commits into
Conversation
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds cursor-keyset paginated public post list filtered to public boards and non-deleted/non-merged posts, with sort=newest|votes support. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ity + rename Rewrites the relational db.query.* call to db.select().from(posts).innerJoin(boards,...) so boards.isPublic and boards.deletedAt filters are applied against the correct table. Renames listPublicPosts → listPublicPostFeed and aligns type names to PublicPostFeedSummary. Tests are reworked to mock and assert the core query builder chain. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Anonymous-read routes for published changelog entries: GET /api/public/v1/changelog (hardcoded status:'published', cursor+limit) and GET /api/public/v1/changelog/:entryId (404 for missing or non-published). 16 vitest tests all passing. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…jection test Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ead routes Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Member
|
Closing this as superseded/stale after the public mobile API work landed on current main.\n\nThe read surface from this PR now overlaps/conflicts with the merged public API compatibility routes in #3, and the branch no longer merges cleanly. The remaining useful pieces here — portal-session auth, public write endpoints, config/openapi/search/detail expansions — should be re-cut as a smaller follow-up PR against current main so they can be reviewed and verified independently without replaying the already-shipped route work. |
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.
Summary
Adds a thin public end-user REST API under
/api/public/v1/*so native apps (and any first-party client) can read and write feedback as an end user — without a workspace API key. It reuses existing domain services (no new business logic, no schema migrations) and uses the existing better-auth bearer session for writes.Motivation: the admin
/api/v1/*API is API-key/team-scoped (not shippable in a consumer app), and end-user content is otherwise only reachable via the portal's server functions / the widget iframe — neither a public contract. This unblocks a native give-feedback app (a separate iOS repo consumes this via the published OpenAPI spec).Auth model
hasVoted).requirePortalSession(newdomains/api/portal-auth.ts) resolves a better-auth session token → user + principal, mirroringgetWidgetSession. The actor is alwayssession.principal.id— never client-supplied.Endpoints
Reads:
GET /config,/boards,/posts(feed,hasVoted),/posts/:id,/posts/:id/comments,/changelog(+/:id),/help/categories,/help/articles/:slug,/help/search,/openapi.json.Writes (bearer):
POST /posts(submit),/posts/:id/vote,/posts/:id/comments.Visibility / safety (enforced + tested)
publicOnlyoption, backward-compatible) and prunes deleted leaves.Reuse, not rewrite
Handlers call existing services (
createPost,voteOnPost,createComment,listChangelogs,getPublicArticleBySlug,hybridSearch,getPublicWidgetConfig, …). The only new query islistPublicPostFeed(cursor keyset over public boards). The one shared change — addingboard.isPublictoPostWithDetailsand an optionalpublicOnlytogetCommentsWithReplies— is additive and leaves admin behavior unchanged (verified: admin posts tests pass,tscclean).Test plan
bunx vitest runover the public API + touched services: 114 tests passv1/poststests still pass (10/10) — no regression from shared-service changestsc --noEmit -p apps/web→ 0 errors (with route tree generated, as CI does)eslintclean on all new files🤖 Generated with Claude Code