feat: wip server folder structure (#4573)
* feat: wip server folder structure * fix: merge * fix: wrong merge * fix: remove unused file * fix: comment * fix: lint * fix: merge * fix: remove console.log * fix: metadata graphql arguments broken
This commit is contained in:
@ -0,0 +1,76 @@
|
||||
import { Field, ObjectType } from '@nestjs/graphql';
|
||||
|
||||
@ObjectType()
|
||||
class AuthProviders {
|
||||
@Field(() => Boolean)
|
||||
google: boolean;
|
||||
|
||||
@Field(() => Boolean)
|
||||
magicLink: boolean;
|
||||
|
||||
@Field(() => Boolean)
|
||||
password: boolean;
|
||||
}
|
||||
|
||||
@ObjectType()
|
||||
class Telemetry {
|
||||
@Field(() => Boolean)
|
||||
enabled: boolean;
|
||||
|
||||
@Field(() => Boolean)
|
||||
anonymizationEnabled: boolean;
|
||||
}
|
||||
|
||||
@ObjectType()
|
||||
class Billing {
|
||||
@Field(() => Boolean)
|
||||
isBillingEnabled: boolean;
|
||||
|
||||
@Field(() => String, { nullable: true })
|
||||
billingUrl?: string;
|
||||
|
||||
@Field(() => Number, { nullable: true })
|
||||
billingFreeTrialDurationInDays?: number;
|
||||
}
|
||||
|
||||
@ObjectType()
|
||||
class Support {
|
||||
@Field(() => String)
|
||||
supportDriver: string;
|
||||
|
||||
@Field(() => String, { nullable: true })
|
||||
supportFrontChatId?: string;
|
||||
}
|
||||
|
||||
@ObjectType()
|
||||
class Sentry {
|
||||
@Field(() => String, { nullable: true })
|
||||
dsn?: string;
|
||||
}
|
||||
|
||||
@ObjectType()
|
||||
export class ClientConfig {
|
||||
@Field(() => AuthProviders, { nullable: false })
|
||||
authProviders: AuthProviders;
|
||||
|
||||
@Field(() => Telemetry, { nullable: false })
|
||||
telemetry: Telemetry;
|
||||
|
||||
@Field(() => Billing, { nullable: false })
|
||||
billing: Billing;
|
||||
|
||||
@Field(() => Boolean)
|
||||
signInPrefilled: boolean;
|
||||
|
||||
@Field(() => Boolean)
|
||||
signUpDisabled: boolean;
|
||||
|
||||
@Field(() => Boolean)
|
||||
debugMode: boolean;
|
||||
|
||||
@Field(() => Support)
|
||||
support: Support;
|
||||
|
||||
@Field(() => Sentry)
|
||||
sentry: Sentry;
|
||||
}
|
||||
@ -0,0 +1,8 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
|
||||
import { ClientConfigResolver } from './client-config.resolver';
|
||||
|
||||
@Module({
|
||||
providers: [ClientConfigResolver],
|
||||
})
|
||||
export class ClientConfigModule {}
|
||||
@ -0,0 +1,27 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
|
||||
import { EnvironmentService } from 'src/engine/integrations/environment/environment.service';
|
||||
|
||||
import { ClientConfigResolver } from './client-config.resolver';
|
||||
|
||||
describe('ClientConfigResolver', () => {
|
||||
let resolver: ClientConfigResolver;
|
||||
|
||||
beforeEach(async () => {
|
||||
const module: TestingModule = await Test.createTestingModule({
|
||||
providers: [
|
||||
ClientConfigResolver,
|
||||
{
|
||||
provide: EnvironmentService,
|
||||
useValue: {},
|
||||
},
|
||||
],
|
||||
}).compile();
|
||||
|
||||
resolver = module.get<ClientConfigResolver>(ClientConfigResolver);
|
||||
});
|
||||
|
||||
it('should be defined', () => {
|
||||
expect(resolver).toBeDefined();
|
||||
});
|
||||
});
|
||||
@ -0,0 +1,48 @@
|
||||
import { Resolver, Query } from '@nestjs/graphql';
|
||||
|
||||
import { EnvironmentService } from 'src/engine/integrations/environment/environment.service';
|
||||
|
||||
import { ClientConfig } from './client-config.entity';
|
||||
|
||||
@Resolver()
|
||||
export class ClientConfigResolver {
|
||||
constructor(private environmentService: EnvironmentService) {}
|
||||
|
||||
@Query(() => ClientConfig)
|
||||
async clientConfig(): Promise<ClientConfig> {
|
||||
const clientConfig: ClientConfig = {
|
||||
authProviders: {
|
||||
google: this.environmentService.get('AUTH_GOOGLE_ENABLED'),
|
||||
magicLink: false,
|
||||
password: true,
|
||||
},
|
||||
telemetry: {
|
||||
enabled: this.environmentService.get('TELEMETRY_ENABLED'),
|
||||
anonymizationEnabled: this.environmentService.get(
|
||||
'TELEMETRY_ANONYMIZATION_ENABLED',
|
||||
),
|
||||
},
|
||||
billing: {
|
||||
isBillingEnabled: this.environmentService.get('IS_BILLING_ENABLED'),
|
||||
billingUrl: this.environmentService.get('BILLING_PLAN_REQUIRED_LINK'),
|
||||
billingFreeTrialDurationInDays: this.environmentService.get(
|
||||
'BILLING_FREE_TRIAL_DURATION_IN_DAYS',
|
||||
),
|
||||
},
|
||||
signInPrefilled: this.environmentService.get('SIGN_IN_PREFILLED'),
|
||||
signUpDisabled: this.environmentService.get('IS_SIGN_UP_DISABLED'),
|
||||
debugMode: this.environmentService.get('DEBUG_MODE'),
|
||||
support: {
|
||||
supportDriver: this.environmentService.get('SUPPORT_DRIVER'),
|
||||
supportFrontChatId: this.environmentService.get(
|
||||
'SUPPORT_FRONT_CHAT_ID',
|
||||
),
|
||||
},
|
||||
sentry: {
|
||||
dsn: this.environmentService.get('SENTRY_DSN'),
|
||||
},
|
||||
};
|
||||
|
||||
return Promise.resolve(clientConfig);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user