csehatt741 1 day ago
committed by GitHub
parent
commit
27b0774e53
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 1
      CHANGELOG.md
  2. 5
      apps/api/src/app/admin/admin.service.ts
  3. 8
      apps/api/src/app/endpoints/ai/ai.service.ts
  4. 4
      apps/api/src/app/endpoints/data-providers/ghostfolio/ghostfolio.service.ts
  5. 20
      apps/api/src/app/info/info.service.ts
  6. 3
      apps/api/src/app/subscription/subscription.controller.ts
  7. 6
      apps/api/src/app/subscription/subscription.service.ts
  8. 11
      apps/api/src/app/user/user.service.ts
  9. 12
      apps/api/src/services/benchmark/benchmark.service.ts
  10. 8
      apps/api/src/services/data-provider/data-provider.service.ts
  11. 4
      apps/api/src/services/data-provider/ghostfolio/ghostfolio.service.ts
  12. 8
      apps/api/src/services/demo/demo.service.ts
  13. 5
      apps/api/src/services/exchange-rate-data/exchange-rate-data.service.ts
  14. 7
      apps/api/src/services/property/property.service.ts
  15. 4
      apps/api/src/services/queues/data-gathering/data-gathering.service.ts

1
CHANGELOG.md

@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Enhanced the sitemap to dynamically compose public routes
- Renamed `Account` to `account` in the `Order` database schema
- Improved the language localization for German (`de`)
- Improved `PropertyService` by making `getByKey()` function generic
## 2.175.0 - 2025-06-28

5
apps/api/src/app/admin/admin.service.ts

