Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
ehasa-backend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
WIMMA Lab 2019
Overflow
ehasa-backend
Commits
36a5ecb9
Commit
36a5ecb9
authored
5 years ago
by
Ronnie Friman
Browse files
Options
Downloads
Patches
Plain Diff
create upload path
parent
770c82cc
No related branches found
Branches containing commit
No related tags found
3 merge requests
!59
Development to master
,
!58
Development to testing
,
!56
Cluster update to Development
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/game/game.controller.ts
+27
-2
27 additions, 2 deletions
src/game/game.controller.ts
with
27 additions
and
2 deletions
src/game/game.controller.ts
+
27
−
2
View file @
36a5ecb9
...
@@ -10,12 +10,16 @@ import {
...
@@ -10,12 +10,16 @@ import {
UseInterceptors
,
UseInterceptors
,
ClassSerializerInterceptor
,
ClassSerializerInterceptor
,
Delete
,
Delete
,
UploadedFile
,
}
from
'
@nestjs/common
'
;
}
from
'
@nestjs/common
'
;
import
{
FileInterceptor
}
from
'
@nestjs/platform-express
'
;
import
{
diskStorage
}
from
'
multer
'
;
import
{
extname
}
from
'
path
'
;
import
{
GameService
}
from
'
./game.service
'
;
import
{
GameService
}
from
'
./game.service
'
;
import
{
AuthGuard
}
from
'
../shared/auth.guard
'
;
import
{
AuthGuard
}
from
'
../shared/auth.guard
'
;
import
{
User
}
from
'
../user/user.decorator
'
;
import
{
User
}
from
'
../user/user.decorator
'
;
import
{
GameDTO
,
FlagboxEventDTO
,
GameStateDTO
}
from
'
./game.dto
'
;
import
{
GameDTO
,
FlagboxEventDTO
,
GameStateDTO
,
newGameDTO
}
from
'
./game.dto
'
;
import
{
ValidationPipe
}
from
'
../shared/validation.pipe
'
;
import
{
ValidationPipe
}
from
'
../shared/validation.pipe
'
;
import
{
Roles
,
GameStates
}
from
'
../shared/guard.decorator
'
;
import
{
Roles
,
GameStates
}
from
'
../shared/guard.decorator
'
;
import
{
GameEntity
}
from
'
./game.entity
'
;
import
{
GameEntity
}
from
'
./game.entity
'
;
...
@@ -36,7 +40,7 @@ export class GameController {
...
@@ -36,7 +40,7 @@ export class GameController {
@
Post
(
'
new
'
)
@
Post
(
'
new
'
)
@
UseGuards
(
new
AuthGuard
())
@
UseGuards
(
new
AuthGuard
())
@
UsePipes
(
new
ValidationPipe
())
@
UsePipes
(
new
ValidationPipe
())
async
newGame
(@
User
(
'
id
'
)
person
,
@
Body
()
body
:
GameDTO
)
{
async
newGame
(@
User
(
'
id
'
)
person
,
@
Body
()
body
:
new
GameDTO
)
{
return
this
.
gameservice
.
createNewGame
(
person
,
body
);
return
this
.
gameservice
.
createNewGame
(
person
,
body
);
}
}
...
@@ -101,4 +105,25 @@ export class GameController {
...
@@ -101,4 +105,25 @@ export class GameController {
async
flagboxEvent
(@
Param
(
'
id
'
)
id
:
string
,
@
Body
()
data
:
FlagboxEventDTO
)
{
async
flagboxEvent
(@
Param
(
'
id
'
)
id
:
string
,
@
Body
()
data
:
FlagboxEventDTO
)
{
return
this
.
gameservice
.
flagboxEvent
(
id
,
data
);
return
this
.
gameservice
.
flagboxEvent
(
id
,
data
);
}
}
@
Post
(
'
upload
'
)
@
UseInterceptors
(
FileInterceptor
(
'
image
'
,
{
storage
:
diskStorage
({
destination
:
'
./images
'
,
filename
:
(
req
,
file
,
cb
)
=>
{
// Generating a 32 random chars long string
const
randomName
=
Array
(
32
)
.
fill
(
null
)
.
map
(()
=>
Math
.
round
(
Math
.
random
()
*
16
).
toString
(
16
))
.
join
(
''
);
//Calling the callback passing the random name generated with the original extension name
cb
(
null
,
`
${
randomName
}${
extname
(
file
.
originalname
)}
`
);
},
}),
}),
)
uploadImage
(@
UploadedFile
()
image
)
{
return
image
;
}
}
}
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