perf: use repository for apiKeys list query & caching in /settings/developer/api-keys RSC (#21776)
This commit is contained in:
1 parent
cbb020911d
commit
e6497c87ca
4 files changed
+50
-23
No files matched your search
@@ -0,0 +1,22 @@
|
||||
import prisma from "@calcom/prisma";
|
||||
|
||||
export class ApiKeyRepository {
|
||||
static async findApiKeysFromUserId({ userId }: { userId: number }) {
|
||||
return await prisma.apiKey.findMany({
|
||||
where: {
|
||||
userId,
|
||||
OR: [
|
||||
{
|
||||
NOT: {
|
||||
appId: "zapier",
|
||||
},
|
||||
},
|
||||
{
|
||||
appId: null,
|
||||
},
|
||||
],
|
||||
},
|
||||
orderBy: { createdAt: "desc" },
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import prisma from "@calcom/prisma";
|
||||
import { ApiKeyRepository } from "@calcom/lib/server/repository/apiKey";
|
||||
|
||||
import type { TrpcSessionUser } from "../../../types";
|
||||
|
||||
@@ -9,20 +9,5 @@ type ListOptions = {
|
||||
};
|
||||
|
||||
export const listHandler = async ({ ctx }: ListOptions) => {
|
||||
return await prisma.apiKey.findMany({
|
||||
where: {
|
||||
userId: ctx.user.id,
|
||||
OR: [
|
||||
{
|
||||
NOT: {
|
||||
appId: "zapier",
|
||||
},
|
||||
},
|
||||
{
|
||||
appId: null,
|
||||
},
|
||||
],
|
||||
},
|
||||
orderBy: { createdAt: "desc" },
|
||||
});
|
||||
return ApiKeyRepository.findApiKeysFromUserId({ userId: ctx.user.id });
|
||||
};
|
||||
Reference in new issue
Block a user