Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
Backend-MECRED
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
MECRED
Backend-MECRED
Commits
204a5c8b
Commit
204a5c8b
authored
10 months ago
by
Richard Fernando Heise Ferreira
Browse files
Options
Downloads
Plain Diff
Merge branch 'issue/3-delete-user-route' into 'develop'
Issue
#3
: ADD Delete User Route See merge request
!3
parents
7c2ed1bb
a1ef1119
No related branches found
No related tags found
1 merge request
!3
Issue #3: ADD Delete User Route
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/db/repo/user.repo.ts
+9
-0
9 additions, 0 deletions
src/db/repo/user.repo.ts
src/routes/user.routes.ts
+23
-0
23 additions, 0 deletions
src/routes/user.routes.ts
src/services/user.service.ts
+5
-0
5 additions, 0 deletions
src/services/user.service.ts
with
37 additions
and
0 deletions
src/db/repo/user.repo.ts
+
9
−
0
View file @
204a5c8b
...
...
@@ -69,4 +69,13 @@ export class UserRepo {
return
userSchemas
.
userModelSchema
.
parse
(
ret
)
}
async
delete
(
id
:
UserModel
[
'
id
'
]):
Promise
<
UserModel
>
{
const
[
ret
]
=
await
db
.
delete
(
userTable
)
.
where
(
eq
(
userTable
.
id
,
id
))
.
returning
()
return
userSchemas
.
userModelSchema
.
parse
(
ret
)
}
}
This diff is collapsed.
Click to expand it.
src/routes/user.routes.ts
+
23
−
0
View file @
204a5c8b
...
...
@@ -75,3 +75,26 @@ export const userRouter = honoWithJwt()
}
})
.
post
(
'
/delete/:id
'
,
async
(
c
)
=>
{
try
{
const
id
=
c
.
req
.
param
(
'
id
'
)
const
user
=
userSchemas
.
userDtoSchema
.
parse
(
await
service
.
delete
(
id
!
)
)
return
c
.
json
(
user
)
}
catch
(
e
)
{
return
c
.
json
(
createApexError
({
status
:
'
error
'
,
message
:
'
could not delete user
'
,
code
:
HttpStatus
.
BAD_REQUEST
,
path
:
c
.
req
.
routePath
,
suggestion
:
'
check the input and try again
'
,
}),
HttpStatus
.
BAD_REQUEST
)
}
}
)
This diff is collapsed.
Click to expand it.
src/services/user.service.ts
+
5
−
0
View file @
204a5c8b
...
...
@@ -58,4 +58,9 @@ export class UserService {
user
.
password
=
hashPassword
(
user
.
password
)
return
this
.
repo
.
update
(
user
)
}
async
delete
(
user
:
UserModel
[
'
id
'
]):
Promise
<
UserModel
>
{
return
this
.
repo
.
delete
(
user
)
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment