From 152b541a6c22145e6d430d39a9c617c62d3b98ff Mon Sep 17 00:00:00 2001 From: BinarySandia04 Date: Wed, 22 Apr 2026 13:49:12 +0200 Subject: [PATCH] Test --- quibot-web/server/api/motor/step.post.ts | 10 ---------- .../server/api/motor/step/[direction].post.ts | 18 ++++++++++++++++++ 2 files changed, 18 insertions(+), 10 deletions(-) delete mode 100644 quibot-web/server/api/motor/step.post.ts create mode 100644 quibot-web/server/api/motor/step/[direction].post.ts diff --git a/quibot-web/server/api/motor/step.post.ts b/quibot-web/server/api/motor/step.post.ts deleted file mode 100644 index 2dca8e5..0000000 --- a/quibot-web/server/api/motor/step.post.ts +++ /dev/null @@ -1,10 +0,0 @@ -export default defineEventHandler(async () => { - const config = useRuntimeConfig() - - return await $fetch(`${config.quibotBaseUrl}/motor/step`, { - method: 'POST', - query: { - token: config.quibotToken, - }, - }) -}) diff --git a/quibot-web/server/api/motor/step/[direction].post.ts b/quibot-web/server/api/motor/step/[direction].post.ts new file mode 100644 index 0000000..a2a9302 --- /dev/null +++ b/quibot-web/server/api/motor/step/[direction].post.ts @@ -0,0 +1,18 @@ +export default defineEventHandler(async (event) => { + const config = useRuntimeConfig() + const direction = getRouterParam(event, 'direction') + + if (direction !== 'forward' && direction !== 'backwards') { + throw createError({ + statusCode: 400, + statusMessage: 'Invalid motor direction', + }) + } + + return await $fetch(`${config.quibotBaseUrl}/motor/step/${direction}`, { + method: 'POST', + query: { + token: config.quibotToken, + }, + }) +})