From b2cbb1a3885fd3ce8efd5ccd661d9e2b45af16b3 Mon Sep 17 00:00:00 2001 From: Manuel Date: Sat, 12 Aug 2023 23:23:04 +0200 Subject: [PATCH] fix: allow note only in edit mode --- src/server/api/routers/notebook.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/server/api/routers/notebook.ts b/src/server/api/routers/notebook.ts index c0df1beb1..d7eb065cb 100644 --- a/src/server/api/routers/notebook.ts +++ b/src/server/api/routers/notebook.ts @@ -12,13 +12,20 @@ export const notebookRouter = createTRPCRouter({ update: publicProcedure .input(z.object({ widgetId: z.string(), content: z.string(), configName: z.string() })) .mutation(async ({ input }) => { + if (!process.env.DISABLE_EDIT_MODE) { + throw new TRPCError({ + code: 'METHOD_NOT_SUPPORTED', + message: 'Edit is not allowed, because edit mode is disabled' + }); + } + const config = getConfig(input.configName); const widget = config.widgets.find((widget) => widget.id === input.widgetId) as | INotebookWidget | undefined; if (!widget) { - return new TRPCError({ + throw new TRPCError({ code: 'BAD_REQUEST', message: 'Specified widget was not found', });