小编Vla*_*kov的帖子

如何将 PyCairo 表面转换为 OpenCV numpy 并返回 Python 3

我想将 OpenCV 图像转换为 PyCairo,进行一些操作(绘图等)并将其转换回 OpenCV。你知道怎么做吗?简单的例子就足够了。谢谢你。

opencv pycairo python-3.x

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

如何从控制器JSON返回的值中排除实体字段。NestJS + Typeorm

我想从返回的JSON中排除密码字段。我正在使用NestJS和Typeorm。

针对此问题提供的解决方案不适用于我或NestJS。如果需要,我可以发布我的代码。还有其他想法或解决方案吗?谢谢。

node.js typescript typeorm nestjs

4
推荐指数
5
解决办法
5084
查看次数

NestJS。自定义提供程序,注入无法解析 useFactory 的依赖项

我在应用程序启动期间收到以下错误: Error: Nest can't resolve dependencies of the useFactory (?). Please verify whether [0] argument is available in the current context.

ConfigService被导出并ConfigModule作为第一个模块加载。不知道是我的错还是NestJS的错误。也许有人可以找到一些东西)谢谢。

数据库.providers.ts:

import { Sequelize } from 'sequelize-typescript';
import { SEQUELIZE_TOKEN } from './constants';
import { User } from '../users/user.entity';
import { ConfigService } from '../config/config.service';

export const databaseProviders = [
 {
  provide: SEQUELIZE_TOKEN,
  useFactory: async (configService: ConfigService) => {
    const sequelize = new Sequelize({
      dialect: 'mysql',
      host: 'localhost',
      port: 3306,
      username: configService.databaseUser,
      password: configService.databasePassword,
      database: …
Run Code Online (Sandbox Code Playgroud)

typescript nestjs

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

NestJS JwtStrategy 使用 configService 传递秘钥

我有文档示例中的 JwtStrategy 类(https://docs.nestjs.com/techniques/authentication):

@Injectable()
export class JwtStrategy extends PassportStrategy(Strategy) {
    constructor(
        private readonly authService: AuthService,
        private readonly configService: ConfigService,
    ) {
        super({
            jwtFromRequest: ExtractJwt.fromAuthHeaderAsBearerToken(),
            secretOrKey: this.configService.getSecretKey,
        });
    }
    // ...
}
Run Code Online (Sandbox Code Playgroud)

当我this在调用 super() 之前尝试访问时,出现错误。但我还是想用 configService 来获取秘钥。

我知道我可以使用 env var 来做到这一点,但在我看来,服务方法是更清晰的解决方案。

我如何使用 configService 或者从中获取价值并传递给 super() 调用?谢谢。

typescript nestjs passport-jwt

3
推荐指数
1
解决办法
1510
查看次数

NestJS无法解析UsersModule的依赖项

NestJS无法解析UsersModule的依赖项。错误: Error: Nest can't resolve dependencies of the UsersModule (?). Please verify whether [0] argument is available in the current context.

app.module.ts:

@Module({
  imports: [
    ConfigModule,
    DatabaseModule,
    GraphQLModule,
    UsersModule,
  ],
  providers: [
    ErrorService,
  ],
  exports: [
    DatabaseModule,
    ErrorService,
  ],
})
export class AppModule implements NestModule {}
Run Code Online (Sandbox Code Playgroud)

users.module.ts:

@Module({
    imports: [
        DatabaseModule,
        ErrorService,
    ],
    providers: [
        UsersService,
        ...usersProviders,
        UserResolver,
    ],
})
export class UsersModule {
    constructor(private readonly errorService: ErrorService) {}
}
Run Code Online (Sandbox Code Playgroud)

问题是此ErrorService,但是例如数据库模块以类似的方式使用,并且可以正常工作而没有任何错误。我有点困惑)也许有人会帮忙。谢谢。

typescript nestjs

0
推荐指数
1
解决办法
1529
查看次数

NestJS cookie-parser 在 e2e 测试期间不是函数错误

我试图将 cookie-parser - https://www.npmjs.com/package/cookie-parser添加到我的 NestJS 应用程序:

import * as cookieParser from 'cookie-parser';
consumer
.apply(cookieParser())
.forRoutes('/');
Run Code Online (Sandbox Code Playgroud)

当正常运行(编译并运行 js)时,不会发生错误并且代码按预期工作,但是当尝试在相同的代码上运行 e2e 测试(使用 Jest、Supertest)时,在启动过程中会发生以下错误: TypeError: cookieParser is not a function

此外,当使用cookieParser代替时cookieParser(),不会发生上述错误,但代码无法按预期工作。

在 e2e 测试期间,我使用了Test.createTestingModule然后moduleFixture.createNestApplication().

你知道这里有什么问题吗?谢谢你。

node.js typescript jestjs nestjs

0
推荐指数
1
解决办法
1310
查看次数