Skip to content

Commit

Permalink
🐛 Fixed Prisma Services
Browse files Browse the repository at this point in the history
  • Loading branch information
naelob committed Jun 17, 2024
1 parent 5099e45 commit f18d028
Show file tree
Hide file tree
Showing 117 changed files with 163 additions and 172 deletions.
2 changes: 1 addition & 1 deletion docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ services:
context: ./
dockerfile: ./packages/api/Dockerfile.dev
environment:
DATABASE_URL: postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:5432/${POSTGRES_DB}?ssl=false
DATABASE_URL: postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:5432/${POSTGRES_DB}?ssl=false&connection_limit=1
DISTRIBUTION: ${DISTRIBUTION}
WEBHOOK_INGRESS: ${WEBHOOK_INGRESS}
JWT_SECRET: ${JWT_SECRET}
Expand Down
3 changes: 1 addition & 2 deletions packages/api/src/@core/auth/auth.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import { ProjectsService } from '@@core/projects/projects.service';
JwtStrategy,
JwtService,
ApiKeyStrategy,
PrismaService,
ConfigService,
ProjectsService,
LoggerService,
Expand All @@ -30,6 +29,6 @@ import { ProjectsService } from '@@core/projects/projects.service';
secret: process.env.JWT_SECRET,
}),
],
exports: [PrismaService, JwtService],
exports: [JwtService],
})
export class AuthModule {}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { EncryptionService } from '@@core/encryption/encryption.service';
providers: [
LoggerService,
EncryptionService,
PrismaService,

ConnectionsStrategiesService,
ConfigService,
ValidateUserService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import { ConnectionUtils } from '../@utils';
imports: [WebhookModule],
providers: [
AccountingConnectionsService,
PrismaService,
LoggerService,
WebhookService,
EnvironmentService,
Expand Down
1 change: 0 additions & 1 deletion packages/api/src/@core/connections/connections.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ import { ConnectionUtils } from './@utils';
],
providers: [
LoggerService,
PrismaService,
ValidateUserService,
CoreSyncService,
ConnectionUtils,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import { ConnectionUtils } from '../@utils';
imports: [WebhookModule],
providers: [
CrmConnectionsService,
PrismaService,
ServiceRegistry,
LoggerService,
WebhookService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import { ConnectionUtils } from '../@utils';
imports: [WebhookModule],
providers: [
FilestorageConnectionsService,
PrismaService,
ServiceRegistry,
LoggerService,
WebhookService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import { ConnectionUtils } from '../@utils';
imports: [WebhookModule],
providers: [
HrisConnectionsService,
PrismaService,
ServiceRegistry,
LoggerService,
WebhookService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { ConnectionUtils } from '../@utils';
imports: [WebhookModule],
providers: [
MarketingAutomationConnectionsService,
PrismaService,

LoggerService,
WebhookService,
EnvironmentService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { ConnectionUtils } from '../@utils';
imports: [WebhookModule, ManagedWebhooksModule],
providers: [
TicketingConnectionsService,
PrismaService,

LoggerService,
WebhookService,
EnvironmentService,
Expand Down
2 changes: 1 addition & 1 deletion packages/api/src/@core/events/events.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { PrismaService } from '@@core/prisma/prisma.service';
import { ValidateUserService } from '@@core/utils/services/validateUser.service';

@Module({
providers: [EventsService, LoggerService, PrismaService, ValidateUserService],
providers: [EventsService, LoggerService, ValidateUserService],
controllers: [EventsController],
})
export class EventsModule {}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { EncryptionService } from '@@core/encryption/encryption.service';
@Module({
providers: [
FieldMappingService,
PrismaService,

LoggerService,
EncryptionService,
],
Expand Down
2 changes: 1 addition & 1 deletion packages/api/src/@core/linked-users/linked-users.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { ValidateUserService } from '@@core/utils/services/validateUser.service'
providers: [
LinkedUsersService,
LoggerService,
PrismaService,

ValidateUserService,
],
controllers: [LinkedUsersController],
Expand Down
2 changes: 1 addition & 1 deletion packages/api/src/@core/magic-link/magic-link.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ import { JwtService } from '@nestjs/jwt';

@Module({
controllers: [MagicLinkController],
providers: [MagicLinkService, PrismaService, LoggerService, JwtService],
providers: [MagicLinkService, LoggerService, JwtService],
})
export class MagicLinkModule {}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { CrmWebhookHandlerModule } from '@crm/@webhook/handler.module';
],
providers: [
ManagedWebhooksService,
PrismaService,

LoggerService,
ValidateUserService,
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { PrismaService } from '../prisma/prisma.service';
import { LoggerService } from '../logger/logger.service';

@Module({
providers: [OrganisationsService, PrismaService, LoggerService],
providers: [OrganisationsService, LoggerService],
controllers: [OrganisationsController],
})
export class OrganisationsModule {}
2 changes: 1 addition & 1 deletion packages/api/src/@core/passthrough/passthrough.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { EncryptionService } from '@@core/encryption/encryption.service';
providers: [
PassthroughService,
LoggerService,
PrismaService,

EncryptionService,
],
controllers: [PassthroughController],
Expand Down
9 changes: 9 additions & 0 deletions packages/api/src/@core/prisma/prisma.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { Global, Module } from '@nestjs/common';
import { PrismaService } from './prisma.service';

@Global()
@Module({
providers: [PrismaService],
exports: [PrismaService],
})
export class PrismaModule {}
3 changes: 0 additions & 3 deletions packages/api/src/@core/prisma/prisma.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,4 @@ export class PrismaService extends PrismaClient implements OnModuleInit {
throw new Error(error);
}
}
async onModuleDestroy() {
await this.$disconnect();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { LoggerService } from '../logger/logger.service';
import { PrismaService } from '../prisma/prisma.service';

@Module({
providers: [ProjectConnectorsService, LoggerService, PrismaService],
providers: [ProjectConnectorsService, LoggerService],
controllers: [ProjectConnectorsController],
})
export class ProjectConnectorsModule {}
2 changes: 1 addition & 1 deletion packages/api/src/@core/projects/projects.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { LoggerService } from '../logger/logger.service';
import { PrismaService } from '../prisma/prisma.service';

@Module({
providers: [ProjectsService, LoggerService, PrismaService],
providers: [ProjectsService, LoggerService],
controllers: [ProjectsController],
})
export class ProjectsModule {}
2 changes: 1 addition & 1 deletion packages/api/src/@core/sync/sync.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ import { UserModule as TUserModule } from '@ticketing/user/user.module';
providers: [
CoreSyncService,
LoggerService,
PrismaService,

],
controllers: [SyncController],
})
Expand Down
43 changes: 16 additions & 27 deletions packages/api/src/@core/utils/services/core.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ export class CoreUnification {
switch (vertical.toLowerCase()) {
case ConnectorCategory.Crm:
targetType_ = targetType as CrmObject;
const crmRegistry: CrmUnificationService =
this.registry.getService('crm');
const crmRegistry = this.registry.getService('crm');
return crmRegistry.unify({
sourceObject,
targetType_,
Expand All @@ -59,8 +58,7 @@ export class CoreUnification {
});
case ConnectorCategory.Ats:
targetType_ = targetType as AtsObject;
const atsRegistry: AtsUnificationService =
this.registry.getService('ats');
const atsRegistry = this.registry.getService('ats');
return atsRegistry.unify({
sourceObject,
targetType_,
Expand All @@ -69,8 +67,7 @@ export class CoreUnification {
});
case ConnectorCategory.Accounting:
targetType_ = targetType as AccountingObject;
const accountingRegistry: AccountingUnificationService =
this.registry.getService('accounting');
const accountingRegistry = this.registry.getService('accounting');

return accountingRegistry.unify({
sourceObject,
Expand All @@ -80,8 +77,7 @@ export class CoreUnification {
});
case ConnectorCategory.FileStorage:
targetType_ = targetType as FileStorageObject;
const filestorageRegistry: FileStorageUnificationService =
this.registry.getService('filestorage');
const filestorageRegistry = this.registry.getService('filestorage');

return filestorageRegistry.unify({
sourceObject,
Expand All @@ -91,8 +87,7 @@ export class CoreUnification {
});
case ConnectorCategory.Hris:
targetType_ = targetType as HrisObject;
const hrisRegistry: HrisUnificationService =
this.registry.getService('hris');
const hrisRegistry = this.registry.getService('hris');

return hrisRegistry.unify({
sourceObject,
Expand All @@ -102,8 +97,9 @@ export class CoreUnification {
});
case ConnectorCategory.MarketingAutomation:
targetType_ = targetType as MarketingAutomationObject;
const marketingautomationRegistry: MarketingAutomationUnificationService =
this.registry.getService('marketingautomation');
const marketingautomationRegistry = this.registry.getService(
'marketingautomation',
);

return marketingautomationRegistry.unify({
sourceObject,
Expand All @@ -113,8 +109,7 @@ export class CoreUnification {
});
case ConnectorCategory.Ticketing:
targetType_ = targetType as TicketingObject;
const ticketingRegistry: TicketingUnificationService =
this.registry.getService('ticketing');
const ticketingRegistry = this.registry.getService('ticketing');

return ticketingRegistry.unify({
sourceObject,
Expand Down Expand Up @@ -151,8 +146,7 @@ export class CoreUnification {
switch (vertical.toLowerCase()) {
case ConnectorCategory.Crm:
targetType_ = targetType as CrmObject;
const crmRegistry: CrmUnificationService =
this.registry.getService('crm');
const crmRegistry = this.registry.getService('crm');
return crmRegistry.desunify({
sourceObject,
targetType_,
Expand All @@ -161,8 +155,7 @@ export class CoreUnification {
});
case ConnectorCategory.Ats:
targetType_ = targetType as AtsObject;
const atsRegistry: AtsUnificationService =
this.registry.getService('ats');
const atsRegistry = this.registry.getService('ats');
return atsRegistry.desunify({
sourceObject,
targetType_,
Expand All @@ -171,8 +164,7 @@ export class CoreUnification {
});
case ConnectorCategory.Accounting:
targetType_ = targetType as AccountingObject;
const accountingRegistry: AccountingUnificationService =
this.registry.getService('accounting');
const accountingRegistry = this.registry.getService('accounting');
return accountingRegistry.desunify({
sourceObject,
targetType_,
Expand All @@ -181,8 +173,7 @@ export class CoreUnification {
});
case ConnectorCategory.FileStorage:
targetType_ = targetType as FileStorageObject;
const filestorageRegistry: FileStorageUnificationService =
this.registry.getService('filestorage');
const filestorageRegistry = this.registry.getService('filestorage');
return filestorageRegistry.desunify({
sourceObject,
targetType_,
Expand All @@ -191,8 +182,7 @@ export class CoreUnification {
});
case ConnectorCategory.Hris:
targetType_ = targetType as HrisObject;
const hrisRegistry: HrisUnificationService =
this.registry.getService('crm');
const hrisRegistry = this.registry.getService('crm');
return hrisRegistry.desunify({
sourceObject,
targetType_,
Expand All @@ -201,7 +191,7 @@ export class CoreUnification {
});
case ConnectorCategory.MarketingAutomation:
targetType_ = targetType as MarketingAutomationObject;
const marketingautomationRegistry: MarketingAutomationUnificationService =
const marketingautomationRegistry =
this.registry.getService('arketingautomation');
return marketingautomationRegistry.desunify({
sourceObject,
Expand All @@ -211,8 +201,7 @@ export class CoreUnification {
});
case ConnectorCategory.Ticketing:
targetType_ = targetType as TicketingObject;
const ticketingRegistry: TicketingUnificationService =
this.registry.getService('ticketing');
const ticketingRegistry = this.registry.getService('ticketing');
return ticketingRegistry.desunify({
sourceObject,
targetType_,
Expand Down
2 changes: 1 addition & 1 deletion packages/api/src/@core/webhook/webhook.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { ValidateUserService } from '@@core/utils/services/validateUser.service'
],
providers: [
WebhookService,
PrismaService,

LoggerService,
WebhookProcessor,
ValidateUserService,
Expand Down
2 changes: 2 additions & 0 deletions packages/api/src/accounting/@lib/@unification/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import { UnifySourceType } from '@@core/utils/types/unify.output';
import { MappersRegistry } from '@@core/utils/registry/mappings.registry';
import { UnificationRegistry } from '@@core/utils/registry/unification.registry';
import { IUnification } from '@@core/utils/types/interface';
import { Injectable } from '@nestjs/common';

@Injectable()
export class AccountingUnificationService implements IUnification {
constructor(
private registry: UnificationRegistry<AccountingUnificationService>,
Expand Down
2 changes: 1 addition & 1 deletion packages/api/src/accounting/account/account.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { AccountService } from './services/account.service';
controllers: [AccountController],
providers: [
AccountService,
PrismaService,

LoggerService,
SyncService,
WebhookService,
Expand Down
2 changes: 1 addition & 1 deletion packages/api/src/accounting/address/address.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { ConnectionUtils } from '@@core/connections/@utils';
controllers: [AddressController],
providers: [
AddressService,
PrismaService,

LoggerService,
SyncService,
WebhookService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { ConnectionUtils } from '@@core/connections/@utils';
controllers: [AttachmentController],
providers: [
AttachmentService,
PrismaService,

LoggerService,
SyncService,
WebhookService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { ConnectionUtils } from '@@core/connections/@utils';
controllers: [BalanceSheetController],
providers: [
BalanceSheetService,
PrismaService,

LoggerService,
SyncService,
WebhookService,
Expand Down
Loading

0 comments on commit f18d028

Please sign in to comment.