| 10 | const logger = createLogger('CredentialByIdAPI') |
| 11 | |
| 12 | function formatCredentialResponse(access: CredentialActorContext) { |
| 13 | const cred = access.credential |
| 14 | if (!cred) return null |
| 15 | |
| 16 | return { |
| 17 | id: cred.id, |
| 18 | workspaceId: cred.workspaceId, |
| 19 | type: cred.type, |
| 20 | displayName: cred.displayName, |
| 21 | description: cred.description, |
| 22 | providerId: cred.providerId, |
| 23 | accountId: cred.accountId, |
| 24 | envKey: cred.envKey, |
| 25 | envOwnerUserId: cred.envOwnerUserId, |
| 26 | createdBy: cred.createdBy, |
| 27 | createdAt: cred.createdAt, |
| 28 | updatedAt: cred.updatedAt, |
| 29 | role: access.isAdmin ? 'admin' : (access.member?.role ?? null), |
| 30 | status: access.member?.status ?? (access.isAdmin ? 'active' : null), |
| 31 | } |
| 32 | } |
| 33 | |
| 34 | export const GET = withRouteHandler( |
| 35 | async (request: NextRequest, { params }: { params: Promise<{ id: string }> }) => { |