6
6
Res ,
7
7
} from '@nestjs/common' ;
8
8
import { FileService } from './file.service' ;
9
- import fastify = require( 'fastify' ) ;
10
9
import { LoggedIn , Public } from '../auth/authentication.decorator' ;
10
+ import { FastifyReply , FastifyRequest } from 'fastify' ;
11
11
12
12
@Controller ( )
13
13
export class FileController {
@@ -16,28 +16,28 @@ export class FileController {
16
16
@Public ( )
17
17
@Post ( '/uploadPublicFile' )
18
18
async uploadPublicFile (
19
- @Req ( ) req : fastify . FastifyRequest ,
20
- @Res ( ) res : fastify . FastifyReply < any > ,
19
+ @Req ( ) req : FastifyRequest ,
20
+ @Res ( ) res : FastifyReply < any > ,
21
21
) : Promise < any > {
22
22
// Verify that request is multipart
23
23
if ( ! req . isMultipart ( ) ) {
24
24
res . send ( new BadRequestException ( 'File expected on this endpoint' ) ) ;
25
25
return ;
26
26
}
27
27
const file = await req . file ( ) ;
28
- const file_buffer = await file . toBuffer ( ) ;
29
- const new_file = await this . taskService . uploadPublicFile (
30
- file_buffer ,
28
+ const fileBuffer = await file . toBuffer ( ) ;
29
+ const newFile = await this . taskService . uploadPublicFile (
30
+ fileBuffer ,
31
31
file . filename ,
32
32
) ;
33
- res . send ( new_file ) ;
33
+ res . send ( newFile ) ;
34
34
}
35
35
36
36
@Post ( '/uploadPrivateFile' )
37
37
@LoggedIn ( )
38
38
async uploadPrivateFile (
39
- @Req ( ) req : fastify . FastifyRequest ,
40
- @Res ( ) res : fastify . FastifyReply < any > ,
39
+ @Req ( ) req : FastifyRequest ,
40
+ @Res ( ) res : FastifyReply < any > ,
41
41
) : Promise < any > {
42
42
// Verify that request is multipart
43
43
if ( ! req . isMultipart ( ) ) {
@@ -49,12 +49,12 @@ export class FileController {
49
49
const owner = req [ 'user' ] . userId ;
50
50
51
51
const file = await req . file ( ) ;
52
- const file_buffer = await file . toBuffer ( ) ;
53
- const new_file = await this . taskService . uploadPrivateFile (
54
- file_buffer ,
52
+ const fileBuffer = await file . toBuffer ( ) ;
53
+ const newFile = await this . taskService . uploadPrivateFile (
54
+ fileBuffer ,
55
55
file . filename ,
56
56
owner ,
57
57
) ;
58
- res . send ( new_file ) ;
58
+ res . send ( newFile ) ;
59
59
}
60
60
}
0 commit comments