nestjsx / crud

NestJs CRUD for RESTful APIs
https://github.com/nestjsx/crud/wiki
MIT License
4.04k stars 534 forks source link

TypeError: next.handle is not a function #328

Closed akash-gupt closed 4 years ago

akash-gupt commented 4 years ago

TypeError: next.handle is not a function at CrudRequestInterceptor.intercept

@Crud({
    model: {
      type: Customer
    },
  })
@ApiUseTags('Customer')
// @UseGuards(TokenGuard)
@Controller('customers')
export class CustomerController implements CrudController<Customer> {
    constructor(public service: CustomerService) { }

}
@Injectable()
export class CustomerService extends TypeOrmCrudService<Customer> {
    constructor (@InjectRepository(Customer) repo) {
        super(repo);
    }

}
@Entity()
export class Customer extends BaseEntity {

    @Column({ nullable: false }) name: string;

    @Column({ nullable: false }) email: string;

    @Column({ nullable: false, name: 'phone_number' }) phoneNumber: string;

    @Column({ nullable: false, name: 'alternate_phone_number' }) alternatePhoneNumber: string;

    @Column() age: number;

    @Column() weight: number;

    @Column({ name: 'id_type' }) idType: IdType;

    @Column({ name: 'id_number' }) idNumber: string;
}
akash-gupt commented 4 years ago

@frco9 @NKJe @asheliahut @avatsaev

NKJe commented 4 years ago

Honestly it seems just fine. Are you sure that there is a issue in the listed code? I tested it locally, and it worked just fine. Only added a PrimaryColumn and changed type of IdType.

akash-gupt commented 4 years ago

@NKJe

PrimaryColumn

is already defined on BaseEntity, I tried everything every CrudController have same problem

NKJe commented 4 years ago

Well, I generated a completely clean installation using nest new ... and then added typeorm crud-typeorm and swagger stuff... and added your code, with the previously mentioned changes. And it seems fine. Made a repository: https://github.com/NKJe/prof

asheliahut commented 4 years ago

The use of next.handle makes me want to believe there is an issue in a middleware you are using in your stack. Can you provide a version of the library that you are using? As Nkje just said there doesn't seem to be anything in the recent releases that is causing this.

akash-gupt commented 4 years ago

"@nestjs/common": "^5.4.0", "@nestjs/core": "^5.4.0", "@nestjs/jwt": "^6.1.1", "@nestjs/passport": "^6.1.0", "@nestjs/swagger": "^2.5.1", "@nestjs/typeorm": "^6.2.0", "@nestjsx/crud": "^4.2.0", "@nestjsx/crud-typeorm": "^4.2.0", "@phc/argon2": "^1.0.9", "@types/md5": "^2.1.33", "class-transformer": "^0.2.3", "class-validator": "^0.11.0", "dateformat": "^3.0.3", "md5": "^2.2.1", "mysql2": "^1.6.5", "node-schedule": "^1.3.2", "nodemailer": "^5.1.1", "passport": "^0.4.0", "passport-jwt": "^4.0.0", "pg": "^7.12.1", "pg-hstore": "^2.3.3", "reflect-metadata": "^0.1.12", "rimraf": "^2.6.2", "rxjs": "^6.2.2", "sequelize": "^4.42.0", "sequelize-cli": "^5.4.0", "sequelize-typescript": "^0.6.7", "typeorm": "^0.2.20", "typescript": "^3.0.1", "upash": "^1.0.2"

akash-gupt commented 4 years ago

Thanks

vrxj81 commented 4 years ago

I'm having the same "next.handle is not a function" issue. Clean app, just set up nestjsx/crud, no funky middleware or the such

michaelyali commented 4 years ago

@vrxj81 what's your nest version? It should be 6 at least