From e96d3e24c26d1e6857d64ab7df882ed9b68e06c8 Mon Sep 17 00:00:00 2001 From: Task Grading Bot Date: Sun, 7 Sep 2025 02:17:17 +0300 Subject: [PATCH] Add: Adding Docs for APIs --- APIs/Auth.md | 149 ++++++++++++++++++ APIs/User.md | 105 ++++++++++++ AskFm/AskFm.API/Controllers/AuthController.cs | 2 +- AskFm/AskFm.API/Controllers/UserController.cs | 2 +- 4 files changed, 256 insertions(+), 2 deletions(-) create mode 100644 APIs/Auth.md create mode 100644 APIs/User.md diff --git a/APIs/Auth.md b/APIs/Auth.md new file mode 100644 index 0000000..1918d5a --- /dev/null +++ b/APIs/Auth.md @@ -0,0 +1,149 @@ +# Endpoints for Authentication + +### Register +POST: `/api/Auth/register` + +**Request** +```json +{ + "name": "string", + "username": "string", + "email": "string", + "bio": "string", + "avatarPath": "string", + "passwrod": "string", + "lastSeen": "2025-09-06T22:27:00.026Z" +} +``` +**Response** + +Status Code: 200 + +```json +{ + "success": true, + "errors": [ + "string" + ], + "data": { + "isAuthenticated": true, + "token": "string", + "refreshToken": { + "token": "string", + "expireOn": "2025-09-06T22:57:05.109Z", + "isExpired": true, + "revokedOn": "2025-09-06T22:57:05.109Z", + "isActive": true, + "createdOn": "2025-09-06T22:57:05.109Z" + }, + "user": { + "name": "string", + "email": "string", + "lastSeen": "2025-09-06T22:57:05.109Z", + "bio": "string", + "avatarPath": "string", + "followerCount": 0 + } + } +} +``` + +----- +### Login +POST: `/api/Auth/login` + +**Request** +```json +{ + "email": "string", + "password": "string" + +} +``` +**Response** + +Status Code: 200 + +```json +{ + "success": true, + "errors": [ + "string" + ], + "data": { + "isAuthenticated": true, + "token": "string", + "refreshToken": { + "token": "string", + "expireOn": "2025-09-06T22:57:05.109Z", + "isExpired": true, + "revokedOn": "2025-09-06T22:57:05.109Z", + "isActive": true, + "createdOn": "2025-09-06T22:57:05.109Z" + }, + "user": { + "name": "string", + "email": "string", + "lastSeen": "2025-09-06T22:57:05.109Z", + "bio": "string", + "avatarPath": "string", + "followerCount": 0 + } + } +} +``` + +------ +### Refresh Token +POST: `/api/Auth/refresh-token/{id}` +Description: refersh token when jwt token is expired + +**Response** + +Status Code: 200 +```json +{ + "success": true, + "errors": [ + "string" + ], + "data": { + "isAuthenticated": true, + "token": "string", + "refreshToken": { + "token": "string", + "expireOn": "2025-09-06T22:57:05.109Z", + "isExpired": true, + "revokedOn": "2025-09-06T22:57:05.109Z", + "isActive": true, + "createdOn": "2025-09-06T22:57:05.109Z" + }, + "user": { + "name": "string", + "email": "string", + "lastSeen": "2025-09-06T22:57:05.109Z", + "bio": "string", + "avatarPath": "string", + "followerCount": 0 + } + } +} +``` + +--------- +### Logout +POST: `/api/Auth/logout/{id}` +Description: refersh token when jwt token is expired + +**Response** + +Status Code: 200 +```json +{ + "success": true, + "errors": [ + "string" + ], + "data": true +} +``` diff --git a/APIs/User.md b/APIs/User.md new file mode 100644 index 0000000..8fb39fa --- /dev/null +++ b/APIs/User.md @@ -0,0 +1,105 @@ +# Endpoints for User +### Get current user Profile +GET: `/api/User/profile` + +**Response** + +Status Code: 200 + +```json +{ + "name": "string", + "email": "string", + "lastSeen": "2025-09-06T23:04:42.634Z", + "bio": "string", + "avatarPath": "string", + "followerCount": 0 +} +``` + +--------- +### Get User By +GET: `/api/User/profile/{userId}` +Description: Get user by id + +**Response** + +Status Code: 200 + +```json +{ + "name": "string", + "email": "string", + "lastSeen": "2025-09-06T23:04:42.634Z", + "bio": "string", + "avatarPath": "string", + "followerCount": 0 +} +``` + +--------- +### Delete current user +Delete: `/api/User/profile/{userId}` + +**Response** +Status Code: 200 + +--------- +### Update User +POST: `/api/User/profile/update/{userId}` + +**Request** +```json +{ + "name": "string", + "bio": "string", + "avatarPath": "string" +} +``` + +**Response** + +Status Code: 200 + +```json +{ + "name": "string", + "email": "string", + "lastSeen": "2025-09-06T23:10:21.411Z", + "bio": "string", + "avatarPath": "string", + "followerCount": 0 +} +``` + +--------- +### Follow +POST: `/api/User/profile/{followerId}/follow/{targetUserId}` + +**Response** + +Status Code: 200 + +--------- +### Unfollow +POST: `/api/User/profile/{followerId}/unfollow/{targetUserId}` + +**Response** + +Status Code: 200 + +--------- +### Update Password +GET: `/api/User/profile/update/pass/{userId}` + +**Request** +```json +{ + "currentPassword": "string", + "updatedPassword": "string" +} +``` + +**Response** + +Status Code: 200 diff --git a/AskFm/AskFm.API/Controllers/AuthController.cs b/AskFm/AskFm.API/Controllers/AuthController.cs index 355b213..9760609 100644 --- a/AskFm/AskFm.API/Controllers/AuthController.cs +++ b/AskFm/AskFm.API/Controllers/AuthController.cs @@ -56,7 +56,7 @@ public async Task Login(LoginDTO login) return Ok(result); } - [HttpGet] + [HttpPost] [Route("refresh-token/{id}")] [Authorize(AuthenticationSchemes = "Bearer")] public async Task RefreshToken(int id) diff --git a/AskFm/AskFm.API/Controllers/UserController.cs b/AskFm/AskFm.API/Controllers/UserController.cs index 3f60899..894daed 100644 --- a/AskFm/AskFm.API/Controllers/UserController.cs +++ b/AskFm/AskFm.API/Controllers/UserController.cs @@ -72,7 +72,7 @@ public async Task UpdateUserAsync(int userId, UpdateUserDTO updat } var userRead = await _userService.GetUserByIdAsync(userId); - return Ok(userRead); + return Ok(userRead.Data); } [HttpDelete]