Fix issue with PUT requests, everything so far is tested
This commit is contained in:
@@ -5,7 +5,7 @@ meta {
|
|||||||
}
|
}
|
||||||
|
|
||||||
put {
|
put {
|
||||||
url: http://localhost:14014/api/move/[planId]
|
url: http://localhost:14014/api/update/[planId]
|
||||||
body: json
|
body: json
|
||||||
auth: inherit
|
auth: inherit
|
||||||
}
|
}
|
||||||
|
|||||||
7
mod.ts
7
mod.ts
@@ -103,7 +103,7 @@ Deno.serve({ port: config.api.port }, async (req) => {
|
|||||||
failed = true;
|
failed = true;
|
||||||
});
|
});
|
||||||
if (failed) return genericResponse(STATUS_CODE.InternalServerError, "Couldn't update DB.");
|
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/')) {
|
} else if (path.startsWith('/update/')) {
|
||||||
const planId = path.replace('/update/', '');
|
const planId = path.replace('/update/', '');
|
||||||
const planMatch = await dbClient.query('SELECT ownerId FROM plans WHERE id = ?', [planId]).catch(() => {
|
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.");
|
if (failed) return genericResponse(STATUS_CODE.InternalServerError, "Couldn't update DB.");
|
||||||
return genericResponse(STATUS_CODE.OK, 'Plan renamed.');
|
return genericResponse(STATUS_CODE.OK, 'Plan renamed.');
|
||||||
} else if (path.startsWith('/move/')) {
|
} 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 planId = path.replace('/move/', '');
|
||||||
const planMatch = await dbClient.query('SELECT ownerId FROM plans WHERE id = ?', [planId]).catch(() => {
|
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);
|
return genericResponse(STATUS_CODE.NotImplemented);
|
||||||
} catch (_e) {
|
} catch (e) {
|
||||||
|
console.error(e);
|
||||||
return genericResponse(STATUS_CODE.InternalServerError);
|
return genericResponse(STATUS_CODE.InternalServerError);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user