tariffs/src/services/account/account.service.ts
2023-05-12 04:07:58 +00:00

17 lines
435 B
TypeScript

import { RoleModel } from "@/models/role.model";
import type { Role } from "@/types/models/role.type";
import type { Account } from "@/types/models/account.type";
export class AccountService {
public static async determineAccountRole(account: Account): Promise<Role> {
const role = await RoleModel.findOne({ name: account.role }).lean();
if (!role) {
throw new Error("role not found");
}
return role;
}
}