Skip to content

Commit d2ba5f7

Browse files
committed
format
1 parent 97e5747 commit d2ba5f7

File tree

4 files changed

+83
-83
lines changed

4 files changed

+83
-83
lines changed

rr/app/lib/auth.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ import { drizzleAdapter } from "better-auth/adapters/drizzle";
33
import { getDB } from "./db";
44

55
export function getAuth(env?: Env) {
6-
const auth = betterAuth({
7-
database: drizzleAdapter(getDB(env), {
8-
provider: "pg",
9-
}),
10-
emailAndPassword: {
11-
enabled: true,
12-
},
13-
});
14-
return auth;
6+
const auth = betterAuth({
7+
database: drizzleAdapter(getDB(env), {
8+
provider: "pg",
9+
}),
10+
emailAndPassword: {
11+
enabled: true,
12+
},
13+
});
14+
return auth;
1515
}
1616

1717
export const auth = getAuth();

rr/app/lib/db/index.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ import { drizzle as drizzleNeon } from "drizzle-orm/neon-http";
22
import { drizzle as drizzlePg } from "drizzle-orm/node-postgres";
33

44
export function getDB(env?: Env) {
5-
// better-auth/cli を実行するとき
6-
if (!env) {
7-
const db = drizzlePg(process.env.DATABASE_URL);
8-
return db;
9-
}
10-
const db =
11-
env.NODE_ENV === "development"
12-
? drizzlePg(env.DATABASE_URL)
13-
: drizzleNeon(env.DATABASE_URL);
14-
return db;
5+
// better-auth/cli を実行するとき
6+
if (!env) {
7+
const db = drizzlePg(process.env.DATABASE_URL);
8+
return db;
9+
}
10+
const db =
11+
env.NODE_ENV === "development"
12+
? drizzlePg(env.DATABASE_URL)
13+
: drizzleNeon(env.DATABASE_URL);
14+
return db;
1515
}

rr/app/lib/db/schema.ts

Lines changed: 58 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,76 @@
11
import {
2-
integer,
3-
pgTable,
4-
varchar,
5-
text,
6-
timestamp,
7-
boolean,
2+
integer,
3+
pgTable,
4+
varchar,
5+
text,
6+
timestamp,
7+
boolean,
88
} from "drizzle-orm/pg-core";
99

1010
export const usersTable = pgTable("users", {
11-
id: integer().primaryKey().generatedAlwaysAsIdentity(),
12-
name: varchar({ length: 255 }).notNull(),
13-
age: integer().notNull(),
14-
email: varchar({ length: 255 }).notNull().unique(),
11+
id: integer().primaryKey().generatedAlwaysAsIdentity(),
12+
name: varchar({ length: 255 }).notNull(),
13+
age: integer().notNull(),
14+
email: varchar({ length: 255 }).notNull().unique(),
1515
});
1616

1717
// better-auth
1818
export const user = pgTable("user", {
19-
id: text("id").primaryKey(),
20-
name: text("name").notNull(),
21-
email: text("email").notNull().unique(),
22-
emailVerified: boolean("email_verified").default(false).notNull(),
23-
image: text("image"),
24-
createdAt: timestamp("created_at").defaultNow().notNull(),
25-
updatedAt: timestamp("updated_at")
26-
.defaultNow()
27-
.$onUpdate(() => /* @__PURE__ */ new Date())
28-
.notNull(),
19+
id: text("id").primaryKey(),
20+
name: text("name").notNull(),
21+
email: text("email").notNull().unique(),
22+
emailVerified: boolean("email_verified").default(false).notNull(),
23+
image: text("image"),
24+
createdAt: timestamp("created_at").defaultNow().notNull(),
25+
updatedAt: timestamp("updated_at")
26+
.defaultNow()
27+
.$onUpdate(() => /* @__PURE__ */ new Date())
28+
.notNull(),
2929
});
3030

