-
Notifications
You must be signed in to change notification settings - Fork 0
4. Profile
Abdullah bin Ammar edited this page May 20, 2025
·
1 revision
Note
These endpoints manage user account operations such as retrieving profile info, registration (in development only), and deleting accounts.
| Method | Endpoint | Description |
|---|---|---|
| GET | /profile |
Fetch the logged-in user’s profile. |
| POST | /profile |
Create a new user account (disabled in production). |
| DELETE | /profile |
Delete the logged-in user’s account. |
- 👤 Profile Fetching: Retrieves authenticated user info with optional field and relation filters.
- 🆕 Account Creation: Allows creating accounts in non-production environments using
insertUserSchema. - ❌ Account Deletion: Allows users to delete their account and clears their session.
- 🔐 Authentication Guard:
GETandDELETErequire authentication viaisAuthenticated. - 🧪 Validation: Uses Zod schema to validate registration input in development.
GET /profileReturns user profile data.
Query Parameters (optional):
-
fields[]: Array of user fields to retrieve -
include[]: Related entities to include
Requires: Authentication
Response:
-
200 OKwith{ user } -
401 Unauthorizedif not logged in -
404if user not found
POST /profileRegisters a new user. Only allowed in non-production environments.
Requires: No authentication
Body Schema: insertUserSchema
Response:
-
201 Createdwith newuserdata -
400 Bad Requestif validation fails -
403 Forbiddenin production -
500on server error
DELETE /profileDeletes the currently logged-in user’s account and destroys the session if active.
Requires: Authentication
Response:
-
200 OKwith{ success: true } -
401 Unauthorizedif not logged in -
500on error