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
d82c3461
Commit
d82c3461
authored
Apr 01, 2023
by
Рахметова Альбина
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
posts controllers created
parent
11ef6884
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
77 additions
and
0 deletions
+77
-0
posts.ts
backend/src/controllers/posts.ts
+29
-0
Estatuses.ts
backend/src/enums/Estatuses.ts
+4
-0
index.config.ts
backend/src/index.config.ts
+5
-0
index.ts
backend/src/index.ts
+2
-0
IPost.ts
backend/src/interfaces/IPost.ts
+9
-0
IPostDto.ts
backend/src/interfaces/IPostDto.ts
+7
-0
Post.ts
backend/src/models/Post.ts
+21
-0
posts.ts
backend/src/services/posts.ts
+0
-0
No files found.
backend/src/controllers/posts.ts
0 → 100644
View file @
d82c3461
import
express
,
{
Router
,
Request
,
Response
}
from
'express'
import
multer
from
'multer'
import
{
config
}
from
'../index.config'
const
storage
=
multer
.
diskStorage
({
destination
(
req
,
file
,
callback
)
{
callback
(
null
,
config
.
filePath
)
},
filename
(
req
,
file
,
callback
)
{
callback
(
null
,
file
.
originalname
)
},
})
const
upload
=
multer
({
storage
})
export
class
PostsController
{
private
router
:
Router
constructor
()
{
this
.
router
=
express
.
Router
()
}
public
getRouter
=
():
Router
=>
{
return
this
.
router
}
}
\ No newline at end of file
backend/src/enums/Estatuses.ts
0 → 100644
View file @
d82c3461
export
const
enum
EStatuses
{
OK
=
1
,
NOT_OK
=
0
}
\ No newline at end of file
backend/src/index.config.ts
0 → 100644
View file @
d82c3461
import
path
from
'path'
export
const
config
=
{
filePath
:
path
.
join
(
__dirname
,
'../public/uploads'
)
}
\ No newline at end of file
backend/src/index.ts
View file @
d82c3461
...
...
@@ -15,3 +15,5 @@ app.use(express.static('public/uploads'));
app
.
listen
(
process
.
env
.
PORT
,
()
=>
{
console
.
log
(
`App started on port
${
process
.
env
.
PORT
}
`
);
});
backend/src/interfaces/IPost.ts
0 → 100644
View file @
d82c3461
import
{
Document
,
ObjectId
}
from
"mongoose"
;
export
default
interface
IPost
extends
Document
{
_id
:
ObjectId
title
:
string
description
:
string
image
:
File
|
undefined
|
string
datetime
:
Date
}
\ No newline at end of file
backend/src/interfaces/IPostDto.ts
0 → 100644
View file @
d82c3461
import
IPost
from
"./IPost"
export
default
interface
IPostDto
{
title
:
IPost
[
'title'
]
description
:
IPost
[
'description'
]
image
:
File
|
undefined
|
string
}
\ No newline at end of file
backend/src/models/Post.ts
0 → 100644
View file @
d82c3461
import
mongoose
,
{
Schema
}
from
"mongoose"
;
import
IPost
from
"../interfaces/IPost"
;
const
PostsSchema
:
Schema
=
new
Schema
<
IPost
>
({
title
:
{
type
:
String
,
required
:
true
},
description
:
{
type
:
String
,
required
:
false
},
image
:
String
,
datetime
:
{
type
:
Date
}
},
{
versionKey
:
false
})
export
const
Post
=
mongoose
.
model
<
IPost
>
(
'Post'
,
PostsSchema
)
\ No newline at end of file
backend/src/services/posts.ts
0 → 100644
View file @
d82c3461
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