From 31df862c322268fe8d7034b664b9edaa5a7cec86 Mon Sep 17 00:00:00 2001 From: unl0ck Date: Sat, 9 Nov 2024 22:47:18 +0000 Subject: [PATCH 1/2] Add Server API to OpenAPI --- docs/controllers/ServerController.yaml | 30 ++++++++++++++++++++++++++ docs/root.yaml | 4 ++++ 2 files changed, 34 insertions(+) create mode 100644 docs/controllers/ServerController.yaml diff --git a/docs/controllers/ServerController.yaml b/docs/controllers/ServerController.yaml new file mode 100644 index 0000000000..09ed1ebf63 --- /dev/null +++ b/docs/controllers/ServerController.yaml @@ -0,0 +1,30 @@ +paths: + /ping: + get: + operationId: ping + summary: Ping the server + description: This endpoint is a simple check to see if the server is operating and responding with JSON correctly. + tags: + - Server + responses: + 200: + description: ping OK + content: + application/json: + schema: + type: object + properties: + success: + type: boolean + example: true + /healthcheck: + get: + operationId: healthcheck + summary: Health check + description: This endpoint is a simple check to see if the server is operating and can respond. + tags: + - Server + responses: + 200: + description: healthcheck OK + content: {} \ No newline at end of file diff --git a/docs/root.yaml b/docs/root.yaml index 4d6c055db7..275f302891 100644 --- a/docs/root.yaml +++ b/docs/root.yaml @@ -15,6 +15,8 @@ components: security: - BearerAuth: [] paths: + /ping: + $ref: './controllers/ServerCONTROLLER.yaml#/paths/~1ping' /api/authors/{id}: $ref: './controllers/AuthorController.yaml#/paths/~1api~1authors~1{id}' /api/authors/{id}/image: @@ -90,3 +92,5 @@ tags: description: Notifications endpoints - name: Podcasts description: Podcast endpoints + - name: Server + description: Server endpoints From d7262d4725690f08abea92ad5041e81b6b78a1c9 Mon Sep 17 00:00:00 2001 From: unl0ck Date: Sun, 10 Nov 2024 12:05:02 +0000 Subject: [PATCH 2/2] set id to lower case --- server/controllers/LibraryController.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/controllers/LibraryController.js b/server/controllers/LibraryController.js index 0bd499f1cf..961472d56b 100644 --- a/server/controllers/LibraryController.js +++ b/server/controllers/LibraryController.js @@ -1314,12 +1314,12 @@ class LibraryController { * @param {NextFunction} next */ async middleware(req, res, next) { - if (!req.user.checkCanAccessLibrary(req.params.id)) { + if (!req.user.checkCanAccessLibrary(req.params.id.toLowerCase())) { Logger.warn(`[LibraryController] Library ${req.params.id} not accessible to user ${req.user.username}`) return res.sendStatus(403) } - const library = await Database.libraryModel.findByIdWithFolders(req.params.id) + const library = await Database.libraryModel.findByIdWithFolders(req.params.id.toLowerCase()) if (!library) { return res.status(404).send('Library not found') }