How to use the @nestjs/swagger.ApiBearerAuth function in @nestjs/swagger

To help you get started, we’ve selected a few @nestjs/swagger examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nayutaco / ptarmigan / ptarmapi / src / ptarmigan / ptarmigan.controller.ts View on Github external
@ApiBearerAuth()
    @UseGuards(AuthGuard())
    @Post('close') // close -> closechannel
    async executeCloseChannel(@Body() dto: PeerNodeDto) {
        return await this.ptarmiganService.requestTCP('close', [dto.peerNodeId, '0.0.0.0', 0]);
    }

    @ApiBearerAuth()
    @UseGuards(AuthGuard())
    @Post('forceclose') // close -> closechannel
    async executeForceCloseChannel(@Body() dto: PeerNodeDto) {
        return await this.ptarmiganService.requestTCP('close', [dto.peerNodeId, '0.0.0.0', 0, 'force']);
    }

    @ApiBearerAuth()
    @UseGuards(AuthGuard())
    @Post('dev-removechannel/:channelId') // removechannel -> dev-removechannel
    async executeRemoveChannel(@Param('channelId') channelId: string) {
        return await this.ptarmiganService.requestTCP('removechannel', [channelId]);
    }

    @ApiBearerAuth()
    @UseGuards(AuthGuard())
    @Post('resetroutestate') // removechannel -> dev-removechannel
    async executeResetRouteState() {
        return await this.ptarmiganService.requestTCP('resetroutestate', []);
    }

    // ------------------------------------------------------------------------------
    // payment
    // ------------------------------------------------------------------------------
github nayutaco / ptarmigan / ptarmapi / src / ptarmigan / ptarmigan.controller.ts View on Github external
async executeGetLastErrort(@Body() dto: PeerNodeDto) {
        return await this.ptarmiganService.requestTCP('getlasterror', [dto.peerNodeId, '0.0.0.0', 0]);
    }

    @ApiBearerAuth()
    @UseGuards(AuthGuard())
    @Post('dev-disautoconn') // disautoconn -> dev-disableautoconnect
    @ApiImplicitQuery({
        name: 'enable',
        enum: [0, 1],
    })
    async executeDisAutoConn(@Query('enable') enable: number) {
        return await this.ptarmiganService.requestTCP('disautoconn', [enable.toString(10)]);
    }

    @ApiBearerAuth()
    @UseGuards(AuthGuard())
    @Post('dev-listtransactions') // getcommittx -> dev-listtransactions
    async executeGetCommitTx(@Body() dto: PeerNodeDto) {
        return await this.ptarmiganService.requestTCP('getcommittx', [dto.peerNodeId, '0.0.0.0', 0]);
    }

    // ------------------------------------------------------------------------------
    // channel
    // ------------------------------------------------------------------------------

    @ApiBearerAuth()
    @UseGuards(AuthGuard())
    @Post('openchannel') // fund -> openchannel
    async executeOpenChannel(@Body() dto: FundDto) {
        return await this.ptarmiganService.commandExecuteOpenChannel(dto.peerNodeId, dto.fundingSat, dto.pushMsat, dto.feeratePerKw);
    }
github nayutaco / ptarmigan / ptarmapi / src / ptarmigan / ptarmigan.controller.ts View on Github external
async executeListPaymentState(@Body() dto: ListPaymentDto) {
        return await this.ptarmiganService.requestTCP('listpayment', [dto.listpayment]);
    }

    @ApiBearerAuth()
    @UseGuards(AuthGuard())
    @Post('removepayment') // removepayment -> removepayment
    async executeRemovePaymentState(@Body() dto: PaymentIdDto) {
        return await this.ptarmiganService.requestTCP('removepayment', [dto.paymentId]);
    }

    // ------------------------------------------------------------------------------
    // fund
    // ------------------------------------------------------------------------------

    @ApiBearerAuth()
    @UseGuards(AuthGuard())
    @Post('getwalletinfo') // getnewaddress
    async executeGetWalletInfo(): Promise {
        return await this.bitcoinService.requestHTTP('getwalletinfo', []);
    }

    @ApiBearerAuth()
    @UseGuards(AuthGuard())
    @Post('getnewaddress') // getnewaddress
    async executeGetNewAddress(): Promise {
        return await this.bitcoinService.requestHTTP('getnewaddress', ['', 'p2sh-segwit']);
    }

    @ApiBearerAuth()
    @UseGuards(AuthGuard())
    @Post('listunspent') // listunspent
