Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
P
products_lesson
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
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
Pavel Mishakov
products_lesson
Commits
aabf6f85
Commit
aabf6f85
authored
Mar 24, 2023
by
Pavel Mishakov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixes
parent
ca2b7957
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
2 deletions
+8
-2
products.ts
src/controllers/products.ts
+6
-0
mongo.ts
src/repository/mongo.ts
+2
-2
No files found.
src/controllers/products.ts
View file @
aabf6f85
...
...
@@ -25,6 +25,7 @@ export class ProductsController {
this
.
router
.
get
(
'/'
,
this
.
getProducts
)
this
.
router
.
get
(
'/:id'
,
this
.
getProductById
)
this
.
router
.
post
(
'/'
,
upload
.
single
(
'image'
),
this
.
addProduct
)
this
.
router
.
delete
(
'/:id'
,
this
.
deleteProductById
)
this
.
service
=
productService
}
...
...
@@ -49,4 +50,9 @@ export class ProductsController {
const
response
=
await
this
.
service
.
addProduct
(
product
)
res
.
send
(
response
)
}
private
deleteProductById
=
async
(
req
:
Request
,
res
:
Response
):
Promise
<
void
>
=>
{
const
response
=
await
this
.
service
.
deleteProductById
(
req
.
params
.
id
)
res
.
send
(
response
)
}
}
\ No newline at end of file
src/repository/mongo.ts
View file @
aabf6f85
...
...
@@ -77,7 +77,7 @@ export class Mongo implements IDataBase {
const
data
=
await
product
.
save
()
const
response
:
IResponse
<
IProduct
>
=
{
status
:
EStatuses
.
OK
,
result
:
data
as
any
,
result
:
data
,
message
:
''
}
return
response
...
...
@@ -97,7 +97,7 @@ export class Mongo implements IDataBase {
const
data
=
await
Product
.
findOneAndDelete
({
_id
:
id
})
const
response
:
IResponse
<
IProduct
>
=
{
status
:
EStatuses
.
OK
,
result
:
data
as
any
,
result
:
data
,
message
:
''
}
return
response
...
...
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