Spell UI, variables saving and mail server fixes (finally working in prod !!!)

This commit is contained in:
Clément Pons
2025-09-30 17:15:49 +02:00
parent 1642cd513f
commit 61d2d144b7
16 changed files with 336 additions and 269 deletions

View File

@@ -4,7 +4,11 @@ declare module 'nitropack'
{
interface TaskPayload
{
type: string
type: string;
}
interface TaskResult<RT = unknown>
{
error?: Error | string;
}
}
@@ -17,7 +21,7 @@ export default defineEventHandler(async (e) => {
return;
}
const id = getRouterParam(e, 'id');
const payload: Record<string, any> = await readBody(e);
const body: Record<string, any> = await readBody(e);
if(!id)
{
@@ -25,8 +29,11 @@ export default defineEventHandler(async (e) => {
return;
}
payload.type = id;
payload.data = JSON.parse(payload.data);
body.data = JSON.parse(body.data);
const payload = {
type: id,
data: body,
}
const result = await runTask(id, {
payload: payload
@@ -36,7 +43,7 @@ export default defineEventHandler(async (e) => {
{
setResponseStatus(e, 500);
if(result.error && (result.error as Error).message)
if(result.error && result.error.message)
throw result.error;
else if(result.error)
throw new Error(result.error);