Skip to content

Commit 751f05a

Browse files
msukkariclaude
andcommitted
feat(web): add GET /api/ee/user endpoint for owner user info
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent f9421ed commit 751f05a

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

  • packages/web/src/app/api/(server)/ee/user

packages/web/src/app/api/(server)/ee/user/route.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,41 @@ import { NextRequest } from "next/server";
1414
const logger = createLogger('ee-user-api');
1515
const auditService = getAuditService();
1616

17+
export const GET = apiHandler(async () => {
18+
const result = await withAuthV2(async ({ org, role, user, prisma }) => {
19+
return withMinimumOrgRole(role, OrgRole.OWNER, async () => {
20+
try {
21+
const userData = await prisma.user.findUnique({
22+
where: {
23+
id: user.id,
24+
},
25+
select: {
26+
name: true,
27+
email: true,
28+
createdAt: true,
29+
updatedAt: true,
30+
},
31+
});
32+
33+
if (!userData) {
34+
return notFound('User not found');
35+
}
36+
37+
return userData;
38+
} catch (error) {
39+
logger.error('Error fetching user info', { error, userId: user.id });
40+
throw error;
41+
}
42+
});
43+
});
44+
45+
if (isServiceError(result)) {
46+
return serviceErrorResponse(result);
47+
}
48+
49+
return Response.json(result, { status: StatusCodes.OK });
50+
});
51+
1752
export const DELETE = apiHandler(async (request: NextRequest) => {
1853
const url = new URL(request.url);
1954
const userId = url.searchParams.get('userId');

0 commit comments

Comments
 (0)