2021-01-05 21:12:38 +00:00
|
|
|
/*
|
2022-01-30 14:48:59 +00:00
|
|
|
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
2021-01-05 21:12:38 +00:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
*/
|
2020-07-25 18:26:00 +00:00
|
|
|
import { Module } from '@nestjs/common';
|
2020-10-30 21:35:12 +00:00
|
|
|
import { ConfigModule } from '@nestjs/config';
|
2023-06-16 20:49:45 +00:00
|
|
|
import { RouterModule, Routes } from '@nestjs/core';
|
2022-09-22 20:08:23 +00:00
|
|
|
import { EventEmitterModule } from '@nestjs/event-emitter';
|
2021-08-29 16:45:46 +00:00
|
|
|
import { ScheduleModule } from '@nestjs/schedule';
|
2020-07-25 18:26:00 +00:00
|
|
|
import { TypeOrmModule } from '@nestjs/typeorm';
|
2021-08-29 16:45:46 +00:00
|
|
|
|
|
|
|
import { PrivateApiModule } from './api/private/private-api.module';
|
2020-07-25 18:26:00 +00:00
|
|
|
import { PublicApiModule } from './api/public/public-api.module';
|
2021-08-29 16:45:46 +00:00
|
|
|
import { AuthModule } from './auth/auth.module';
|
2020-07-25 18:26:00 +00:00
|
|
|
import { AuthorsModule } from './authors/authors.module';
|
2021-08-29 16:45:46 +00:00
|
|
|
import appConfig from './config/app.config';
|
|
|
|
import authConfig from './config/auth.config';
|
|
|
|
import cspConfig from './config/csp.config';
|
|
|
|
import customizationConfig from './config/customization.config';
|
2022-04-18 13:29:36 +00:00
|
|
|
import databaseConfig, { DatabaseConfig } from './config/database.config';
|
2021-08-29 16:45:46 +00:00
|
|
|
import externalConfig from './config/external-services.config';
|
|
|
|
import mediaConfig from './config/media.config';
|
2022-01-30 14:48:59 +00:00
|
|
|
import noteConfig from './config/note.config';
|
2022-09-22 20:08:23 +00:00
|
|
|
import { eventModuleConfig } from './events';
|
2021-08-29 16:45:46 +00:00
|
|
|
import { FrontendConfigModule } from './frontend-config/frontend-config.module';
|
|
|
|
import { FrontendConfigService } from './frontend-config/frontend-config.service';
|
2020-09-27 19:48:42 +00:00
|
|
|
import { GroupsModule } from './groups/groups.module';
|
2020-07-25 18:26:00 +00:00
|
|
|
import { HistoryModule } from './history/history.module';
|
2021-08-08 19:59:23 +00:00
|
|
|
import { IdentityModule } from './identity/identity.module';
|
2020-09-27 19:48:42 +00:00
|
|
|
import { LoggerModule } from './logger/logger.module';
|
2022-04-18 14:26:13 +00:00
|
|
|
import { TypeormLoggerService } from './logger/typeorm-logger.service';
|
2020-10-16 20:38:31 +00:00
|
|
|
import { MediaModule } from './media/media.module';
|
2020-07-26 19:36:28 +00:00
|
|
|
import { MonitoringModule } from './monitoring/monitoring.module';
|
2020-09-27 19:48:42 +00:00
|
|
|
import { NotesModule } from './notes/notes.module';
|
2020-08-12 18:24:43 +00:00
|
|
|
import { PermissionsModule } from './permissions/permissions.module';
|
2022-04-02 21:45:46 +00:00
|
|
|
import { WebsocketModule } from './realtime/websocket/websocket.module';
|
2020-09-27 19:48:42 +00:00
|
|
|
import { RevisionsModule } from './revisions/revisions.module';
|
2023-06-25 19:52:44 +00:00
|
|
|
import { SessionModule } from './sessions/session.module';
|
2020-09-27 19:48:42 +00:00
|
|
|
import { UsersModule } from './users/users.module';
|
2021-02-15 09:26:12 +00:00
|
|
|
|
|
|
|
const routes: Routes = [
|
|
|
|
{
|
|
|
|
path: '/api/v2',
|
|
|
|
module: PublicApiModule,
|
|
|
|
},
|
2021-04-02 15:33:42 +00:00
|
|
|
{
|
|
|
|
path: '/api/private',
|
|
|
|
module: PrivateApiModule,
|
|
|
|
},
|
2021-02-15 09:26:12 +00:00
|
|
|
];
|
2020-07-21 19:24:56 +00:00
|
|
|
|
|
|
|
@Module({
|
2020-07-25 18:26:00 +00:00
|
|
|
imports: [
|
2023-06-16 20:49:45 +00:00
|
|
|
RouterModule.register(routes),
|
2022-04-18 13:29:36 +00:00
|
|
|
TypeOrmModule.forRootAsync({
|
2022-04-18 14:26:13 +00:00
|
|
|
imports: [ConfigModule, LoggerModule],
|
|
|
|
inject: [databaseConfig.KEY, TypeormLoggerService],
|
|
|
|
useFactory: (
|
|
|
|
databaseConfig: DatabaseConfig,
|
|
|
|
logger: TypeormLoggerService,
|
|
|
|
) => {
|
2022-04-18 13:29:36 +00:00
|
|
|
return {
|
|
|
|
type: databaseConfig.type,
|
|
|
|
host: databaseConfig.host,
|
|
|
|
port: databaseConfig.port,
|
|
|
|
username: databaseConfig.username,
|
|
|
|
password: databaseConfig.password,
|
|
|
|
database: databaseConfig.database,
|
|
|
|
autoLoadEntities: true,
|
2023-10-07 11:31:25 +00:00
|
|
|
synchronize: true, // ToDo: Remove this before release. It should be replaced by database migrations
|
|
|
|
// https://stackoverflow.com/questions/65222981/typeorm-synchronize-in-production
|
2022-04-18 14:26:13 +00:00
|
|
|
logging: true,
|
|
|
|
logger: logger,
|
2022-04-18 13:29:36 +00:00
|
|
|
};
|
|
|
|
},
|
2020-07-25 18:26:00 +00:00
|
|
|
}),
|
2020-10-30 21:35:12 +00:00
|
|
|
ConfigModule.forRoot({
|
2021-01-15 15:57:04 +00:00
|
|
|
load: [
|
|
|
|
appConfig,
|
2022-01-30 14:48:59 +00:00
|
|
|
noteConfig,
|
2021-01-15 15:57:04 +00:00
|
|
|
mediaConfig,
|
|
|
|
cspConfig,
|
|
|
|
databaseConfig,
|
|
|
|
authConfig,
|
2021-03-01 20:10:16 +00:00
|
|
|
customizationConfig,
|
|
|
|
externalConfig,
|
2021-01-15 15:57:04 +00:00
|
|
|
],
|
2021-01-08 11:52:30 +00:00
|
|
|
isGlobal: true,
|
2020-10-30 21:35:12 +00:00
|
|
|
}),
|
2022-09-22 20:08:23 +00:00
|
|
|
EventEmitterModule.forRoot(eventModuleConfig),
|
2021-01-24 19:37:04 +00:00
|
|
|
ScheduleModule.forRoot(),
|
2020-07-25 18:26:00 +00:00
|
|
|
NotesModule,
|
|
|
|
UsersModule,
|
|
|
|
RevisionsModule,
|
|
|
|
AuthorsModule,
|
|
|
|
PublicApiModule,
|
2021-01-21 18:37:43 +00:00
|
|
|
PrivateApiModule,
|
2020-07-25 18:26:00 +00:00
|
|
|
HistoryModule,
|
2020-07-26 19:36:28 +00:00
|
|
|
MonitoringModule,
|
2020-08-12 18:24:43 +00:00
|
|
|
PermissionsModule,
|
|
|
|
GroupsModule,
|
2020-09-27 19:48:42 +00:00
|
|
|
LoggerModule,
|
2020-10-13 08:33:54 +00:00
|
|
|
MediaModule,
|
2021-01-15 17:53:09 +00:00
|
|
|
AuthModule,
|
2021-03-01 20:16:01 +00:00
|
|
|
FrontendConfigModule,
|
2022-04-02 21:45:46 +00:00
|
|
|
WebsocketModule,
|
2021-08-08 19:59:23 +00:00
|
|
|
IdentityModule,
|
2022-06-21 14:16:40 +00:00
|
|
|
SessionModule,
|
2020-07-25 18:26:00 +00:00
|
|
|
],
|
2020-07-21 19:24:56 +00:00
|
|
|
controllers: [],
|
2021-03-01 20:16:01 +00:00
|
|
|
providers: [FrontendConfigService],
|
2020-07-21 19:24:56 +00:00
|
|
|
})
|
2020-07-25 18:26:00 +00:00
|
|
|
export class AppModule {}
|