From 1aac83d33f72852ae00557a8d95d001e18b2c505 Mon Sep 17 00:00:00 2001 From: Manuel <30572287+manuel-rw@users.noreply.github.com> Date: Sat, 14 Jan 2023 23:28:59 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20=20Add=20logging=20for=20config=20d?= =?UTF-8?q?eletion?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Config/ConfigChanger.tsx | 3 --- src/pages/api/configs/[slug].ts | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/Config/ConfigChanger.tsx b/src/components/Config/ConfigChanger.tsx index 7d5c43c33..c4c499154 100644 --- a/src/components/Config/ConfigChanger.tsx +++ b/src/components/Config/ConfigChanger.tsx @@ -16,9 +16,6 @@ export default function ConfigChanger() { const [isRefreshing, toggle] = useToggle(); const onConfigChange = (value: string) => { - // TODO: check what should happen here with @manuel-rw - // Wheter it should check for the current url and then load the new config only on index - // Or it should always load the selected config and open index or ? --> change url to page setCookie('config-name', value ?? 'default', { maxAge: 60 * 60 * 24 * 30, sameSite: 'strict', diff --git a/src/pages/api/configs/[slug].ts b/src/pages/api/configs/[slug].ts index 9dc1a8dc8..2f628d00e 100644 --- a/src/pages/api/configs/[slug].ts +++ b/src/pages/api/configs/[slug].ts @@ -130,6 +130,7 @@ function Delete(req: NextApiRequest, res: NextApiResponse) { // Get the slug of the request const { slug } = req.query as { slug: string }; if (!slug) { + Consola.error('Rejected config deletion request because config slug was not present'); return res.status(400).json({ message: 'Wrong request', }); @@ -145,6 +146,7 @@ function Delete(req: NextApiRequest, res: NextApiResponse) { // If the target is not in the list of files, return an error if (!configs.includes(slug)) { + Consola.error(`Rejected config deletion request because config name '${slug}' was not included in present configurations`); return res.status(404).json({ message: 'Target not found', }); @@ -152,6 +154,7 @@ function Delete(req: NextApiRequest, res: NextApiResponse) { // Delete the file fs.unlinkSync(path.join('data/configs', `${slug}.json`)); + Consola.info(`Successfully deleted configuration '${slug}' from your file system`); return res.status(200).json({ message: 'Configuration deleted with success', });