mirror of
https://github.com/AmruthPillai/Reactive-Resume.git
synced 2025-11-18 10:41:56 +10:00
feat(feature-flags): fixes #1592, introduces new flags DISABLE_SIGNUPS and DISABLE_EMAIL_AUTH, renamed STORAGE_SKIP_BUCKET_CHECK
This commit is contained in:
@ -10,6 +10,7 @@ import { AuthModule } from "./auth/auth.module";
|
||||
import { ConfigModule } from "./config/config.module";
|
||||
import { ContributorsModule } from "./contributors/contributors.module";
|
||||
import { DatabaseModule } from "./database/database.module";
|
||||
import { FeatureModule } from "./feature/feature.module";
|
||||
import { HealthModule } from "./health/health.module";
|
||||
import { MailModule } from "./mail/mail.module";
|
||||
import { PrinterModule } from "./printer/printer.module";
|
||||
@ -33,6 +34,7 @@ import { UserModule } from "./user/user.module";
|
||||
ResumeModule,
|
||||
StorageModule,
|
||||
PrinterModule,
|
||||
FeatureModule,
|
||||
TranslationModule,
|
||||
ContributorsModule,
|
||||
|
||||
|
||||
@ -44,17 +44,21 @@ export const configSchema = z.object({
|
||||
.string()
|
||||
.default("false")
|
||||
.transform((s) => s !== "false" && s !== "0"),
|
||||
STORAGE_SKIP_BUCKET_CHECK: z
|
||||
.string()
|
||||
.default("false")
|
||||
.transform((s) => s !== "false" && s !== "0"),
|
||||
|
||||
// Crowdin (Optional)
|
||||
CROWDIN_PROJECT_ID: z.coerce.number().optional(),
|
||||
CROWDIN_PERSONAL_TOKEN: z.string().optional(),
|
||||
|
||||
// Flags (Optional)
|
||||
DISABLE_EMAIL_AUTH: z
|
||||
// Feature Flags (Optional)
|
||||
DISABLE_SIGNUPS: z
|
||||
.string()
|
||||
.default("false")
|
||||
.transform((s) => s !== "false" && s !== "0"),
|
||||
SKIP_STORAGE_BUCKET_CHECK: z
|
||||
DISABLE_EMAIL_AUTH: z
|
||||
.string()
|
||||
.default("false")
|
||||
.transform((s) => s !== "false" && s !== "0"),
|
||||
|
||||
@ -6,6 +6,7 @@ import { ContributorDto } from "@reactive-resume/dto";
|
||||
import { Config } from "../config/schema";
|
||||
|
||||
type GitHubResponse = { id: number; login: string; html_url: string; avatar_url: string }[];
|
||||
|
||||
type CrowdinContributorsResponse = {
|
||||
data: { data: { id: number; username: string; avatarUrl: string } }[];
|
||||
};
|
||||
|
||||
13
apps/server/src/feature/feature.controller.ts
Normal file
13
apps/server/src/feature/feature.controller.ts
Normal file
@ -0,0 +1,13 @@
|
||||
import { Controller, Get } from "@nestjs/common";
|
||||
|
||||
import { FeatureService } from "./feature.service";
|
||||
|
||||
@Controller("feature")
|
||||
export class FeatureController {
|
||||
constructor(private readonly featureService: FeatureService) {}
|
||||
|
||||
@Get("/flags")
|
||||
getFeatureFlags() {
|
||||
return this.featureService.getFeatures();
|
||||
}
|
||||
}
|
||||
11
apps/server/src/feature/feature.module.ts
Normal file
11
apps/server/src/feature/feature.module.ts
Normal file
@ -0,0 +1,11 @@
|
||||
import { Module } from "@nestjs/common";
|
||||
|
||||
import { FeatureController } from "./feature.controller";
|
||||
import { FeatureService } from "./feature.service";
|
||||
|
||||
@Module({
|
||||
providers: [FeatureService],
|
||||
controllers: [FeatureController],
|
||||
exports: [FeatureService],
|
||||
})
|
||||
export class FeatureModule {}
|
||||
19
apps/server/src/feature/feature.service.ts
Normal file
19
apps/server/src/feature/feature.service.ts
Normal file
@ -0,0 +1,19 @@
|
||||
import { Injectable } from "@nestjs/common";
|
||||
import { ConfigService } from "@nestjs/config";
|
||||
|
||||
import { Config } from "../config/schema";
|
||||
|
||||
@Injectable()
|
||||
export class FeatureService {
|
||||
constructor(private readonly configService: ConfigService<Config>) {}
|
||||
|
||||
getFeatures() {
|
||||
const isSignupsDisabled = this.configService.getOrThrow<boolean>("DISABLE_SIGNUPS");
|
||||
const isEmailAuthDisabled = this.configService.getOrThrow<boolean>("DISABLE_EMAIL_AUTH");
|
||||
|
||||
return {
|
||||
isSignupsDisabled,
|
||||
isEmailAuthDisabled,
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -49,14 +49,13 @@ export class StorageService implements OnModuleInit {
|
||||
this.client = this.minioService.client;
|
||||
this.bucketName = this.configService.getOrThrow<string>("STORAGE_BUCKET");
|
||||
|
||||
const skipBucketCheck = this.configService.getOrThrow<boolean>("SKIP_STORAGE_BUCKET_CHECK");
|
||||
const skipBucketCheck = this.configService.getOrThrow<boolean>("STORAGE_SKIP_BUCKET_CHECK");
|
||||
|
||||
if (skipBucketCheck) {
|
||||
this.logger.log("Skipping the verification of whether the storage bucket exists.");
|
||||
this.logger.warn("Make sure that the following paths are publicly accessible: ");
|
||||
this.logger.warn("- /pictures/*");
|
||||
this.logger.warn("- /previews/*");
|
||||
this.logger.warn("- /resumes/*");
|
||||
this.logger.warn("Skipping the verification of whether the storage bucket exists.");
|
||||
this.logger.warn(
|
||||
"Make sure that the following paths are publicly accessible: `/{pictures,previews,resumes}/*`",
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user