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
729a8bad
Commit
729a8bad
authored
Jan 17, 2023
by
Евгений Положенцев
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#151
added try blocks to copyTasks.ts
parent
9e80d81e
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
0 deletions
+12
-0
copyTasks.ts
planner-api/src/routers/copyTasks.ts
+12
-0
No files found.
planner-api/src/routers/copyTasks.ts
View file @
729a8bad
...
...
@@ -9,6 +9,7 @@ const dataSource = myDataSource;
/** make copy of task in calendar view */
router
.
post
(
"/make-copy"
,
auth
,
authAuthorOrExecutorOfTask
,
async
(
req
:
Request
,
res
:
Response
):
Promise
<
Response
>=>
{
try
{
const
{
taskId
,
dateTimeDue
,
dateTimeStart
,
authorStatus
,
executorStatus
,
task
}
=
req
.
body
;
if
(
!
task
)
return
res
.
status
(
401
).
send
({
message
:
'task with possible user involved is not found'
})
const
newDateTimeTask
=
new
DateTimeTask
();
...
...
@@ -17,10 +18,14 @@ router.post("/make-copy",auth,authAuthorOrExecutorOfTask, async(req:Request, res
newDateTimeTask
.
task
=
taskId
;
await
newDateTimeTask
.
save
();
return
res
.
send
({
task
,
message
:
"copyTask created!"
})
}
catch
(
e
)
{
return
res
.
status
(
502
).
send
({
message
:(
e
as
Error
).
message
})
}
}
)
/** change date time of copy of task in calendar view */
router
.
put
(
"/change-copy/:dateTimeTaskId"
,
auth
,
authAuthorOrExecutorOfTask
,
async
(
req
:
Request
,
res
:
Response
):
Promise
<
Response
>=>
{
try
{
const
{
dateTimeTaskId
}
=
req
.
params
const
{
executorStatus
,
authorStatus
,
task
,
dateTimeStart
,
dateTimeDue
,
description
,
title
,
priority
,
project
}
=
req
.
body
if
(
authorStatus
){
...
...
@@ -76,10 +81,14 @@ router.put("/change-copy/:dateTimeTaskId",auth, authAuthorOrExecutorOfTask, asyn
task
.
project
=
project
await
task
.
save
()
return
res
.
send
({
task
})
}
catch
(
e
)
{
return
res
.
status
(
502
).
send
({
message
:(
e
as
Error
).
message
})
}
})
/**delete copyTask by dateTimeTaskId */
router
.
delete
(
'/:dateTimeTaskId'
,
authAuthorOrExecutorOfDateTimeTask
,
async
(
req
:
Request
,
res
:
Response
):
Promise
<
Response
|
void
>=>
{
try
{
const
{
authorStatus
,
executorStatus
,
task
}
=
req
.
body
const
{
dateTimeTaskId
}
=
req
.
params
...
...
@@ -117,6 +126,9 @@ router.delete('/:dateTimeTaskId',authAuthorOrExecutorOfDateTimeTask, async(req:R
return
res
.
send
({
message
:
"not uathorized to delete task"
})
}
}
}
catch
(
e
)
{
return
res
.
status
(
502
).
send
({
message
:(
e
as
Error
).
message
})
}
}
)
...
...
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