mirror of
https://github.com/documenso/documenso.git
synced 2025-11-13 08:13:56 +10:00
31 lines
691 B
TypeScript
31 lines
691 B
TypeScript
import { prisma } from '@documenso/prisma';
|
|
|
|
import { TEAM_MEMBER_ROLE_PERMISSIONS_MAP } from '../../constants/teams';
|
|
import { buildTeamWhereQuery } from '../../utils/teams';
|
|
|
|
export type GetApiTokensOptions = {
|
|
userId: number;
|
|
teamId: number;
|
|
};
|
|
|
|
export const getApiTokens = async ({ userId, teamId }: GetApiTokensOptions) => {
|
|
return await prisma.apiToken.findMany({
|
|
where: {
|
|
team: buildTeamWhereQuery({
|
|
teamId,
|
|
userId,
|
|
roles: TEAM_MEMBER_ROLE_PERMISSIONS_MAP['MANAGE_TEAM'],
|
|
}),
|
|
},
|
|
select: {
|
|
id: true,
|
|
name: true,
|
|
createdAt: true,
|
|
expires: true,
|
|
},
|
|
orderBy: {
|
|
createdAt: 'desc',
|
|
},
|
|
});
|
|
};
|