Skip to content

Build your personal knowledge base with Trilium Notes

1.4 KB
Raw Blame
import type { Request } from "../../http_interface";

import cloningService from "../../services/cloning.js";

function cloneNoteToBranch(req: Request<{ noteId: string; parentBranchId: string }>) {
    const { noteId, parentBranchId } = req.params;
    const { prefix } = req.body;

    return cloningService.cloneNoteToBranch(noteId, parentBranchId, prefix);
}

function cloneNoteToParentNote(req: Request<{ noteId: string; parentNoteId: string }>) {
    const { noteId, parentNoteId } = req.params;
    const { prefix } = req.body;

    return cloningService.cloneNoteToParentNote(noteId, parentNoteId, prefix);
}

function cloneNoteAfter(req: Request<{ noteId: string; afterBranchId: string }>) {
    const { noteId, afterBranchId } = req.params;

    return cloningService.cloneNoteAfter(noteId, afterBranchId);
}

function cloneNoteBefore(req: Request<{ noteId: string; beforeBranchId: string }>) {
    const { noteId, beforeBranchId } = req.params;

    return cloningService.cloneNoteBefore(noteId, beforeBranchId);
}

function toggleNoteInParent(req: Request<{ noteId: string; parentNoteId: string; present: string }>) {
    const { noteId, parentNoteId, present } = req.params;

    return cloningService.toggleNoteInParent(present === "true", noteId, parentNoteId);
}

export default {
    cloneNoteToBranch,
    cloneNoteToParentNote,
    cloneNoteAfter,
    cloneNoteBefore,
    toggleNoteInParent
};