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
d3d46475
Commit
d3d46475
authored
Apr 01, 2023
by
Рахметова Альбина
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
file index changed to class component
parent
40667cb7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
14 deletions
+29
-14
.env
backend/.env
+1
-1
index.ts
backend/src/index.ts
+28
-13
No files found.
backend/.env
View file @
d3d46475
MONGO_URL='mongodb://localhost:27017'
MONGO_URL='mongodb://localhost:27017'
PORT='3000'
PORT='8002'
\ No newline at end of file
\ No newline at end of file
backend/src/index.ts
View file @
d3d46475
...
@@ -6,19 +6,34 @@ import {UsersRouter} from './routes/user';
...
@@ -6,19 +6,34 @@ import {UsersRouter} from './routes/user';
import
{
CommentController
}
from
'./controllers/comments'
;
import
{
CommentController
}
from
'./controllers/comments'
;
import
{
PostsController
}
from
'./controllers/posts'
;
import
{
PostsController
}
from
'./controllers/posts'
;
mongo
.
run
();
const
app
:
Express
=
express
();
class
App
{
app
.
use
(
json
());
private
app
:
Express
app
.
use
(
cors
());
constructor
()
{
app
.
use
(
urlencoded
({
extended
:
true
}));
this
.
app
=
express
()
this
.
app
.
use
(
express
.
json
())
this
.
app
.
use
(
express
.
static
(
'public'
))
this
.
app
.
use
(
express
.
urlencoded
({
extended
:
true
}));
this
.
app
.
use
(
cors
())
}
app
.
use
(
express
.
static
(
'public/uploads'
));
public
init
=
async
():
Promise
<
void
>
=>
{
app
.
use
(
'/users'
,
UsersRouter
);
try
{
app
.
use
(
'/posts'
,
new
PostsController
().
getRouter
())
await
mongo
.
init
()
app
.
use
(
'/comments'
,
new
CommentController
().
getRouter
())
process
.
on
(
'exit'
,
()
=>
{
app
.
use
(
'/comments'
,
new
CommentController
().
getRouter
())
mongo
.
close
()
})
this
.
app
.
use
(
'/posts'
,
new
PostsController
().
getRouter
())
this
.
app
.
use
(
'/users'
,
UsersRouter
)
this
.
app
.
use
(
'/comments'
,
new
CommentController
().
getRouter
())
this
.
app
.
listen
(
process
.
env
.
PORT
,
()
=>
{
console
.
log
(
`Server is running on port
${
process
.
env
.
PORT
}
`
)
})
}
catch
(
err
:
unknown
)
{
console
.
log
(
err
)
}
}
}
app
.
listen
(
process
.
env
.
PORT
,
()
=>
{
const
app
=
new
App
()
console
.
log
(
`App started on port
${
process
.
env
.
PORT
}
`
);
app
.
init
()
});
\ No newline at end of file
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