refactors

This commit is contained in:
Michael Dausmann
2024-02-25 00:31:55 +11:00
parent 786665e84e
commit 0abc4ec624
2 changed files with 5 additions and 9 deletions

View File

@@ -101,13 +101,13 @@ export namespace AccountService {
account_id: number, account_id: number,
membership_id: number membership_id: number
): Promise<MembershipWithAccount> { ): Promise<MembershipWithAccount> {
const membership = prisma_client.membership.findFirstOrThrow({ const membership = await prisma_client.membership.findFirstOrThrow({
where: { where: {
id: membership_id id: membership_id
} }
}); });
if ((await membership).account_id != account_id) { if (membership.account_id != account_id) {
throw new Error(`Membership does not belong to current account`); throw new Error(`Membership does not belong to current account`);
} }
@@ -126,13 +126,13 @@ export namespace AccountService {
account_id: number, account_id: number,
membership_id: number membership_id: number
): Promise<MembershipWithAccount> { ): Promise<MembershipWithAccount> {
const membership = prisma_client.membership.findFirstOrThrow({ const membership = await prisma_client.membership.findFirstOrThrow({
where: { where: {
id: membership_id id: membership_id
} }
}); });
if ((await membership).account_id != account_id) { if (membership.account_id != account_id) {
throw new Error(`Membership does not belong to current account`); throw new Error(`Membership does not belong to current account`);
} }
@@ -214,7 +214,7 @@ export namespace AccountService {
length: 10, length: 10,
numbers: true numbers: true
}); });
return prisma_client.account.update({ return await prisma_client.account.update({
where: { id: account_id }, where: { id: account_id },
data: { join_password } data: { join_password }
}); });

View File

@@ -4,10 +4,6 @@ import { AccountLimitError } from './errors';
import { AccountService } from './account.service'; import { AccountService } from './account.service';
export namespace NotesService { export namespace NotesService {
export async function getAllNotes() {
return prisma_client.note.findMany();
}
export async function getNoteById(id: number) { export async function getNoteById(id: number) {
return prisma_client.note.findUniqueOrThrow({ where: { id } }); return prisma_client.note.findUniqueOrThrow({ where: { id } });
} }