From dfbe901e3b50f46b5ce345f8aa89909d62613861 Mon Sep 17 00:00:00 2001
From: Jonas Schlabertz <jonas@schlabertz.de>
Date: Fri, 29 Apr 2022 13:07:00 +0200
Subject: [PATCH] Improvement to returned HTTP Status Codes.

---
 src/controller/ComponentInformationController.ts | 3 ++-
 src/controller/TypeDefinitionController.ts       | 4 ++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/controller/ComponentInformationController.ts b/src/controller/ComponentInformationController.ts
index dd2cbcc..6a26579 100644
--- a/src/controller/ComponentInformationController.ts
+++ b/src/controller/ComponentInformationController.ts
@@ -115,7 +115,8 @@ export default class ComponentInformationController extends BaseController {
                 if(information.id != oldVersionId) {
                     // Topic is already related by a information object which is not
                     // the old version.
-                    response.status(412);
+                    // 409 - Conflict
+                    response.status(409);
                     this.setJSONLDResponseType(response);
                     response.send(new APIError("Topic is already in use by another component information."));
                     return;
diff --git a/src/controller/TypeDefinitionController.ts b/src/controller/TypeDefinitionController.ts
index f070118..5435db1 100644
--- a/src/controller/TypeDefinitionController.ts
+++ b/src/controller/TypeDefinitionController.ts
@@ -87,8 +87,8 @@ export default class TypeDefinitionController extends BaseController {
             // Thus in this case someone wants to insert a type definition with a name
             // which already exists within the database.
             if(error.code == "23505") {
-                // 412 - Precondition Failed
-                response.status(412);
+                // 409 - Conflict
+                response.status(409);
                 this.setJSONLDResponseType(response);
                 response.send(new APIError("A type definition with this name already exists."));
                 return;
-- 
GitLab