chore(bruno): update library API collection and add dev DB setup
Update all library API request files to the current Bruno format with proper settings blocks, updated sequence numbers, and cleaner YAML formatting. Add NewDevDBSetup collection with requests for creating comic, ebook, and manga libraries, user registration, and folder configuration to speed up development environment setup.
This commit is contained in:
@@ -0,0 +1,83 @@
|
||||
info:
|
||||
name: CreateComicLibrary
|
||||
type: http
|
||||
seq: 3
|
||||
|
||||
http:
|
||||
method: POST
|
||||
url: "{{base_url}}/api/libraries"
|
||||
body:
|
||||
type: json
|
||||
data: |-
|
||||
{
|
||||
"name": "My Ebook Library",
|
||||
"description": "A collection of technical books and novels",
|
||||
"type": "ebooks"
|
||||
}
|
||||
auth: inherit
|
||||
|
||||
runtime:
|
||||
scripts:
|
||||
- type: after-response
|
||||
code: |-
|
||||
function onResponse(res) {
|
||||
try {
|
||||
const responseBody = res.getBody();
|
||||
const id = responseBody.id;
|
||||
|
||||
if (id) {
|
||||
bru.setEnvVar("library_id", id, { persist: true });
|
||||
console.log("Library ID saved:", id);
|
||||
}
|
||||
|
||||
if (!id) {
|
||||
console.log("No id found in response.");
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error in post-response script:", error.message);
|
||||
}
|
||||
}
|
||||
onResponse(res);
|
||||
|
||||
settings:
|
||||
encodeUrl: true
|
||||
timeout: 0
|
||||
followRedirects: true
|
||||
maxRedirects: 5
|
||||
|
||||
docs: |-
|
||||
## Create Library
|
||||
|
||||
Creates a new library for organizing media items.
|
||||
|
||||
**Method:** POST
|
||||
|
||||
**Endpoint:** /api/libraries
|
||||
|
||||
**Authentication:** Required (Bearer token)
|
||||
|
||||
**Request Body:**
|
||||
- `name` (string, required): Library name
|
||||
- `description` (string, optional): Library description
|
||||
- `type` (string, required): Library type
|
||||
- `"ebooks"`: Electronic books
|
||||
- `"audiobooks"`: Audio books
|
||||
- `"videos"`: Video content
|
||||
- `"other"`: Other media types
|
||||
|
||||
**Response:** Library object
|
||||
- `id` (string): Library UUID
|
||||
- `name` (string): Library name
|
||||
- `description` (string, optional): Library description
|
||||
- `type` (string): Library type
|
||||
- `is_visible` (boolean): Library visibility status
|
||||
- `created_at` (string): Creation timestamp
|
||||
- `updated_at` (string): Last update timestamp
|
||||
|
||||
**Status Codes:**
|
||||
- 201: Library created successfully
|
||||
- 400: Invalid request data
|
||||
- 401: Unauthorized
|
||||
- 403: Forbidden (insufficient permissions)
|
||||
- 409: Library name already exists
|
||||
- 500: Internal server error
|
||||
@@ -0,0 +1,83 @@
|
||||
info:
|
||||
name: CreateEbookLibrary
|
||||
type: http
|
||||
seq: 1
|
||||
|
||||
http:
|
||||
method: POST
|
||||
url: "{{base_url}}/api/libraries"
|
||||
body:
|
||||
type: json
|
||||
data: |-
|
||||
{
|
||||
"name": "My Ebook Library",
|
||||
"description": "A collection of technical books and novels",
|
||||
"type": "ebooks"
|
||||
}
|
||||
auth: inherit
|
||||
|
||||
runtime:
|
||||
scripts:
|
||||
- type: after-response
|
||||
code: |-
|
||||
function onResponse(res) {
|
||||
try {
|
||||
const responseBody = res.getBody();
|
||||
const id = responseBody.id;
|
||||
|
||||
if (id) {
|
||||
bru.setEnvVar("library_id", id, { persist: true });
|
||||
console.log("Library ID saved:", id);
|
||||
}
|
||||
|
||||
if (!id) {
|
||||
console.log("No id found in response.");
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error in post-response script:", error.message);
|
||||
}
|
||||
}
|
||||
onResponse(res);
|
||||
|
||||
settings:
|
||||
encodeUrl: true
|
||||
timeout: 0
|
||||
followRedirects: true
|
||||
maxRedirects: 5
|
||||
|
||||
docs: |-
|
||||
## Create Library
|
||||
|
||||
Creates a new library for organizing media items.
|
||||
|
||||
**Method:** POST
|
||||
|
||||
**Endpoint:** /api/libraries
|
||||
|
||||
**Authentication:** Required (Bearer token)
|
||||
|
||||
**Request Body:**
|
||||
- `name` (string, required): Library name
|
||||
- `description` (string, optional): Library description
|
||||
- `type` (string, required): Library type
|
||||
- `"ebooks"`: Electronic books
|
||||
- `"audiobooks"`: Audio books
|
||||
- `"videos"`: Video content
|
||||
- `"other"`: Other media types
|
||||
|
||||
**Response:** Library object
|
||||
- `id` (string): Library UUID
|
||||
- `name` (string): Library name
|
||||
- `description` (string, optional): Library description
|
||||
- `type` (string): Library type
|
||||
- `is_visible` (boolean): Library visibility status
|
||||
- `created_at` (string): Creation timestamp
|
||||
- `updated_at` (string): Last update timestamp
|
||||
|
||||
**Status Codes:**
|
||||
- 201: Library created successfully
|
||||
- 400: Invalid request data
|
||||
- 401: Unauthorized
|
||||
- 403: Forbidden (insufficient permissions)
|
||||
- 409: Library name already exists
|
||||
- 500: Internal server error
|
||||
@@ -0,0 +1,83 @@
|
||||
info:
|
||||
name: CreateMangaLibrary
|
||||
type: http
|
||||
seq: 4
|
||||
|
||||
http:
|
||||
method: POST
|
||||
url: "{{base_url}}/api/libraries"
|
||||
body:
|
||||
type: json
|
||||
data: |-
|
||||
{
|
||||
"name": "My Ebook Library",
|
||||
"description": "A collection of technical books and novels",
|
||||
"type": "ebooks"
|
||||
}
|
||||
auth: inherit
|
||||
|
||||
runtime:
|
||||
scripts:
|
||||
- type: after-response
|
||||
code: |-
|
||||
function onResponse(res) {
|
||||
try {
|
||||
const responseBody = res.getBody();
|
||||
const id = responseBody.id;
|
||||
|
||||
if (id) {
|
||||
bru.setEnvVar("library_id", id, { persist: true });
|
||||
console.log("Library ID saved:", id);
|
||||
}
|
||||
|
||||
if (!id) {
|
||||
console.log("No id found in response.");
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error in post-response script:", error.message);
|
||||
}
|
||||
}
|
||||
onResponse(res);
|
||||
|
||||
settings:
|
||||
encodeUrl: true
|
||||
timeout: 0
|
||||
followRedirects: true
|
||||
maxRedirects: 5
|
||||
|
||||
docs: |-
|
||||
## Create Library
|
||||
|
||||
Creates a new library for organizing media items.
|
||||
|
||||
**Method:** POST
|
||||
|
||||
**Endpoint:** /api/libraries
|
||||
|
||||
**Authentication:** Required (Bearer token)
|
||||
|
||||
**Request Body:**
|
||||
- `name` (string, required): Library name
|
||||
- `description` (string, optional): Library description
|
||||
- `type` (string, required): Library type
|
||||
- `"ebooks"`: Electronic books
|
||||
- `"audiobooks"`: Audio books
|
||||
- `"videos"`: Video content
|
||||
- `"other"`: Other media types
|
||||
|
||||
**Response:** Library object
|
||||
- `id` (string): Library UUID
|
||||
- `name` (string): Library name
|
||||
- `description` (string, optional): Library description
|
||||
- `type` (string): Library type
|
||||
- `is_visible` (boolean): Library visibility status
|
||||
- `created_at` (string): Creation timestamp
|
||||
- `updated_at` (string): Last update timestamp
|
||||
|
||||
**Status Codes:**
|
||||
- 201: Library created successfully
|
||||
- 400: Invalid request data
|
||||
- 401: Unauthorized
|
||||
- 403: Forbidden (insufficient permissions)
|
||||
- 409: Library name already exists
|
||||
- 500: Internal server error
|
||||
@@ -0,0 +1,98 @@
|
||||
info:
|
||||
name: RegisterUser
|
||||
type: http
|
||||
seq: 2
|
||||
|
||||
http:
|
||||
method: POST
|
||||
url: "{{base_url}}/api/auth/register"
|
||||
body:
|
||||
type: json
|
||||
data: |-
|
||||
{
|
||||
"username": "testuser",
|
||||
"email": "testuser@tests.bookhoard.internal",
|
||||
"password": "Test@Pass123!",
|
||||
"first_name": "Test",
|
||||
"last_name": "User"
|
||||
}
|
||||
auth: inherit
|
||||
|
||||
runtime:
|
||||
scripts:
|
||||
- type: after-response
|
||||
code: |-
|
||||
function onResponse(res) {
|
||||
try {
|
||||
const responseBody = res.getBody();
|
||||
const token = responseBody.access_token;
|
||||
const refreshToken = responseBody.refresh_token;
|
||||
|
||||
if (token) {
|
||||
bru.setEnvVar("token", token, { persist: true });
|
||||
console.log("Access token saved:", token);
|
||||
}
|
||||
|
||||
if (refreshToken) {
|
||||
bru.setEnvVar("refresh_token", refreshToken, { persist: true });
|
||||
console.log("Refresh token saved:", refreshToken);
|
||||
}
|
||||
|
||||
if (!token && !refreshToken) {
|
||||
console.log("No tokens found in response.");
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error in post-response script:", error.message);
|
||||
}
|
||||
}
|
||||
onResponse(res);
|
||||
|
||||
settings:
|
||||
encodeUrl: true
|
||||
timeout: 0
|
||||
followRedirects: true
|
||||
maxRedirects: 5
|
||||
|
||||
docs: |-
|
||||
## Register User
|
||||
|
||||
Creates a new user account with role-based restrictions.
|
||||
|
||||
**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): User role ("user" or "admin")
|
||||
|
||||
**Response:**
|
||||
- `token` (string): JWT token
|
||||
- `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 ("user" or "admin")
|
||||
|
||||
**Status Codes:**
|
||||
- 201: Created
|
||||
- 400: Invalid input data
|
||||
- 403: Forbidden - role-based restrictions apply
|
||||
- 409: User exists
|
||||
|
||||
**Role Restrictions:**
|
||||
- **First User**: Automatically gets admin role regardless of request
|
||||
- **Existing Admins Present**: Only authenticated admins can create new admin accounts
|
||||
- **No Admins Yet**: Anyone can create first admin (auto-assigned)
|
||||
- **Regular User Creation**: Anyone can create regular user accounts
|
||||
- **Unauthenticated Users**: Can only create first admin, not subsequent admins
|
||||
|
||||
**Examples:**
|
||||
- First admin creation: `{"email": "admin@example.com", "username": "admin", "password": "password123", "role": "admin"
|
||||
@@ -0,0 +1,7 @@
|
||||
info:
|
||||
name: NewDevDBSetup
|
||||
type: folder
|
||||
seq: 22
|
||||
|
||||
request:
|
||||
auth: inherit
|
||||
@@ -1,7 +1,7 @@
|
||||
info:
|
||||
name: Create Library
|
||||
type: http
|
||||
seq: 1
|
||||
seq: 2
|
||||
|
||||
http:
|
||||
method: POST
|
||||
|
||||
@@ -1,23 +1,32 @@
|
||||
info:
|
||||
name: Delete Library Folder
|
||||
type: http
|
||||
seq: 4
|
||||
seq: 13
|
||||
|
||||
http:
|
||||
method: DELETE
|
||||
url: '{{base_url}}/api/libraries/{{library_id}}/folders'
|
||||
auth: inherit
|
||||
url: "{{base_url}}/api/libraries/{{library_id}}/folders"
|
||||
headers:
|
||||
- name: ""
|
||||
value: application/json
|
||||
body:
|
||||
type: json
|
||||
json:
|
||||
folder_path: /path/to/folder
|
||||
headers:
|
||||
- key: Content-Type
|
||||
value: application/json
|
||||
data: ""
|
||||
auth: inherit
|
||||
|
||||
runtime:
|
||||
scripts:
|
||||
- type: tests
|
||||
code: "test_delete_library_folder_success(status, headers, body) {\n if (status\
|
||||
\ !== 204) {\n throw new Error(\"Expected status 204, got \" + status);"
|
||||
code: |-
|
||||
test_delete_library_folder_success(status, headers, body) {
|
||||
if (status !== 204) {
|
||||
throw new Error("Expected status 204, got " + status);
|
||||
|
||||
settings:
|
||||
encodeUrl: true
|
||||
timeout: 0
|
||||
followRedirects: true
|
||||
maxRedirects: 5
|
||||
|
||||
docs: |-
|
||||
## Delete Library Folder
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
info:
|
||||
name: Delete Library
|
||||
type: http
|
||||
seq: 3
|
||||
seq: 12
|
||||
|
||||
http:
|
||||
method: DELETE
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
info:
|
||||
name: Get Libraries (Admin)
|
||||
type: http
|
||||
seq: 1
|
||||
seq: 3
|
||||
|
||||
http:
|
||||
method: GET
|
||||
|
||||
@@ -1,16 +1,21 @@
|
||||
info:
|
||||
name: Get Library Folders
|
||||
type: http
|
||||
seq: 1
|
||||
seq: 5
|
||||
|
||||
http:
|
||||
method: GET
|
||||
url: '{{base_url}}/api/libraries/{{library_id}}/folders'
|
||||
auth: inherit
|
||||
body:
|
||||
type: none
|
||||
url: "{{base_url}}/api/libraries/{{library_id}}/folders"
|
||||
headers:
|
||||
- key: Content-Type
|
||||
- name: ""
|
||||
value: application/json
|
||||
auth: inherit
|
||||
|
||||
settings:
|
||||
encodeUrl: true
|
||||
timeout: 0
|
||||
followRedirects: true
|
||||
maxRedirects: 5
|
||||
|
||||
docs: |-
|
||||
## Get Library Folders
|
||||
|
||||
@@ -1,21 +1,29 @@
|
||||
info:
|
||||
name: Get Library Stats
|
||||
type: http
|
||||
seq: 5
|
||||
seq: 14
|
||||
|
||||
http:
|
||||
method: GET
|
||||
url: '{{base_url}}/api/libraries/{{library_id}}/stats'
|
||||
auth: inherit
|
||||
body:
|
||||
type: none
|
||||
url: "{{base_url}}/api/libraries/{{library_id}}/stats"
|
||||
headers:
|
||||
- key: Content-Type
|
||||
- name: ""
|
||||
value: application/json
|
||||
auth: inherit
|
||||
|
||||
runtime:
|
||||
scripts:
|
||||
- type: tests
|
||||
code: "test_get_library_stats_success(status, headers, body) {\n if (status\
|
||||
\ !== 200) {\n throw new Error(\"Expected status 200, got \" + status);"
|
||||
code: |-
|
||||
test_get_library_stats_success(status, headers, body) {
|
||||
if (status !== 200) {
|
||||
throw new Error("Expected status 200, got " + status);
|
||||
|
||||
settings:
|
||||
encodeUrl: true
|
||||
timeout: 0
|
||||
followRedirects: true
|
||||
maxRedirects: 5
|
||||
|
||||
docs: |-
|
||||
## Get Library Stats
|
||||
|
||||
@@ -1,16 +1,21 @@
|
||||
info:
|
||||
name: Get Library Types
|
||||
type: http
|
||||
seq: 1
|
||||
seq: 6
|
||||
|
||||
http:
|
||||
method: GET
|
||||
url: '{{base_url}}/api/libraries/types'
|
||||
auth: inherit
|
||||
body:
|
||||
type: none
|
||||
url: "{{base_url}}/api/libraries/types"
|
||||
headers:
|
||||
- key: Content-Type
|
||||
- name: ""
|
||||
value: application/json
|
||||
auth: inherit
|
||||
|
||||
settings:
|
||||
encodeUrl: true
|
||||
timeout: 0
|
||||
followRedirects: true
|
||||
maxRedirects: 5
|
||||
|
||||
docs: |-
|
||||
## Get Library Types
|
||||
|
||||
@@ -1,21 +1,29 @@
|
||||
info:
|
||||
name: Get Library
|
||||
type: http
|
||||
seq: 1
|
||||
seq: 4
|
||||
|
||||
http:
|
||||
method: GET
|
||||
url: '{{base_url}}/api/libraries/{{library_id}}'
|
||||
auth: inherit
|
||||
body:
|
||||
type: none
|
||||
url: "{{base_url}}/api/libraries/{{library_id}}"
|
||||
headers:
|
||||
- key: Content-Type
|
||||
- name: ""
|
||||
value: application/json
|
||||
auth: inherit
|
||||
|
||||
runtime:
|
||||
scripts:
|
||||
- type: tests
|
||||
code: "test_get_library_success(status, headers, body) {\n if (status !== 200)\
|
||||
\ {\n throw new Error(\"Expected status 200, got \" + status);"
|
||||
code: |-
|
||||
test_get_library_success(status, headers, body) {
|
||||
if (status !== 200) {
|
||||
throw new Error("Expected status 200, got " + status);
|
||||
|
||||
settings:
|
||||
encodeUrl: true
|
||||
timeout: 0
|
||||
followRedirects: true
|
||||
maxRedirects: 5
|
||||
|
||||
docs: |-
|
||||
## Get Library
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
info:
|
||||
name: Get Scan Settings
|
||||
type: http
|
||||
seq: 2
|
||||
seq: 10
|
||||
|
||||
http:
|
||||
method: GET
|
||||
|
||||
@@ -1,16 +1,21 @@
|
||||
info:
|
||||
name: Get User Visible Libraries
|
||||
type: http
|
||||
seq: 1
|
||||
seq: 7
|
||||
|
||||
http:
|
||||
method: GET
|
||||
url: '{{base_url}}/api/libraries/visible'
|
||||
auth: inherit
|
||||
body:
|
||||
type: none
|
||||
url: "{{base_url}}/api/libraries/visible"
|
||||
headers:
|
||||
- key: Content-Type
|
||||
- name: ""
|
||||
value: application/json
|
||||
auth: inherit
|
||||
|
||||
settings:
|
||||
encodeUrl: true
|
||||
timeout: 0
|
||||
followRedirects: true
|
||||
maxRedirects: 5
|
||||
|
||||
docs: |-
|
||||
## Get User Visible Libraries
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
info:
|
||||
name: Set Library Visibility
|
||||
type: http
|
||||
seq: 1
|
||||
seq: 8
|
||||
|
||||
http:
|
||||
method: POST
|
||||
url: '{{base_url}}/api/libraries/visibility'
|
||||
auth: inherit
|
||||
url: "{{base_url}}/api/libraries/visibility"
|
||||
headers:
|
||||
- name: ""
|
||||
value: application/json
|
||||
body:
|
||||
type: json
|
||||
data: |-
|
||||
@@ -13,9 +16,13 @@ http:
|
||||
"library_id": "{{library_id}}",
|
||||
"is_visible": true
|
||||
}
|
||||
headers:
|
||||
- key: Content-Type
|
||||
value: application/json
|
||||
auth: inherit
|
||||
|
||||
settings:
|
||||
encodeUrl: true
|
||||
timeout: 0
|
||||
followRedirects: true
|
||||
maxRedirects: 5
|
||||
|
||||
docs: |-
|
||||
## Set Library Visibility
|
||||
|
||||
@@ -1,24 +1,32 @@
|
||||
info:
|
||||
name: Update Library
|
||||
type: http
|
||||
seq: 2
|
||||
seq: 11
|
||||
|
||||
http:
|
||||
method: PUT
|
||||
url: '{{base_url}}/api/libraries/{{library_id}}'
|
||||
auth: inherit
|
||||
url: "{{base_url}}/api/libraries/{{library_id}}"
|
||||
headers:
|
||||
- name: ""
|
||||
value: application/json
|
||||
body:
|
||||
type: json
|
||||
json:
|
||||
name: Updated Library Name
|
||||
description: Updated library description
|
||||
headers:
|
||||
- key: Content-Type
|
||||
value: application/json
|
||||
data: ""
|
||||
auth: inherit
|
||||
|
||||
runtime:
|
||||
scripts:
|
||||
- type: tests
|
||||
code: "test_update_library_success(status, headers, body) {\n if (status !==\
|
||||
\ 200) {\n throw new Error(\"Expected status 200, got \" + status);"
|
||||
code: |-
|
||||
test_update_library_success(status, headers, body) {
|
||||
if (status !== 200) {
|
||||
throw new Error("Expected status 200, got " + status);
|
||||
|
||||
settings:
|
||||
encodeUrl: true
|
||||
timeout: 0
|
||||
followRedirects: true
|
||||
maxRedirects: 5
|
||||
|
||||
docs: |-
|
||||
## Update Library
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
info:
|
||||
name: Update Scan Settings
|
||||
type: http
|
||||
seq: 1
|
||||
seq: 9
|
||||
|
||||
http:
|
||||
method: PUT
|
||||
|
||||
Reference in New Issue
Block a user