我正在使用 opentelemetry 来检测 Nest js 应用程序。假设要发出的请求数量很大。那么我们如何指定要收集的痕迹数量呢?
描述我试图迁移到的错误Mikro-Orm,我已经被这个错误困扰了超过 3 天,该错误的问题是它不能帮助我知道它来自哪里,问题是它发生在随机区域,我评论了很多代码并试图隔离它的来源,但它是不可预测的。我做了很多研究,我想出了这个https://github.com/mysqljs/mysql/issues/1949和https://github.com/sipcentric/node-pbx-client/issues/4,我唯一能想到的就是这mysql就是为什么我猜测 MikroOrm 可能会喜欢它。
任何专家的建议将不胜感激。
问题是我加粗的 Nestjs api 没有响应响应
堆栈跟踪
domain.js:547
domain.enter();
^
TypeError: domain.enter is not a function
at IncomingMessage.EventEmitter.emit (domain.js:547:10)
at resume_ (_stream_readable.js:972:10)
at processTicksAndRejections (internal/process/task_queues.js:80:21)
Run Code Online (Sandbox Code Playgroud)
重现 我不知道它是如何发生的。
版本 以下是项目的所有依赖项:
"dependencies": {
"@angular/animations": "~10.1.4",
"@angular/cdk": "^10.2.3",
"@angular/common": "~10.1.4",
"@angular/compiler": "~10.1.4",
"@angular/core": "~10.1.4",
"@angular/forms": "~10.1.4",
"@angular/localize": "^10.0.4",
"@angular/material": "^10.2.3",
"@angular/platform-browser": "~10.1.4",
"@angular/platform-browser-dynamic": "~10.1.4",
"@angular/router": "~10.1.4",
"@fortawesome/angular-fontawesome": "^0.7.0",
"@fortawesome/fontawesome-svg-core": "^1.2.30",
"@fortawesome/free-brands-svg-icons": "^5.14.0",
"@fortawesome/free-regular-svg-icons": "^5.14.0",
"@fortawesome/free-solid-svg-icons": "^5.14.0",
"@mikro-orm/core": "^4.3.4",
"@mikro-orm/mariadb": "^4.3.4", …Run Code Online (Sandbox Code Playgroud) 我面临与https://github.com/winstonjs/winston/issues/1416相同的问题,结果logger.info(\'Hello there. How are you?\');是\xef\xbf\xbd[32minfo\xef\xbf\xbd[39m: \xef\xbf\xbd[32mHello there. How are you?\xef\xbf\xbd[39m
我不知道在哪里colorize可以删除它,这是我的代码:
new winston.transports.File({\n format: winston.format.combine(\n winston.format.colorize({ // I added this but it\'s still not helping\n all: false,\n message: false,\n level: false,\n }),\n winston.format.label({ label: \'API\' }),\n winston.format.timestamp(),\n winston.format.printf(({ level, message, label, timestamp }) => {\n return `${timestamp} [${label}] ${level}: ${message}`;\n }),\n ),\n filename: environment.logDirectory,\n level: \'http\',\n maxsize: 1024 * 1024 * 10,\n }),\nRun Code Online (Sandbox Code Playgroud)\n在 中main.ts,我有
import { WINSTON_MODULE_NEST_PROVIDER …Run Code Online (Sandbox Code Playgroud) 我这里有一些奇怪的问题。我有2种获取方法,一种是通过companyId获取员工列表,一种是通过staffId获取员工详细信息。第二种方法getStaffById不行。如果我注释掉第一个 get 方法getStaffByCompanyId,第二个方法将按预期工作。看起来第一个 get 方法阻止了第二个方法。我在这里错过了什么吗?
@Controller('staff')
@ApiTags('Staff')
export class StaffController {
constructor(private staffService: StaffService) {}
@Get(':companyId')
@ApiResponse({
status: HttpStatus.OK,
description: 'Return staffs by id',
})
@ApiResponse({
status: HttpStatus.UNAUTHORIZED,
description: 'Unauthorized',
type: Error,
})
@ApiResponse({
status: HttpStatus.UNPROCESSABLE_ENTITY,
description: 'Get particular staff details',
type: Error,
})
@ApiResponse({
status: HttpStatus.INTERNAL_SERVER_ERROR,
description: 'Internal server error',
type: Error,
})
@ApiResponse({
status: HttpStatus.BAD_GATEWAY,
description: 'Internal communication error',
type: Error,
})
@ApiOperation({
operationId: 'getStaffByCompanyId',
summary: 'Get staff list that attach to the company', …Run Code Online (Sandbox Code Playgroud) 我想完全覆盖控制器路线。例如:
@Controller('shipments')
export class ShipmentsController {
@Post('/create')
async find(): Promise<Activities> {
return service.find()
}
}
Run Code Online (Sandbox Code Playgroud)
为了向前面的示例发出请求,URL 将为:http://localhost:8080/shipments/create
我想更改该 URL,而不将控制器移动到另一个类。例如,我希望该特定函数的 URL 为 http://localhost:8080/whatever/i/want。
这可能吗?
对于这个可能非常业余的问题,我深表歉意。来自 Laravel,这对我来说仍然很困惑,我只是不明白需要什么。
我有一个user.repository.ts文件和一个location.repository.ts文件。每个都有自己的模块、控制器和服务。我已成功为每个实体创建 CRUD 操作,但现在正在尝试建立多对多关系。
在我的user.repository.ts文件中,我尝试保存相关的(多对多)存储库:
// user.repository.ts
user.locations = await this.locationRepository.findByIds(locations);
...
await user.save();
Run Code Online (Sandbox Code Playgroud)
我不确定如何注入或导入location.repository.ts文件。我尝试了多种将服务导入到每个模块的方法。或者将每个模块导入到另一个模块中。我尝试过不同的版本:
@EntityRepository(User)
@EntityRepository(Location)
Run Code Online (Sandbox Code Playgroud)
或者将其导入LocationService到UserService.
在 Laravel 中,这就像“简单”一样$model->sync($relationship);
我如何导入/注入locationRepository到我的userRepository?感谢您的任何建议!
我在 NestJS + TypeORM 中遇到一个奇怪的问题。
我几乎已经在实体中创建了一个 ManyToMany 关系,并且在该关系的拥有方,我添加了不带参数的 @JoinTable() 。
运行 Nest build 后,entity.js 文件添加了一个新的 import const browser_1 = require("typeorm/browser");,我发现它用于在编译的 JS 文件 => 中声明 JoinTable 选项browser_1.JoinTable()。
问题是,当使用 typeorm 生成新的迁移文件时,我不断收到以下错误:
import { __awaiter, __generator } from "tslib";
^^^^^^
SyntaxError: Cannot use import statement outside a module
at wrapSafe (internal/modules/cjs/loader.js:979:16)
at Module._compile (internal/modules/cjs/loader.js:1027:27)
at Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Object.require.extensions.<computed> [as .js] (C:\XXX\XXX\dev\XXX\pistis-api\node_modules\ts-node\src\index.ts:1045:43)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Module.require (internal/modules/cjs/loader.js:952:19)
at require (internal/modules/cjs/helpers.js:88:18)
at Object.<anonymous> (C:\XXX\XXX\dev\XXX\pistis-api\dist\modules\collaborator\entity\collaborator.entity.js:17:19)
at Module._compile (internal/modules/cjs/loader.js:1063:30) …Run Code Online (Sandbox Code Playgroud) 我的模型中有这个字段,但不起作用
@Field(type => [],{ nullable: true })
product: string[];
Run Code Online (Sandbox Code Playgroud)
我不知道我想念什么。
我想确切地知道 Type orm 中的一对多关系是什么
\n@oneTomany \nRun Code Online (Sandbox Code Playgroud)\n这个命令本身是否是一个列并且该列的值保存在另一个表\xd8\x9f\xd8\x9f中
\n它的具体参数是什么?
\n