-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtrack.controller.js
More file actions
52 lines (42 loc) · 1.46 KB
/
track.controller.js
File metadata and controls
52 lines (42 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// // Работа с запросами и ответами, с входными параметрами
// // Работа с запросами и ответами, с входными параметрами
import { Controller } from '@nestjs/common';
import { TrackService } from './track.service';
import { CreateTrackDto } from './dto/create-track.dto';
@Controller('/tracks')
export class TrackController {
constructor(private TrackService: TrackService) {}
@Post()
@UseInterceptors(FileFieldsInterceptor([
{ name: 'picture', maxCount: 1 },
{ name: 'audio', maxCount: 1 },
]))
create(@UploadedFiles() files, @Body() dto: CreateTrackDto) {
const {picture, audio} = files
return this.trackService.create(dto, picture[0], audio[0]);
}
@Get()
getAll(@Query('count') count: number,
@Query('offset') offset: number) {
return this.trackService.getAll(count, offset)
}
@Get('/search')
search(@Query('query') query: string) {
return this.trackService.search(query)
@Get('id')
getOne(@Param('id') id: ObjectId) {
return this.trackService.getOne(id)
}
@Delete('id')
delete(@Param('id') id: ObjectId) {
return this.trackService.delete(id)
}
@Post( '/comment')
addComment(@Body() dto: CreateCommentDto) {
return this.trackService.addComment(dto);
}
@Post('/listen/:id')
listen(@Param('id') id: ObjectId) {
return this.trackService.listen(id);
}
}