github kuangshp / nestjs-mysql-api / src / core / user / user.controller.ts View on Github external
description: '可传递id或者uuid',
  })
  @ApiBearerAuth()
  @HttpCode(HttpStatus.OK)
  async updateById(
    @Param('id', new ParseIdAndUuidPipe()) id: string,
    @Body() data: UpdateUserDto,
  ): Promise {
    return await this.userService.updateById(data, id);
  }

  @ApiOperation({
    title: '根据用户id删除用户',
    description: '可传递id或者uuid',
  })
  @ApiBearerAuth()
  @Delete('user/:id')
  @HttpCode(HttpStatus.OK)
  async destroyById(
    @Param('id', new ParseIdAndUuidPipe()) id: string,
  ): Promise {
    return await this.userService.destroyById(id);
  }

  @ApiOperation({
    title: '根据用户id修改当前用户是否可用',
    description: '可传递id或者uuid',
  })
  @ApiBearerAuth()
  @Post('change_status/:id')
  @HttpCode(HttpStatus.OK)
  async changeStatus(
github kuangshp / nestjs-mysql-api / src / core / role / role.controller.ts View on Github external
Get,
  HttpCode,
  HttpStatus,
  UseInterceptors,
  Query,
} from '@nestjs/common';
import { ApiUseTags, ApiBearerAuth, ApiOperation } from '@nestjs/swagger';

import { RoleEntity } from './role.entity';
import { RoleService } from './role.service';
import { UpdateRoleDto } from './dto/update.role.dto';
import { CreateRoleDto } from './dto/create.role.dto';
import { PaginateInterceptor } from './../../shared/interceptor/paginate.interceptor';

@ApiUseTags('role')
@ApiBearerAuth()
@Controller('role')
export class RoleController {
  constructor(private readonly roleService: RoleService) {}

  @ApiOperation({ title: '添加角色' })
  @HttpCode(HttpStatus.CREATED)
  @Post()
  async create(@Body() data: CreateRoleDto): Promise {
    return this.roleService.create(data);
  }

  @ApiOperation({ title: '查询所有的角色', description: '支持分页查询' })
  @Get()
  @UseInterceptors(PaginateInterceptor)
  @HttpCode(HttpStatus.OK)
  async showAll(
github new-eden-social / new-eden-social / src / gateway-http / comment / comment.controller.ts View on Github external
@AuthenticatedCharacter() character: ICharacterResponse,
  ): Promise {
    const comment = await this.commentClient.service.createAsCharacter({
      comment: commentData,
      postId,
      characterId: character.id,
    }).toPromise();
    return new DComment(comment);
  }

