db from config

This commit is contained in:
Evert Prants 2022-11-06 13:55:24 +02:00
parent 1555334021
commit 27b5c1c6aa
Signed by: evert
GPG Key ID: 1688DA83D222D0B5

View File

@ -1,7 +1,6 @@
import { Module } from '@nestjs/common'; import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm'; import { TypeOrmModule } from '@nestjs/typeorm';
import { join } from 'path'; import { ConfigModule, ConfigService } from '@nestjs/config';
import { ConfigModule } from '@nestjs/config';
import { AppController } from './app.controller'; import { AppController } from './app.controller';
import { AppService } from './app.service'; import { AppService } from './app.service';
import { ObjectsModule } from './modules/objects/objects.module'; import { ObjectsModule } from './modules/objects/objects.module';
@ -11,11 +10,10 @@ import configuration from './config/configuration';
@Module({ @Module({
imports: [ imports: [
ConfigModule.forRoot({ isGlobal: true, load: [configuration] }), ConfigModule.forRoot({ isGlobal: true, load: [configuration] }),
TypeOrmModule.forRoot({ TypeOrmModule.forRootAsync({
type: 'sqlite', imports: [ConfigModule],
database: join(__dirname, '..', 'data.db'), useFactory: (config: ConfigService) => config.get('database'),
autoLoadEntities: true, inject: [ConfigService],
synchronize: true,
}), }),
ObjectsModule, ObjectsModule,
ZoneModule, ZoneModule,