refactor: add audit

This commit is contained in:
Mauricio Siu
2024-12-15 19:55:45 -06:00
parent 413536a336
commit c0acdc5df1
6 changed files with 490 additions and 1 deletions

View File

@@ -26,6 +26,7 @@ import {
getPublicIpWithFallback,
haveActiveServices,
removeDeploymentsByServerId,
serverSecurity,
serverSetup,
serverValidate,
updateServerById,
@@ -166,6 +167,33 @@ export const serverRouter = createTRPCRouter({
});
}
}),
security: protectedProcedure
.input(apiFindOneServer)
.query(async ({ input, ctx }) => {
try {
const server = await findServerById(input.serverId);
if (server.adminId !== ctx.user.adminId) {
throw new TRPCError({
code: "UNAUTHORIZED",
message: "You are not authorized to validate this server",
});
}
const response = await serverSecurity(input.serverId);
return {} as unknown as {
docker: {
enabled: boolean;
version: string;
};
};
} catch (error) {
throw new TRPCError({
code: "BAD_REQUEST",
message: error instanceof Error ? error?.message : `Error: ${error}`,
cause: error as Error,
});
}
}),
remove: protectedProcedure
.input(apiRemoveServer)
.mutation(async ({ input, ctx }) => {