Skip to content

Commit f444026

Browse files
authored
Merge pull request #92 from better-stack-ai/feat/comments-plugin
Feat: Comments Plugin
2 parents f9f5406 + 6c639cd commit f444026

File tree

88 files changed

+8443
-265
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+8443
-265
lines changed

.github/workflows/e2e.yml

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,29 @@ on:
99

1010
jobs:
1111
e2e:
12+
name: E2E (${{ matrix.framework }})
1213
runs-on: ubuntu-latest
1314
concurrency:
14-
group: e2e-${{ github.ref }}
15+
group: e2e-${{ matrix.framework }}-${{ github.ref }}
1516
cancel-in-progress: true
1617
permissions:
1718
contents: read
1819
env:
1920
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
2021
NODE_OPTIONS: --max-old-space-size=8192
2122

23+
strategy:
24+
fail-fast: false
25+
matrix:
26+
framework: [nextjs, tanstack, react-router]
27+
2228
steps:
2329
- name: Checkout
2430
uses: actions/checkout@v4
2531

2632
- name: Setup PNPM
2733
uses: pnpm/action-setup@v4
2834

29-
3035
- name: Setup Node.js
3136
uses: actions/setup-node@v4
3237
with:
@@ -42,23 +47,23 @@ jobs:
4247
- name: Build workspace
4348
run: pnpm -w build
4449

45-
- name: Run Playwright smoke tests
46-
run: pnpm e2e:smoke
50+
- name: Run Playwright smoke tests (${{ matrix.framework }})
51+
run: pnpm e2e:smoke:${{ matrix.framework }}
4752
env:
4853
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
4954

5055
- name: Upload Playwright report
5156
if: always()
5257
uses: actions/upload-artifact@v4
5358
with:
54-
name: playwright-report
59+
name: playwright-report-${{ matrix.framework }}
5560
path: e2e/playwright-report
5661
if-no-files-found: ignore
5762

5863
- name: Upload traces
5964
if: failure()
6065
uses: actions/upload-artifact@v4
6166
with:
62-
name: traces
67+
name: traces-${{ matrix.framework }}
6368
path: test-results/**/*.zip
6469
if-no-files-found: ignore

AGENTS.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -588,6 +588,13 @@ export $(cat ../examples/nextjs/.env | xargs)
588588
pnpm e2e:smoke
589589
```
590590

591+
Run for a single framework only (starts only that framework's server):
592+
```bash
593+
pnpm e2e:smoke:nextjs
594+
pnpm e2e:smoke:tanstack
595+
pnpm e2e:smoke:react-router
596+
```
597+
591598
Run specific test file:
592599
```bash
593600
pnpm e2e:smoke -- tests/smoke.chat.spec.ts
@@ -605,7 +612,7 @@ The `playwright.config.ts` defines three projects:
605612
- `tanstack:memory` - port 3004
606613
- `react-router:memory` - port 3005
607614

608-
All three web servers start for every test run. Timeout is 300 seconds per server.
615+
By default (`pnpm e2e:smoke`) all three web servers start. Set `BTST_FRAMEWORK=nextjs|tanstack|react-router` (or use the per-framework scripts above) to start only the matching server and run only its tests. The CI workflow uses a matrix to run each framework in a separate parallel job.
609616

610617
### API Key Requirements
611618

