* feat: update prettier configuration for print width * chore: apply code formatting to entire repository * fix: remove build files * fix: format issue --------- Co-authored-by: Meier Lukas <meierschlumpf@gmail.com>
27 lines
839 B
TypeScript
27 lines
839 B
TypeScript
import { count, like } from "@homarr/db";
|
|
import { icons } from "@homarr/db/schema/sqlite";
|
|
import { validation } from "@homarr/validation";
|
|
|
|
import { createTRPCRouter, publicProcedure } from "../trpc";
|
|
|
|
export const iconsRouter = createTRPCRouter({
|
|
findIcons: publicProcedure.input(validation.icons.findIcons).query(async ({ ctx, input }) => {
|
|
return {
|
|
icons: await ctx.db.query.iconRepositories.findMany({
|
|
with: {
|
|
icons: {
|
|
columns: {
|
|
id: true,
|
|
name: true,
|
|
url: true,
|
|
},
|
|
where: input.searchText?.length ?? 0 > 0 ? like(icons.name, `%${input.searchText}%`) : undefined,
|
|
limit: 5,
|
|
},
|
|
},
|
|
}),
|
|
countIcons: (await ctx.db.select({ count: count() }).from(icons))[0]?.count ?? 0,
|
|
};
|
|
}),
|
|
});
|