🏗️ Migrate dashdot storage to tRPC

This commit is contained in:
Meier Lukas
2023-06-10 13:26:33 +02:00
parent 05e01286d4
commit b1adcf673f
4 changed files with 30 additions and 31 deletions

View File

@@ -42,4 +42,26 @@ export const dashDotRouter = createTRPCRouter({
});
return response.data;
}),
storage: publicProcedure
.input(
z.object({
url: dashDotUrlSchema.transform(removeLeadingSlash),
})
)
.output(z.array(z.number()))
.query(async ({ input }) => {
const response = await axios.get(`${input.url}/load/storage`).catch((error) => {
if (error.response.status === 404) {
throw new TRPCError({
code: 'NOT_FOUND',
message: 'Unable to find specified dash-dot',
});
}
throw new TRPCError({
code: 'INTERNAL_SERVER_ERROR',
});
});
return response.data;
}),
});