Skip to content

Commit

Permalink
Merge pull request #1640 from otterDeveloper/bucket-skip-check
Browse files Browse the repository at this point in the history
Add option to skip storage bucket check & creation in storage service
  • Loading branch information
AmruthPillai authored Dec 4, 2023
2 parents 1de4b5c + 5a149f9 commit 3ddb2c1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions apps/server/src/config/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ export const configSchema = z.object({
.string()
.default("false")
.transform((s) => s !== "false" && s !== "0"),
STORAGE_SKIP_CREATE_BUCKET: z
.string()
.default("false")
.transform((s) => s !== "false" && s !== "0"),

// Redis
REDIS_URL: z.string().url().startsWith("redis://").optional(),
Expand Down
12 changes: 12 additions & 0 deletions apps/server/src/storage/storage.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ export class StorageService implements OnModuleInit {
private client: Client;
private bucketName: string;

private skipCreateBucket: boolean;

constructor(
private readonly configService: ConfigService<Config>,
private readonly minioService: MinioService,
Expand All @@ -55,6 +57,16 @@ export class StorageService implements OnModuleInit {
async onModuleInit() {
this.client = this.minioService.client;
this.bucketName = this.configService.getOrThrow<string>("STORAGE_BUCKET");
this.skipCreateBucket = this.configService.getOrThrow<boolean>("STORAGE_SKIP_CREATE_BUCKET");

if (this.skipCreateBucket) {
this.logger.log("Skipping the creation of the storage bucket.");
this.logger.warn("Make sure that the following paths are publicly accessible: ");
this.logger.warn("- /pictures/*");
this.logger.warn("- /previews/*");
this.logger.warn("- /resumes/*");
return;
}

try {
// Create a storage bucket if it doesn't exist
Expand Down

0 comments on commit 3ddb2c1

Please sign in to comment.