feat(api): authentication

This commit is contained in:
2025-11-18 00:38:27 +02:00
parent 3f53c1e03f
commit baad24fecc
34 changed files with 910 additions and 234 deletions
+1
View File
@@ -1,2 +1,3 @@
export * from "./articles";
export * from "./sources";
export * from "./users";
+23
View File
@@ -0,0 +1,23 @@
import { and, eq, ilike } from "drizzle-orm";
import { Database } from "#db/client";
import { users } from "#db/schema";
export type User = typeof users.$inferSelect;
export async function getUserByEmail(db: Database, email: string): Promise<User | undefined> {
return db.query.users.findFirst({
where: ilike(users.email, email),
});
}
export async function getUserById(
db: Database,
params: { id: string; email?: string },
): Promise<User | undefined> {
const { id, email } = params;
return db.query.users.findFirst({
where: email ? and(eq(users.id, id), ilike(users.email, email)) : eq(users.id, id),
});
}