我在npm依赖项的类型记录中工作。
理论:
假设是一个库A和两个项目B和C
我的库A使用B中所需的依赖项,但在C中不使用
如何在项目B中安装此依赖项,但在C中却没有编译错误?
project B
|----library A
|----library D
project C
|----library A
library A
|----library D
实用:
由于我可能在错误的轨道上,这里是具体的情况!我是在一个项目与一个角前端和雀巢后端。我创建了一个公共库,其中包含DTO。我想使用来自@ApiProperty()的@nestjs/swagger注释。但是我不想在我的@nestj
我有这个错误
GraphQLError: Input Object type CreateUserInputDTO must define one or more fields.
at SchemaValidationContext.reportError
我已经尝试过一些建议,但是仍然不起作用
我不知道为什么会有这个错误,因为我有工作的另一个项目。我怀疑我可能使用了最新的模块?
这是代码
import {
Field,
InputType,
IntersectionType,
ObjectType,
OmitType,
} from '@nestjs/
我试图通过@Query参数将默认参数maxnodes=3和addstats=false传递给控制器。
代码工作正常,但不使用默认参数。当我传递查询参数时,将显示传递的参数,但如果没有传递,则不使用默认值(3和false)。
怎么解决这个问题?
context.contructor.ts:
import { CreateContextQuery } from './context.query';
import { CreateContextDto } from './context.dto';
@Post('graph')
public as
当我将@nest/swagger库更新到版本4时,发生了以下错误:
(node:16134) UnhandledPromiseRejectionWarning: Error: A circular dependency has been detected (property key: "customer"). Please, make sure that each side of a bidirectional relationships are using lazy resolvers ("type: () => ClassType").
at
我正在使用一个很棒的库:
整个追溯过程如下:
(node:22654) UnhandledPromiseRejectionWarning: Error: A circular dependency has been detected (property key: "firstName"). Please, make sure that each side of a bidirectional relationships are using lazy resolvers ("type: () => ClassType").
at SchemaObje
我试图使用ValidationPipe,但无论我如何编写代码,发送请求时都会收到以下警告:No metadata found. There is more than once class-validator version installed probably. You need to flatten your dependencies。
我的路线是这样的:
@Get()
@UsePipes(new ValidationPipe({ transform: true }))
async findAll(@Query() queryDto: QueryDto) {
return await
我使用的是自定义的Firewall装饰器,它为我的许多端点(例如节流、授权等)提供了一些实用功能。我希望能够在我的端点上模仿这个装潢师:
@Controller('some')
export class SomeController {
@Firewall() // mock it and check that it's called with correct arguments
async testEndpoint() {
return 'test';
}
}
我想模拟它并检查它是否使用正确的参数调用,但是我不知道如何在我的测试用例
我试图在我的NestJS应用程序中使用swagger,但我无法定义用于additionalProperties类型的自定义类。 我有一个自定义类: @ApiExtraModels(Entity)
export class Entity {
@ApiProperty({description:"Map of the entities"}) entityID: string;
} 在此之后,我检查了模式路径(应该使用ApiExtraModels装饰器定义)是否已定义-控制台日志... console.log("getSchemaPath", ge
我有一个泛型类如下:
import {IsArray, IsNotEmpty, IsString, ValidateNested} from "class-validator";
import {PatientInfoValidator} from "./businessInfo/PatientInfoValidator";
import {TypeValidator} from "./TypeValidator";
import {Type} from "class-transformer";
export class Gen
我正在尝试将swagger添加到我的nestjs应用程序中,这是我得到的一个错误。
(node:78477) UnhandledPromiseRejectionWarning: TypeError: Cannot read property '0' of undefined
at lodash_1.mapValues.param (/Users/anna/SoFetch/node_modules/@nestjs/swagger/dist/explorers/api-parameters.explorer.js:34:20)
at /Users/anna/SoFe