title: Run program on init
body: <p>I would create a program (script) that launches actions when it's get run, so I'm not using routes in this program</p>
  
  <p>I'm using <a href="https://docs.nestjs.com/" rel="noreferrer">NestJS framework</a> (requirement).</p>
  
  <p>Actually I'm trying to write my code in <code>main.ts</code> file and importing a service with my methods .</p>
  
  <pre><code>import { NestFactory } from '@nestjs/core';
  import { AppModule } from './app.module';
  import {AppService} from './app.service'
  import { TreeChildren } from 'typeorm';
  async function bootstrap() {
    const app = await NestFactory.create(AppModule);
    await app.listen(3000);
  }
  let appService: AppService; &lt;- can't use appService methods
  this.appService.
  bootstrap();
  </code></pre>
  
  <p>My service</p>
  
  <pre><code>@Injectable()
  export class AppService {
    constructor(
      @InjectRepository(File) private readonly fileRepository: Repository&lt;File&gt;,
    ) {}
  
    async getTypes(): Promise&lt;File[]&gt; {
      return await this.fileRepository.find();
    }
  }
  </code></pre>
  
  <p>I would use services to treat my operations so I sould use DI, which is not working in a non class file.</p>
  
  <p>I would know how to run my operations in init time in a proper way</p>