mirror of
https://github.com/ajnart/homarr.git
synced 2025-11-16 18:26:20 +01:00
feature: add trpc openapi (#1818)
This commit is contained in:
@@ -4,35 +4,40 @@ import { LocalIconsRepository } from '~/tools/server/images/local-icons-reposito
|
||||
import { UnpkgIconsRepository } from '~/tools/server/images/unpkg-icons-repository';
|
||||
|
||||
import { createTRPCRouter, publicProcedure } from '../trpc';
|
||||
import { z } from 'zod';
|
||||
import { NormalizedIconRepositoryResult } from '~/tools/server/images/abstract-icons-repository';
|
||||
|
||||
export const IconRespositories = [
|
||||
new LocalIconsRepository(),
|
||||
new GitHubIconsRepository(
|
||||
GitHubIconsRepository.walkxcode,
|
||||
'Walkxcode Dashboard Icons',
|
||||
'Walkxcode on Github'
|
||||
'Walkxcode on Github',
|
||||
),
|
||||
new UnpkgIconsRepository(
|
||||
UnpkgIconsRepository.tablerRepository,
|
||||
'Tabler Icons',
|
||||
'Tabler Icons - GitHub (MIT)'
|
||||
'Tabler Icons - GitHub (MIT)',
|
||||
),
|
||||
new JsdelivrIconsRepository(
|
||||
JsdelivrIconsRepository.papirusRepository,
|
||||
'Papirus Icons',
|
||||
'Papirus Development Team on GitHub (Apache 2.0)'
|
||||
'Papirus Development Team on GitHub (Apache 2.0)',
|
||||
),
|
||||
new JsdelivrIconsRepository(
|
||||
JsdelivrIconsRepository.homelabSvgAssetsRepository,
|
||||
'Homelab Svg Assets',
|
||||
'loganmarchione on GitHub (MIT)'
|
||||
'loganmarchione on GitHub (MIT)',
|
||||
),
|
||||
];
|
||||
|
||||
export const iconRouter = createTRPCRouter({
|
||||
all: publicProcedure.query(async () => {
|
||||
const fetches = IconRespositories.map((rep) => rep.fetch());
|
||||
const data = await Promise.all(fetches);
|
||||
return data;
|
||||
}),
|
||||
all: publicProcedure
|
||||
.meta({ openapi: { method: 'GET', path: '/icons', tags: ['icon'] } })
|
||||
.input(z.void())
|
||||
.output(z.array(z.custom<NormalizedIconRepositoryResult>()))
|
||||
.query(async () => {
|
||||
const fetches = IconRespositories.map((rep) => rep.fetch());
|
||||
return await Promise.all(fetches);
|
||||
}),
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user