import type { ServiceMethodFactory } from "@ethicdevs/react-monolith";
import { User, UserSSHKey } from "@prisma/client";
import type { UsersServiceDeps } from "./types";
const getUserSSHKeys: ServiceMethodFactory<
UsersServiceDeps,
[User, ("active" | "revoked" | "all")?],
Promise<UserSSHKey[]>
> = ({ request }) => {
return async (user, filter = "active") => {
const keys = await request.prisma.userSSHKey.findMany({
where: {
user: { id: user.id },
revoked: filter == "revoked",
},
orderBy: {
updatedAt: "desc",
},
});
return keys;
};
};
export default getUserSSHKeys;