auth, trips and join trips

This commit is contained in:
2026-04-16 14:51:54 +07:00
parent de0d1c5413
commit 237caad488
49 changed files with 11343 additions and 334 deletions
+21
View File
@@ -0,0 +1,21 @@
import bcrypt from "bcryptjs";
import { userRepo } from "@/server/repositories/user.repo";
export const authService = {
async register(data: { name: string; email: string; password: string }) {
const existing = await userRepo.findByEmail(data.email);
if (existing) {
throw new Error("Email sudah terdaftar");
}
const hashedPassword = await bcrypt.hash(data.password, 12);
const user = await userRepo.create({
name: data.name,
email: data.email,
password: hashedPassword,
});
return { id: user.id, name: user.name, email: user.email };
},
};