90 lines
2.8 KiB
TypeScript
90 lines
2.8 KiB
TypeScript
import { Module } from '@nestjs/common';
|
|
import { ConfigService } from '@nestjs/config';
|
|
import { RouterModule } from '@nestjs/core';
|
|
|
|
import { UserModule } from '../user/user.module';
|
|
|
|
import { NetDiskManageController } from './manager/manage.controller';
|
|
import { NetDiskOverviewController } from './overview/overview.controller';
|
|
import { NetDiskOverviewService } from './overview/overview.service';
|
|
import { MinioService } from './minio/minio.service';
|
|
import { NetDiskManageService } from './manager/manage.service';
|
|
import { NestMinioModule } from 'nestjs-minio';
|
|
// const getMinioConfig = () => {
|
|
// const configService = new ConfigService();
|
|
// const endPoint = configService.get<string>('MINIO_ENDPOINT', 'localhost');
|
|
// const accessKey = configService.get<string>('MINIO_ACCESSKEY', 'accessKey');
|
|
// const secretKey = configService.get<string>('MINIO_SECRET_KEY', 'secretKey');
|
|
|
|
// return NestMinioModule.register({
|
|
// isGlobal: true,
|
|
// endPoint,
|
|
// port: 9000,
|
|
// accessKey,
|
|
// secretKey,
|
|
// useSSL: false
|
|
// });
|
|
// };
|
|
|
|
@Module({
|
|
imports: [
|
|
UserModule,
|
|
RouterModule.register([
|
|
{
|
|
path: 'netdisk',
|
|
module: NetdiskModule
|
|
}
|
|
]),
|
|
// getMinioConfig()
|
|
NestMinioModule.registerAsync({
|
|
inject: [ConfigService],
|
|
isGlobal: true,
|
|
useFactory: async (configService: ConfigService) => {
|
|
const ossConfig = configService.get('oss');
|
|
return {
|
|
endPoint: ossConfig.domain,
|
|
port: ossConfig.port,
|
|
useSSL: ossConfig.useSSL,
|
|
accessKey: ossConfig.accessKey,
|
|
secretKey: ossConfig.secretKey
|
|
};
|
|
}
|
|
// endPoint: 'play.min.io',
|
|
// port: 9000,
|
|
// useSSL: true,
|
|
// accessKey: 'Q3AM3UQ867SPQQA43P2F',
|
|
// secretKey: 'zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG'
|
|
})
|
|
],
|
|
controllers: [NetDiskManageController, NetDiskOverviewController],
|
|
providers: [NetDiskManageService, NetDiskOverviewService, MinioService]
|
|
})
|
|
export class NetdiskModule {}
|
|
// TypeOrmModule.forRootAsync({
|
|
// inject: [ConfigService],
|
|
// useFactory: (configService: ConfigService<ConfigKeyPaths>) => {
|
|
// let loggerOptions: LoggerOptions = env('DB_LOGGING') as 'all';
|
|
|
|
// try {
|
|
// // 解析成 js 数组 ['error']
|
|
// loggerOptions = JSON.parse(loggerOptions);
|
|
// } catch {
|
|
// // ignore
|
|
// }
|
|
|
|
// return {
|
|
// ...configService.get<IDatabaseConfig>('database'),
|
|
// autoLoadEntities: true,
|
|
// logging: loggerOptions,
|
|
// logger: new TypeORMLogger(loggerOptions)
|
|
// };
|
|
// },
|
|
// // dataSource receives the configured DataSourceOptions
|
|
// // and returns a Promise<DataSource>.
|
|
// dataSourceFactory: async options => {
|
|
// const dataSource = await new DataSource(options).initialize();
|
|
// return dataSource;
|
|
// }
|
|
// })
|
|
// ],
|