Files
kakeibo/backend/src/models/user.rs
T
suphicakir 906f05f62f feat(arayüz): API istemcisi, TanStack Query, ts-rs tip üretimi ve oturum durumu
- Backend: ts-rs ile DTO'lardan TypeScript tipleri (frontend/src/types, npm run types)
- Hata ve health yanıtları tipli yapılara çevrildi
- lib/api.ts: tek API istemcisi, Türkçe ApiError, ağ hatası mesajı
- lib/query.ts: QueryClient (4xx tekrar denenmez, 401 → oturum kapanır)
- lib/auth.ts: useMe, useLogin, useRegister, useLogout
- Vitest: 7 API istemcisi testi (toplam 29)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 00:39:56 +03:00

35 lines
756 B
Rust
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
//! `users` koleksiyonu (DATA_MODEL.md §3.1).
use mongodb::bson::Uuid;
use serde::{Deserialize, Serialize};
use ts_rs::TS;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, TS)]
#[serde(rename_all = "lowercase")]
#[ts(export)]
pub enum Role {
Owner,
Member,
}
impl Role {
pub fn as_str(self) -> &'static str {
match self {
Role::Owner => "owner",
Role::Member => "member",
}
}
}
/// Veritabanından okunan kullanıcı (yalnızca ihtiyaç duyulan alanlar).
#[derive(Debug, Deserialize)]
pub struct User {
#[serde(rename = "_id")]
pub id: Uuid,
pub household_id: Uuid,
pub email: String,
pub password_hash: String,
pub name: String,
pub role: Role,
}