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