Skip to content

Commit 898eca1

Browse files
committed
docs: update README with new features and API documentation
1 parent f7d2c67 commit 898eca1

File tree

1 file changed

+119
-17
lines changed

1 file changed

+119
-17
lines changed

README.md

Lines changed: 119 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
55
[![GitHub Repo](https://img.shields.io/badge/GitHub-Repository-blue)](https://github.com/haxurn/better-waitlist)
66
[![Better Auth](https://img.shields.io/badge/Better_Auth-Plugin-blue)](https://better-auth.com)
7+
[![GitHub Stars](https://img.shields.io/github/stars/haxurn/better-waitlist?style=social)](https://github.com/haxurn/better-waitlist/stargazers)
8+
[![Stars Over Time](https://starchart.cc/haxurn/better-waitlist.svg)](https://starchart.cc/haxurn/better-waitlist)
79

810
Waitlist plugin for [Better Auth](https://github.com/better-auth/better-auth)
911

@@ -73,7 +75,37 @@ import { waitlist } from 'better-waitlist';
7375
export const auth = betterAuth({
7476
plugins: [
7577
waitlist({
78+
// Authentication
7679
requireAdmin: true, // require session for admin endpoints (default: true)
80+
81+
// Entry Management
82+
maxEntries: 0, // maximum entries allowed (0 = unlimited, default: 0)
83+
enabled: true, // allow new waitlist joins (default: true)
84+
85+
// Public Features
86+
allowStatusCheck: true, // allow public status checks (default: true)
87+
showPosition: false, // show position in status response (default: false)
88+
89+
// Invitations
90+
sendInviteOnApprove: false, // auto-send invite when approving (default: false)
91+
92+
// Callbacks
93+
onJoin: async (entry) => {
94+
// Called when user joins waitlist
95+
console.log('New entry:', entry.email);
96+
},
97+
onApprove: async (entry) => {
98+
// Called when entry is approved
99+
console.log('Approved:', entry.email);
100+
},
101+
onReject: async (entry) => {
102+
// Called when entry is rejected
103+
console.log('Rejected:', entry.email);
104+
},
105+
onSignUp: async (entry) => {
106+
// Called when entry is removed (user signed up)
107+
console.log('Signed up:', entry.email);
108+
},
77109
}),
78110
],
79111
});
@@ -133,12 +165,31 @@ if (data) {
133165
}
134166
```
135167

168+
### Admin: Get Stats
169+
170+
```ts
171+
const { data, error } = await authClient.waitlist.stats();
172+
173+
if (data) {
174+
console.log(data.total);
175+
console.log(data.pending);
176+
console.log(data.approved);
177+
console.log(data.rejected);
178+
}
179+
```
180+
136181
### Admin: Approve Entry
137182

138183
```ts
139184
const { data, error } = await authClient.waitlist.approve({
140185
email: 'user@example.com',
141186
});
187+
188+
// With auto-send invite
189+
const { data: data2 } = await authClient.waitlist.approve({
190+
email: 'user@example.com',
191+
sendInvite: true, // override plugin setting for this call
192+
});
142193
```
143194

144195
### Admin: Reject Entry
@@ -149,29 +200,72 @@ const { data, error } = await authClient.waitlist.reject({
149200
});
150201
```
151202

203+
### Admin: Promote Entry
204+
205+
Send an invite to an approved user:
206+
207+
```ts
208+
const { data, error } = await authClient.waitlist.promote({
209+
email: 'user@example.com',
210+
});
211+
```
212+
213+
### Admin: Promote All
214+
215+
Send invites to all approved users:
216+
217+
```ts
218+
const { data, error } = await authClient.waitlist.promoteAll({
219+
status: 'approved', // or 'pending' - default: 'approved'
220+
});
221+
222+
if (data) {
223+
console.log(data.promoted); // count of promoted entries
224+
}
225+
```
226+
227+
### Admin: Remove Entry
228+
229+
Remove an entry from the waitlist (e.g., after user signs up):
230+
231+
```ts
232+
const { data, error } = await authClient.waitlist.remove({
233+
email: 'user@example.com',
234+
});
235+
236+
if (data) {
237+
console.log(data.entry); // the removed entry data
238+
}
239+
```
240+
152241
## Schema
153242

154-
The plugin adds a `waitlistEntry` table with the following fields:
243+
The plugin adds a `waitlist` table with the following fields:
155244

156-
| Field | Type | Description |
157-
| ----------- | ------- | ------------------------------------- |
158-
| `id` | string | Unique identifier |
159-
| `email` | string | User's email (unique) |
160-
| `status` | string | `pending` \| `approved` \| `rejected` |
161-
| `position` | number | Position in queue |
162-
| `userId` | string? | Optional relation to user |
163-
| `createdAt` | date | Timestamp |
245+
| Field | Type | Description |
246+
| ------------ | -------- | ------------------------------------- |
247+
| `id` | string | Unique identifier |
248+
| `email` | string | User's email (unique) |
249+
| `status` | string | `pending` \| `approved` \| `rejected` |
250+
| `position` | number | Position in queue |
251+
| `userId` | string? | Optional relation to user |
252+
| `invitedAt` | date? | Timestamp when invite was sent |
253+
| `createdAt` | date | Timestamp when joined |
164254

165255
## API Endpoints
166256

167-
| Method | Endpoint | Auth | Description |
168-
| ------ | -------------------- | ------- | ------------- |
169-
| POST | `/waitlist/join` | None | Join waitlist |
170-
| GET | `/waitlist/status` | None | Check status |
171-
| GET | `/waitlist/position` | None | Get position |
172-
| GET | `/waitlist/list` | Session | List entries |
173-
| POST | `/waitlist/approve` | Session | Approve entry |
174-
| POST | `/waitlist/reject` | Session | Reject entry |
257+
| Method | Endpoint | Auth | Description |
258+
| ------ | ---------------------- | ------- | ------------------------- |
259+
| POST | `/waitlist/join` | None | Join waitlist |
260+
| GET | `/waitlist/status` | None | Check status |
261+
| GET | `/waitlist/position` | None | Get position |
262+
| GET | `/waitlist/list` | Session | List entries |
263+
| GET | `/waitlist/stats` | Session | Get waitlist statistics |
264+
| POST | `/waitlist/approve` | Session | Approve entry |
265+
| POST | `/waitlist/reject` | Session | Reject entry |
266+
| POST | `/waitlist/promote` | Session | Send invite to user |
267+
| POST | `/waitlist/promote-all` | Session | Send invites to all |
268+
| POST | `/waitlist/remove` | Session | Remove entry |
175269

176270
## TypeScript
177271

@@ -190,3 +284,11 @@ const result = await authClient.waitlist.join({
190284
## License
191285

192286
MIT
287+
288+
## Contributing
289+
290+
Contributions are welcome! Please see our [CONTRIBUTING.md](CONTRIBUTING.md) for details.
291+
292+
## Code of Conduct
293+
294+
Please read our [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md) before participating in our community.

0 commit comments

Comments
 (0)