-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathqueue.controller.ts
More file actions
51 lines (43 loc) · 1.67 KB
/
queue.controller.ts
File metadata and controls
51 lines (43 loc) · 1.67 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
import { Body, Controller, Delete, Get, Param, Patch, Post, Req } from '@nestjs/common';
import { QueuesService } from './queues.service';
import { CreateQueueDto } from './dto/create-queue.dto';
import { Public } from '../utils/decorators/skip-auth.decorator';
import { Request } from 'express';
@Controller('queues')
export class QueuesController {
constructor (private readonly queuesService: QueuesService) {}
@Get(':id')
async findQueueById (@Param('id') id: string) {
return await this.queuesService.findQueueById(id);
}
@Public()
@Get('lab/:labId')
async findAllQueuesByLabId (@Param('labId') labId: string) {
return await this.queuesService.findAllQueuesByLabId(labId);
}
@Delete(':id')
async deleteQueueById (@Param('id') id: string, @Req() req: Request) {
return this.queuesService.deleteQueueById(id, req);
}
@Post(':id/join')
async joinQueue (@Param('id') queueId: string, @Req() req: Request) {
return this.queuesService.joinQueue(queueId, req);
}
@Delete(':id/leave')
async leaveQueue (@Param('id') queueId: string, @Req() req: Request) {
return this.queuesService.leaveQueue(queueId, req);
}
@Delete(':queueId/remove/:removedUserId')
async removeUserFromQueue (
@Param('queueId') queueId: string,
@Param('removedUserId') removedUserId: string,
@Req() req: Request,
) {
return this.queuesService.removeUserFromQueue(queueId, req, removedUserId);
}
@Patch(':id/resume-status')
async resumeQueueStatus (@Param('id') queueId: string, @Req() req: Request) {
await this.queuesService.resumeQueueStatus(queueId, req);
return { message: `Queue with id ${queueId} has changed its status to 'PENDING'` };
}
}