refactor: Reorganize Bruno requests by role permissions
- Create separate admin folder for admin-only operations
- Move admin endpoints (Create/Update/Delete Ebook, Scanner, Folder Management) to /bruno/admin/
- Add admin dashboard, profile, and library page requests
- Add Register Admin User request with explicit admin role
- Update Register User request to include role field
- Remove empty scanner folder structure
API organization:
- Admin requests: /bruno/admin/ (require admin role)
- User requests: /bruno/user/ (available to all authenticated users)
- Environment: Single {{token}} variable works for both roles
This commit is contained in:
@@ -1,50 +0,0 @@
|
||||
meta {
|
||||
name: Add Ebook Folder
|
||||
type: http
|
||||
seq: 8
|
||||
}
|
||||
|
||||
post {
|
||||
url: {{base_url}}/api/auth/ebook-folders
|
||||
body: json
|
||||
auth: inherit
|
||||
}
|
||||
|
||||
body:json {
|
||||
{
|
||||
"folder_path": "/app/uploads"
|
||||
}
|
||||
}
|
||||
|
||||
settings {
|
||||
encodeUrl: true
|
||||
timeout: 0
|
||||
}
|
||||
|
||||
docs {
|
||||
## Add Ebook Folder
|
||||
|
||||
Adds a new ebook folder for scanning. **Admin only operation.**
|
||||
|
||||
**Method:** POST
|
||||
|
||||
**Endpoint:** /api/auth/ebook-folders
|
||||
|
||||
**Authentication:** Required (Admin role required)
|
||||
|
||||
**Request Body:**
|
||||
- `folder_path` (string, required): Path to the ebook folder
|
||||
|
||||
**Response:**
|
||||
- `id` (string): Folder ID
|
||||
- `user_id` (string): Admin user ID
|
||||
- `folder_path` (string): Folder path
|
||||
- `created_at` (string): Creation timestamp
|
||||
|
||||
**Status Codes:**
|
||||
- 201: Created
|
||||
- 400: Invalid request
|
||||
- 401: Unauthorized
|
||||
- 403: Forbidden (non-admin users)
|
||||
- 409: Folder already exists
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
meta {
|
||||
name: Delete Ebook Folder
|
||||
type: http
|
||||
seq: 10
|
||||
}
|
||||
|
||||
delete {
|
||||
url: {{base_url}}/api/auth/ebook-folders
|
||||
body: json
|
||||
auth: inherit
|
||||
}
|
||||
|
||||
body:json {
|
||||
{
|
||||
"folder_path": "/app/uploads"
|
||||
}
|
||||
}
|
||||
|
||||
settings {
|
||||
encodeUrl: true
|
||||
timeout: 0
|
||||
}
|
||||
|
||||
docs {
|
||||
## Delete Ebook Folder
|
||||
|
||||
Removes an ebook folder for the authenticated user.
|
||||
|
||||
**Method:** DELETE
|
||||
|
||||
**Endpoint:** /api/auth/ebook-folders
|
||||
|
||||
**Authentication:** Required
|
||||
|
||||
**Request Body:**
|
||||
- `folder_path` (string, required): Path to the ebook folder to remove
|
||||
|
||||
**Response:**
|
||||
- `message` (string): Success message
|
||||
|
||||
**Status Codes:**
|
||||
- 200: Success
|
||||
- 400: Invalid request
|
||||
- 401: Unauthorized
|
||||
- 500: Internal server error
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
meta {
|
||||
name: Get Ebook Folders
|
||||
type: http
|
||||
seq: 9
|
||||
}
|
||||
|
||||
get {
|
||||
url: {{base_url}}/api/auth/ebook-folders
|
||||
body: none
|
||||
auth: inherit
|
||||
}
|
||||
|
||||
settings {
|
||||
encodeUrl: true
|
||||
timeout: 0
|
||||
}
|
||||
|
||||
docs {
|
||||
## Get Ebook Folders
|
||||
|
||||
Retrieves the list of ebook folders for the authenticated user.
|
||||
|
||||
**Method:** GET
|
||||
|
||||
**Endpoint:** /api/auth/ebook-folders
|
||||
|
||||
**Authentication:** Required
|
||||
|
||||
**Response:** Array of folder objects
|
||||
- `id` (string): Folder ID
|
||||
- `user_id` (string): User ID
|
||||
- `folder_path` (string): Folder path
|
||||
- `created_at` (string): Creation timestamp
|
||||
|
||||
**Status Codes:**
|
||||
- 200: Success
|
||||
- 401: Unauthorized
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
meta {
|
||||
name: Register Admin User
|
||||
type: http
|
||||
seq: 4
|
||||
}
|
||||
|
||||
post {
|
||||
url: {{base_url}}/api/auth/register
|
||||
body: json
|
||||
auth: inherit
|
||||
}
|
||||
|
||||
body:json {
|
||||
{
|
||||
"email": "admin@example.com",
|
||||
"username": "admin",
|
||||
"password": "admin123",
|
||||
"first_name": "Admin",
|
||||
"last_name": "User",
|
||||
"role": "admin"
|
||||
}
|
||||
}
|
||||
|
||||
script:post-response {
|
||||
function onResponse(res) {
|
||||
let data = res.getBody();
|
||||
return bru.setEnvVar("token", data.token, { persist: true });
|
||||
}
|
||||
onResponse(res);
|
||||
}
|
||||
|
||||
settings {
|
||||
encodeUrl: true
|
||||
timeout: 0
|
||||
}
|
||||
|
||||
docs {
|
||||
## Register Admin User
|
||||
|
||||
Creates a new admin user account.
|
||||
|
||||
**Method:** POST
|
||||
|
||||
**Endpoint:** /api/auth/register
|
||||
|
||||
**Request Body:**
|
||||
- `email` (string): Email address
|
||||
- `username` (string): Username
|
||||
- `password` (string): Password
|
||||
- `first_name` (string, optional): First name
|
||||
- `last_name` (string, optional): Last name
|
||||
- `role` (string): Must be "admin"
|
||||
|
||||
**Response:**
|
||||
- `token` (string): JWT token with admin role
|
||||
- `user` (object): User details
|
||||
- `id` (string): User ID
|
||||
- `email` (string): Email
|
||||
- `username` (string): Username
|
||||
- `theme` (string): User theme preference
|
||||
- `first_name` (string, optional): First name
|
||||
- `last_name` (string, optional): Last name
|
||||
- `role` (string): User role ("admin")
|
||||
|
||||
**Status Codes:**
|
||||
- 201: Created
|
||||
- 409: User exists
|
||||
}
|
||||
@@ -16,7 +16,8 @@ body:json {
|
||||
"username": "testuser",
|
||||
"password": "password123",
|
||||
"first_name": "Test",
|
||||
"last_name": "User"
|
||||
"last_name": "User",
|
||||
"role": "user"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,6 +49,7 @@ docs {
|
||||
- `password` (string): Password
|
||||
- `first_name` (string, optional): First name
|
||||
- `last_name` (string, optional): Last name
|
||||
- `role` (string): User role ("user" or "admin")
|
||||
|
||||
**Response:**
|
||||
- `token` (string): JWT token
|
||||
@@ -55,9 +57,10 @@ docs {
|
||||
- `id` (string): User ID
|
||||
- `email` (string): Email
|
||||
- `username` (string): Username
|
||||
- `theme` (string): User theme preference
|
||||
- `first_name` (string, optional): First name
|
||||
- `last_name` (string, optional): Last name
|
||||
- `theme` (string): User theme preference
|
||||
- `first_name` (string, optional): First name
|
||||
- `last_name` (string, optional): Last name
|
||||
- `role` (string): User role ("user" or "admin")
|
||||
|
||||
**Status Codes:**
|
||||
- 201: Created
|
||||
|
||||
Reference in New Issue
Block a user