aboutsummaryrefslogtreecommitdiffstats
path: root/packages/trpc/routers
diff options
context:
space:
mode:
Diffstat (limited to 'packages/trpc/routers')
-rw-r--r--packages/trpc/routers/users.ts18
1 files changed, 17 insertions, 1 deletions
diff --git a/packages/trpc/routers/users.ts b/packages/trpc/routers/users.ts
index b5334f99..efef61af 100644
--- a/packages/trpc/routers/users.ts
+++ b/packages/trpc/routers/users.ts
@@ -1,5 +1,10 @@
import { zSignUpSchema } from "../types/users";
-import { adminProcedure, publicProcedure, router } from "../index";
+import {
+ adminProcedure,
+ authedProcedure,
+ publicProcedure,
+ router,
+} from "../index";
import { SqliteError } from "@hoarder/db";
import { z } from "zod";
import { hashPassword } from "../auth";
@@ -90,4 +95,15 @@ export const usersAppRouter = router({
throw new TRPCError({ code: "NOT_FOUND" });
}
}),
+ whoami: authedProcedure
+ .output(
+ z.object({
+ id: z.string(),
+ name: z.string(),
+ email: z.string(),
+ }),
+ )
+ .query(async ({ ctx }) => {
+ return { id: ctx.user.id, name: ctx.user.name, email: ctx.user.email };
+ }),
});