CONTRIBUTING.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -709,27 +709,35 @@ test.describe("Your Plugin", () => {
709709
})
710710
```
711711
712-
Run the full E2E suite (requires all three example apps to start):
712+
Run the full E2E suite (starts all three example apps):
713713
714714
```bash
715715
cd e2e
716716
export $(cat ../examples/nextjs/.env | xargs)
717717
pnpm e2e:smoke
718718
```
719719
720+
Run against a single framework only (starts only that framework's server — faster):
721+
722+
```bash
723+
pnpm e2e:smoke:nextjs
724+
pnpm e2e:smoke:tanstack
725+
pnpm e2e:smoke:react-router
726+
```
727+
720728
Run a single test file:
721729
722730
```bash
723731
pnpm e2e:smoke -- tests/smoke.your-plugin.spec.ts
724732
```
725733
726-
Run against a specific framework:
734+
Run against a specific Playwright project:
727735
728736
```bash
729737
pnpm e2e:smoke -- --project="nextjs:memory"
730738
```
731739
732-
Tests run against three Playwright projects: `nextjs:memory` (port 3003), `tanstack:memory` (3004), `react-router:memory` (3005).
740+
Tests run against three Playwright projects: `nextjs:memory` (port 3003), `tanstack:memory` (3004), `react-router:memory` (3005). In CI, each framework runs as a separate parallel job via a matrix strategy.
733741
734742
---
735743

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ Enable the features you need and keep building your product.
4040
| **OpenAPI** | Auto-generated API documentation with interactive Scalar UI |
4141
| **Route Docs** | Auto-generated client route documentation with interactive navigation |
4242
| **Better Auth UI** | Beautiful shadcn/ui authentication components for better-auth |
43+
| **Comments** | Commenting system with moderation, likes, and nested replies |
4344

4445
Each plugin ships **frontend + backend together**:
4546
routes, APIs, database models, React components, SSR, and SEO — already wired.

docs/content/docs/cli.mdx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,3 +124,9 @@ Because the CLI executes your config file to extract the `dbSchema`, there are a
124124
```bash
125125
SOME_VAR=value npx @btst/cli generate --config=lib/stack.ts --orm=prisma --output=schema.prisma
126126
```
127+
128+
or using dotenv-cli:
129+
130+
```bash
131+
npx dotenv-cli -e .env.local -- npx @btst/cli generate --orm drizzle --config lib/stack.ts --output db/btst-schema.ts
132+
```

docs/content/docs/installation.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,7 @@ In order to use BTST, your application must meet the following requirements:
354354
export const GET = handler
355355
export const POST = handler
356356
export const PUT = handler
357+
export const PATCH = handler
357358
export const DELETE = handler
358359
```
359360
</Tab>
@@ -390,6 +391,9 @@ In order to use BTST, your application must meet the following requirements:
390391
PUT: async ({ request }) => {
391392
return handler(request)
392393
},
394+
PATCH: async ({ request }) => {
395+
return handler(request)
396+
},
393397
DELETE: async ({ request }) => {
394398
return handler(request)
395399
},

docs/content/docs/meta.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"plugins/form-builder",
1818
"plugins/ui-builder",
1919
"plugins/kanban",
20+
"plugins/comments",
2021
"plugins/open-api",
2122
"plugins/route-docs",
2223
"plugins/better-auth-ui",

docs/content/docs/plugins/blog.mdx

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,32 @@ overrides={{
509509
}}
510510
```
511511

512+
**Slot overrides:**
513+
514+
| Override | Type | Description |
515+
|----------|------|-------------|
516+
| `postBottomSlot` | `(post: SerializedPost) => ReactNode` | Render additional content below each blog post — use to embed a `CommentThread` |
517+
518+
```tsx
519+
import { CommentThread } from "@btst/stack/plugins/comments/client/components"
520+
521+
overrides={{
522+
blog: {
523+
// ...
524+
postBottomSlot: (post) => (
525+
<CommentThread
526+
resourceId={post.slug}
527+
resourceType="blog-post"
528+
apiBaseURL={baseURL}
529+
apiBasePath="/api/data"
530+
currentUserId={session?.user?.id}
531+
loginHref="/login"
532+
/>
533+
),
534+
}
535+
}}
536+
```
537+
512538
## React Data Hooks and Types
513539
You can import the hooks from `"@btst/stack/plugins/blog/client/hooks"` to use in your components.
514540

0 commit comments

Comments
 (0)