Skip to content

Commit 90e37a7

Browse files
committed
format
1 parent 0465c09 commit 90e37a7

File tree

6 files changed

+183
-183
lines changed

6 files changed

+183
-183
lines changed

lefthook.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ pre-commit:
22
commands:
33
check:
44
glob: "*.{js,ts,cjs,mjs,d.cts,d.mts,jsx,tsx,json,jsonc}"
5-
run: bunx biome format --write {staged_files}
5+
run: bunx @biomejs/biome check --write {staged_files} && git add {staged_files}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"build": "bun vite build",
1212
"lint": "eslint .",
1313
"preview": "bun vite preview",
14-
"format": "bunx biome check . --write"
14+
"format": "bunx @biomejs/biome check . --write"
1515
},
1616
"dependencies": {},
1717
"devDependencies": {

rr/app/lib/auth-client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { anonymousClient } from "better-auth/client/plugins";
22
import { createAuthClient } from "better-auth/react";
33
export const authClient = createAuthClient({
4-
plugins: [anonymousClient()],
4+
plugins: [anonymousClient()],
55
});

rr/app/lib/auth.ts

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
11
import { betterAuth } from "better-auth";
22
import { drizzleAdapter } from "better-auth/adapters/drizzle";
3-
import { getDB } from "./db";
43
import { anonymous } from "better-auth/plugins";
54
import { eq } from "drizzle-orm";
5+
import { getDB } from "./db";
66

77
export function getAuth(env?: Env) {
8-
const auth = betterAuth({
9-
database: drizzleAdapter(getDB(env), {
10-
provider: "pg",
11-
}),
12-
emailAndPassword: {
13-
enabled: true,
14-
},
15-
plugins: [
16-
anonymous({
17-
onLinkAccount: async ({ anonymousUser, newUser }) => {
18-
const db = getDB(env);
19-
// migrate like this
20-
// await db
21-
// .update(playHistory)
22-
// .set({ userId: newUser.user.id })
23-
// .where(eq(playHistory.userId, anonymousUser.user.id));
24-
},
25-
}),
26-
],
27-
});
28-
return auth;
8+
const auth = betterAuth({
9+
database: drizzleAdapter(getDB(env), {
10+
provider: "pg",
11+
}),
12+
emailAndPassword: {
13+
enabled: true,
14+
},
15+
plugins: [
16+
anonymous({
17+
onLinkAccount: async ({ anonymousUser, newUser }) => {
18+
const db = getDB(env);
19+
// migrate like this
20+
// await db
21+
// .update(playHistory)
22+
// .set({ userId: newUser.user.id })
23+
// .where(eq(playHistory.userId, anonymousUser.user.id));
24+
},
25+
}),
26+
],
27+
});
28+
return auth;
2929
}
3030

3131
export const auth = getAuth();

rr/app/lib/db/schema.ts

Lines changed: 92 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -1,122 +1,122 @@
11
import { sql } from "drizzle-orm";
22
import {
3-
check,
4-
integer,
5-
pgTable,
6-
serial,
7-
text,
8-
timestamp,
9-
boolean,
10-
primaryKey,
11-
pgEnum,
12-
index,
3+
boolean,
4+
check,
5+
index,
6+
integer,
7+
pgEnum,
8+
pgTable,
9+
primaryKey,
10+
serial,
11+
text,
12+
timestamp,
1313
} from "drizzle-orm/pg-core";
1414

1515
export const haiyama = pgTable("haiyama", {
16-
id: text("id").primaryKey(),
16+
id: text("id").primaryKey(),
1717
});
1818

1919
export const haiKindEnum = pgEnum("hai_kind", [
20-
"manzu",
21-
"pinzu",
22-
"souzu",
23-
"jihai",
20+
"manzu",
21+
"pinzu",
22+
"souzu",
23+
"jihai",
2424
]);
2525

2626
export const hai = pgTable("hai", {
27-
id: serial("id").primaryKey(),
28-
haiyamaId: text("haiyama_id")
29-
.notNull()
30-
.references(() => haiyama.id, { onDelete: "cascade" }),
31-
kind: haiKindEnum("kind").notNull(), // "manzu" | "pinzu" | "souzu" | "jihai"
32-
value: text("value").notNull(), // 1~9 or "ton" ~ "tyun"
33-
order: integer("order").notNull(), // 0~17
34-
index: integer("index").notNull(), // haiToIndex
27+
id: serial("id").primaryKey(),
28+
haiyamaId: text("haiyama_id")
29+
.notNull()
30+
.references(() => haiyama.id, { onDelete: "cascade" }),
31+
kind: haiKindEnum("kind").notNull(), // "manzu" | "pinzu" | "souzu" | "jihai"
32+
value: text("value").notNull(), // 1~9 or "ton" ~ "tyun"
33+
order: integer("order").notNull(), // 0~17
34+
index: integer("index").notNull(), // haiToIndex
3535
});
3636

3737
// relation between user and haiyama
3838
// TODO: index
3939
export const kyoku = pgTable(
40-
"kyoku",
41-
{
42-
userId: text("user_id")
43-
.notNull()
44-
.references(() => user.id, { onDelete: "cascade" }),
45-
haiyamaId: text("haiyama_id")
46-
.notNull()
47-
.references(() => haiyama.id, { onDelete: "cascade" }),
48-
didAgari: boolean("did_agari").notNull(),
49-
agariJunme: integer("agari_junme"),
50-
},
51-
(table) => [
52-
primaryKey({ columns: [table.userId, table.haiyamaId] }),
53-
index("kyoku_user_id_idx").on(table.userId),
54-
index("kyoku_haiyama_id_idx").on(table.haiyamaId),
55-
check(
56-
"agari_consistency",
57-
sql`(${table.didAgari} = false) OR (${table.didAgari} = true AND ${table.agariJunme} IS NOT NULL)`,
58-
),
59-
],
40+
"kyoku",
41+
{
42+
userId: text("user_id")
43+
.notNull()
44+
.references(() => user.id, { onDelete: "cascade" }),
45+
haiyamaId: text("haiyama_id")
46+
.notNull()
47+
.references(() => haiyama.id, { onDelete: "cascade" }),
48+
didAgari: boolean("did_agari").notNull(),
49+
agariJunme: integer("agari_junme"),
50+
},
51+
(table) => [
52+
primaryKey({ columns: [table.userId, table.haiyamaId] }),
53+
index("kyoku_user_id_idx").on(table.userId),
54+
index("kyoku_haiyama_id_idx").on(table.haiyamaId),
55+
check(
56+
"agari_consistency",
57+
sql`(${table.didAgari} = false) OR (${table.didAgari} = true AND ${table.agariJunme} IS NOT NULL)`,
58+
),
59+
],
6060
);
6161

6262
// better-auth
6363
export const user = pgTable("user", {
64-
id: text("id").primaryKey(),
65-
name: text("name").notNull(),
66-
email: text("email").notNull().unique(),
67-
emailVerified: boolean("email_verified").default(false).notNull(),
68-
image: text("image"),
69-
createdAt: timestamp("created_at").defaultNow().notNull(),
70-
updatedAt: timestamp("updated_at")
71-
.defaultNow()
72-
.$onUpdate(() => /* @__PURE__ */ new Date())
73-
.notNull(),
74-
isAnonymous: boolean("is_anonymous"),
64+
id: text("id").primaryKey(),
65+
name: text("name").notNull(),
66+
email: text("email").notNull().unique(),
67+
emailVerified: boolean("email_verified").default(false).notNull(),
68+
image: text("image"),
69+
createdAt: timestamp("created_at").defaultNow().notNull(),
70+
updatedAt: timestamp("updated_at")
71+
.defaultNow()
72+
.$onUpdate(() => /* @__PURE__ */ new Date())
73+
.notNull(),
74+
isAnonymous: boolean("is_anonymous"),
7575
});
7676

7777
export const session = pgTable("session", {
78-
id: text("id").primaryKey(),
79-
expiresAt: timestamp("expires_at").notNull(),
80-
token: text("token").notNull().unique(),
81-
createdAt: timestamp("created_at").defaultNow().notNull(),
82-
updatedAt: timestamp("updated_at")
83-
.$onUpdate(() => /* @__PURE__ */ new Date())
84-
.notNull(),
85-
ipAddress: text("ip_address"),
86-
userAgent: text("user_agent"),
87-
userId: text("user_id")
88-
.notNull()
89-
.references(() => user.id, { onDelete: "cascade" }),
78+
id: text("id").primaryKey(),
79+
expiresAt: timestamp("expires_at").notNull(),
80+
token: text("token").notNull().unique(),
81+
createdAt: timestamp("created_at").defaultNow().notNull(),
82+
updatedAt: timestamp("updated_at")
83+
.$onUpdate(() => /* @__PURE__ */ new Date())
84+
.notNull(),
85+
ipAddress: text("ip_address"),
86+
userAgent: text("user_agent"),
87+
userId: text("user_id")
88+
.notNull()
89+
.references(() => user.id, { onDelete: "cascade" }),
9090
});
9191

9292
export const account = pgTable("account", {
93-
id: text("id").primaryKey(),
94-
accountId: text("account_id").notNull(),
95-
providerId: text("provider_id").notNull(),
96-
userId: text("user_id")
97-
.notNull()
98-
.references(() => user.id, { onDelete: "cascade" }),
99-
accessToken: text("access_token"),
100-
refreshToken: text("refresh_token"),
101-
idToken: text("id_token"),
102-
accessTokenExpiresAt: timestamp("access_token_expires_at"),
103-
refreshTokenExpiresAt: timestamp("refresh_token_expires_at"),
104-
scope: text("scope"),
105-
password: text("password"),
106-
createdAt: timestamp("created_at").defaultNow().notNull(),
107-
updatedAt: timestamp("updated_at")
108-
.$onUpdate(() => /* @__PURE__ */ new Date())
109-
.notNull(),
93+
id: text("id").primaryKey(),
94+
accountId: text("account_id").notNull(),
95+
providerId: text("provider_id").notNull(),
96+
userId: text("user_id")
97+
.notNull()
98+
.references(() => user.id, { onDelete: "cascade" }),
99+
accessToken: text("access_token"),
100+
refreshToken: text("refresh_token"),
101+
idToken: text("id_token"),
102+
accessTokenExpiresAt: timestamp("access_token_expires_at"),
103+
refreshTokenExpiresAt: timestamp("refresh_token_expires_at"),
104+
scope: text("scope"),
105+
password: text("password"),
106+
createdAt: timestamp("created_at").defaultNow().notNull(),
107+
updatedAt: timestamp("updated_at")
108+
.$onUpdate(() => /* @__PURE__ */ new Date())
109+
.notNull(),
110110
});
111111

112112
export const verification = pgTable("verification", {
113-
id: text("id").primaryKey(),
114-
identifier: text("identifier").notNull(),
115-
value: text("value").notNull(),
116-
expiresAt: timestamp("expires_at").notNull(),
117-
createdAt: timestamp("created_at").defaultNow().notNull(),
118-
updatedAt: timestamp("updated_at")
119-
.defaultNow()
120-
.$onUpdate(() => /* @__PURE__ */ new Date())
121-
.notNull(),
113+
id: text("id").primaryKey(),
114+
identifier: text("identifier").notNull(),
115+
value: text("value").notNull(),
116+
expiresAt: timestamp("expires_at").notNull(),
117+
createdAt: timestamp("created_at").defaultNow().notNull(),
118+
updatedAt: timestamp("updated_at")
119+
.defaultNow()
120+
.$onUpdate(() => /* @__PURE__ */ new Date())
121+
.notNull(),
122122
});

0 commit comments

Comments
 (0)