Files
hydra/src/main/events/library/get-library.ts
Chubby Granny Chaser 4941709296 feat: adding aria2
2024-05-20 02:21:11 +01:00

31 lines
670 B
TypeScript

import { gameRepository } from "@main/repository";
import { searchRepacks } from "../helpers/search-games";
import { registerEvent } from "../register-event";
import { sortBy } from "lodash-es";
const getLibrary = async () =>
gameRepository
.find({
where: {
isDeleted: false,
},
order: {
createdAt: "desc",
},
relations: {
repack: true,
},
})
.then((games) =>
sortBy(
games.map((game) => ({
...game,
repacks: searchRepacks(game.title),
})),
(game) => (game.status !== "removed" ? 0 : 1)
)
);
registerEvent("getLibrary", getLibrary);