better-auth-studio 1.0.0
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 -0
- package/dist/auth-adapter.d.ts +24 -0
- package/dist/auth-adapter.d.ts.map +1 -0
- package/dist/auth-adapter.js +481 -0
- package/dist/auth-adapter.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +49 -0
- package/dist/cli.js.map +1 -0
- package/dist/config.d.ts +25 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +308 -0
- package/dist/config.js.map +1 -0
- package/dist/data.d.ts +38 -0
- package/dist/data.d.ts.map +1 -0
- package/dist/data.js +275 -0
- package/dist/data.js.map +1 -0
- package/dist/routes.d.ts +3 -0
- package/dist/routes.d.ts.map +1 -0
- package/dist/routes.js +1490 -0
- package/dist/routes.js.map +1 -0
- package/dist/studio.d.ts +10 -0
- package/dist/studio.d.ts.map +1 -0
- package/dist/studio.js +70 -0
- package/dist/studio.js.map +1 -0
- package/frontend/index.html +13 -0
- package/frontend/package-lock.json +4675 -0
- package/frontend/package.json +52 -0
- package/frontend/pnpm-lock.yaml +4020 -0
- package/frontend/postcss.config.js +6 -0
- package/frontend/src/App.tsx +36 -0
- package/frontend/src/components/CommandPalette.tsx +219 -0
- package/frontend/src/components/Layout.tsx +159 -0
- package/frontend/src/components/ui/badge.tsx +40 -0
- package/frontend/src/components/ui/button.tsx +53 -0
- package/frontend/src/components/ui/card.tsx +78 -0
- package/frontend/src/components/ui/input.tsx +20 -0
- package/frontend/src/components/ui/label.tsx +19 -0
- package/frontend/src/components/ui/select.tsx +71 -0
- package/frontend/src/index.css +130 -0
- package/frontend/src/lib/utils.ts +6 -0
- package/frontend/src/main.tsx +10 -0
- package/frontend/src/pages/Dashboard.tsx +231 -0
- package/frontend/src/pages/OrganizationDetails.tsx +1281 -0
- package/frontend/src/pages/Organizations.tsx +874 -0
- package/frontend/src/pages/Sessions.tsx +623 -0
- package/frontend/src/pages/Settings.tsx +1019 -0
- package/frontend/src/pages/TeamDetails.tsx +666 -0
- package/frontend/src/pages/Users.tsx +728 -0
- package/frontend/tailwind.config.js +75 -0
- package/frontend/tsconfig.json +31 -0
- package/frontend/tsconfig.node.json +10 -0
- package/frontend/vite.config.ts +31 -0
- package/package.json +59 -0
- package/public/assets/main-C-TXCXVW.css +1 -0
- package/public/assets/main-CCzTTP3P.js +296 -0
- package/public/index.html +14 -0
- package/src/auth-adapter.ts +471 -0
- package/src/cli.ts +51 -0
- package/src/config.ts +318 -0
- package/src/data.ts +351 -0
- package/src/routes.ts +1585 -0
- package/src/studio.ts +86 -0
- package/test-project/README.md +0 -0
- package/test-project/better-auth.db +0 -0
- package/test-project/better-auth_migrations/2025-08-27T15-55-04.099Z.sql +7 -0
- package/test-project/better-auth_migrations/2025-09-04T02-33-19.422Z.sql +7 -0
- package/test-project/package.json +29 -0
- package/test-project/pnpm-lock.yaml +1728 -0
- package/test-project/src/auth.ts +47 -0
- package/test-project/src/index.ts +40 -0
- package/tsconfig.json +21 -0
package/src/studio.ts
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import express from 'express';
|
|
2
|
+
import cors from 'cors';
|
|
3
|
+
import { createServer } from 'http';
|
|
4
|
+
import { WebSocketServer } from 'ws';
|
|
5
|
+
import { join } from 'path';
|
|
6
|
+
import open from 'open';
|
|
7
|
+
import chalk from 'chalk';
|
|
8
|
+
import { createRoutes } from './routes';
|
|
9
|
+
import { AuthConfig } from './config';
|
|
10
|
+
|
|
11
|
+
interface StudioOptions {
|
|
12
|
+
port: number;
|
|
13
|
+
host: string;
|
|
14
|
+
openBrowser: boolean;
|
|
15
|
+
authConfig: AuthConfig;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export async function startStudio(options: StudioOptions) {
|
|
19
|
+
const { port, host, openBrowser, authConfig } = options;
|
|
20
|
+
const app = express();
|
|
21
|
+
const server = createServer(app);
|
|
22
|
+
|
|
23
|
+
// CORS configuration
|
|
24
|
+
app.use(cors({
|
|
25
|
+
origin: ['http://localhost:3000', 'http://localhost:3001'],
|
|
26
|
+
credentials: true
|
|
27
|
+
}));
|
|
28
|
+
|
|
29
|
+
app.use(express.json());
|
|
30
|
+
app.use(express.urlencoded({ extended: true }));
|
|
31
|
+
|
|
32
|
+
const wss = new WebSocketServer({ server });
|
|
33
|
+
|
|
34
|
+
wss.on('connection', (ws) => {
|
|
35
|
+
console.log(chalk.gray('š WebSocket client connected'));
|
|
36
|
+
|
|
37
|
+
const heartbeat = setInterval(() => {
|
|
38
|
+
ws.ping();
|
|
39
|
+
}, 30000);
|
|
40
|
+
|
|
41
|
+
ws.on('close', () => {
|
|
42
|
+
console.log(chalk.gray('š WebSocket client disconnected'));
|
|
43
|
+
clearInterval(heartbeat);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
ws.on('error', (error) => {
|
|
47
|
+
console.error('WebSocket error:', error);
|
|
48
|
+
clearInterval(heartbeat);
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
app.use(createRoutes(authConfig));
|
|
53
|
+
|
|
54
|
+
app.use(express.static(join(__dirname, '../public')));
|
|
55
|
+
|
|
56
|
+
app.get('*', (req, res) => {
|
|
57
|
+
res.sendFile(join(__dirname, '../public/index.html'));
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
server.listen(port, host, () => {
|
|
61
|
+
const url = `http://${host}:${port}`;
|
|
62
|
+
console.log(chalk.green('ā
Better Auth Studio is running!'));
|
|
63
|
+
console.log(chalk.blue(`š Dashboard: ${url}`));
|
|
64
|
+
console.log(chalk.gray(`š API: ${url}/api`));
|
|
65
|
+
console.log(chalk.gray(`š WebSocket: ws://${host}:${port}`));
|
|
66
|
+
console.log(chalk.yellow('\nPress Ctrl+C to stop the server\n'));
|
|
67
|
+
|
|
68
|
+
if (openBrowser) {
|
|
69
|
+
setTimeout(() => {
|
|
70
|
+
open(url).catch(() => {
|
|
71
|
+
console.log(chalk.yellow('Could not open browser automatically. Please visit:'), url);
|
|
72
|
+
});
|
|
73
|
+
}, 1000);
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
process.on('SIGINT', () => {
|
|
78
|
+
console.log(chalk.yellow('\nš Shutting down Better Auth Studio...'));
|
|
79
|
+
server.close(() => {
|
|
80
|
+
console.log(chalk.green('ā
Server stopped'));
|
|
81
|
+
process.exit(0);
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
return server;
|
|
86
|
+
}
|
|
File without changes
|
|
Binary file
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
create table "user" ("id" text not null primary key, "name" text not null, "email" text not null unique, "emailVerified" integer not null, "image" text, "createdAt" date not null, "updatedAt" date not null);
|
|
2
|
+
|
|
3
|
+
create table "session" ("id" text not null primary key, "expiresAt" date not null, "token" text not null unique, "createdAt" date not null, "updatedAt" date not null, "ipAddress" text, "userAgent" text, "userId" text not null references "user" ("id") on delete cascade);
|
|
4
|
+
|
|
5
|
+
create table "account" ("id" text not null primary key, "accountId" text not null, "providerId" text not null, "userId" text not null references "user" ("id") on delete cascade, "accessToken" text, "refreshToken" text, "idToken" text, "accessTokenExpiresAt" date, "refreshTokenExpiresAt" date, "scope" text, "password" text, "createdAt" date not null, "updatedAt" date not null);
|
|
6
|
+
|
|
7
|
+
create table "verification" ("id" text not null primary key, "identifier" text not null, "value" text not null, "expiresAt" date not null, "createdAt" date, "updatedAt" date);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
alter table "session" add column "activeOrganizationId" text;
|
|
2
|
+
|
|
3
|
+
create table "organization" ("id" text not null primary key, "name" text not null, "slug" text not null unique, "logo" text, "createdAt" date not null, "metadata" text);
|
|
4
|
+
|
|
5
|
+
create table "member" ("id" text not null primary key, "organizationId" text not null references "organization" ("id") on delete cascade, "userId" text not null references "user" ("id") on delete cascade, "role" text not null, "createdAt" date not null);
|
|
6
|
+
|
|
7
|
+
create table "invitation" ("id" text not null primary key, "organizationId" text not null references "organization" ("id") on delete cascade, "email" text not null, "role" text, "status" text not null, "expiresAt" date not null, "inviterId" text not null references "user" ("id") on delete cascade);
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "better-auth-test-project",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Test project for Better Auth Studio",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"build": "tsc",
|
|
8
|
+
"dev": "tsx src/index.ts",
|
|
9
|
+
"start": "node dist/index.js",
|
|
10
|
+
"studio": "better-auth-studio studio",
|
|
11
|
+
"studio:dev": "rm -rf node_modules && rm -rf dist && pnpm install && pnpm studio --port 3001"
|
|
12
|
+
},
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"@types/better-sqlite3": "^7.6.13",
|
|
15
|
+
"better-auth": "1.3.5",
|
|
16
|
+
"better-auth-studio": "file:../",
|
|
17
|
+
"better-sqlite3": "^12.2.0",
|
|
18
|
+
"express": "^4.18.2"
|
|
19
|
+
},
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"@types/express": "^4.17.21",
|
|
22
|
+
"@types/node": "^20.10.0",
|
|
23
|
+
"tsx": "^4.6.0",
|
|
24
|
+
"typescript": "^5.3.2"
|
|
25
|
+
},
|
|
26
|
+
"engines": {
|
|
27
|
+
"node": ">=18.0.0"
|
|
28
|
+
}
|
|
29
|
+
}
|