mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-14 19:44:52 +00:00
Add PIT rollback
This commit is contained in:
@@ -24,4 +24,38 @@ export const registerPITRouter = async (server: FastifyZodProvider) => {
|
||||
return backup;
|
||||
}
|
||||
});
|
||||
|
||||
server.route({
|
||||
method: "POST",
|
||||
url: "/rollback",
|
||||
config: {
|
||||
rateLimit: readLimit
|
||||
},
|
||||
schema: {
|
||||
body: z.object({
|
||||
fromCommit: z.string().trim(),
|
||||
toCommit: z.string().trim(),
|
||||
folderId: z.string().trim(),
|
||||
projectId: z.string().trim()
|
||||
}),
|
||||
response: {
|
||||
200: z.any()
|
||||
}
|
||||
},
|
||||
handler: async (req) => {
|
||||
const diff = await server.services.folderCommit.compareFolderStates(req.body.fromCommit, req.body.toCommit);
|
||||
const response = await server.services.folderCommit.applyFolderStateDifferences(
|
||||
diff,
|
||||
{
|
||||
actorType: req.permission?.type || "PLATFORM",
|
||||
actorId: req.permission?.id,
|
||||
message: "Rollback to previous commit"
|
||||
},
|
||||
req.body.folderId,
|
||||
req.body.projectId
|
||||
);
|
||||
|
||||
return response;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user