  @ApiResponse({
    status: HttpStatus.CREATED,
    type: DComment,
    description: 'Post as Character',
  })
  @ApiBearerAuth()
  @UseGuards(CorporationRolesGuard)
  @CorporationRoles(
    CORPORATION_ROLES.DIRECTOR,
    CORPORATION_ROLES.DIPLOMAT,
    CORPORATION_ROLES.COMMUNICATION_OFFICER)
  @Post(':postId/corporation')
  public async createAsCorporation(
    @Body() commentData: VCreateComment,
    @Param('postId') postId: string,
    @AuthenticatedCharacter() character: ICharacterResponse,
  ): Promise {
    const comment = await this.commentClient.service.createAsCorporation({
      comment: commentData,
      postId,
      corporationId: character.corporationId,
    }).toPromise();
github danielwii / asuna-node-server / src / modules / core / uploader / controller.ts View on Github external
createChunksUploadTask(
    @Query() query: CreateChunksUploadTaskQuery,
    @Req() req: AnyAuthRequest,
  ): Promise {
    const { identifier } = req;
    logger.log(`createChunksUploadTask: ${r(query)}`);
    return UploaderHelper.createChunksUploadTask({ ...query, identifier });
  }

  /**
   * 流式上传 chunk
   * @param filename
   * @param chunk
   * @param req
   */
  @ApiBearerAuth()
  @ApiOperation({ summary: 'Stream upload chunked file' })
  @ApiConsumes('multipart/form-data')
  @ApiQuery({
    name: 'chunk',
    required: false,
    description: 'chunked upload file index',
  })
  @UseGuards(AnyAuthGuard, OperationTokenGuard)
  @Post('chunks-stream')
  async streamChunkedUploader(
    @Query('filename') filename: string,
    @Query('chunk') chunk: number,
    @Req() req: AnyAuthRequest & OperationTokenRequest,
  ): Promise {
    assert(!isBlank(filename), 'filename needed');
    assert(!isBlank(chunk), 'chunk needed');
github Coding-Coach / find-a-mentor-api / src / modules / lists / lists.controller.ts View on Github external
UnauthorizedException,
  UsePipes,
  ValidationPipe,
  Delete,
  Put,
} from '@nestjs/common';
import { ApiBearerAuth, ApiOperation, ApiUseTags } from '@nestjs/swagger';
import { Request } from 'express';
import { Role, User } from '../common/interfaces/user.interface';
import { List } from './interfaces/list.interface';
import { UsersService } from '../common/users.service';
import { ListsService } from './lists.service';
import { ListDto } from './dto/list.dto';

@ApiUseTags('/users/:userid/lists')
@ApiBearerAuth()
@Controller('users/:userid/lists')
export class ListsController {
  constructor(
    private readonly usersService: UsersService,
    private readonly listsService: ListsService,
  ) {}

  @ApiOperation({ title: `Creates a new mentor's list for the given user` })
  @Post()
  @UsePipes(new ValidationPipe({ transform: true, whitelist: true }))
  async store(
    @Req() request: Request,
    @Param('userid') userId: string,
    @Body() data: ListDto,
  ) {
    const current: User = await this.usersService.findByAuth0Id(
github new-eden-social / new-eden-social / src / api / src / modules / authentication / authentication.controller.ts View on Github external
@ApiResponse({
    status: HttpStatus.FOUND,
    description: 'Redirects to EVE SSO Authentication Page',
  })
  @Get('/sso')
  public async authenticate(@Response() res) {
    res.redirect(this.authenticationService.authenticationRedirect);
  }

  @ApiResponse({
    status: HttpStatus.OK,
    type: DCharacterShort,
    description: 'Returns authenticated character',
  })
  @ApiBearerAuth()
  @Get('/sso/verify')
  public async verify(
    @Headers('authorization') token: string,
  ): Promise {
    if (!token) {
      throw new HttpException('Authorization header is required!', HttpStatus.BAD_REQUEST);
    }

    const character = await this.authenticationService
    .verifyAuthentication(token.slice('Bearer '.length));

    return new DCharacterShort(character);
  }

  @ApiResponse({
    status: HttpStatus.FOUND,
github rucken / core-nestjs / libs / rucken / core-nestjs / src / controllers / content-types.controller.ts View on Github external
import { Body, Controller, Delete, Get, HttpCode, HttpStatus, Inject, MethodNotAllowedException, Param, ParseIntPipe, Post, Put, Query } from '@nestjs/common';
import { ApiBearerAuth, ApiImplicitParam, ApiImplicitQuery, ApiResponse, ApiUseTags } from '@nestjs/swagger';
import { plainToClass } from 'class-transformer';
import { CORE_CONFIG_TOKEN } from '../configs/core.config';
import { Permissions } from '../decorators/permissions.decorator';
import { Roles } from '../decorators/roles.decorator';
import { InContentTypeDto } from '../dto/in-content-type.dto';
import { OutContentTypeDto } from '../dto/out-content-type.dto';
import { OutContentTypesDto } from '../dto/out-content-types.dto';
import { ContentType } from '../entities/content-type.entity';
import { ICoreConfig } from '../interfaces/core-config.interface';
import { ParseIntWithDefaultPipe } from '../pipes/parse-int-with-default.pipe';
import { ContentTypesService } from '../services/content-types.service';

@ApiUseTags('content-types')
@ApiBearerAuth()
@Controller('/api/content_types')
export class ContentTypesController {
  constructor(
    @Inject(CORE_CONFIG_TOKEN) private readonly coreConfig: ICoreConfig,
    private readonly service: ContentTypesService
  ) { }

  @Roles('isSuperuser')
  @Permissions('add_content-type')
  @HttpCode(HttpStatus.CREATED)
  @ApiResponse({
    status: HttpStatus.CREATED,
    type: OutContentTypeDto,
    description: 'The record has been successfully created.'
  })
  @ApiResponse({ status: HttpStatus.FORBIDDEN, description: 'Forbidden.' })