-
-
Notifications
You must be signed in to change notification settings - Fork 130
/
push.controller.ts
31 lines (29 loc) · 1.13 KB
/
push.controller.ts
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
import { Body, Controller, HttpStatus, Post } from '@nestjs/common';
import { ApiOAuth2Auth, ApiOperation, ApiResponse, ApiUseTags } from '@nestjs/swagger';
import { CrudController } from '../core';
import { Subscription } from './subscription.entity';
import { PushService } from './push.service';
import { CreateSubscriptionDto } from './dto/create-subscription.dto';
import { CurrentUser, User } from '../auth';
@ApiOAuth2Auth(['read'])
@ApiUseTags('Sumo', 'Push')
@Controller()
export class PushController extends CrudController<Subscription> {
constructor(private readonly pushService: PushService) {
super(pushService);
}
@ApiOperation({ title: 'Create new record' })
@ApiResponse({
status: HttpStatus.CREATED,
description: 'The record has been successfully created.',
type: Subscription,
})
@ApiResponse({
status: HttpStatus.BAD_REQUEST,
description: 'Invalid input, The response body may contain clues as to what went wrong',
})
@Post()
async create(@Body() entity: CreateSubscriptionDto, @CurrentUser() user: User): Promise<Subscription> {
return super.create({ ...entity, userId: user.userId });
}
}