mirror of
https://github.com/lingble/twenty.git
synced 2025-10-29 20:02:29 +00:00
This PR is dropping the column `targetColumnMap` of fieldMetadata entities. The goal of this column was to properly map field to their respecting column in the table. We decide to drop it and instead compute the column name on the fly when we need it, as it's more easier to support. Some parts of the code has been refactored to try making implementation of composite type more easier to understand and maintain. Fix #3760 --------- Co-authored-by: Charles Bochet <charles@twenty.com>
90 lines
3.1 KiB
TypeScript
90 lines
3.1 KiB
TypeScript
import {
|
|
DynamicModule,
|
|
MiddlewareConsumer,
|
|
Module,
|
|
RequestMethod,
|
|
} from '@nestjs/common';
|
|
import { ConfigModule } from '@nestjs/config';
|
|
import { ServeStaticModule } from '@nestjs/serve-static';
|
|
import { GraphQLModule } from '@nestjs/graphql';
|
|
import { DevtoolsModule } from '@nestjs/devtools-integration';
|
|
|
|
import { existsSync } from 'fs';
|
|
import { join } from 'path';
|
|
|
|
import { YogaDriverConfig, YogaDriver } from '@graphql-yoga/nestjs';
|
|
|
|
import { ApiRestModule } from 'src/engine/api/rest/api-rest.module';
|
|
import { ModulesModule } from 'src/modules/modules.module';
|
|
import { CoreGraphQLApiModule } from 'src/engine/api/graphql/core-graphql-api.module';
|
|
import { MetadataGraphQLApiModule } from 'src/engine/api/graphql/metadata-graphql-api.module';
|
|
import { GraphQLConfigModule } from 'src/engine/api/graphql/graphql-config/graphql-config.module';
|
|
import { GraphQLConfigService } from 'src/engine/api/graphql/graphql-config/graphql-config.service';
|
|
import { EnvironmentService } from 'src/engine/integrations/environment/environment.service';
|
|
import { UserWorkspaceMiddleware } from 'src/engine/middlewares/user-workspace.middleware';
|
|
import { WorkspaceCacheVersionModule } from 'src/engine/metadata-modules/workspace-cache-version/workspace-cache-version.module';
|
|
|
|
import { CoreEngineModule } from './engine/core-modules/core-engine.module';
|
|
import { IntegrationsModule } from './engine/integrations/integrations.module';
|
|
|
|
@Module({
|
|
imports: [
|
|
// Nest.js devtools, use devtools.nestjs.com to debug
|
|
DevtoolsModule.registerAsync({
|
|
useFactory: (environmentService: EnvironmentService) => ({
|
|
http: environmentService.get('DEBUG_MODE'),
|
|
port: environmentService.get('DEBUG_PORT'),
|
|
}),
|
|
inject: [EnvironmentService],
|
|
}),
|
|
ConfigModule.forRoot({
|
|
isGlobal: true,
|
|
}),
|
|
GraphQLModule.forRootAsync<YogaDriverConfig>({
|
|
driver: YogaDriver,
|
|
imports: [CoreEngineModule, GraphQLConfigModule],
|
|
useClass: GraphQLConfigService,
|
|
}),
|
|
// Integrations module, contains all the integrations with other services
|
|
IntegrationsModule,
|
|
// Core engine module, contains all the core modules
|
|
CoreEngineModule,
|
|
// Modules module, contains all business logic modules
|
|
ModulesModule,
|
|
// Needed for the user workspace middleware
|
|
WorkspaceCacheVersionModule,
|
|
// Api modules
|
|
CoreGraphQLApiModule,
|
|
MetadataGraphQLApiModule,
|
|
ApiRestModule,
|
|
// Conditional modules
|
|
...AppModule.getConditionalModules(),
|
|
],
|
|
})
|
|
export class AppModule {
|
|
private static getConditionalModules(): DynamicModule[] {
|
|
const modules: DynamicModule[] = [];
|
|
const frontPath = join(__dirname, '..', 'front');
|
|
|
|
if (existsSync(frontPath)) {
|
|
modules.push(
|
|
ServeStaticModule.forRoot({
|
|
rootPath: frontPath,
|
|
}),
|
|
);
|
|
}
|
|
|
|
return modules;
|
|
}
|
|
|
|
configure(consumer: MiddlewareConsumer) {
|
|
consumer
|
|
.apply(UserWorkspaceMiddleware)
|
|
.forRoutes({ path: 'graphql', method: RequestMethod.ALL });
|
|
|
|
consumer
|
|
.apply(UserWorkspaceMiddleware)
|
|
.forRoutes({ path: 'metadata', method: RequestMethod.ALL });
|
|
}
|
|
}
|