feat: Use real database config for app

Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
David Mehren 2022-04-18 15:29:36 +02:00
parent cd5256da7f
commit b670702f41

View file

@ -17,7 +17,7 @@ import appConfig from './config/app.config';
import authConfig from './config/auth.config'; import authConfig from './config/auth.config';
import cspConfig from './config/csp.config'; import cspConfig from './config/csp.config';
import customizationConfig from './config/customization.config'; import customizationConfig from './config/customization.config';
import databaseConfig from './config/database.config'; import databaseConfig, { DatabaseConfig } from './config/database.config';
import externalConfig from './config/external-services.config'; import externalConfig from './config/external-services.config';
import hstsConfig from './config/hsts.config'; import hstsConfig from './config/hsts.config';
import mediaConfig from './config/media.config'; import mediaConfig from './config/media.config';
@ -49,11 +49,21 @@ const routes: Routes = [
@Module({ @Module({
imports: [ imports: [
RouterModule.forRoutes(routes), RouterModule.forRoutes(routes),
TypeOrmModule.forRoot({ TypeOrmModule.forRootAsync({
type: 'sqlite', imports: [ConfigModule],
database: './hedgedoc.sqlite', inject: [databaseConfig.KEY],
autoLoadEntities: true, useFactory: (databaseConfig: DatabaseConfig) => {
synchronize: true, // ToDo: Remove this before release return {
type: databaseConfig.type,
host: databaseConfig.host,
port: databaseConfig.port,
username: databaseConfig.username,
password: databaseConfig.password,
database: databaseConfig.database,
autoLoadEntities: true,
synchronize: true, // ToDo: Remove this before release
};
},
}), }),
ConfigModule.forRoot({ ConfigModule.forRoot({
load: [ load: [