create-donghanh 0.3.0 → 0.3.2
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/dist/index.js +1 -5
- package/package.json +1 -1
- package/templates/kanban-gpt/.dev.vars +1 -0
- package/templates/kanban-gpt/auth.ts +8 -2
- package/templates/kanban-gpt/db/schema.ts +52 -0
- package/templates/kanban-gpt/drizzle.config.ts +0 -3
- package/templates/kanban-gpt/package.json +1 -1
- package/templates/kanban-gpt/schema.sql +86 -0
package/dist/index.js
CHANGED
|
@@ -95,11 +95,7 @@ async function main() {
|
|
|
95
95
|
console.log(" Next steps:");
|
|
96
96
|
console.log(` cd ${target}`);
|
|
97
97
|
console.log(" bun install");
|
|
98
|
-
|
|
99
|
-
console.log(" bun run db:init # initialize D1 database");
|
|
100
|
-
} else {
|
|
101
|
-
console.log(" bun run db:push # push schema to D1");
|
|
102
|
-
}
|
|
98
|
+
console.log(" bun run db:init # initialize D1 database");
|
|
103
99
|
console.log(" bun run dev # start dev server");
|
|
104
100
|
console.log();
|
|
105
101
|
}
|
package/package.json
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
BETTER_AUTH_SECRET=dev-secret-change-me-in-production
|
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
import { betterAuth } from "better-auth";
|
|
2
2
|
import { drizzleAdapter } from "better-auth/adapters/drizzle";
|
|
3
3
|
import { bearer } from "better-auth/plugins";
|
|
4
|
-
import {
|
|
4
|
+
import { drizzle } from "drizzle-orm/d1";
|
|
5
|
+
import * as schema from "./db/schema";
|
|
5
6
|
import { getEnv } from "./env";
|
|
6
7
|
|
|
7
8
|
function createAuth() {
|
|
8
9
|
const env = getEnv();
|
|
10
|
+
const authDb = drizzle(env.DB, { schema });
|
|
9
11
|
return betterAuth({
|
|
10
|
-
database: drizzleAdapter(
|
|
12
|
+
database: drizzleAdapter(authDb, {
|
|
13
|
+
provider: "sqlite",
|
|
14
|
+
usePlural: true,
|
|
15
|
+
schema,
|
|
16
|
+
}),
|
|
11
17
|
plugins: [bearer()],
|
|
12
18
|
emailAndPassword: {
|
|
13
19
|
enabled: true,
|
|
@@ -1,5 +1,57 @@
|
|
|
1
1
|
import { integer, sqliteTable, text } from "drizzle-orm/sqlite-core";
|
|
2
2
|
|
|
3
|
+
// ── Better Auth tables ──
|
|
4
|
+
|
|
5
|
+
export const users = sqliteTable("users", {
|
|
6
|
+
id: text("id").primaryKey(),
|
|
7
|
+
name: text("name").notNull(),
|
|
8
|
+
email: text("email").notNull().unique(),
|
|
9
|
+
emailVerified: integer("email_verified", { mode: "boolean" }).notNull().default(false),
|
|
10
|
+
image: text("image"),
|
|
11
|
+
createdAt: integer("created_at", { mode: "timestamp" }).$defaultFn(() => new Date()),
|
|
12
|
+
updatedAt: integer("updated_at", { mode: "timestamp" }).$defaultFn(() => new Date()),
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
export const sessions = sqliteTable("sessions", {
|
|
16
|
+
id: text("id").primaryKey(),
|
|
17
|
+
userId: text("user_id")
|
|
18
|
+
.notNull()
|
|
19
|
+
.references(() => users.id),
|
|
20
|
+
token: text("token").notNull().unique(),
|
|
21
|
+
expiresAt: integer("expires_at", { mode: "timestamp" }).notNull(),
|
|
22
|
+
ipAddress: text("ip_address"),
|
|
23
|
+
userAgent: text("user_agent"),
|
|
24
|
+
createdAt: integer("created_at", { mode: "timestamp" }).$defaultFn(() => new Date()),
|
|
25
|
+
updatedAt: integer("updated_at", { mode: "timestamp" }).$defaultFn(() => new Date()),
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
export const accounts = sqliteTable("accounts", {
|
|
29
|
+
id: text("id").primaryKey(),
|
|
30
|
+
userId: text("user_id")
|
|
31
|
+
.notNull()
|
|
32
|
+
.references(() => users.id),
|
|
33
|
+
accountId: text("account_id").notNull(),
|
|
34
|
+
providerId: text("provider_id").notNull(),
|
|
35
|
+
accessToken: text("access_token"),
|
|
36
|
+
refreshToken: text("refresh_token"),
|
|
37
|
+
accessTokenExpiresAt: integer("access_token_expires_at", { mode: "timestamp" }),
|
|
38
|
+
refreshTokenExpiresAt: integer("refresh_token_expires_at", { mode: "timestamp" }),
|
|
39
|
+
scope: text("scope"),
|
|
40
|
+
idToken: text("id_token"),
|
|
41
|
+
password: text("password"),
|
|
42
|
+
createdAt: integer("created_at", { mode: "timestamp" }).$defaultFn(() => new Date()),
|
|
43
|
+
updatedAt: integer("updated_at", { mode: "timestamp" }).$defaultFn(() => new Date()),
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
export const verifications = sqliteTable("verifications", {
|
|
47
|
+
id: text("id").primaryKey(),
|
|
48
|
+
identifier: text("identifier").notNull(),
|
|
49
|
+
value: text("value").notNull(),
|
|
50
|
+
expiresAt: integer("expires_at", { mode: "timestamp" }).notNull(),
|
|
51
|
+
createdAt: integer("created_at", { mode: "timestamp" }).$defaultFn(() => new Date()),
|
|
52
|
+
updatedAt: integer("updated_at", { mode: "timestamp" }).$defaultFn(() => new Date()),
|
|
53
|
+
});
|
|
54
|
+
|
|
3
55
|
// ── App tables ──
|
|
4
56
|
|
|
5
57
|
export const boards = sqliteTable("boards", {
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
-- Better Auth tables
|
|
2
|
+
CREATE TABLE IF NOT EXISTS users (
|
|
3
|
+
id TEXT PRIMARY KEY,
|
|
4
|
+
name TEXT NOT NULL,
|
|
5
|
+
email TEXT NOT NULL UNIQUE,
|
|
6
|
+
email_verified INTEGER NOT NULL DEFAULT 0,
|
|
7
|
+
image TEXT,
|
|
8
|
+
created_at INTEGER,
|
|
9
|
+
updated_at INTEGER
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
CREATE TABLE IF NOT EXISTS sessions (
|
|
13
|
+
id TEXT PRIMARY KEY,
|
|
14
|
+
user_id TEXT NOT NULL REFERENCES users(id),
|
|
15
|
+
token TEXT NOT NULL UNIQUE,
|
|
16
|
+
expires_at INTEGER NOT NULL,
|
|
17
|
+
ip_address TEXT,
|
|
18
|
+
user_agent TEXT,
|
|
19
|
+
created_at INTEGER,
|
|
20
|
+
updated_at INTEGER
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
CREATE TABLE IF NOT EXISTS accounts (
|
|
24
|
+
id TEXT PRIMARY KEY,
|
|
25
|
+
user_id TEXT NOT NULL REFERENCES users(id),
|
|
26
|
+
account_id TEXT NOT NULL,
|
|
27
|
+
provider_id TEXT NOT NULL,
|
|
28
|
+
access_token TEXT,
|
|
29
|
+
refresh_token TEXT,
|
|
30
|
+
access_token_expires_at INTEGER,
|
|
31
|
+
refresh_token_expires_at INTEGER,
|
|
32
|
+
scope TEXT,
|
|
33
|
+
id_token TEXT,
|
|
34
|
+
password TEXT,
|
|
35
|
+
created_at INTEGER,
|
|
36
|
+
updated_at INTEGER
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
CREATE TABLE IF NOT EXISTS verifications (
|
|
40
|
+
id TEXT PRIMARY KEY,
|
|
41
|
+
identifier TEXT NOT NULL,
|
|
42
|
+
value TEXT NOT NULL,
|
|
43
|
+
expires_at INTEGER NOT NULL,
|
|
44
|
+
created_at INTEGER,
|
|
45
|
+
updated_at INTEGER
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
-- App tables
|
|
49
|
+
CREATE TABLE IF NOT EXISTS boards (
|
|
50
|
+
id TEXT PRIMARY KEY,
|
|
51
|
+
name TEXT NOT NULL,
|
|
52
|
+
created_by TEXT NOT NULL,
|
|
53
|
+
created_at TEXT DEFAULT (datetime('now'))
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
CREATE TABLE IF NOT EXISTS columns (
|
|
57
|
+
id TEXT PRIMARY KEY,
|
|
58
|
+
board_id TEXT NOT NULL REFERENCES boards(id),
|
|
59
|
+
name TEXT NOT NULL,
|
|
60
|
+
position INTEGER NOT NULL DEFAULT 0
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
CREATE TABLE IF NOT EXISTS cards (
|
|
64
|
+
id TEXT PRIMARY KEY,
|
|
65
|
+
column_id TEXT NOT NULL REFERENCES columns(id),
|
|
66
|
+
board_id TEXT NOT NULL REFERENCES boards(id),
|
|
67
|
+
title TEXT NOT NULL,
|
|
68
|
+
position INTEGER NOT NULL DEFAULT 0,
|
|
69
|
+
created_at TEXT DEFAULT (datetime('now'))
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
CREATE TABLE IF NOT EXISTS members (
|
|
73
|
+
id TEXT PRIMARY KEY,
|
|
74
|
+
board_id TEXT NOT NULL REFERENCES boards(id),
|
|
75
|
+
name TEXT NOT NULL,
|
|
76
|
+
user_id TEXT,
|
|
77
|
+
added_at TEXT DEFAULT (datetime('now'))
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
CREATE TABLE IF NOT EXISTS oauth_codes (
|
|
81
|
+
code TEXT PRIMARY KEY,
|
|
82
|
+
user_id TEXT NOT NULL,
|
|
83
|
+
session_token TEXT NOT NULL,
|
|
84
|
+
redirect_uri TEXT NOT NULL,
|
|
85
|
+
expires_at INTEGER NOT NULL
|
|
86
|
+
);
|