Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
P
planner-team-one
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
21
Issues
21
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Евгений Положенцев
planner-team-one
Commits
b2296f46
Commit
b2296f46
authored
Nov 26, 2022
by
Евгений Положенцев
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#68
description for router/tasks added
parent
76277e72
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
5 deletions
+12
-5
tasks.ts
planner-api/src/routers/tasks.ts
+12
-5
No files found.
planner-api/src/routers/tasks.ts
View file @
b2296f46
...
...
@@ -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
;
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment