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