小编Vig*_*esh的帖子

有没有办法使用单个装饰器隐藏controller.ts中的所有端点?

目前,我在所有方法之上使用 @ApiExcludeEndpoint() ### 来隐藏 swagger-ui 中的端点,如下所示:

import { Controller, Get, Query, Param } from '@nestjs/common';
import { ResourceService } from './resource.service';
import { Auth } from 'src/auth/auth.decorator';
import {
  ApiTags,
  ApiSecurity,
  ApiOkResponse,
  ApiForbiddenResponse,
  ApiCreatedResponse,
  ApiExcludeEndpoint
} from '@nestjs/swagger';


@Controller()
@ApiTags('Resources')
@ApiSecurity('apiKey')
export class ResourceController {
  constructor(private readonly resourceService: ResourceService) {}

  @Get('get_url')
  @ApiExcludeEndpoint()
  @Get()
  @ApiOkResponse({
    description: 'Resources list has succesfully been returned',
  })
  @ApiForbiddenResponse({ description: 'You are not allowed' })
  @Auth(...common_privileges)
  findAll(@Query() query: any): any {
    ......
  }

  
  @Get('get_url/:id')
  @ApiExcludeEndpoint()
  @ApiOkResponse({ …
Run Code Online (Sandbox Code Playgroud)

nestjs nestjs-swagger

5
推荐指数
2
解决办法
1万
查看次数

如何在创建用户时生成一次性密码并将其发送给 Django 中的用户邮件 ID?

我试图在创建新用户时向用户发送一个随机的一次性密码,并在用户第一次登录时让他更改密码。

python django django-rest-framework

4
推荐指数
1
解决办法
928
查看次数

如何在 NEST JS 中处理特定/不同请求方法的多个中间件?

下面解释我的代码:有两个中间件 AuthenticationMiddleware 和 RequestFilterMiddleware 介入所有请求方法。

我的问题是如何制作RequestFilterMiddleware仅用于 GET 方法的中间件和AuthenticationMiddleware用于所有请求方法的中间件

应用程序模块.ts

export class AppModule implements NestModule {
  configure(consumer: MiddlewareConsumer) {
    consumer
      .apply(AuthenticationMiddleware, RequestFilterMiddleware)
      .forRoutes({ path: '/**', method: RequestMethod.ALL });
  }
}
Run Code Online (Sandbox Code Playgroud)

middleware node.js nestjs nestjs-config

4
推荐指数
1
解决办法
6868
查看次数