aboutsummaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
authorMohamedBassem <me@mbassem.com>2024-03-13 22:37:41 +0000
committerMohamed Bassem <me@mbassem.com>2024-03-14 16:40:45 +0000
commita03f1dc2ac25579df30e8cb59d2703110c3e564d (patch)
tree59315e73cd83dc391660071c70752cf23989b3da /packages
parent04572a8e5081b1e4871e273cde9dbaaa44c52fe0 (diff)
downloadkarakeep-a03f1dc2ac25579df30e8cb59d2703110c3e564d.tar.zst
lint: Lint and format the entire repo with the new configs
Diffstat (limited to 'packages')
-rw-r--r--packages/shared/index.ts2
-rw-r--r--packages/trpc/index.ts14
2 files changed, 15 insertions, 1 deletions
diff --git a/packages/shared/index.ts b/packages/shared/index.ts
index 8b93520f..e449443d 100644
--- a/packages/shared/index.ts
+++ b/packages/shared/index.ts
@@ -1 +1 @@
-export * as Queues from "./queues.ts";
+export * as Queues from "./queues";
diff --git a/packages/trpc/index.ts b/packages/trpc/index.ts
index bcfa7211..51c713c0 100644
--- a/packages/trpc/index.ts
+++ b/packages/trpc/index.ts
@@ -2,6 +2,7 @@ import { db } from "@hoarder/db";
import serverConfig from "@hoarder/shared/config";
import { TRPCError, initTRPC } from "@trpc/server";
import superjson from "superjson";
+import { ZodError } from "zod";
type User = {
id: string;
@@ -21,6 +22,19 @@ export type Context = {
// is common in i18n libraries.
const t = initTRPC.context<Context>().create({
transformer: superjson,
+ errorFormatter(opts) {
+ const { shape, error } = opts;
+ return {
+ ...shape,
+ data: {
+ ...shape.data,
+ zodError:
+ error.code === 'BAD_REQUEST' && error.cause instanceof ZodError
+ ? error.cause.flatten()
+ : null,
+ },
+ };
+ },
});
export const createCallerFactory = t.createCallerFactory;
// Base router and procedure helpers