NexGenStudioDev/FastKit

Build a Reusable Folder Management Module for Any Application

Aperta

#16 aperta il 28 giu 2025

 (0 commenti) (0 reazioni) (0 assegnatari)TypeScript (0 fork)auto 404
TypeScriptbackenddocumentationenhancementgood first issuehelp wantednpm

Metriche repository

Star
 (1 stella)
Metriche merge PR
 (Metriche PR in attesa)

Descrizione

📖 Description (In Simple Words)

We want to build a complete Folder Management System that developers can use in any project without writing it from scratch.

This folder system should let users:

  • ✅ Create folders (like Google Drive, Notion, etc.)

  • ✏️ Rename folders

  • 📁 Organize folders inside folders (parent-child)

  • 🗑️ Move folders to trash (soft delete)

  • ♻️ Restore deleted folders

  • ❌ Delete folders permanently

  • 📌 Pin or hide folders

  • 👁️ Show only visible folders

  • 👤 Use folders per user (based on authId)

  • It should be created using modular and class-based structure so any developer can just import the controller/service and use it right away.


🚀 Why This Is Useful

  • This feature is useful in so many types of apps:

  • ✅ Note-taking or document tools (like Notion, Evernote)

  • ✅ File upload systems (like Google Drive, Dropbox)

  • ✅ Task or project managers (like Trello, Todoist)

  • ✅ School or learning systems (for organizing materials)

  • ✅ Admin dashboards (organizing reports or files)

🧠 Key Features

✅ Must-Have Features

  • Create folders

  • Rename folders

  • Delete folders (soft)

  • Restore folders

  • Permanently delete folders

  • Organize folders under other folders

  • Show folders per logged-in user

📌 Useful Flags

  • isPinned: To highlight important folders

  • isHidden: To hide folders from view

  • isDeleted: To mark folders in trash

  • isArchived: (optional)

  • isShared: To Allow account folder authentication user

🔐 Security

  • Each folder belongs to one user via authId

  • No one else can access or edit it

🏗️ File Structure (Organized & Clean)

src/
└── features/
    └── Folder/
        └── v1/
            ├── Folder.controller.ts    // Handle API calls
            ├── Folder.service.ts       // Business logic
            ├── Folder.validators.ts    // Validate data
            ├── Folder.model.ts         // Folder schema/interface
            ├── Folder.constant.ts      // Common messages/flags
            ├── Folder.middleware.ts    // (Optional) Access control
            ├── Folder.demo.ts          // Example usage
            └── README.md               // Guide for devs


🎮 Controller Methods

router.post('/folders', folderController.create);        // Create
router.get('/folders', folderController.getAll);         // Get all folders
router.patch('/folders/:id/rename', folderController.rename);
router.patch('/folders/:id/restore', folderController.restore);
router.delete('/folders/:id', folderController.softDelete);  // Soft delete
router.delete('/folders/:id/permanent', folderController.permanentDelete);

📦 Example Folder Schema (Folder.model.ts)

interface Folder {
  id: string;
  name: string;
  parentId?: string;
  Child_id?: [string]
  authId: string;
  isPinned: boolean;
  isHidden: boolean;
  isDeleted: boolean;
  createdAt: Date;
  updatedAt: Date;
}

⚙️ Service Functions

class FolderService {
  static async createFolder(data) { ... }
  static async renameFolder(id, newName) { ... }
  static async moveFolder(id, newParentId) { ... }
  static async deleteFolder(id) { ... }       // soft delete
  static async restoreFolder(id) { ... }
  static async permanentlyDeleteFolder(id) { ... }
  static async getUserFolders(authId, filters?) { ... }
}

🧪 Smart Additions You Can Include (Optional But Powerful)

  • ✅ Folder Tree Generator – get nested structure like:
[
  { id: 1, name: "Docs", children: [{ id: 2, name: "Projects" }] }
]

✅ Folder Sharing – mark folders as shared (isShared = true)

✅ Sorting – sort by createdAt, name, pinned first

✅ Recycle Bin View – filter all folders with isDeleted = true

✅ Folder Activity Logs – who renamed, deleted, restored, and when

📘 README.md Should Include:

  • ✅ How to import controller/service

  • ✅ Sample API usage

  • ✅ Description of all flags

  • ✅ How to add your own logic (custom filters or roles)

  • ✅ How to integrate it into your app

📌 Final Usage Example

import { FolderController } from '@fastkit/folder';

const folderController = new FolderController();

router.post('/folders', verifyToken, folderController.create);
router.get('/folders', verifyToken, folderController.getAll);

  • You can even build your file management or note app folder tree using this module.

✅ Expected Output

[x] Full-featured folder system that works in any project

[x] Flags like pinned/hidden/deleted

[x] Controller works out of the box

[x] Tree-ready folder support

[x] Scalable and modular

🙋 Contributors Can Help Add:

  • 🌐 Tree view structure

  • 🔁 Folder sharing and permissions

  • 📅 Sorting folders

  • 📁 File upload inside folders (future)

🧪 Test Ideas

  • Create a folder

  • Move under another folder

  • Rename and restore

  • Filter only pinned folders

  • Show tree-like folder structure

Guida contributor