3131
export const session = pgTable("session", {
32-
id: text("id").primaryKey(),
33-
expiresAt: timestamp("expires_at").notNull(),
34-
token: text("token").notNull().unique(),
35-
createdAt: timestamp("created_at").defaultNow().notNull(),
36-
updatedAt: timestamp("updated_at")
37-
.$onUpdate(() => /* @__PURE__ */ new Date())
38-
.notNull(),
39-
ipAddress: text("ip_address"),
40-
userAgent: text("user_agent"),
41-
userId: text("user_id")
42-
.notNull()
43-
.references(() => user.id, { onDelete: "cascade" }),
32+
id: text("id").primaryKey(),
33+
expiresAt: timestamp("expires_at").notNull(),
34+
token: text("token").notNull().unique(),
35+
createdAt: timestamp("created_at").defaultNow().notNull(),
36+
updatedAt: timestamp("updated_at")
37+
.$onUpdate(() => /* @__PURE__ */ new Date())
38+
.notNull(),
39+
ipAddress: text("ip_address"),
40+
userAgent: text("user_agent"),
41+
userId: text("user_id")
42+
.notNull()
43+
.references(() => user.id, { onDelete: "cascade" }),
4444
});
4545

4646
export const account = pgTable("account", {
47-
id: text("id").primaryKey(),
48-
accountId: text("account_id").notNull(),
49-
providerId: text("provider_id").notNull(),
50-
userId: text("user_id")
51-
.notNull()
52-
.references(() => user.id, { onDelete: "cascade" }),
53-
accessToken: text("access_token"),
54-
refreshToken: text("refresh_token"),
55-
idToken: text("id_token"),
56-
accessTokenExpiresAt: timestamp("access_token_expires_at"),
57-
refreshTokenExpiresAt: timestamp("refresh_token_expires_at"),
58-
scope: text("scope"),
59-
password: text("password"),
60-
createdAt: timestamp("created_at").defaultNow().notNull(),
61-
updatedAt: timestamp("updated_at")
62-
.$onUpdate(() => /* @__PURE__ */ new Date())
63-
.notNull(),
47+
id: text("id").primaryKey(),
48+
accountId: text("account_id").notNull(),
49+
providerId: text("provider_id").notNull(),
50+
userId: text("user_id")
51+
.notNull()
52+
.references(() => user.id, { onDelete: "cascade" }),
53+
accessToken: text("access_token"),
54+
refreshToken: text("refresh_token"),
55+
idToken: text("id_token"),
56+
accessTokenExpiresAt: timestamp("access_token_expires_at"),
57+
refreshTokenExpiresAt: timestamp("refresh_token_expires_at"),
58+
scope: text("scope"),
59+
password: text("password"),
60+
createdAt: timestamp("created_at").defaultNow().notNull(),
61+
updatedAt: timestamp("updated_at")
62+
.$onUpdate(() => /* @__PURE__ */ new Date())
63+
.notNull(),
6464
});
6565

6666
export const verification = pgTable("verification", {
67-
id: text("id").primaryKey(),
68-
identifier: text("identifier").notNull(),
69-
value: text("value").notNull(),
70-
expiresAt: timestamp("expires_at").notNull(),
71-
createdAt: timestamp("created_at").defaultNow().notNull(),
72-
updatedAt: timestamp("updated_at")
73-
.defaultNow()
74-
.$onUpdate(() => /* @__PURE__ */ new Date())
75-
.notNull(),
67+
id: text("id").primaryKey(),
68+
identifier: text("identifier").notNull(),
69+
value: text("value").notNull(),
70+
expiresAt: timestamp("expires_at").notNull(),
71+
createdAt: timestamp("created_at").defaultNow().notNull(),
72+
updatedAt: timestamp("updated_at")
73+
.defaultNow()
74+
.$onUpdate(() => /* @__PURE__ */ new Date())
75+
.notNull(),
7676
});

rr/app/routes/api.auth.$.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ import type { Route } from "./+types/api.auth.$";
22
import { getAuth } from "~/lib/auth";
33

44
export async function loader({ request, context }: Route.LoaderArgs) {
5-
const { env } = context.cloudflare;
6-
const auth = getAuth(env);
7-
return auth.handler(request);
5+
const { env } = context.cloudflare;
6+
const auth = getAuth(env);
7+
return auth.handler(request);
88
}
99

1010
export async function action({ request, context }: Route.ActionArgs) {
11-
const { env } = context.cloudflare;
12-
const auth = getAuth(env);
13-
return auth.handler(request);
11+
const { env } = context.cloudflare;
12+
const auth = getAuth(env);
13+
return auth.handler(request);
1414
}

0 commit comments

Comments
 (0)