Make google auth optional on server side (#508)

* Make google auth optional on server side

* fix lint

* Fix according to review
This commit is contained in:
Charles Bochet
2023-07-04 23:53:53 +02:00
committed by GitHub
parent 6fc416da76
commit 2afe933055
10 changed files with 86 additions and 39 deletions

View File

@ -6,7 +6,6 @@ import { LocalStorageModule } from './local-storage/local-storage.module';
import { LocalStorageModuleOptions } from './local-storage/interfaces';
import { EnvironmentModule } from './environment/environment.module';
import { EnvironmentService } from './environment/environment.service';
import { assert } from 'src/utils/assert';
/**
* S3 Storage Module factory
@ -16,23 +15,16 @@ import { assert } from 'src/utils/assert';
const S3StorageModuleFactory = async (
environmentService: EnvironmentService,
): Promise<S3StorageModuleOptions> => {
const fileSystem = environmentService.getStorageType();
const bucketName = environmentService.getStorageLocation();
const region = environmentService.getStorageRegion();
if (fileSystem === 'local') {
return { bucketName };
}
assert(region, 'S3 region is not defined');
const bucketName = environmentService.getStorageS3Name();
const region = environmentService.getStorageS3Region();
return {
bucketName,
bucketName: bucketName ?? '',
credentials: fromNodeProviderChain({
clientConfig: { region },
}),
forcePathStyle: true,
region,
region: region ?? '',
};
};
@ -44,10 +36,10 @@ const S3StorageModuleFactory = async (
const localStorageModuleFactory = async (
environmentService: EnvironmentService,
): Promise<LocalStorageModuleOptions> => {
const folderName = environmentService.getStorageLocation();
const storagePath = environmentService.getStorageLocalPath();
return {
storagePath: process.cwd() + '/' + folderName,
storagePath: process.cwd() + '/' + storagePath,
};
};