mirror of
https://github.com/docmost/docmost.git
synced 2025-11-13 09:42:37 +10:00
cleanups
This commit is contained in:
@ -9,6 +9,8 @@ import { ServeStaticModule } from '@nestjs/serve-static';
|
|||||||
import { join } from 'path';
|
import { join } from 'path';
|
||||||
import { DatabaseModule } from '@docmost/db/database.module';
|
import { DatabaseModule } from '@docmost/db/database.module';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
|
import { StorageModule } from './integrations/storage/storage.module';
|
||||||
|
import { MailModule } from './integrations/mail/mail.module';
|
||||||
|
|
||||||
const clientDistPath = join(__dirname, '..', '..', 'client/dist');
|
const clientDistPath = join(__dirname, '..', '..', 'client/dist');
|
||||||
|
|
||||||
@ -31,6 +33,12 @@ function getServeStaticModule() {
|
|||||||
CollaborationModule,
|
CollaborationModule,
|
||||||
WsModule,
|
WsModule,
|
||||||
...getServeStaticModule(),
|
...getServeStaticModule(),
|
||||||
|
StorageModule.forRootAsync({
|
||||||
|
imports: [EnvironmentModule],
|
||||||
|
}),
|
||||||
|
MailModule.forRootAsync({
|
||||||
|
imports: [EnvironmentModule],
|
||||||
|
}),
|
||||||
],
|
],
|
||||||
controllers: [AppController],
|
controllers: [AppController],
|
||||||
providers: [AppService],
|
providers: [AppService],
|
||||||
|
|||||||
@ -8,16 +8,13 @@ import { UserModule } from './user/user.module';
|
|||||||
import { AuthModule } from './auth/auth.module';
|
import { AuthModule } from './auth/auth.module';
|
||||||
import { WorkspaceModule } from './workspace/workspace.module';
|
import { WorkspaceModule } from './workspace/workspace.module';
|
||||||
import { PageModule } from './page/page.module';
|
import { PageModule } from './page/page.module';
|
||||||
import { StorageModule } from '../integrations/storage/storage.module';
|
|
||||||
import { AttachmentModule } from './attachment/attachment.module';
|
import { AttachmentModule } from './attachment/attachment.module';
|
||||||
import { EnvironmentModule } from '../integrations/environment/environment.module';
|
|
||||||
import { CommentModule } from './comment/comment.module';
|
import { CommentModule } from './comment/comment.module';
|
||||||
import { SearchModule } from './search/search.module';
|
import { SearchModule } from './search/search.module';
|
||||||
import { SpaceModule } from './space/space.module';
|
import { SpaceModule } from './space/space.module';
|
||||||
import { GroupModule } from './group/group.module';
|
import { GroupModule } from './group/group.module';
|
||||||
import { CaslModule } from './casl/casl.module';
|
import { CaslModule } from './casl/casl.module';
|
||||||
import { DomainMiddleware } from '../middlewares/domain.middleware';
|
import { DomainMiddleware } from '../middlewares/domain.middleware';
|
||||||
import { MailModule } from '../integrations/mail/mail.module';
|
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [
|
imports: [
|
||||||
@ -25,12 +22,6 @@ import { MailModule } from '../integrations/mail/mail.module';
|
|||||||
AuthModule,
|
AuthModule,
|
||||||
WorkspaceModule,
|
WorkspaceModule,
|
||||||
PageModule,
|
PageModule,
|
||||||
StorageModule.forRootAsync({
|
|
||||||
imports: [EnvironmentModule],
|
|
||||||
}),
|
|
||||||
MailModule.forRootAsync({
|
|
||||||
imports: [EnvironmentModule],
|
|
||||||
}),
|
|
||||||
AttachmentModule,
|
AttachmentModule,
|
||||||
CommentModule,
|
CommentModule,
|
||||||
SearchModule,
|
SearchModule,
|
||||||
|
|||||||
1
apps/server/src/helpers/index.ts
Normal file
1
apps/server/src/helpers/index.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
export * from './utils';
|
||||||
@ -2,7 +2,7 @@ import { Global, Module } from '@nestjs/common';
|
|||||||
import { EnvironmentService } from './environment.service';
|
import { EnvironmentService } from './environment.service';
|
||||||
import { ConfigModule } from '@nestjs/config';
|
import { ConfigModule } from '@nestjs/config';
|
||||||
import { validate } from './environment.validation';
|
import { validate } from './environment.validation';
|
||||||
import { envPath } from '../../helpers/utils';
|
import { envPath } from '../../helpers';
|
||||||
|
|
||||||
@Global()
|
@Global()
|
||||||
@Module({
|
@Module({
|
||||||
|
|||||||
@ -9,8 +9,8 @@ export class EnvironmentService {
|
|||||||
return this.configService.get<string>('NODE_ENV');
|
return this.configService.get<string>('NODE_ENV');
|
||||||
}
|
}
|
||||||
|
|
||||||
getPort(): string {
|
getPort(): number {
|
||||||
return this.configService.get<string>('PORT');
|
return parseInt(this.configService.get<string>('PORT'));
|
||||||
}
|
}
|
||||||
getDatabaseURL(): string {
|
getDatabaseURL(): string {
|
||||||
return this.configService.get<string>('DATABASE_URL');
|
return this.configService.get<string>('DATABASE_URL');
|
||||||
@ -80,7 +80,7 @@ export class EnvironmentService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getMailPort(): number {
|
getMailPort(): number {
|
||||||
return this.configService.get<number>('MAIL_PORT');
|
return parseInt(this.configService.get<string>('MAIL_PORT'));
|
||||||
}
|
}
|
||||||
|
|
||||||
getMailUsername(): string {
|
getMailUsername(): string {
|
||||||
|
|||||||
@ -24,7 +24,8 @@ export const mailDriverConfigProvider = {
|
|||||||
useFactory: async (environmentService: EnvironmentService) => {
|
useFactory: async (environmentService: EnvironmentService) => {
|
||||||
const driver = environmentService.getMailDriver().toLocaleLowerCase();
|
const driver = environmentService.getMailDriver().toLocaleLowerCase();
|
||||||
|
|
||||||
if (driver === MailOption.SMTP) {
|
switch (driver) {
|
||||||
|
case MailOption.SMTP:
|
||||||
return {
|
return {
|
||||||
driver,
|
driver,
|
||||||
config: {
|
config: {
|
||||||
@ -37,24 +38,22 @@ export const mailDriverConfigProvider = {
|
|||||||
},
|
},
|
||||||
} as SMTPTransport.Options,
|
} as SMTPTransport.Options,
|
||||||
};
|
};
|
||||||
}
|
|
||||||
|
|
||||||
if (driver === MailOption.Postmark) {
|
case MailOption.Postmark:
|
||||||
return {
|
return {
|
||||||
driver,
|
driver,
|
||||||
config: {
|
config: {
|
||||||
postmarkToken: environmentService.getPostmarkToken(),
|
postmarkToken: environmentService.getPostmarkToken(),
|
||||||
} as PostmarkConfig,
|
} as PostmarkConfig,
|
||||||
};
|
};
|
||||||
}
|
|
||||||
|
|
||||||
if (driver === MailOption.Log) {
|
case MailOption.Log:
|
||||||
return {
|
return {
|
||||||
driver,
|
driver,
|
||||||
};
|
};
|
||||||
}
|
default:
|
||||||
|
|
||||||
throw new Error(`Unknown mail driver: ${driver}`);
|
throw new Error(`Unknown mail driver: ${driver}`);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
inject: [EnvironmentService],
|
inject: [EnvironmentService],
|
||||||
|
|||||||
@ -26,9 +26,10 @@ function createStorageDriver(disk: StorageConfig): StorageDriver {
|
|||||||
export const storageDriverConfigProvider = {
|
export const storageDriverConfigProvider = {
|
||||||
provide: STORAGE_CONFIG_TOKEN,
|
provide: STORAGE_CONFIG_TOKEN,
|
||||||
useFactory: async (environmentService: EnvironmentService) => {
|
useFactory: async (environmentService: EnvironmentService) => {
|
||||||
const driver = environmentService.getStorageDriver();
|
const driver = environmentService.getStorageDriver().toLowerCase();
|
||||||
|
|
||||||
if (driver === StorageOption.LOCAL) {
|
switch (driver) {
|
||||||
|
case StorageOption.LOCAL:
|
||||||
return {
|
return {
|
||||||
driver,
|
driver,
|
||||||
config: {
|
config: {
|
||||||
@ -36,9 +37,8 @@ export const storageDriverConfigProvider = {
|
|||||||
process.cwd() + '/' + environmentService.getLocalStoragePath(),
|
process.cwd() + '/' + environmentService.getLocalStoragePath(),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
|
||||||
|
|
||||||
if (driver === StorageOption.S3) {
|
case StorageOption.S3:
|
||||||
return {
|
return {
|
||||||
driver,
|
driver,
|
||||||
config: {
|
config: {
|
||||||
@ -51,9 +51,10 @@ export const storageDriverConfigProvider = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
|
||||||
|
|
||||||
|
default:
|
||||||
throw new Error(`Unknown storage driver: ${driver}`);
|
throw new Error(`Unknown storage driver: ${driver}`);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
inject: [EnvironmentService],
|
inject: [EnvironmentService],
|
||||||
@ -61,6 +62,6 @@ export const storageDriverConfigProvider = {
|
|||||||
|
|
||||||
export const storageDriverProvider = {
|
export const storageDriverProvider = {
|
||||||
provide: STORAGE_DRIVER_TOKEN,
|
provide: STORAGE_DRIVER_TOKEN,
|
||||||
useFactory: (config) => createStorageDriver(config),
|
useFactory: (config: StorageConfig) => createStorageDriver(config),
|
||||||
inject: [STORAGE_CONFIG_TOKEN],
|
inject: [STORAGE_CONFIG_TOKEN],
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user