@ -114,9 +114,8 @@ export class AdminService {
await this.marketDataService.deleteMany({ dataSource, symbol });
const currency = getCurrencyFromSymbol(symbol);
const customCurrencies = (await this.propertyService.getByKey(
PROPERTY_CURRENCIES
)) as string[];
const customCurrencies =
await this.propertyService.getByKey<string[]>(PROPERTY_CURRENCIES);
if (customCurrencies.includes(currency)) {
const updatedCustomCurrencies = customCurrencies.filter(

8
apps/api/src/app/endpoints/ai/ai.service.ts

@ -19,13 +19,13 @@ export class AiService {
) {}
public async generateText({ prompt }: { prompt: string }) {
const openRouterApiKey = (await this.propertyService.getByKey(
const openRouterApiKey = await this.propertyService.getByKey<string>(
PROPERTY_API_KEY_OPENROUTER
)) as string;
);
const openRouterModel = (await this.propertyService.getByKey(
const openRouterModel = await this.propertyService.getByKey<string>(
PROPERTY_OPENROUTER_MODEL
)) as string;
);
const openRouterService = createOpenRouter({
apiKey: openRouterApiKey

4
apps/api/src/app/endpoints/data-providers/ghostfolio/ghostfolio.service.ts

@ -164,9 +164,9 @@ export class GhostfolioService {
public async getMaxDailyRequests() {
return parseInt(
((await this.propertyService.getByKey(
(await this.propertyService.getByKey<string>(
PROPERTY_DATA_SOURCES_GHOSTFOLIO_DATA_PROVIDER_MAX_REQUESTS
)) as string) || '0',
)) || '0',
10
);
}

20
apps/api/src/app/info/info.service.ts

@ -64,9 +64,9 @@ export class InfoService {
}
if (this.configurationService.get('ENABLE_FEATURE_READ_ONLY_MODE')) {
isReadOnlyMode = (await this.propertyService.getByKey(
isReadOnlyMode = await this.propertyService.getByKey<boolean>(
PROPERTY_IS_READ_ONLY_MODE
)) as boolean;
);
}
if (this.configurationService.get('ENABLE_FEATURE_SOCIAL_LOGIN')) {
@ -81,9 +81,9 @@ export class InfoService {
globalPermissions.push(permissions.enableSubscription);
info.countriesOfSubscribers =
((await this.propertyService.getByKey(
(await this.propertyService.getByKey<string[]>(
PROPERTY_COUNTRIES_OF_SUBSCRIBERS
)) as string[]) ?? [];
)) ?? [];
info.stripePublicKey = this.configurationService.get('STRIPE_PUBLIC_KEY');
}
@ -230,15 +230,15 @@ export class InfoService {
}
private async countSlackCommunityUsers() {
return (await this.propertyService.getByKey(
return await this.propertyService.getByKey<string>(
PROPERTY_SLACK_COMMUNITY_USERS
)) as string;
);
}
private async getDemoAuthToken() {
const demoUserId = (await this.propertyService.getByKey(
const demoUserId = await this.propertyService.getByKey<string>(
PROPERTY_DEMO_USER_ID
)) as string;
);
if (demoUserId) {
return this.jwtService.sign({
@ -298,9 +298,9 @@ export class InfoService {
private async getUptime(): Promise<number> {
{
try {
const monitorId = (await this.propertyService.getByKey(
const monitorId = await this.propertyService.getByKey<string>(
PROPERTY_BETTER_UPTIME_MONITOR_ID
)) as string;
);
const { data } = await fetch(
`https://uptime.betterstack.com/api/v2/monitors/${monitorId}/sla?from=${format(

3
apps/api/src/app/subscription/subscription.controller.ts

@ -49,8 +49,7 @@ export class SubscriptionController {
}
let coupons =
((await this.propertyService.getByKey(PROPERTY_COUPONS)) as Coupon[]) ??
[];
(await this.propertyService.getByKey<Coupon[]>(PROPERTY_COUPONS)) ?? [];
const coupon = coupons.find((currentCoupon) => {
return currentCoupon.code === couponCode;

6
apps/api/src/app/subscription/subscription.service.ts

@ -50,8 +50,7 @@ export class SubscriptionService {
const subscriptionOffers: {
[offer in SubscriptionOfferKey]: SubscriptionOffer;
} =
((await this.propertyService.getByKey(PROPERTY_STRIPE_CONFIG)) as any) ??
{};
(await this.propertyService.getByKey<any>(PROPERTY_STRIPE_CONFIG)) ?? {};
const subscriptionOffer = Object.values(subscriptionOffers).find(
(subscriptionOffer) => {
@ -213,8 +212,7 @@ export class SubscriptionService {
const offers: {
[offer in SubscriptionOfferKey]: SubscriptionOffer;
} =
((await this.propertyService.getByKey(PROPERTY_STRIPE_CONFIG)) as any) ??
{};
(await this.propertyService.getByKey<any>(PROPERTY_STRIPE_CONFIG)) ?? {};
return {
...offers[key],

11
apps/api/src/app/user/user.service.ts

@ -125,9 +125,10 @@ export class UserService {
let systemMessage: SystemMessage;
const systemMessageProperty = (await this.propertyService.getByKey(
PROPERTY_SYSTEM_MESSAGE
)) as SystemMessage;
const systemMessageProperty =
await this.propertyService.getByKey<SystemMessage>(
PROPERTY_SYSTEM_MESSAGE
);
if (systemMessageProperty?.targetGroups?.includes(subscription?.type)) {
systemMessage = systemMessageProperty;
@ -443,9 +444,9 @@ export class UserService {
currentPermissions.push(permissions.toggleReadOnlyMode);
}
const isReadOnlyMode = (await this.propertyService.getByKey(
const isReadOnlyMode = await this.propertyService.getByKey<boolean>(
PROPERTY_IS_READ_ONLY_MODE
)) as boolean;
);
if (isReadOnlyMode) {
currentPermissions = currentPermissions.filter((permission) => {

12
apps/api/src/services/benchmark/benchmark.service.ts

@ -106,9 +106,9 @@ export class BenchmarkService {
enableSharing = false
} = {}): Promise<Partial<SymbolProfile>[]> {
const symbolProfileIds: string[] = (
((await this.propertyService.getByKey(
(await this.propertyService.getByKey<BenchmarkProperty[]>(
PROPERTY_BENCHMARKS
)) as BenchmarkProperty[]) ?? []
)) ?? []
)
.filter((benchmark) => {
if (enableSharing) {
@ -154,9 +154,9 @@ export class BenchmarkService {
}
let benchmarks =
((await this.propertyService.getByKey(
(await this.propertyService.getByKey<BenchmarkProperty[]>(
PROPERTY_BENCHMARKS
)) as BenchmarkProperty[]) ?? [];
)) ?? [];
benchmarks.push({ symbolProfileId: assetProfile.id });
@ -191,9 +191,9 @@ export class BenchmarkService {
}
let benchmarks =
((await this.propertyService.getByKey(
(await this.propertyService.getByKey<BenchmarkProperty[]>(
PROPERTY_BENCHMARKS
)) as BenchmarkProperty[]) ?? [];
)) ?? [];
benchmarks = benchmarks.filter(({ symbolProfileId }) => {
return symbolProfileId !== assetProfile.id;

8
apps/api/src/services/data-provider/data-provider.service.ts

@ -52,9 +52,9 @@ export class DataProviderService implements OnModuleInit {
public async onModuleInit() {
this.dataProviderMapping =
((await this.propertyService.getByKey(PROPERTY_DATA_SOURCE_MAPPING)) as {
(await this.propertyService.getByKey<{
[dataProviderName: string]: string;
}) ?? {};
}>(PROPERTY_DATA_SOURCE_MAPPING)) ?? {};
}
public async checkQuote(dataSource: DataSource) {
@ -183,9 +183,9 @@ export class DataProviderService implements OnModuleInit {
return DataSource[dataSource];
});
const ghostfolioApiKey = (await this.propertyService.getByKey(
const ghostfolioApiKey = await this.propertyService.getByKey<string>(
PROPERTY_API_KEY_GHOSTFOLIO
)) as string;
);
if (includeGhostfolio || ghostfolioApiKey) {
dataSources.push('GHOSTFOLIO');

4
apps/api/src/services/data-provider/ghostfolio/ghostfolio.service.ts

@ -295,9 +295,9 @@ export class GhostfolioService implements DataProviderInterface {
}
private async getRequestHeaders() {
const apiKey = (await this.propertyService.getByKey(
const apiKey = await this.propertyService.getByKey<string>(
PROPERTY_API_KEY_GHOSTFOLIO
)) as string;
);
return {
[HEADER_KEY_TOKEN]: `Api-Key ${apiKey}`

8
apps/api/src/services/demo/demo.service.ts

@ -17,10 +17,10 @@ export class DemoService {
) {}
public async syncDemoUserAccount() {
const [demoAccountId, demoUserId] = (await Promise.all([
this.propertyService.getByKey(PROPERTY_DEMO_ACCOUNT_ID),
this.propertyService.getByKey(PROPERTY_DEMO_USER_ID)
])) as [string, string];
const [demoAccountId, demoUserId] = await Promise.all([
this.propertyService.getByKey<string>(PROPERTY_DEMO_ACCOUNT_ID),
this.propertyService.getByKey<string>(PROPERTY_DEMO_USER_ID)
]);
let activities = await this.prismaService.order.findMany({
orderBy: {

5
apps/api/src/services/exchange-rate-data/exchange-rate-data.service.ts

@ -497,9 +497,8 @@ export class ExchangeRateDataService {
currencies.push(currency);
});
const customCurrencies = (await this.propertyService.getByKey(
PROPERTY_CURRENCIES
)) as string[];
const customCurrencies =
await this.propertyService.getByKey<string[]>(PROPERTY_CURRENCIES);
if (customCurrencies?.length > 0) {
currencies = currencies.concat(customCurrencies);

7
apps/api/src/services/property/property.service.ts

@ -38,15 +38,14 @@ export class PropertyService {
return response;
}
public async getByKey(aKey: string) {
public async getByKey<TKey>(aKey: string): Promise<TKey | undefined> {
const properties = await this.get();
return properties?.[aKey];
return properties?.[aKey] as TKey;
}
public async isUserSignupEnabled() {
return (
((await this.getByKey(PROPERTY_IS_USER_SIGNUP_ENABLED)) as boolean) ??
true
(await this.getByKey<boolean>(PROPERTY_IS_USER_SIGNUP_ENABLED)) ?? true
);
}

4
apps/api/src/services/queues/data-gathering/data-gathering.service.ts

@ -406,9 +406,9 @@ export class DataGatheringService {
private async getSymbolsMax(): Promise<IDataGatheringItem[]> {
const benchmarkAssetProfileIdMap: { [key: string]: boolean } = {};
(
((await this.propertyService.getByKey(
(await this.propertyService.getByKey<BenchmarkProperty[]>(
PROPERTY_BENCHMARKS
)) as BenchmarkProperty[]) ?? []
)) ?? []
).forEach(({ symbolProfileId }) => {
benchmarkAssetProfileIdMap[symbolProfileId] = true;
});

Loading…
Cancel
Save