Add more audit log events

This commit is contained in:
Tuan Dang
2023-08-08 09:50:49 +07:00
parent 648968c453
commit 2591161272
19 changed files with 1117 additions and 53 deletions
+16 -1
View File
@@ -1,6 +1,7 @@
import { nanoid } from "nanoid";
import { Types } from "mongoose";
import Folder, { TFolderSchema } from "../models/folder";
import Folder, { TFolderSchema, TFolderRootSchema } from "../models/folder";
import { ResourceNotFoundError } from "../utils/errors";
type TAppendFolderDTO = {
folderName: string;
@@ -172,6 +173,20 @@ export const searchByFolderIdWithDir = (
return;
};
export const getFolderPath = (
folders: TFolderRootSchema,
folderId: string
) => {
const folderBySearch = searchByFolderIdWithDir(folders.nodes, folderId);
if (!folderBySearch) throw ResourceNotFoundError({
message: "Failed to find folder"
});
const folderPath = folderBySearch.dir.map((folder) => folder.name).join("/");
return folderPath;
}
// to get folder of a path given
// Like /frontend/folder#1
export const getFolderByPath = (folders: TFolderSchema, searchPath: string) => {