nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: OWASP/threat-dragon
Pull request #482 (2022-08-10 16:10:48)

revert breaking change to homecontroller
**Summary**
reverts breaking change to homecontroller

**Description for the changelog**
revert breaking change to homecontroller

**Other info**
Reverts change to the homecontroller, which I did in an earlier pull-request #480 because I misunderstood one of the routes


Patch:
diff --git a/td.server/src/controllers/homecontroller.js b/td.server/src/controllers/homecontroller.js
index ae9979c2..5f148e3d 100644
--- a/td.server/src/controllers/homecontroller.js
+++ b/td.server/src/controllers/homecontroller.js
@@ -1,12 +1,25 @@
-// index page
-
 import loggerHelper from '../helpers/logger.helper.js';
+import path from 'path';
 
 const logger = loggerHelper.get('controllers/homecontroller.js');
 
+import { upDir } from '../helpers/path.helper.js';
+
+/**
+ * The path to the index.html file
+ * @type {String}
+ */
+const indexHtmlPath = path.join(__dirname, upDir, upDir, upDir, 'dist', 'index.html');
+
+/**
+ * Serves the index.html page for the SPA
+ * @param {Object} req
+ * @param {Object} res
+ * @returns {Object}
+ */
 const index = (req, res) => {
-    logger.debug('index request');
-    res.send('Threat Dragon back-end server');
+    logger.debug('API index request, sendFile ' + indexHtmlPath);
+    res.sendFile(indexHtmlPath);
 };
 
 


Test patch:
diff --git a/td.server/test/controllers/homecontroller.spec.js b/td.server/test/controllers/homecontroller.spec.js
index f1003522..5e405ba2 100644
--- a/td.server/test/controllers/homecontroller.spec.js
+++ b/td.server/test/controllers/homecontroller.spec.js
@@ -24,8 +24,8 @@ describe('homecontroller tests', () => {
             homeController.index(mockRequest, mockResponse);
         });
 
-        it('should send the home page', () => {
-            expect(mockResponse.send).to.have.been.calledOnce;
+        it('should send the home page file', () => {
+            expect(mockResponse.sendFile).to.have.been.calledWith(sinon.match(/index\.html$/));
         });
     });
 });