Add deploy buttons and clean environment variables (#974)

* add render.yaml

* Clean environment variables



---------

Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
Félix Malfait
2023-07-31 14:36:04 -07:00
committed by GitHub
parent a90cbac5e6
commit b028d9fd2a
31 changed files with 194 additions and 112 deletions

View File

@ -47,9 +47,10 @@ export class UpdateActivityTargetAbilityHandler implements IAbilityHandler {
async handle(ability: AppAbility, context: ExecutionContext) {
const gqlContext = GqlExecutionContext.create(context);
const args = gqlContext.getArgs<ActivityTargetArgs>();
const ActivityTarget = await this.prismaService.client.activityTarget.findFirst({
where: args.where,
});
const ActivityTarget =
await this.prismaService.client.activityTarget.findFirst({
where: args.where,
});
assert(ActivityTarget, '', NotFoundException);
return ability.can(
@ -66,9 +67,10 @@ export class DeleteActivityTargetAbilityHandler implements IAbilityHandler {
async handle(ability: AppAbility, context: ExecutionContext) {
const gqlContext = GqlExecutionContext.create(context);
const args = gqlContext.getArgs<ActivityTargetArgs>();
const ActivityTarget = await this.prismaService.client.activityTarget.findFirst({
where: args.where,
});
const ActivityTarget =
await this.prismaService.client.activityTarget.findFirst({
where: args.where,
});
assert(ActivityTarget, '', NotFoundException);
return ability.can(

View File

@ -30,7 +30,7 @@ export class ClientConfig {
telemetry: Telemetry;
@Field(() => Boolean)
demoMode: boolean;
signInPrefilled: boolean;
@Field(() => Boolean)
debugMode: boolean;

View File

@ -12,17 +12,17 @@ export class ClientConfigResolver {
async clientConfig(): Promise<ClientConfig> {
const clientConfig: ClientConfig = {
authProviders: {
google: this.environmentService.isAuthGoogleEnabled() ?? false,
google: this.environmentService.isAuthGoogleEnabled(),
magicLink: false,
password: true,
},
telemetry: {
enabled: this.environmentService.isTelemetryEnabled() ?? false,
enabled: this.environmentService.isTelemetryEnabled(),
anonymizationEnabled:
this.environmentService.isTelemetryAnonymizationEnabled() ?? false,
this.environmentService.isTelemetryAnonymizationEnabled(),
},
demoMode: this.environmentService.isDemoMode() ?? false,
debugMode: this.environmentService.isDebugMode() ?? false,
signInPrefilled: this.environmentService.isSignInPrefilled(),
debugMode: this.environmentService.isDebugMode(),
};
return Promise.resolve(clientConfig);

View File

@ -13,15 +13,15 @@ export class EnvironmentService {
return this.configService.get<boolean>('DEBUG_MODE') ?? false;
}
isDemoMode(): boolean {
return this.configService.get<boolean>('DEMO_MODE') ?? false;
isSignInPrefilled(): boolean {
return this.configService.get<boolean>('IS_SIGN_IN_PREFILLED') ?? false;
}
isTelemetryEnabled(): boolean {
return this.configService.get<boolean>('TELEMETRY_ENABLED') ?? true;
}
isTelemetryAnonymizationEnabled(): boolean | undefined {
isTelemetryAnonymizationEnabled(): boolean {
return (
this.configService.get<boolean>('TELEMETRY_ANONYMIZATION_ENABLED') ?? true
);
@ -31,12 +31,16 @@ export class EnvironmentService {
return this.configService.get<string>('PG_DATABASE_URL')!;
}
getFrontBaseUrl(): string {
return this.configService.get<string>('FRONT_BASE_URL')!;
}
getAccessTokenSecret(): string {
return this.configService.get<string>('ACCESS_TOKEN_SECRET')!;
}
getAccessTokenExpiresIn(): string {
return this.configService.get<string>('ACCESS_TOKEN_EXPIRES_IN')!;
return this.configService.get<string>('ACCESS_TOKEN_EXPIRES_IN') ?? '30m';
}
getRefreshTokenSecret(): string {
@ -44,7 +48,7 @@ export class EnvironmentService {
}
getRefreshTokenExpiresIn(): string {
return this.configService.get<string>('REFRESH_TOKEN_EXPIRES_IN')!;
return this.configService.get<string>('REFRESH_TOKEN_EXPIRES_IN') ?? '90d';
}
getLoginTokenSecret(): string {
@ -52,15 +56,18 @@ export class EnvironmentService {
}
getLoginTokenExpiresIn(): string {
return this.configService.get<string>('LOGIN_TOKEN_EXPIRES_IN')!;
return this.configService.get<string>('LOGIN_TOKEN_EXPIRES_IN') ?? '15m';
}
getFrontAuthCallbackUrl(): string {
return this.configService.get<string>('FRONT_AUTH_CALLBACK_URL')!;
return (
this.configService.get<string>('FRONT_AUTH_CALLBACK_URL') ??
this.getFrontBaseUrl() + '/auth/callback'
);
}
isAuthGoogleEnabled(): boolean | undefined {
return this.configService.get<boolean>('AUTH_GOOGLE_ENABLED');
isAuthGoogleEnabled(): boolean {
return this.configService.get<boolean>('AUTH_GOOGLE_ENABLED') ?? false;
}
getAuthGoogleClientId(): string | undefined {
@ -75,8 +82,10 @@ export class EnvironmentService {
return this.configService.get<string>('AUTH_GOOGLE_CALLBACK_URL');
}
getStorageType(): StorageType | undefined {
return this.configService.get<StorageType>('STORAGE_TYPE');
getStorageType(): StorageType {
return (
this.configService.get<StorageType>('STORAGE_TYPE') ?? StorageType.Local
);
}
getStorageS3Region(): AwsRegion | undefined {
@ -87,7 +96,9 @@ export class EnvironmentService {
return this.configService.get<AwsRegion>('STORAGE_S3_NAME');
}
getStorageLocalPath(): string | undefined {
return this.configService.get<string>('STORAGE_LOCAL_PATH')!;
getStorageLocalPath(): string {
return (
this.configService.get<string>('STORAGE_LOCAL_PATH') ?? '.local-storage'
);
}
}

View File

@ -27,7 +27,7 @@ export class EnvironmentVariables {
@CastToBoolean()
@IsOptional()
@IsBoolean()
DEMO_MODE?: boolean;
IS_SIGN_IN_PREFILLED?: boolean;
@CastToBoolean()
@IsOptional()
@ -43,24 +43,32 @@ export class EnvironmentVariables {
@IsUrl({ protocols: ['postgres'], require_tld: false })
PG_DATABASE_URL: string;
// Frontend URL
@IsUrl({ require_tld: false })
FRONT_BASE_URL: string;
// Json Web Token
@IsString()
ACCESS_TOKEN_SECRET: string;
@IsDuration()
@IsOptional()
ACCESS_TOKEN_EXPIRES_IN: string;
@IsString()
REFRESH_TOKEN_SECRET: string;
@IsDuration()
@IsOptional()
REFRESH_TOKEN_EXPIRES_IN: string;
@IsString()
LOGIN_TOKEN_SECRET: string;
@IsDuration()
@IsOptional()
LOGIN_TOKEN_EXPIRES_IN: string;
// Auth
@IsUrl({ require_tld: false })
@IsOptional()
FRONT_AUTH_CALLBACK_URL: string;
@CastToBoolean()

View File

@ -19,7 +19,6 @@ const fileStorageModuleFactory = async (
const type = environmentService.getStorageType();
switch (type) {
case undefined:
case StorageType.Local: {
const storagePath = environmentService.getStorageLocalPath();