Fix issue with PUT requests, everything so far is tested

This commit is contained in:
Ean Milligan
2026-04-09 23:07:52 -04:00
parent 820af82bde
commit 79313eeff9
2 changed files with 5 additions and 4 deletions

View File

@@ -5,7 +5,7 @@ meta {
}
put {
url: http://localhost:14014/api/move/[planId]
url: http://localhost:14014/api/update/[planId]
body: json
auth: inherit
}

7
mod.ts
View File

@@ -103,7 +103,7 @@ Deno.serve({ port: config.api.port }, async (req) => {
failed = true;
});
if (failed) return genericResponse(STATUS_CODE.InternalServerError, "Couldn't update DB.");
return genericResponse(STATUS_CODE.OK, 'Plan deleted.');
return genericResponse(STATUS_CODE.OK, 'Plan restored.');
} else if (path.startsWith('/update/')) {
const planId = path.replace('/update/', '');
const planMatch = await dbClient.query('SELECT ownerId FROM plans WHERE id = ?', [planId]).catch(() => {
@@ -135,7 +135,7 @@ Deno.serve({ port: config.api.port }, async (req) => {
if (failed) return genericResponse(STATUS_CODE.InternalServerError, "Couldn't update DB.");
return genericResponse(STATUS_CODE.OK, 'Plan renamed.');
} else if (path.startsWith('/move/')) {
if (body.planName.trim().length > 200) return genericResponse(STATUS_CODE.BadRequest, 'Folder name too long.');
if (body.folder.trim().length > 200) return genericResponse(STATUS_CODE.BadRequest, 'Folder name too long.');
const planId = path.replace('/move/', '');
const planMatch = await dbClient.query('SELECT ownerId FROM plans WHERE id = ?', [planId]).catch(() => {
@@ -237,7 +237,8 @@ Deno.serve({ port: config.api.port }, async (req) => {
}
return genericResponse(STATUS_CODE.NotImplemented);
} catch (_e) {
} catch (e) {
console.error(e);
return genericResponse(STATUS_CODE.InternalServerError);
}
});