crud icon indicating copy to clipboard operation
crud copied to clipboard

Cannot destructure property 'parsed' of 'req' as it is null.

Open its-dibo opened this issue 1 year ago • 8 comments

I just setup a baisc crud with typeORM as in docs, but for Cannot destructure property 'parsed' of 'req' as it is null.

@Entity('users')
export class UserEntity {
  id: string;
}
@Crud({
  model: {
    type: UserEntity,
  },
})
@Controller('users')
export class UsersController implements CrudController<UserEntity> {
  constructor(public service: UsersService) {}
}
@Injectable()
export class UsersService extends TypeOrmCrudService<UserEntity> {
  constructor(
    @InjectRepository(UserEntity) protected repo: Repository<UserEntity>,
  ) {
    super(repo);
  }
}
@Module({
  imports: [TypeOrmModule.forFeature([UserEntity])],
  controllers: [UsersController],
  providers: [UsersService],
  exports: [UsersService],
})
export class UsersModule {}

environment:

Node v20.10.0
"@nestjs/common": "^10.2.10",
    "@nestjs/config": "^3.1.1",
    "@nestjs/core": "^10.2.10",
    "@nestjs/platform-express": "^10.2.10",
    "@nestjs/platform-fastify": "^10.2.10",
    "@nestjs/swagger": "^7.1.16",
    "@nestjs/typeorm": "^10.0.1",
    "@nestjsx/crud": "^5.0.0-alpha.3",
    "@nestjsx/crud-typeorm": "^5.0.0-alpha.3",
    "class-transformer": "^0.5.1",
    "class-validator": "0.14.0",
    "fastify": "^4.24.3",
    "pg": "^8.11.3",
    "reflect-metadata": "^0.1.14",
    "rxjs": "^7.8.1",
    "typeorm": "^0.3.17"

its-dibo avatar Mar 29 '24 20:03 its-dibo

Problem in this code with small typo fix CUSTOM_ROUTE_AGRS_METADATA, right version is CUSTOM_ROUTE_ARGS_METADATA https://github.com/nestjsx/crud/blob/d6d3c4ebd844d543ab71b494d424660c448a9d42/packages/crud/src/crud/reflection.helper.ts#L2-L9

Kolobok12309 avatar Apr 05 '24 15:04 Kolobok12309

Currently i fix it by .pnpmfile.cjs with content

function readPackage(pkg, context) {
  if (pkg.name === '@nestjsx/crud') {
    console.log('crud', pkg.dependencies);
    pkg.dependencies = {
      ...pkg.dependencies,
      '@nestjs/common': '9.0.5',
    };
  }

  return pkg;
}

module.exports = {
  hooks: {
    readPackage
  }
}

For yarn you can try use resolutions of package.json

But both variants is trick and can broke some features of @nestjsx/crud. Best variant is update code of this repository

Kolobok12309 avatar Apr 05 '24 16:04 Kolobok12309

@Kolobok12309 As this repo seems dead (your PR will never be merged), can you please do the same for this fork instead?https://github.com/gid-oss/dataui-nestjs-crud

afilp avatar May 08 '24 09:05 afilp

This is already solved there, as I can see now:

https://github.com/search?q=repo%3Agid-oss%2Fdataui-nestjs-crud+CUSTOM_ROUTE_ARGS_METADATA+&type=code

afilp avatar May 08 '24 09:05 afilp

This is already solved there, as I can see now:

https://github.com/search?q=repo%3Agid-oss%2Fdataui-nestjs-crud+CUSTOM_ROUTE_ARGS_METADATA+&type=code

Ya, i know) if I encounter any more errors, i use your repo Thanks for it)

Kolobok12309 avatar May 08 '24 09:05 Kolobok12309

As this repo seems dead

you are right, I already switched to that repo

its-dibo avatar May 08 '24 10:05 its-dibo

To fix this issue

HORKimhab avatar Jun 01 '24 04:06 HORKimhab