Skip to content

TaskView is a self-hosted project and task management platform focused on clarity, ownership, and control. TaskView is built for teams that want a transparent, self-hosted alternative to SaaS task managers.

1.1 KB
Raw Blame
import { Router } from 'express';
import type { Routable } from '../../types/routable.type';
import { IsLoggedIn } from '../auth/middlewares/is-logged-in';
import { GraphController } from './GraphControler';
import { CanManageGraph } from './middlewares/CanManageGraph';
import { CanViewGraph } from './middlewares/CanViewGraph';

export default class GraphRoutes implements Routable {
    private readonly router: ReturnType<typeof Router>;
    private readonly graphController: GraphController;

    constructor() {
        this.router = Router();
        this.graphController = new GraphController();
        this.initRoutes();
    }

    getRouter() {
        return this.router;
    }

    initRoutes() {
        this.router.post('', [IsLoggedIn, CanManageGraph], this.graphController.addEdge);
        this.router.get('/task/:taskId', [IsLoggedIn, CanViewGraph], this.graphController.fetchTaskEdges);
        this.router.get('/:goalId', [IsLoggedIn, CanViewGraph], this.graphController.fetchAllEdges);
        this.router.delete('/:id', [IsLoggedIn, CanManageGraph], this.graphController.deleteEdge);
    }
}