summaryrefslogtreecommitdiff
path: root/backend/src/controllers/stopAllRobots.ts
diff options
context:
space:
mode:
Diffstat (limited to 'backend/src/controllers/stopAllRobots.ts')
-rw-r--r--backend/src/controllers/stopAllRobots.ts21
1 files changed, 21 insertions, 0 deletions
diff --git a/backend/src/controllers/stopAllRobots.ts b/backend/src/controllers/stopAllRobots.ts
new file mode 100644
index 0000000..7218e66
--- /dev/null
+++ b/backend/src/controllers/stopAllRobots.ts
@@ -0,0 +1,21 @@
+import { Request, Response } from "express";
+import { setAllRobotsIdle } from "../simulation/robotMovementSimulator";
+import { ErrorResponse } from "../types/error";
+import { SimulationResponse } from "../types/robot";
+
+async function stopAllRobots(_req: Request, res: Response) {
+ try {
+ const result: SimulationResponse = await setAllRobotsIdle();
+ return res.status(200).json(result);
+ } catch (error) {
+ console.error("Error on trying to stop all robots:", error);
+
+ const errorResponse: ErrorResponse = {
+ message: "Internal server error on trying to stop all robots.",
+ error,
+ };
+ return res.status(500).json(errorResponse);
+ }
+}
+
+export default stopAllRobots;