I am working on a Nest.js project and
this is what I have in the automobile.service.ts
import { Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { Car } from './entities/car.entity';
import { Repository } from 'typeorm';
import { CreateAutoDto } from './dto/create-auto.dto';
import { UpdateAutoDto } from './dto/update-auto.dto';
export class AutoService {
constructor(
@InjectRepository(Car)
private autoRepository:Repository<Car>,
){}
create(createAutoDto: CreateAutoDto) {
return this.autoRepository.save(createAutoDto)
The issue I am facing right now is, after I typed nom run start:dev in the terminal, the log just stopped from here:
[Nest] 234 - 10/10/2021, 7:36:53 PM [NestFactory] Starting Nest application...
[Nest] 234 - 10/10/2021, 7:36:54 PM [InstanceLoader] TypeOrmModule dependencies initialized +958ms
Nothing more, and with that I can't open the page in browser. However, if I have the whole
constructor(
@InjectRepository(Car)
private autoRepository:Repository<Car>,
){}
thing deleted, the code finishes compiling without any error.
[Nest] 101 - 10/10/2021, 7:05:57 PM [NestApplication] Nest application successfully started +3ms
I am new to Nest.js. What could be the root-cause here?
EDIT:
In automobile.module.ts
import { AutoService } from './automobile.service';
import { AutoController } from './automobile.controller';
@Module({
controllers: [AutoController],
providers: [AutoService],
})
export class AutoModule {}
So what I did wrong was that in automobile.module.ts file, I forgot to include imports: [TypeOrmModule.forFeature([Car])], and that might be the root-cause resulting in the timeout on the DB connection.