From e2d2dbecab07acb544d32566fd678ca1e2860212 Mon Sep 17 00:00:00 2001 From: John O'Keefe Date: Sun, 19 Apr 2026 14:27:35 -0400 Subject: [PATCH] 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. --- bruno/NewDevDBSetup/CreateComicLibrary.yml | 83 +++++++++++++++++ bruno/NewDevDBSetup/CreateEbookLibrary.yml | 83 +++++++++++++++++ bruno/NewDevDBSetup/CreateMangaLibrary.yml | 83 +++++++++++++++++ bruno/NewDevDBSetup/RegisterUser.yml | 98 ++++++++++++++++++++ bruno/NewDevDBSetup/folder.yml | 7 ++ bruno/library/Create Library.yml | 2 +- bruno/library/Delete Library Folder.yml | 31 ++++--- bruno/library/Delete Library.yml | 2 +- bruno/library/Get Libraries (Admin).yml | 2 +- bruno/library/Get Library Folders.yml | 19 ++-- bruno/library/Get Library Stats.yml | 28 ++++-- bruno/library/Get Library Types.yml | 19 ++-- bruno/library/Get Library.yml | 28 ++++-- bruno/library/Get Scan Settings.yml | 2 +- bruno/library/Get User Visible Libraries.yml | 19 ++-- bruno/library/Set Library Visibility.yml | 19 ++-- bruno/library/Update Library.yml | 32 ++++--- bruno/library/Update Scan Settings.yml | 2 +- 18 files changed, 484 insertions(+), 75 deletions(-) create mode 100644 bruno/NewDevDBSetup/CreateComicLibrary.yml create mode 100644 bruno/NewDevDBSetup/CreateEbookLibrary.yml create mode 100644 bruno/NewDevDBSetup/CreateMangaLibrary.yml create mode 100644 bruno/NewDevDBSetup/RegisterUser.yml create mode 100644 bruno/NewDevDBSetup/folder.yml diff --git a/bruno/NewDevDBSetup/CreateComicLibrary.yml b/bruno/NewDevDBSetup/CreateComicLibrary.yml new file mode 100644 index 0000000..ef38541 --- /dev/null +++ b/bruno/NewDevDBSetup/CreateComicLibrary.yml @@ -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 diff --git a/bruno/NewDevDBSetup/CreateEbookLibrary.yml b/bruno/NewDevDBSetup/CreateEbookLibrary.yml new file mode 100644 index 0000000..8792d30 --- /dev/null +++ b/bruno/NewDevDBSetup/CreateEbookLibrary.yml @@ -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 diff --git a/bruno/NewDevDBSetup/CreateMangaLibrary.yml b/bruno/NewDevDBSetup/CreateMangaLibrary.yml new file mode 100644 index 0000000..100bcda --- /dev/null +++ b/bruno/NewDevDBSetup/CreateMangaLibrary.yml @@ -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 diff --git a/bruno/NewDevDBSetup/RegisterUser.yml b/bruno/NewDevDBSetup/RegisterUser.yml new file mode 100644 index 0000000..118fd48 --- /dev/null +++ b/bruno/NewDevDBSetup/RegisterUser.yml @@ -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" diff --git a/bruno/NewDevDBSetup/folder.yml b/bruno/NewDevDBSetup/folder.yml new file mode 100644 index 0000000..889af65 --- /dev/null +++ b/bruno/NewDevDBSetup/folder.yml @@ -0,0 +1,7 @@ +info: + name: NewDevDBSetup + type: folder + seq: 22 + +request: + auth: inherit diff --git a/bruno/library/Create Library.yml b/bruno/library/Create Library.yml index 5cd6ae4..8a29506 100644 --- a/bruno/library/Create Library.yml +++ b/bruno/library/Create Library.yml @@ -1,7 +1,7 @@ info: name: Create Library type: http - seq: 1 + seq: 2 http: method: POST diff --git a/bruno/library/Delete Library Folder.yml b/bruno/library/Delete Library Folder.yml index b01d283..95e3f77 100644 --- a/bruno/library/Delete Library Folder.yml +++ b/bruno/library/Delete Library Folder.yml @@ -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);" + - type: tests + 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 diff --git a/bruno/library/Delete Library.yml b/bruno/library/Delete Library.yml index 75a9995..82e8d4f 100644 --- a/bruno/library/Delete Library.yml +++ b/bruno/library/Delete Library.yml @@ -1,7 +1,7 @@ info: name: Delete Library type: http - seq: 3 + seq: 12 http: method: DELETE diff --git a/bruno/library/Get Libraries (Admin).yml b/bruno/library/Get Libraries (Admin).yml index 3e83a11..fe7fbe0 100644 --- a/bruno/library/Get Libraries (Admin).yml +++ b/bruno/library/Get Libraries (Admin).yml @@ -1,7 +1,7 @@ info: name: Get Libraries (Admin) type: http - seq: 1 + seq: 3 http: method: GET diff --git a/bruno/library/Get Library Folders.yml b/bruno/library/Get Library Folders.yml index 9127edc..68798d1 100644 --- a/bruno/library/Get Library Folders.yml +++ b/bruno/library/Get Library Folders.yml @@ -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 - value: application/json + - name: "" + value: application/json + auth: inherit + +settings: + encodeUrl: true + timeout: 0 + followRedirects: true + maxRedirects: 5 docs: |- ## Get Library Folders diff --git a/bruno/library/Get Library Stats.yml b/bruno/library/Get Library Stats.yml index ee4d131..448d525 100644 --- a/bruno/library/Get Library Stats.yml +++ b/bruno/library/Get Library Stats.yml @@ -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 - value: application/json + - 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);" + - type: tests + 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 diff --git a/bruno/library/Get Library Types.yml b/bruno/library/Get Library Types.yml index 3f1abd5..34e9168 100644 --- a/bruno/library/Get Library Types.yml +++ b/bruno/library/Get Library Types.yml @@ -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 - value: application/json + - name: "" + value: application/json + auth: inherit + +settings: + encodeUrl: true + timeout: 0 + followRedirects: true + maxRedirects: 5 docs: |- ## Get Library Types diff --git a/bruno/library/Get Library.yml b/bruno/library/Get Library.yml index d776a61..e6a02cd 100644 --- a/bruno/library/Get Library.yml +++ b/bruno/library/Get Library.yml @@ -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 - value: application/json + - 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);" + - type: tests + 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 diff --git a/bruno/library/Get Scan Settings.yml b/bruno/library/Get Scan Settings.yml index ac03266..028ef43 100644 --- a/bruno/library/Get Scan Settings.yml +++ b/bruno/library/Get Scan Settings.yml @@ -1,7 +1,7 @@ info: name: Get Scan Settings type: http - seq: 2 + seq: 10 http: method: GET diff --git a/bruno/library/Get User Visible Libraries.yml b/bruno/library/Get User Visible Libraries.yml index fef95a4..6d493e8 100644 --- a/bruno/library/Get User Visible Libraries.yml +++ b/bruno/library/Get User Visible Libraries.yml @@ -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 - value: application/json + - name: "" + value: application/json + auth: inherit + +settings: + encodeUrl: true + timeout: 0 + followRedirects: true + maxRedirects: 5 docs: |- ## Get User Visible Libraries diff --git a/bruno/library/Set Library Visibility.yml b/bruno/library/Set Library Visibility.yml index 0c707cb..dc6f25e 100644 --- a/bruno/library/Set Library Visibility.yml +++ b/bruno/library/Set Library Visibility.yml @@ -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 diff --git a/bruno/library/Update Library.yml b/bruno/library/Update Library.yml index 559278d..bb870f5 100644 --- a/bruno/library/Update Library.yml +++ b/bruno/library/Update Library.yml @@ -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);" + - type: tests + 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 diff --git a/bruno/library/Update Scan Settings.yml b/bruno/library/Update Scan Settings.yml index acf30a0..db43a92 100644 --- a/bruno/library/Update Scan Settings.yml +++ b/bruno/library/Update Scan Settings.yml @@ -1,7 +1,7 @@ info: name: Update Scan Settings type: http - seq: 1 + seq: 9 http: method: PUT