mirror of
https://github.com/Drop-OSS/drop.git
synced 2025-11-19 19:21:12 +10:00
fix: remaining type issues
This commit is contained in:
@ -2,11 +2,10 @@ import { type } from "arktype";
|
||||
import { readDropValidatedBody, throwingArktype } from "~~/server/arktype";
|
||||
import aclManager from "~~/server/internal/acls";
|
||||
import taskHandler from "~~/server/internal/tasks";
|
||||
import type { TaskGroup } from "~~/server/internal/tasks/group";
|
||||
import { taskGroups } from "~~/server/internal/tasks/group";
|
||||
import { TASK_GROUPS, type TaskGroup } from "~~/server/internal/tasks/group";
|
||||
|
||||
const StartTask = type({
|
||||
taskGroup: type("string"),
|
||||
taskGroup: type.enumerated(...TASK_GROUPS),
|
||||
}).configure(throwingArktype);
|
||||
|
||||
export default defineEventHandler(async (h3) => {
|
||||
@ -14,14 +13,8 @@ export default defineEventHandler(async (h3) => {
|
||||
if (!allowed) throw createError({ statusCode: 403 });
|
||||
|
||||
const body = await readDropValidatedBody(h3, StartTask);
|
||||
const taskGroup = body.taskGroup as TaskGroup;
|
||||
if (!taskGroups[taskGroup])
|
||||
throw createError({
|
||||
statusCode: 400,
|
||||
message: "Invalid task group.",
|
||||
});
|
||||
|
||||
const task = await taskHandler.runTaskGroupByName(taskGroup);
|
||||
const task = await taskHandler.runTaskGroupByName(body.taskGroup);
|
||||
if (!task)
|
||||
throw createError({
|
||||
statusCode: 500,
|
||||
|
||||
Reference in New Issue
Block a user