Add server map route

This commit is contained in:
jeffvli
2022-11-15 13:31:11 -08:00
parent 8d5a05c329
commit 758e9d4d2c
8 changed files with 58 additions and 8 deletions
+13
View File
@@ -76,6 +76,18 @@ const remoteServerLogin = async (options: {
throw ApiError.badRequest('Server type invalid.');
};
const getServerListMap = async () => {
const servers = await prisma.server.findMany({});
return servers.reduce((acc, server) => {
acc[server.id] = {
name: server.name,
type: server.type,
};
return acc;
}, {} as Record<string, { name: string; type: string }>);
};
const findById = async (user: AuthUser, options: { id: string }) => {
const { id } = options;
@@ -626,6 +638,7 @@ export const serversService = {
findServerUrlById,
findUrlById,
fullScan,
getServerListMap,
refresh,
remoteServerLogin,
update,