From baa6a3d0f0c2e576319db4fb63be24fbe295b4b2 Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Fri, 18 Feb 2022 19:32:25 +0100 Subject: [PATCH] Feature/restructure api modules (#706) * Restructure modules * Update changelog --- CHANGELOG.md | 1 + apps/api/src/app/access/access.module.ts | 6 +++--- .../src/app/auth-device/auth-device.module.ts | 10 ++++++---- apps/api/src/app/auth/auth.module.ts | 8 ++++---- apps/api/src/app/cache/cache.module.ts | 17 +++++++---------- apps/api/src/app/import/import.module.ts | 7 ++++--- apps/api/src/app/info/info.module.ts | 16 ++++++---------- apps/api/src/app/order/order.module.ts | 9 +++++---- apps/api/src/app/portfolio/portfolio.module.ts | 2 +- .../src/app/redis-cache/redis-cache.module.ts | 6 ++++-- .../src/app/subscription/subscription.module.ts | 10 +++++----- apps/api/src/app/user/user.module.ts | 12 +++++++----- 12 files changed, 53 insertions(+), 51 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b266833e8..5efe84cd0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - Moved the countries and sectors charts in the position detail dialog +- Restructured the server modules ## 1.116.0 - 16.02.2022 diff --git a/apps/api/src/app/access/access.module.ts b/apps/api/src/app/access/access.module.ts index 303989b21..d70388038 100644 --- a/apps/api/src/app/access/access.module.ts +++ b/apps/api/src/app/access/access.module.ts @@ -1,4 +1,4 @@ -import { PrismaService } from '@ghostfolio/api/services/prisma.service'; +import { PrismaModule } from '@ghostfolio/api/services/prisma.module'; import { Module } from '@nestjs/common'; import { AccessController } from './access.controller'; @@ -7,7 +7,7 @@ import { AccessService } from './access.service'; @Module({ controllers: [AccessController], exports: [AccessService], - imports: [], - providers: [AccessService, PrismaService] + imports: [PrismaModule], + providers: [AccessService] }) export class AccessModule {} diff --git a/apps/api/src/app/auth-device/auth-device.module.ts b/apps/api/src/app/auth-device/auth-device.module.ts index 360930cf2..de6cd1cbc 100644 --- a/apps/api/src/app/auth-device/auth-device.module.ts +++ b/apps/api/src/app/auth-device/auth-device.module.ts @@ -1,18 +1,20 @@ import { AuthDeviceController } from '@ghostfolio/api/app/auth-device/auth-device.controller'; import { AuthDeviceService } from '@ghostfolio/api/app/auth-device/auth-device.service'; -import { ConfigurationService } from '@ghostfolio/api/services/configuration.service'; -import { PrismaService } from '@ghostfolio/api/services/prisma.service'; +import { ConfigurationModule } from '@ghostfolio/api/services/configuration.module'; +import { PrismaModule } from '@ghostfolio/api/services/prisma.module'; import { Module } from '@nestjs/common'; import { JwtModule } from '@nestjs/jwt'; @Module({ controllers: [AuthDeviceController], imports: [ + ConfigurationModule, JwtModule.register({ secret: process.env.JWT_SECRET_KEY, signOptions: { expiresIn: '180 days' } - }) + }), + PrismaModule ], - providers: [AuthDeviceService, ConfigurationService, PrismaService] + providers: [AuthDeviceService] }) export class AuthDeviceModule {} diff --git a/apps/api/src/app/auth/auth.module.ts b/apps/api/src/app/auth/auth.module.ts index 8a59ff82a..b25e4c18b 100644 --- a/apps/api/src/app/auth/auth.module.ts +++ b/apps/api/src/app/auth/auth.module.ts @@ -2,8 +2,8 @@ import { AuthDeviceService } from '@ghostfolio/api/app/auth-device/auth-device.s import { WebAuthService } from '@ghostfolio/api/app/auth/web-auth.service'; import { SubscriptionModule } from '@ghostfolio/api/app/subscription/subscription.module'; import { UserModule } from '@ghostfolio/api/app/user/user.module'; -import { ConfigurationService } from '@ghostfolio/api/services/configuration.service'; -import { PrismaService } from '@ghostfolio/api/services/prisma.service'; +import { ConfigurationModule } from '@ghostfolio/api/services/configuration.module'; +import { PrismaModule } from '@ghostfolio/api/services/prisma.module'; import { Module } from '@nestjs/common'; import { JwtModule } from '@nestjs/jwt'; @@ -15,20 +15,20 @@ import { JwtStrategy } from './jwt.strategy'; @Module({ controllers: [AuthController], imports: [ + ConfigurationModule, JwtModule.register({ secret: process.env.JWT_SECRET_KEY, signOptions: { expiresIn: '180 days' } }), + PrismaModule, SubscriptionModule, UserModule ], providers: [ AuthDeviceService, AuthService, - ConfigurationService, GoogleStrategy, JwtStrategy, - PrismaService, WebAuthService ] }) diff --git a/apps/api/src/app/cache/cache.module.ts b/apps/api/src/app/cache/cache.module.ts index a823c2d1e..7b427b7a0 100644 --- a/apps/api/src/app/cache/cache.module.ts +++ b/apps/api/src/app/cache/cache.module.ts @@ -1,30 +1,27 @@ import { CacheService } from '@ghostfolio/api/app/cache/cache.service'; import { RedisCacheModule } from '@ghostfolio/api/app/redis-cache/redis-cache.module'; -import { ConfigurationService } from '@ghostfolio/api/services/configuration.service'; +import { ConfigurationModule } from '@ghostfolio/api/services/configuration.module'; import { DataGatheringModule } from '@ghostfolio/api/services/data-gathering.module'; -import { DataGatheringService } from '@ghostfolio/api/services/data-gathering.service'; import { DataProviderModule } from '@ghostfolio/api/services/data-provider/data-provider.module'; import { ExchangeRateDataModule } from '@ghostfolio/api/services/exchange-rate-data.module'; -import { PrismaService } from '@ghostfolio/api/services/prisma.service'; +import { PrismaModule } from '@ghostfolio/api/services/prisma.module'; import { SymbolProfileModule } from '@ghostfolio/api/services/symbol-profile.module'; import { Module } from '@nestjs/common'; import { CacheController } from './cache.controller'; @Module({ + exports: [CacheService], + controllers: [CacheController], imports: [ + ConfigurationModule, DataGatheringModule, DataProviderModule, ExchangeRateDataModule, + PrismaModule, RedisCacheModule, SymbolProfileModule ], - controllers: [CacheController], - providers: [ - CacheService, - ConfigurationService, - DataGatheringService, - PrismaService - ] + providers: [CacheService] }) export class CacheModule {} diff --git a/apps/api/src/app/import/import.module.ts b/apps/api/src/app/import/import.module.ts index 35781e499..03ff2d3f8 100644 --- a/apps/api/src/app/import/import.module.ts +++ b/apps/api/src/app/import/import.module.ts @@ -1,4 +1,4 @@ -import { CacheService } from '@ghostfolio/api/app/cache/cache.service'; +import { CacheModule } from '@ghostfolio/api/app/cache/cache.module'; import { OrderModule } from '@ghostfolio/api/app/order/order.module'; import { RedisCacheModule } from '@ghostfolio/api/app/redis-cache/redis-cache.module'; import { ConfigurationModule } from '@ghostfolio/api/services/configuration.module'; @@ -11,7 +11,9 @@ import { ImportController } from './import.controller'; import { ImportService } from './import.service'; @Module({ + controllers: [ImportController], imports: [ + CacheModule, ConfigurationModule, DataGatheringModule, DataProviderModule, @@ -19,7 +21,6 @@ import { ImportService } from './import.service'; PrismaModule, RedisCacheModule ], - controllers: [ImportController], - providers: [CacheService, ImportService] + providers: [ImportService] }) export class ImportModule {} diff --git a/apps/api/src/app/info/info.module.ts b/apps/api/src/app/info/info.module.ts index 50edd0eed..5828ac963 100644 --- a/apps/api/src/app/info/info.module.ts +++ b/apps/api/src/app/info/info.module.ts @@ -1,10 +1,9 @@ import { RedisCacheModule } from '@ghostfolio/api/app/redis-cache/redis-cache.module'; -import { ConfigurationService } from '@ghostfolio/api/services/configuration.service'; +import { ConfigurationModule } from '@ghostfolio/api/services/configuration.module'; import { DataGatheringModule } from '@ghostfolio/api/services/data-gathering.module'; -import { DataGatheringService } from '@ghostfolio/api/services/data-gathering.service'; import { DataProviderModule } from '@ghostfolio/api/services/data-provider/data-provider.module'; import { ExchangeRateDataModule } from '@ghostfolio/api/services/exchange-rate-data.module'; -import { PrismaService } from '@ghostfolio/api/services/prisma.service'; +import { PrismaModule } from '@ghostfolio/api/services/prisma.module'; import { PropertyModule } from '@ghostfolio/api/services/property/property.module'; import { SymbolProfileModule } from '@ghostfolio/api/services/symbol-profile.module'; import { Module } from '@nestjs/common'; @@ -14,7 +13,9 @@ import { InfoController } from './info.controller'; import { InfoService } from './info.service'; @Module({ + controllers: [InfoController], imports: [ + ConfigurationModule, DataGatheringModule, DataProviderModule, ExchangeRateDataModule, @@ -22,16 +23,11 @@ import { InfoService } from './info.service'; secret: process.env.JWT_SECRET_KEY, signOptions: { expiresIn: '30 days' } }), + PrismaModule, PropertyModule, RedisCacheModule, SymbolProfileModule ], - controllers: [InfoController], - providers: [ - ConfigurationService, - DataGatheringService, - InfoService, - PrismaService - ] + providers: [InfoService] }) export class InfoModule {} diff --git a/apps/api/src/app/order/order.module.ts b/apps/api/src/app/order/order.module.ts index f2c790ce8..52ffc0266 100644 --- a/apps/api/src/app/order/order.module.ts +++ b/apps/api/src/app/order/order.module.ts @@ -1,5 +1,5 @@ import { AccountService } from '@ghostfolio/api/app/account/account.service'; -import { CacheService } from '@ghostfolio/api/app/cache/cache.service'; +import { CacheModule } from '@ghostfolio/api/app/cache/cache.module'; import { RedisCacheModule } from '@ghostfolio/api/app/redis-cache/redis-cache.module'; import { UserModule } from '@ghostfolio/api/app/user/user.module'; import { ConfigurationModule } from '@ghostfolio/api/services/configuration.module'; @@ -15,7 +15,10 @@ import { OrderController } from './order.controller'; import { OrderService } from './order.service'; @Module({ + controllers: [OrderController], + exports: [OrderService], imports: [ + CacheModule, ConfigurationModule, DataGatheringModule, DataProviderModule, @@ -26,8 +29,6 @@ import { OrderService } from './order.service'; SymbolProfileModule, UserModule ], - controllers: [OrderController], - providers: [AccountService, CacheService, OrderService], - exports: [OrderService] + providers: [AccountService, OrderService] }) export class OrderModule {} diff --git a/apps/api/src/app/portfolio/portfolio.module.ts b/apps/api/src/app/portfolio/portfolio.module.ts index 85bc98e7a..5204f1795 100644 --- a/apps/api/src/app/portfolio/portfolio.module.ts +++ b/apps/api/src/app/portfolio/portfolio.module.ts @@ -20,6 +20,7 @@ import { PortfolioServiceNew } from './portfolio.service-new'; import { RulesService } from './rules.service'; @Module({ + controllers: [PortfolioController], exports: [PortfolioServiceStrategy], imports: [ AccessModule, @@ -34,7 +35,6 @@ import { RulesService } from './rules.service'; SymbolProfileModule, UserModule ], - controllers: [PortfolioController], providers: [ AccountService, CurrentRateService, diff --git a/apps/api/src/app/redis-cache/redis-cache.module.ts b/apps/api/src/app/redis-cache/redis-cache.module.ts index e3275276b..dcda94041 100644 --- a/apps/api/src/app/redis-cache/redis-cache.module.ts +++ b/apps/api/src/app/redis-cache/redis-cache.module.ts @@ -1,3 +1,4 @@ +import { ConfigurationModule } from '@ghostfolio/api/services/configuration.module'; import { ConfigurationService } from '@ghostfolio/api/services/configuration.service'; import { CacheModule, Module } from '@nestjs/common'; import { ConfigModule, ConfigService } from '@nestjs/config'; @@ -17,9 +18,10 @@ import { RedisCacheService } from './redis-cache.service'; store: redisStore, ttl: configurationService.get('CACHE_TTL') }) - }) + }), + ConfigurationModule ], - providers: [ConfigurationService, RedisCacheService], + providers: [RedisCacheService], exports: [RedisCacheService] }) export class RedisCacheModule {} diff --git a/apps/api/src/app/subscription/subscription.module.ts b/apps/api/src/app/subscription/subscription.module.ts index 95d16fb4d..df0861657 100644 --- a/apps/api/src/app/subscription/subscription.module.ts +++ b/apps/api/src/app/subscription/subscription.module.ts @@ -1,5 +1,5 @@ -import { ConfigurationService } from '@ghostfolio/api/services/configuration.service'; -import { PrismaService } from '@ghostfolio/api/services/prisma.service'; +import { ConfigurationModule } from '@ghostfolio/api/services/configuration.module'; +import { PrismaModule } from '@ghostfolio/api/services/prisma.module'; import { PropertyModule } from '@ghostfolio/api/services/property/property.module'; import { Module } from '@nestjs/common'; @@ -7,9 +7,9 @@ import { SubscriptionController } from './subscription.controller'; import { SubscriptionService } from './subscription.service'; @Module({ - imports: [PropertyModule], controllers: [SubscriptionController], - providers: [ConfigurationService, PrismaService, SubscriptionService], - exports: [SubscriptionService] + exports: [SubscriptionService], + imports: [ConfigurationModule, PrismaModule, PropertyModule], + providers: [SubscriptionService] }) export class SubscriptionModule {} diff --git a/apps/api/src/app/user/user.module.ts b/apps/api/src/app/user/user.module.ts index ffbdc80db..976f5b6c3 100644 --- a/apps/api/src/app/user/user.module.ts +++ b/apps/api/src/app/user/user.module.ts @@ -1,6 +1,6 @@ import { SubscriptionModule } from '@ghostfolio/api/app/subscription/subscription.module'; -import { ConfigurationService } from '@ghostfolio/api/services/configuration.service'; -import { PrismaService } from '@ghostfolio/api/services/prisma.service'; +import { ConfigurationModule } from '@ghostfolio/api/services/configuration.module'; +import { PrismaModule } from '@ghostfolio/api/services/prisma.module'; import { PropertyModule } from '@ghostfolio/api/services/property/property.module'; import { Module } from '@nestjs/common'; import { JwtModule } from '@nestjs/jwt'; @@ -9,16 +9,18 @@ import { UserController } from './user.controller'; import { UserService } from './user.service'; @Module({ + controllers: [UserController], + exports: [UserService], imports: [ + ConfigurationModule, JwtModule.register({ secret: process.env.JWT_SECRET_KEY, signOptions: { expiresIn: '30 days' } }), + PrismaModule, PropertyModule, SubscriptionModule ], - controllers: [UserController], - providers: [ConfigurationService, PrismaService, UserService], - exports: [UserService] + providers: [UserService] }) export class UserModule {}