mirror of
https://github.com/Gimanh/taskview-community.git
synced 2026-09-11 21:38:56 +00:00
29 lines
1.1 KiB
TypeScript
29 lines
1.1 KiB
TypeScript
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);
|
|
}
|
|
}
|