create-donghanh 0.3.1 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-donghanh",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "description": "Scaffold a donghanh project — conversational UI with JSX",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -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 { db } from "./db";
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(db, { provider: "sqlite", usePlural: true }),
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", {
@@ -1,3 +1,51 @@
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
1
49
  CREATE TABLE IF NOT EXISTS boards (
2
50
  id TEXT PRIMARY KEY,
3
51
  name TEXT NOT NULL,