Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
H
hw92
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
5
Issues
5
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
Болатов Ален
hw92
Commits
40667cb7
Commit
40667cb7
authored
Apr 01, 2023
by
Рахметова Альбина
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '
#13
' into 'dev'
добавила контроллеры в app See merge request
!17
parents
24bcd78a
631cd4b3
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
11 additions
and
4 deletions
+11
-4
comments.ts
backend/src/controllers/comments.ts
+1
-1
index.ts
backend/src/index.ts
+7
-2
Comments.ts
backend/src/models/Comments.ts
+2
-1
mongoose.ts
backend/src/repository/mongoose.ts
+1
-0
No files found.
backend/src/controllers/comments.ts
View file @
40667cb7
...
...
@@ -36,7 +36,7 @@ export class CommentController {
}
private
deleteCommentById
=
async
(
req
:
Request
,
res
:
Response
):
Promise
<
void
>
=>
{
const
user
=
req
.
user
as
IUser
;
const
user
=
req
.
body
.
_id
;
const
id
=
req
.
params
.
id
;
const
response
=
await
this
.
service
.
deleteCommentById
(
user
,
id
)
res
.
send
(
response
)
...
...
backend/src/index.ts
View file @
40667cb7
import
express
,
{
Express
,
json
,
urlencoded
}
from
'express'
;
import
'dotenv/config'
;
import
cors
from
'cors'
;
import
{
mongo
ose
}
from
'./repository/mongoose'
;
import
{
mongo
}
from
'./repository/mongoose'
;
import
{
UsersRouter
}
from
'./routes/user'
;
import
{
CommentController
}
from
'./controllers/comments'
;
import
{
PostsController
}
from
'./controllers/posts'
;
mongo
ose
.
run
();
mongo
.
run
();
const
app
:
Express
=
express
();
app
.
use
(
json
());
...
...
@@ -13,6 +15,9 @@ app.use(urlencoded({extended: true}));
app
.
use
(
express
.
static
(
'public/uploads'
));
app
.
use
(
'/users'
,
UsersRouter
);
app
.
use
(
'/posts'
,
new
PostsController
().
getRouter
())
app
.
use
(
'/comments'
,
new
CommentController
().
getRouter
())
app
.
use
(
'/comments'
,
new
CommentController
().
getRouter
())
app
.
listen
(
process
.
env
.
PORT
,
()
=>
{
console
.
log
(
`App started on port
${
process
.
env
.
PORT
}
`
);
...
...
backend/src/models/Comments.ts
View file @
40667cb7
...
...
@@ -7,7 +7,8 @@ const CommentSchema: Schema = new Schema<IComment>({
required
:
true
},
datetime
:
{
type
:
Date
type
:
Date
,
default
:
Date
.
now
,
},
user
:
[
{
...
...
backend/src/repository/mongoose.ts
View file @
40667cb7
...
...
@@ -11,6 +11,7 @@ import { Comment } from '../models/Comments';
import
IUser
from
'../interfaces/IUser'
;
export
class
Mongo
implements
IDataBase
{
[
x
:
string
]:
any
;
private
client
:
Mongoose
|
null
=
null
public
close
=
async
():
Promise
<
void
>
=>
{
...
...
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