@sansavision/create-pulse 0.4.2 → 0.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/index.js +1 -1
- package/package.json +2 -2
- package/templates/nextjs-auth-demo/README.md +62 -11
- package/templates/nextjs-auth-demo/package.json +2 -0
- package/templates/nextjs-auth-demo/src/app/dashboard/demos/arena-game/page.tsx +623 -0
- package/templates/nextjs-auth-demo/src/app/dashboard/demos/chat/page.tsx +21 -5
- package/templates/nextjs-auth-demo/src/app/dashboard/demos/encrypted-chat/page.tsx +220 -7
- package/templates/nextjs-auth-demo/src/app/dashboard/demos/game-sync/page.tsx +199 -47
- package/templates/nextjs-auth-demo/src/app/dashboard/demos/video-call/page.tsx +740 -0
- package/templates/nextjs-auth-demo/src/app/dashboard/demos/watch-together/page.tsx +364 -51
- package/templates/nextjs-auth-demo/src/app/dashboard/layout.tsx +4 -0
- package/templates/nextjs-auth-demo/src/app/dashboard/page.tsx +53 -5
- package/templates/nextjs-auth-demo/src/app/layout.tsx +1 -1
- package/templates/nextjs-auth-demo/src/lib/auth.ts +2 -1
- package/templates/nextjs-auth-demo/src/lib/db.ts +2 -1
- package/templates/nextjs-auth-demo/src/lib/schema.ts +107 -0
package/README.md
CHANGED
|
@@ -27,7 +27,7 @@ npx @sansavision/create-pulse my-pulse-app
|
|
|
27
27
|
When you run `create-pulse`, you'll be prompted to select a template.
|
|
28
28
|
|
|
29
29
|
### 1. Next.js + Auth (Full Demo) ⭐
|
|
30
|
-
|
|
30
|
+
A **full-featured** demo application showcasing the full capabilities of Pulse.
|
|
31
31
|
- **Better Auth** with email/password, local SQLite + Drizzle ORM
|
|
32
32
|
- **Webhook auth** — Pulse relay verifies tokens via your Next.js API
|
|
33
33
|
- 5 comprehensive demos: Real-time Chat, Watch Together, Durable Queues (with offline simulation), Game State Sync, E2E Encrypted Chat
|
package/dist/index.js
CHANGED
|
@@ -51,7 +51,7 @@ async function main() {
|
|
|
51
51
|
return p.select({
|
|
52
52
|
message: "Pick a template:",
|
|
53
53
|
options: [
|
|
54
|
-
{ value: "nextjs-auth-demo", label: "Next.js + Auth (Full Demo)", hint: "Better Auth, all features
|
|
54
|
+
{ value: "nextjs-auth-demo", label: "Next.js + Auth (Full Demo)", hint: "Better Auth, video calls, all features" },
|
|
55
55
|
{ value: "react-watch-together", label: "Watch Together (React + TS)", hint: "Synchronized video playback" },
|
|
56
56
|
{ value: "react-all-features", label: "All Features (React + TS)", hint: "Chat, Video, Audio, RPC" },
|
|
57
57
|
{ value: "react-queue-demo", label: "Durable Queues (React + TS)", hint: "Persistent queues with WAL/Postgres/Redis" },
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sansavision/create-pulse",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.4",
|
|
4
4
|
"description": "Scaffold a new Pulse application",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|
|
7
7
|
"create-pulse": "dist/index.js"
|
|
8
8
|
},
|
|
9
9
|
"scripts": {
|
|
10
|
-
"build": "tsup src/index.ts --format cjs
|
|
10
|
+
"build": "tsup src/index.ts --format cjs",
|
|
11
11
|
"dev": "tsup src/index.ts --format cjs --watch"
|
|
12
12
|
},
|
|
13
13
|
"keywords": [
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Pulse + Next.js Auth Demo
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A **full-featured** demo application showcasing the full capabilities of [Pulse](https://github.com/Sansa-Organisation/pulse) — the real-time protocol for modern applications.
|
|
4
4
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
@@ -13,26 +13,58 @@ An **investor-ready** demo application showcasing the full capabilities of [Puls
|
|
|
13
13
|
|
|
14
14
|
## Quick Start
|
|
15
15
|
|
|
16
|
+
### 1. Install dependencies
|
|
17
|
+
|
|
16
18
|
```bash
|
|
17
|
-
# 1. Install dependencies
|
|
18
19
|
npm install
|
|
20
|
+
```
|
|
19
21
|
|
|
20
|
-
|
|
22
|
+
### 2. Configure environment
|
|
23
|
+
|
|
24
|
+
```bash
|
|
21
25
|
cp .env.example .env
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Edit `.env` and set your secret (generate one with `openssl rand -base64 32`):
|
|
29
|
+
|
|
30
|
+
```env
|
|
31
|
+
BETTER_AUTH_SECRET=your-generated-secret-here
|
|
32
|
+
BETTER_AUTH_URL=http://localhost:3000
|
|
33
|
+
NEXT_PUBLIC_PULSE_URL=ws://localhost:4001
|
|
34
|
+
```
|
|
22
35
|
|
|
23
|
-
|
|
24
|
-
openssl rand -base64 32
|
|
36
|
+
> **Note:** `BETTER_AUTH_URL` must match the port your app runs on. If you use `--port 3444`, set it to `http://localhost:3444`.
|
|
25
37
|
|
|
26
|
-
|
|
27
|
-
npx @auth/cli migrate
|
|
38
|
+
### 3. Create database tables
|
|
28
39
|
|
|
29
|
-
|
|
30
|
-
npx @sansavision/pulse-cli serve --auth-mode webhook --auth-webhook http://localhost:3000/api/pulse/verify
|
|
40
|
+
The auth schema is pre-generated in `src/lib/schema.ts`. Push it to SQLite:
|
|
31
41
|
|
|
32
|
-
|
|
42
|
+
```bash
|
|
43
|
+
npm run db:push
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
> This creates the `user`, `session`, `account`, and `verification` tables in `./sqlite.db`.
|
|
47
|
+
|
|
48
|
+
### 4. Start the Pulse relay
|
|
49
|
+
|
|
50
|
+
In a separate terminal, start the relay with webhook auth:
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
npx @sansavision/pulse-cli serve \
|
|
54
|
+
--auth-mode webhook \
|
|
55
|
+
--auth-webhook http://localhost:3000/api/pulse/verify
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
> If your app runs on a different port, update the `--auth-webhook` URL accordingly.
|
|
59
|
+
|
|
60
|
+
### 5. Start the app
|
|
61
|
+
|
|
62
|
+
```bash
|
|
33
63
|
npm run dev
|
|
34
64
|
```
|
|
35
65
|
|
|
66
|
+
Open [http://localhost:3000](http://localhost:3000) in your browser.
|
|
67
|
+
|
|
36
68
|
## Multi-User Testing
|
|
37
69
|
|
|
38
70
|
1. Open `http://localhost:3000` in a browser
|
|
@@ -70,5 +102,24 @@ Next.js App (port 3000) Pulse Relay (port 4001)
|
|
|
70
102
|
| Variable | Description | Default |
|
|
71
103
|
|----------|-------------|---------|
|
|
72
104
|
| `BETTER_AUTH_SECRET` | Auth encryption secret (32+ chars) | — |
|
|
73
|
-
| `BETTER_AUTH_URL` | Base URL of the app | `http://localhost:3000` |
|
|
105
|
+
| `BETTER_AUTH_URL` | Base URL of the app (must match your port) | `http://localhost:3000` |
|
|
74
106
|
| `NEXT_PUBLIC_PULSE_URL` | Pulse relay WebSocket URL | `ws://localhost:4001` |
|
|
107
|
+
|
|
108
|
+
## Troubleshooting
|
|
109
|
+
|
|
110
|
+
### "Invalid origin" error on signup
|
|
111
|
+
|
|
112
|
+
Your `BETTER_AUTH_URL` doesn't match the port the app is running on. For example, if you start the app with `--port 3444`, set `BETTER_AUTH_URL=http://localhost:3444` in `.env`.
|
|
113
|
+
|
|
114
|
+
### "Connecting to Pulse relay..." stays loading
|
|
115
|
+
|
|
116
|
+
Make sure the Pulse relay is running in a separate terminal with `--auth-mode webhook`. Without auth flags, the relay won't accept authenticated connections.
|
|
117
|
+
|
|
118
|
+
### Database errors
|
|
119
|
+
|
|
120
|
+
If you see table-related errors, re-run the schema push:
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
rm -f sqlite.db
|
|
124
|
+
npm run db:push
|
|
125
|
+
```
|