#68 description for router/tasks added

parent 76277e72
......@@ -7,7 +7,7 @@ import { In } from 'typeorm';
const router:Router = express.Router();
const dataSource = myDataSource;
/**get all tasks */
router.get('/', async(req:Request, res:Response):Promise<Response> => {
const tasks = await dataSource
.getRepository(Task)
......@@ -19,6 +19,7 @@ router.get('/', async(req:Request, res:Response):Promise<Response> => {
return res.send({tasks})
})
/**create new task */
router.post('/', async(req:Request, res:Response):Promise<Response>=>{
const token = req.get('Authorization');
const newTask = new Task();
......@@ -42,6 +43,7 @@ router.post('/', async(req:Request, res:Response):Promise<Response>=>{
return res.send({newTask})
})
/**check tasks of specific user by userID */
router.get('/user/:userId', async (req: Request, res: Response):Promise<Response>=>{
const userId = req.params.userId;
const tasks = await dataSource
......@@ -67,6 +69,7 @@ router.get('/user/:userId', async (req: Request, res: Response):Promise<Response
return res.send({tasks})
})
/**check tasks of current user where he is author or executor, search by id*/
router.get('/my', async (req: Request, res: Response):Promise<Response>=>{
const token = req.get('Authorization');
const user = await dataSource
......@@ -99,7 +102,7 @@ router.get('/my', async (req: Request, res: Response):Promise<Response>=>{
return res.send({tasks})
})
/**check tasks of projects in which current user is involved, search by token*/
router.get('/related', async (req: Request, res: Response):Promise<Response>=>{
const token = req.get('Authorization');
const user = await dataSource
......@@ -153,7 +156,7 @@ router.get('/related', async (req: Request, res: Response):Promise<Response>=>{
return res.send({tasks})
})
/**delete of task by task id */
router.delete('/:taskId',async (req: Request, res: Response):Promise<Response>=>{
const taskId = req.params.taskId;
await myDataSource
......@@ -166,6 +169,8 @@ router.delete('/:taskId',async (req: Request, res: Response):Promise<Response>=>
})
/**modification of task by task id */
router.put('/',async(req:Request, res:Response)=> {
const token = req.get('Authorization');
......@@ -198,7 +203,7 @@ router.put('/',async(req:Request, res:Response)=> {
res.send({message:'update task successfully'})
})
/** search all tasks on given projects: projectId[] */
router.post('/project',async (req: Request, res: Response):Promise<Response>=>{
let projectArray :string[]= req.body;
if (projectArray.length===0) {
......@@ -207,7 +212,7 @@ router.post('/project',async (req: Request, res: Response):Promise<Response>=>{
.getRepository(Task)
.find({
relations:{
// executors:true,
executor:true,
author:true,
project:true
}
......@@ -227,4 +232,6 @@ router.post('/project',async (req: Request, res: Response):Promise<Response>=>{
export default router;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment