refactor: extract api implementation to package

Extracts the API implementation to a package so we can
potentially reuse it across different applications in the
event that we move off using a Next.js API route.

Additionally tidies up the tokens page and form to be more simplified.
This commit is contained in:
Mythie
2023-12-31 13:58:15 +11:00
parent d283cc2d26
commit a1215df91a
17 changed files with 802 additions and 398 deletions

View File

@ -5,7 +5,7 @@ export type GetUserTokensOptions = {
};
export const getUserTokens = async ({ userId }: GetUserTokensOptions) => {
return prisma.apiToken.findMany({
return await prisma.apiToken.findMany({
where: {
userId,
},
@ -16,5 +16,8 @@ export const getUserTokens = async ({ userId }: GetUserTokensOptions) => {
createdAt: true,
expires: true,
},
orderBy: {
createdAt: 'desc',
},
});
};