Repository navigation
feat: add community templates API and public schema fields - #80
Conversation
|
Warning Review limit reached
Next review available in: 41 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughAdds ChangesCommunity Templates Feature
Estimated code review effort: 2 (Simple) | ~12 minutes Form Controller Comment Cleanup
Estimated code review effort: 1 (Trivial) | ~5 minutes Sequence Diagram(s)sequenceDiagram
participant Client
participant TemplateRoutes
participant getCommunityTemplates
participant Database
Client->>TemplateRoutes: GET /api/v1/templates/community?search&category&page
TemplateRoutes->>getCommunityTemplates: invoke handler
getCommunityTemplates->>Database: findMany(isPublic true, search, category, sort by useCount)
getCommunityTemplates->>Database: count matching templates
Database-->>getCommunityTemplates: templates + total count
getCommunityTemplates-->>Client: JSON data + pagination meta
Possibly related issues
Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@apps/api/src/controllers/form.controller.ts`:
- Around line 170-172: The `definition` field in `form.controller.ts` has lost
its `UpdateFormInput["definition"]` type by being read directly from `req.body`,
so restore the typed contract by pulling it from the same `req.body as
UpdateFormInput` destructuring used for `title`, `description`, and the other
fields. Keep `definition` strongly typed before the
`FormDefinitionSchema.safeParse` call so TypeScript continues to enforce the
expected shape in the `updateForm` flow.
In `@apps/api/src/controllers/template.controller.ts`:
- Around line 53-54: The template creation logic in template.controller.ts is
forcing every template to be public because `isPublic || true` always becomes
true. Update the assignment in the template controller’s create flow to preserve
an explicit `false` value by using nullish coalescing or equivalent, while
keeping the `price` fallback behavior unchanged. Use the `isPublic` and `price`
fields in the controller method that builds the template payload so private
templates can be created correctly.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: a62e0526-ffbf-4867-9ee6-1c5e11492e00
📒 Files selected for processing (6)
apps/api/src/controllers/form.controller.tsapps/api/src/controllers/template.controller.tsapps/api/src/lib/template-schemas.tsapps/api/src/routes/template/template.routes.tspackages/db/prisma/migrations/20260701063302_add_template_price/migration.sqlpackages/db/prisma/schema/templates.prisma
📜 Review details
🧰 Additional context used
🪛 SQLFluff (4.2.2)
packages/db/prisma/migrations/20260701063302_add_template_price/migration.sql
[error] 6-6: CREATE INDEX should use CONCURRENTLY to avoid locking the table during the build.
(PG01)
🔇 Additional comments (6)
packages/db/prisma/schema/templates.prisma (1)
11-14: LGTM!Also applies to: 41-41
apps/api/src/lib/template-schemas.ts (1)
8-9: LGTM!apps/api/src/controllers/template.controller.ts (1)
130-199: LGTM!apps/api/src/routes/template/template.routes.ts (1)
7-15: LGTM!packages/db/prisma/migrations/20260701063302_add_template_price/migration.sql (1)
5-6: 🚀 Performance & ScalabilityCheck whether this index should be created concurrently. On PostgreSQL,
CONCURRENTLYavoids the table lock fromCREATE INDEX, and Prisma 7.4+ can emit concurrent indexes directly; otherwise this is only worth changing iftemplatesis large enough for the lock to matter.apps/api/src/controllers/form.controller.ts (1)
17-20: LGTM!Also applies to: 30-32, 90-91, 129-131, 139-142, 455-456, 465-468
Basharkhan7776
left a comment
There was a problem hiding this comment.
Merging, will test in future
Summary
Implements the
[Block] Template/Community & Templates APIsto power the public template marketplace.Changes Made
price(Int, default0) andisPublic(Boolean, defaulttrue) to theTemplatemodel. Included a new index onisPublicfor faster querying.CreateTemplateSchemato optionally acceptpriceandisPublicwhen creators publish templates.createTemplatecontroller to correctly mappriceandisPublicto the database payload.GET /api/v1/templates/communitywhich:requireAuth).isPublic: true.useCount: "desc").search,category, and pagination (page,limit).user: { id, name, username, image }) for the UI to display.prefer-constwarnings and unused comments inform.controller.ts.Testing
bun turbo lintpasses with 0 errors/warnings.add_template_price) successfully generated and applied locally.Related Issues
Checklist