Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

feat(web): add desktop user profile endpoint

Richie McIlroy3c381d5c7f38
diff --git a/apps/web/app/api/desktop/[...route]/root.ts b/apps/web/app/api/desktop/[...route]/root.ts
index f2e9927e3..ff790d45f 100644
--- a/apps/web/app/api/desktop/[...route]/root.ts
+++ b/apps/web/app/api/desktop/[...route]/root.ts
@@ -44,6 +44,17 @@ async function resolveOrganizationIconUrl(iconUrl: string | null) {
}).pipe(runPromise);
}
+async function resolveUserImageUrl(imageUrl: string | null) {
+ if (!imageUrl) return null;
+
+ return Effect.gen(function* () {
+ const imageUploads = yield* ImageUploads;
+ return yield* imageUploads.resolveImageUrl(
+ imageUrl as ImageUpload.ImageUrlOrKey,
+ );
+ }).pipe(runPromise);
+}
+
async function toDesktopOrganizations(
rows: DesktopOrganizationRow[],
userId: string,
@@ -423,6 +434,17 @@ app.get("/plan", withAuth, async (c) => {
});
});
+app.get("/user/profile", withAuth, async (c) => {
+ const user = c.get("user");
+ const name = [user.name, user.lastName].filter(Boolean).join(" ").trim();
+
+ return c.json({
+ name: name || null,
+ email: user.email,
+ imageUrl: await resolveUserImageUrl(user.image ?? null),
+ });
+});
+
app.get("/organizations", withAuth, async (c) => {
const user = c.get("user");