Simplify initial project setup (#12)
* Simplify initial project setup * Added a validation for environment variables * Added support for feature flags to simplify the initial project setup * Add configuration service to test * Optimize data gathering and exchange rate calculation (#14) * Clean up changelog
This commit is contained in:
parent
fed10c7110
commit
5d1f1b452a
7
.env
7
.env
@ -1,8 +1,6 @@
|
|||||||
COMPOSE_PROJECT_NAME=ghostfolio-development
|
COMPOSE_PROJECT_NAME=ghostfolio-development
|
||||||
|
|
||||||
# CACHE
|
# CACHE
|
||||||
CACHE_TTL=1
|
|
||||||
MAX_ITEM_IN_CACHE=9999
|
|
||||||
REDIS_HOST=localhost
|
REDIS_HOST=localhost
|
||||||
REDIS_PORT=6379
|
REDIS_PORT=6379
|
||||||
|
|
||||||
@ -14,10 +12,5 @@ POSTGRES_DB=ghostfolio-db
|
|||||||
ACCESS_TOKEN_SALT=GHOSTFOLIO
|
ACCESS_TOKEN_SALT=GHOSTFOLIO
|
||||||
ALPHA_VANTAGE_API_KEY=
|
ALPHA_VANTAGE_API_KEY=
|
||||||
DATABASE_URL=postgresql://user:password@localhost:5432/ghostfolio-db?sslmode=prefer
|
DATABASE_URL=postgresql://user:password@localhost:5432/ghostfolio-db?sslmode=prefer
|
||||||
GOOGLE_CLIENT_ID=test
|
|
||||||
GOOGLE_SECRET=test
|
|
||||||
IS_DEVELOPMENT_MODE=true
|
|
||||||
JWT_SECRET_KEY=123456
|
JWT_SECRET_KEY=123456
|
||||||
PORT=3333
|
PORT=3333
|
||||||
RAKUTEN_RAPID_API_KEY=
|
|
||||||
ROOT_URL=http://localhost:4200
|
|
||||||
|
@ -10,10 +10,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
### Added
|
### Added
|
||||||
|
|
||||||
- Added the license to the about page
|
- Added the license to the about page
|
||||||
|
- Added a validation for environment variables
|
||||||
|
- Added support for feature flags to simplify the initial project setup
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
- Changed the about page for the new license
|
- Changed the about page for the new license
|
||||||
|
- Optimized the data management for historical data
|
||||||
|
- Optimized the exchange rate service
|
||||||
|
|
||||||
## 0.85.0 - 16.04.2021
|
## 0.85.0 - 16.04.2021
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import { Module } from '@nestjs/common';
|
import { Module } from '@nestjs/common';
|
||||||
|
|
||||||
|
import { ConfigurationService } from '../../services/configuration.service';
|
||||||
import { DataGatheringService } from '../../services/data-gathering.service';
|
import { DataGatheringService } from '../../services/data-gathering.service';
|
||||||
import { DataProviderService } from '../../services/data-provider.service';
|
import { DataProviderService } from '../../services/data-provider.service';
|
||||||
import { AlphaVantageService } from '../../services/data-provider/alpha-vantage/alpha-vantage.service';
|
import { AlphaVantageService } from '../../services/data-provider/alpha-vantage/alpha-vantage.service';
|
||||||
@ -16,6 +17,7 @@ import { AdminService } from './admin.service';
|
|||||||
providers: [
|
providers: [
|
||||||
AdminService,
|
AdminService,
|
||||||
AlphaVantageService,
|
AlphaVantageService,
|
||||||
|
ConfigurationService,
|
||||||
DataGatheringService,
|
DataGatheringService,
|
||||||
DataProviderService,
|
DataProviderService,
|
||||||
ExchangeRateDataService,
|
ExchangeRateDataService,
|
||||||
|
@ -5,6 +5,7 @@ import { ConfigModule } from '@nestjs/config';
|
|||||||
import { ScheduleModule } from '@nestjs/schedule';
|
import { ScheduleModule } from '@nestjs/schedule';
|
||||||
import { ServeStaticModule } from '@nestjs/serve-static';
|
import { ServeStaticModule } from '@nestjs/serve-static';
|
||||||
|
|
||||||
|
import { ConfigurationService } from '../services/configuration.service';
|
||||||
import { CronService } from '../services/cron.service';
|
import { CronService } from '../services/cron.service';
|
||||||
import { DataGatheringService } from '../services/data-gathering.service';
|
import { DataGatheringService } from '../services/data-gathering.service';
|
||||||
import { DataProviderService } from '../services/data-provider.service';
|
import { DataProviderService } from '../services/data-provider.service';
|
||||||
@ -59,6 +60,7 @@ import { UserModule } from './user/user.module';
|
|||||||
controllers: [AppController],
|
controllers: [AppController],
|
||||||
providers: [
|
providers: [
|
||||||
AlphaVantageService,
|
AlphaVantageService,
|
||||||
|
ConfigurationService,
|
||||||
CronService,
|
CronService,
|
||||||
DataGatheringService,
|
DataGatheringService,
|
||||||
DataProviderService,
|
DataProviderService,
|
||||||
|
@ -10,11 +10,15 @@ import {
|
|||||||
import { AuthGuard } from '@nestjs/passport';
|
import { AuthGuard } from '@nestjs/passport';
|
||||||
import { StatusCodes, getReasonPhrase } from 'http-status-codes';
|
import { StatusCodes, getReasonPhrase } from 'http-status-codes';
|
||||||
|
|
||||||
|
import { ConfigurationService } from '../../services/configuration.service';
|
||||||
import { AuthService } from './auth.service';
|
import { AuthService } from './auth.service';
|
||||||
|
|
||||||
@Controller('auth')
|
@Controller('auth')
|
||||||
export class AuthController {
|
export class AuthController {
|
||||||
public constructor(private readonly authService: AuthService) {}
|
public constructor(
|
||||||
|
private readonly authService: AuthService,
|
||||||
|
private readonly configurationService: ConfigurationService
|
||||||
|
) {}
|
||||||
|
|
||||||
@Get('anonymous/:accessToken')
|
@Get('anonymous/:accessToken')
|
||||||
public async accessTokenLogin(@Param('accessToken') accessToken: string) {
|
public async accessTokenLogin(@Param('accessToken') accessToken: string) {
|
||||||
@ -44,9 +48,9 @@ export class AuthController {
|
|||||||
const jwt: string = req.user.jwt;
|
const jwt: string = req.user.jwt;
|
||||||
|
|
||||||
if (jwt) {
|
if (jwt) {
|
||||||
res.redirect(`${process.env.ROOT_URL}/auth/${jwt}`);
|
res.redirect(`${this.configurationService.get('ROOT_URL')}/auth/${jwt}`);
|
||||||
} else {
|
} else {
|
||||||
res.redirect(`${process.env.ROOT_URL}/auth`);
|
res.redirect(`${this.configurationService.get('ROOT_URL')}/auth`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import { Module } from '@nestjs/common';
|
import { Module } from '@nestjs/common';
|
||||||
import { JwtModule } from '@nestjs/jwt';
|
import { JwtModule } from '@nestjs/jwt';
|
||||||
|
|
||||||
|
import { ConfigurationService } from '../../services/configuration.service';
|
||||||
import { PrismaService } from '../../services/prisma.service';
|
import { PrismaService } from '../../services/prisma.service';
|
||||||
import { UserService } from '../user/user.service';
|
import { UserService } from '../user/user.service';
|
||||||
import { AuthController } from './auth.controller';
|
import { AuthController } from './auth.controller';
|
||||||
@ -18,6 +19,7 @@ import { JwtStrategy } from './jwt.strategy';
|
|||||||
],
|
],
|
||||||
providers: [
|
providers: [
|
||||||
AuthService,
|
AuthService,
|
||||||
|
ConfigurationService,
|
||||||
GoogleStrategy,
|
GoogleStrategy,
|
||||||
JwtStrategy,
|
JwtStrategy,
|
||||||
PrismaService,
|
PrismaService,
|
||||||
|
@ -1,13 +1,15 @@
|
|||||||
import { Injectable, InternalServerErrorException } from '@nestjs/common';
|
import { Injectable, InternalServerErrorException } from '@nestjs/common';
|
||||||
import { JwtService } from '@nestjs/jwt';
|
import { JwtService } from '@nestjs/jwt';
|
||||||
|
|
||||||
|
import { ConfigurationService } from '../../services/configuration.service';
|
||||||
import { UserService } from '../user/user.service';
|
import { UserService } from '../user/user.service';
|
||||||
import { ValidateOAuthLoginParams } from './interfaces/interfaces';
|
import { ValidateOAuthLoginParams } from './interfaces/interfaces';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class AuthService {
|
export class AuthService {
|
||||||
public constructor(
|
public constructor(
|
||||||
private jwtService: JwtService,
|
private readonly configurationService: ConfigurationService,
|
||||||
|
private readonly jwtService: JwtService,
|
||||||
private readonly userService: UserService
|
private readonly userService: UserService
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
@ -16,7 +18,7 @@ export class AuthService {
|
|||||||
try {
|
try {
|
||||||
const hashedAccessToken = this.userService.createAccessToken(
|
const hashedAccessToken = this.userService.createAccessToken(
|
||||||
accessToken,
|
accessToken,
|
||||||
process.env.ACCESS_TOKEN_SALT
|
this.configurationService.get('ACCESS_TOKEN_SALT')
|
||||||
);
|
);
|
||||||
|
|
||||||
const [user] = await this.userService.users({
|
const [user] = await this.userService.users({
|
||||||
|
@ -3,15 +3,21 @@ import { PassportStrategy } from '@nestjs/passport';
|
|||||||
import { Provider } from '@prisma/client';
|
import { Provider } from '@prisma/client';
|
||||||
import { Strategy } from 'passport-google-oauth20';
|
import { Strategy } from 'passport-google-oauth20';
|
||||||
|
|
||||||
|
import { ConfigurationService } from '../../services/configuration.service';
|
||||||
import { AuthService } from './auth.service';
|
import { AuthService } from './auth.service';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class GoogleStrategy extends PassportStrategy(Strategy, 'google') {
|
export class GoogleStrategy extends PassportStrategy(Strategy, 'google') {
|
||||||
public constructor(private readonly authService: AuthService) {
|
public constructor(
|
||||||
|
private readonly authService: AuthService,
|
||||||
|
readonly configurationService: ConfigurationService
|
||||||
|
) {
|
||||||
super({
|
super({
|
||||||
callbackURL: `${process.env.ROOT_URL}/api/auth/google/callback`,
|
callbackURL: `${configurationService.get(
|
||||||
clientID: process.env.GOOGLE_CLIENT_ID,
|
'ROOT_URL'
|
||||||
clientSecret: process.env.GOOGLE_SECRET,
|
)}/api/auth/google/callback`,
|
||||||
|
clientID: configurationService.get('GOOGLE_CLIENT_ID'),
|
||||||
|
clientSecret: configurationService.get('GOOGLE_SECRET'),
|
||||||
passReqToCallback: true,
|
passReqToCallback: true,
|
||||||
scope: ['email', 'profile']
|
scope: ['email', 'profile']
|
||||||
});
|
});
|
||||||
|
@ -2,18 +2,20 @@ import { Injectable, UnauthorizedException } from '@nestjs/common';
|
|||||||
import { PassportStrategy } from '@nestjs/passport';
|
import { PassportStrategy } from '@nestjs/passport';
|
||||||
import { ExtractJwt, Strategy } from 'passport-jwt';
|
import { ExtractJwt, Strategy } from 'passport-jwt';
|
||||||
|
|
||||||
|
import { ConfigurationService } from '../../services/configuration.service';
|
||||||
import { PrismaService } from '../../services/prisma.service';
|
import { PrismaService } from '../../services/prisma.service';
|
||||||
import { UserService } from '../user/user.service';
|
import { UserService } from '../user/user.service';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class JwtStrategy extends PassportStrategy(Strategy, 'jwt') {
|
export class JwtStrategy extends PassportStrategy(Strategy, 'jwt') {
|
||||||
public constructor(
|
public constructor(
|
||||||
|
readonly configurationService: ConfigurationService,
|
||||||
private prisma: PrismaService,
|
private prisma: PrismaService,
|
||||||
private readonly userService: UserService
|
private readonly userService: UserService
|
||||||
) {
|
) {
|
||||||
super({
|
super({
|
||||||
jwtFromRequest: ExtractJwt.fromAuthHeaderAsBearerToken(),
|
jwtFromRequest: ExtractJwt.fromAuthHeaderAsBearerToken(),
|
||||||
secretOrKey: process.env.JWT_SECRET_KEY
|
secretOrKey: configurationService.get('JWT_SECRET_KEY')
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import { Module } from '@nestjs/common';
|
import { Module } from '@nestjs/common';
|
||||||
|
|
||||||
|
import { ConfigurationService } from '../../services/configuration.service';
|
||||||
import { DataProviderService } from '../../services/data-provider.service';
|
import { DataProviderService } from '../../services/data-provider.service';
|
||||||
import { AlphaVantageService } from '../../services/data-provider/alpha-vantage/alpha-vantage.service';
|
import { AlphaVantageService } from '../../services/data-provider/alpha-vantage/alpha-vantage.service';
|
||||||
import { RakutenRapidApiService } from '../../services/data-provider/rakuten-rapid-api/rakuten-rapid-api.service';
|
import { RakutenRapidApiService } from '../../services/data-provider/rakuten-rapid-api/rakuten-rapid-api.service';
|
||||||
@ -15,6 +16,7 @@ import { ExperimentalService } from './experimental.service';
|
|||||||
controllers: [ExperimentalController],
|
controllers: [ExperimentalController],
|
||||||
providers: [
|
providers: [
|
||||||
AlphaVantageService,
|
AlphaVantageService,
|
||||||
|
ConfigurationService,
|
||||||
DataProviderService,
|
DataProviderService,
|
||||||
ExchangeRateDataService,
|
ExchangeRateDataService,
|
||||||
ExperimentalService,
|
ExperimentalService,
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import { Module } from '@nestjs/common';
|
import { Module } from '@nestjs/common';
|
||||||
import { JwtModule } from '@nestjs/jwt';
|
import { JwtModule } from '@nestjs/jwt';
|
||||||
|
|
||||||
|
import { ConfigurationService } from '../../services/configuration.service';
|
||||||
import { PrismaService } from '../../services/prisma.service';
|
import { PrismaService } from '../../services/prisma.service';
|
||||||
import { InfoController } from './info.controller';
|
import { InfoController } from './info.controller';
|
||||||
import { InfoService } from './info.service';
|
import { InfoService } from './info.service';
|
||||||
@ -13,6 +14,6 @@ import { InfoService } from './info.service';
|
|||||||
})
|
})
|
||||||
],
|
],
|
||||||
controllers: [InfoController],
|
controllers: [InfoController],
|
||||||
providers: [InfoService, PrismaService]
|
providers: [ConfigurationService, InfoService, PrismaService]
|
||||||
})
|
})
|
||||||
export class InfoModule {}
|
export class InfoModule {}
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
|
import { permissions } from '@ghostfolio/helper';
|
||||||
import { Injectable } from '@nestjs/common';
|
import { Injectable } from '@nestjs/common';
|
||||||
import { JwtService } from '@nestjs/jwt';
|
import { JwtService } from '@nestjs/jwt';
|
||||||
import { Currency } from '@prisma/client';
|
import { Currency } from '@prisma/client';
|
||||||
|
|
||||||
|
import { ConfigurationService } from '../../services/configuration.service';
|
||||||
import { PrismaService } from '../../services/prisma.service';
|
import { PrismaService } from '../../services/prisma.service';
|
||||||
import { InfoItem } from './interfaces/info-item.interface';
|
import { InfoItem } from './interfaces/info-item.interface';
|
||||||
|
|
||||||
@ -10,6 +12,7 @@ export class InfoService {
|
|||||||
private static DEMO_USER_ID = '9b112b4d-3b7d-4bad-9bdd-3b0f7b4dac2f';
|
private static DEMO_USER_ID = '9b112b4d-3b7d-4bad-9bdd-3b0f7b4dac2f';
|
||||||
|
|
||||||
public constructor(
|
public constructor(
|
||||||
|
private readonly configurationService: ConfigurationService,
|
||||||
private jwtService: JwtService,
|
private jwtService: JwtService,
|
||||||
private prisma: PrismaService
|
private prisma: PrismaService
|
||||||
) {}
|
) {}
|
||||||
@ -20,7 +23,14 @@ export class InfoService {
|
|||||||
select: { id: true, name: true }
|
select: { id: true, name: true }
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const globalPermissions: string[] = [];
|
||||||
|
|
||||||
|
if (this.configurationService.get('ENABLE_FEATURE_SOCIAL_LOGIN')) {
|
||||||
|
globalPermissions.push(permissions.useSocialLogin);
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
globalPermissions,
|
||||||
platforms,
|
platforms,
|
||||||
currencies: Object.values(Currency),
|
currencies: Object.values(Currency),
|
||||||
demoAuthToken: this.getDemoAuthToken(),
|
demoAuthToken: this.getDemoAuthToken(),
|
||||||
|
@ -3,6 +3,7 @@ import { Currency } from '@prisma/client';
|
|||||||
export interface InfoItem {
|
export interface InfoItem {
|
||||||
currencies: Currency[];
|
currencies: Currency[];
|
||||||
demoAuthToken: string;
|
demoAuthToken: string;
|
||||||
|
globalPermissions: string[];
|
||||||
lastDataGathering?: Date;
|
lastDataGathering?: Date;
|
||||||
message?: {
|
message?: {
|
||||||
text: string;
|
text: string;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import { Module } from '@nestjs/common';
|
import { Module } from '@nestjs/common';
|
||||||
|
|
||||||
|
import { ConfigurationService } from '../../services/configuration.service';
|
||||||
import { DataGatheringService } from '../../services/data-gathering.service';
|
import { DataGatheringService } from '../../services/data-gathering.service';
|
||||||
import { DataProviderService } from '../../services/data-provider.service';
|
import { DataProviderService } from '../../services/data-provider.service';
|
||||||
import { AlphaVantageService } from '../../services/data-provider/alpha-vantage/alpha-vantage.service';
|
import { AlphaVantageService } from '../../services/data-provider/alpha-vantage/alpha-vantage.service';
|
||||||
@ -18,6 +19,7 @@ import { OrderService } from './order.service';
|
|||||||
providers: [
|
providers: [
|
||||||
AlphaVantageService,
|
AlphaVantageService,
|
||||||
CacheService,
|
CacheService,
|
||||||
|
ConfigurationService,
|
||||||
DataGatheringService,
|
DataGatheringService,
|
||||||
DataProviderService,
|
DataProviderService,
|
||||||
ImpersonationService,
|
ImpersonationService,
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import { Module } from '@nestjs/common';
|
import { Module } from '@nestjs/common';
|
||||||
|
|
||||||
|
import { ConfigurationService } from '../../services/configuration.service';
|
||||||
import { DataGatheringService } from '../../services/data-gathering.service';
|
import { DataGatheringService } from '../../services/data-gathering.service';
|
||||||
import { DataProviderService } from '../../services/data-provider.service';
|
import { DataProviderService } from '../../services/data-provider.service';
|
||||||
import { AlphaVantageService } from '../../services/data-provider/alpha-vantage/alpha-vantage.service';
|
import { AlphaVantageService } from '../../services/data-provider/alpha-vantage/alpha-vantage.service';
|
||||||
@ -22,6 +23,7 @@ import { PortfolioService } from './portfolio.service';
|
|||||||
providers: [
|
providers: [
|
||||||
AlphaVantageService,
|
AlphaVantageService,
|
||||||
CacheService,
|
CacheService,
|
||||||
|
ConfigurationService,
|
||||||
DataGatheringService,
|
DataGatheringService,
|
||||||
DataProviderService,
|
DataProviderService,
|
||||||
ExchangeRateDataService,
|
ExchangeRateDataService,
|
||||||
|
@ -2,6 +2,7 @@ import { CacheModule, Module } from '@nestjs/common';
|
|||||||
import { ConfigModule, ConfigService } from '@nestjs/config';
|
import { ConfigModule, ConfigService } from '@nestjs/config';
|
||||||
import * as redisStore from 'cache-manager-redis-store';
|
import * as redisStore from 'cache-manager-redis-store';
|
||||||
|
|
||||||
|
import { ConfigurationService } from '../../services/configuration.service';
|
||||||
import { RedisCacheService } from './redis-cache.service';
|
import { RedisCacheService } from './redis-cache.service';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
@ -9,16 +10,16 @@ import { RedisCacheService } from './redis-cache.service';
|
|||||||
CacheModule.registerAsync({
|
CacheModule.registerAsync({
|
||||||
imports: [ConfigModule],
|
imports: [ConfigModule],
|
||||||
inject: [ConfigService],
|
inject: [ConfigService],
|
||||||
useFactory: async (configService: ConfigService) => ({
|
useFactory: async (configurationService: ConfigurationService) => ({
|
||||||
host: configService.get('REDIS_HOST'),
|
host: configurationService.get('REDIS_HOST'),
|
||||||
max: configService.get('MAX_ITEM_IN_CACHE'),
|
max: configurationService.get('MAX_ITEM_IN_CACHE'),
|
||||||
port: configService.get('REDIS_PORT'),
|
port: configurationService.get('REDIS_PORT'),
|
||||||
store: redisStore,
|
store: redisStore,
|
||||||
ttl: configService.get('CACHE_TTL')
|
ttl: configurationService.get('CACHE_TTL')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
],
|
],
|
||||||
providers: [RedisCacheService],
|
providers: [ConfigurationService, RedisCacheService],
|
||||||
exports: [RedisCacheService]
|
exports: [RedisCacheService]
|
||||||
})
|
})
|
||||||
export class RedisCacheModule {}
|
export class RedisCacheModule {}
|
||||||
|
@ -1,9 +1,14 @@
|
|||||||
import { CACHE_MANAGER, Inject, Injectable } from '@nestjs/common';
|
import { CACHE_MANAGER, Inject, Injectable } from '@nestjs/common';
|
||||||
import { Cache } from 'cache-manager';
|
import { Cache } from 'cache-manager';
|
||||||
|
|
||||||
|
import { ConfigurationService } from '../../services/configuration.service';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class RedisCacheService {
|
export class RedisCacheService {
|
||||||
public constructor(@Inject(CACHE_MANAGER) private readonly cache: Cache) {}
|
public constructor(
|
||||||
|
@Inject(CACHE_MANAGER) private readonly cache: Cache,
|
||||||
|
private readonly configurationService: ConfigurationService
|
||||||
|
) {}
|
||||||
|
|
||||||
public async get(key: string): Promise<string> {
|
public async get(key: string): Promise<string> {
|
||||||
return await this.cache.get(key);
|
return await this.cache.get(key);
|
||||||
@ -18,6 +23,8 @@ export class RedisCacheService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async set(key: string, value: string) {
|
public async set(key: string, value: string) {
|
||||||
await this.cache.set(key, value, { ttl: Number(process.env.CACHE_TTL) });
|
await this.cache.set(key, value, {
|
||||||
|
ttl: this.configurationService.get('CACHE_TTL')
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import { Module } from '@nestjs/common';
|
import { Module } from '@nestjs/common';
|
||||||
|
|
||||||
|
import { ConfigurationService } from '../../services/configuration.service';
|
||||||
import { DataProviderService } from '../../services/data-provider.service';
|
import { DataProviderService } from '../../services/data-provider.service';
|
||||||
import { AlphaVantageService } from '../../services/data-provider/alpha-vantage/alpha-vantage.service';
|
import { AlphaVantageService } from '../../services/data-provider/alpha-vantage/alpha-vantage.service';
|
||||||
import { RakutenRapidApiService } from '../../services/data-provider/rakuten-rapid-api/rakuten-rapid-api.service';
|
import { RakutenRapidApiService } from '../../services/data-provider/rakuten-rapid-api/rakuten-rapid-api.service';
|
||||||
@ -13,6 +14,7 @@ import { SymbolService } from './symbol.service';
|
|||||||
controllers: [SymbolController],
|
controllers: [SymbolController],
|
||||||
providers: [
|
providers: [
|
||||||
AlphaVantageService,
|
AlphaVantageService,
|
||||||
|
ConfigurationService,
|
||||||
DataProviderService,
|
DataProviderService,
|
||||||
PrismaService,
|
PrismaService,
|
||||||
RakutenRapidApiService,
|
RakutenRapidApiService,
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import { Module } from '@nestjs/common';
|
import { Module } from '@nestjs/common';
|
||||||
import { JwtModule } from '@nestjs/jwt';
|
import { JwtModule } from '@nestjs/jwt';
|
||||||
|
|
||||||
|
import { ConfigurationService } from '../../services/configuration.service';
|
||||||
import { PrismaService } from '../../services/prisma.service';
|
import { PrismaService } from '../../services/prisma.service';
|
||||||
import { UserController } from './user.controller';
|
import { UserController } from './user.controller';
|
||||||
import { UserService } from './user.service';
|
import { UserService } from './user.service';
|
||||||
@ -13,6 +14,6 @@ import { UserService } from './user.service';
|
|||||||
})
|
})
|
||||||
],
|
],
|
||||||
controllers: [UserController],
|
controllers: [UserController],
|
||||||
providers: [PrismaService, UserService]
|
providers: [ConfigurationService, PrismaService, UserService]
|
||||||
})
|
})
|
||||||
export class UserModule {}
|
export class UserModule {}
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
import { Injectable } from '@nestjs/common';
|
import { Injectable } from '@nestjs/common';
|
||||||
import { Currency, Prisma, Provider, User } from '@prisma/client';
|
import { Currency, Prisma, Provider, User } from '@prisma/client';
|
||||||
import { add } from 'date-fns';
|
import { add } from 'date-fns';
|
||||||
import { locale, resetHours } from 'libs/helper/src';
|
import { locale, permissions, resetHours } from 'libs/helper/src';
|
||||||
import { getPermissions } from 'libs/helper/src';
|
import { getPermissions } from 'libs/helper/src';
|
||||||
|
|
||||||
|
import { ConfigurationService } from '../../services/configuration.service';
|
||||||
import { PrismaService } from '../../services/prisma.service';
|
import { PrismaService } from '../../services/prisma.service';
|
||||||
import { UserWithSettings } from '../interfaces/user-with-settings';
|
import { UserWithSettings } from '../interfaces/user-with-settings';
|
||||||
import { User as IUser } from './interfaces/user.interface';
|
import { User as IUser } from './interfaces/user.interface';
|
||||||
@ -14,7 +15,10 @@ const crypto = require('crypto');
|
|||||||
export class UserService {
|
export class UserService {
|
||||||
public static DEFAULT_CURRENCY = Currency.USD;
|
public static DEFAULT_CURRENCY = Currency.USD;
|
||||||
|
|
||||||
public constructor(private prisma: PrismaService) {}
|
public constructor(
|
||||||
|
private readonly configurationService: ConfigurationService,
|
||||||
|
private prisma: PrismaService
|
||||||
|
) {}
|
||||||
|
|
||||||
public async getUser({
|
public async getUser({
|
||||||
alias,
|
alias,
|
||||||
@ -30,6 +34,16 @@ export class UserService {
|
|||||||
where: { GranteeUser: { id } }
|
where: { GranteeUser: { id } }
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const currentPermissions = getPermissions(role);
|
||||||
|
|
||||||
|
if (this.configurationService.get('ENABLE_FEATURE_FEAR_AND_GREED_INDEX')) {
|
||||||
|
currentPermissions.push(permissions.accessFearAndGreedIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.configurationService.get('ENABLE_FEATURE_SOCIAL_LOGIN')) {
|
||||||
|
currentPermissions.push(permissions.useSocialLogin);
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
alias,
|
alias,
|
||||||
id,
|
id,
|
||||||
@ -39,7 +53,7 @@ export class UserService {
|
|||||||
id: accessItem.id
|
id: accessItem.id
|
||||||
};
|
};
|
||||||
}),
|
}),
|
||||||
permissions: getPermissions(role),
|
permissions: currentPermissions,
|
||||||
settings: {
|
settings: {
|
||||||
baseCurrency: Settings?.currency || UserService.DEFAULT_CURRENCY,
|
baseCurrency: Settings?.currency || UserService.DEFAULT_CURRENCY,
|
||||||
locale
|
locale
|
||||||
|
@ -4,6 +4,7 @@ import { baseCurrency } from 'libs/helper/src';
|
|||||||
import { getYesterday } from 'libs/helper/src';
|
import { getYesterday } from 'libs/helper/src';
|
||||||
import { getUtc } from 'libs/helper/src';
|
import { getUtc } from 'libs/helper/src';
|
||||||
|
|
||||||
|
import { ConfigurationService } from '../services/configuration.service';
|
||||||
import { DataProviderService } from '../services/data-provider.service';
|
import { DataProviderService } from '../services/data-provider.service';
|
||||||
import { AlphaVantageService } from '../services/data-provider/alpha-vantage/alpha-vantage.service';
|
import { AlphaVantageService } from '../services/data-provider/alpha-vantage/alpha-vantage.service';
|
||||||
import { RakutenRapidApiService } from '../services/data-provider/rakuten-rapid-api/rakuten-rapid-api.service';
|
import { RakutenRapidApiService } from '../services/data-provider/rakuten-rapid-api/rakuten-rapid-api.service';
|
||||||
@ -15,6 +16,7 @@ import { Portfolio } from './portfolio';
|
|||||||
|
|
||||||
describe('Portfolio', () => {
|
describe('Portfolio', () => {
|
||||||
let alphaVantageService: AlphaVantageService;
|
let alphaVantageService: AlphaVantageService;
|
||||||
|
let configurationService: ConfigurationService;
|
||||||
let dataProviderService: DataProviderService;
|
let dataProviderService: DataProviderService;
|
||||||
let exchangeRateDataService: ExchangeRateDataService;
|
let exchangeRateDataService: ExchangeRateDataService;
|
||||||
let portfolio: Portfolio;
|
let portfolio: Portfolio;
|
||||||
@ -28,6 +30,7 @@ describe('Portfolio', () => {
|
|||||||
imports: [],
|
imports: [],
|
||||||
providers: [
|
providers: [
|
||||||
AlphaVantageService,
|
AlphaVantageService,
|
||||||
|
ConfigurationService,
|
||||||
DataProviderService,
|
DataProviderService,
|
||||||
ExchangeRateDataService,
|
ExchangeRateDataService,
|
||||||
PrismaService,
|
PrismaService,
|
||||||
@ -38,6 +41,7 @@ describe('Portfolio', () => {
|
|||||||
}).compile();
|
}).compile();
|
||||||
|
|
||||||
alphaVantageService = app.get<AlphaVantageService>(AlphaVantageService);
|
alphaVantageService = app.get<AlphaVantageService>(AlphaVantageService);
|
||||||
|
configurationService = app.get<ConfigurationService>(ConfigurationService);
|
||||||
dataProviderService = app.get<DataProviderService>(DataProviderService);
|
dataProviderService = app.get<DataProviderService>(DataProviderService);
|
||||||
exchangeRateDataService = app.get<ExchangeRateDataService>(
|
exchangeRateDataService = app.get<ExchangeRateDataService>(
|
||||||
ExchangeRateDataService
|
ExchangeRateDataService
|
||||||
|
32
apps/api/src/services/configuration.service.ts
Normal file
32
apps/api/src/services/configuration.service.ts
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
import { Injectable } from '@nestjs/common';
|
||||||
|
import { bool, cleanEnv, num, port, str } from 'envalid';
|
||||||
|
|
||||||
|
import { Environment } from './interfaces/environment.interface';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class ConfigurationService {
|
||||||
|
private readonly environmentConfiguration: Environment;
|
||||||
|
|
||||||
|
public constructor() {
|
||||||
|
this.environmentConfiguration = cleanEnv(process.env, {
|
||||||
|
ACCESS_TOKEN_SALT: str(),
|
||||||
|
ALPHA_VANTAGE_API_KEY: str({ default: '' }),
|
||||||
|
CACHE_TTL: num({ default: 1 }),
|
||||||
|
ENABLE_FEATURE_FEAR_AND_GREED_INDEX: bool({ default: false }),
|
||||||
|
ENABLE_FEATURE_SOCIAL_LOGIN: bool({ default: false }),
|
||||||
|
GOOGLE_CLIENT_ID: str({ default: 'dummyClientId' }),
|
||||||
|
GOOGLE_SECRET: str({ default: 'dummySecret' }),
|
||||||
|
JWT_SECRET_KEY: str({}),
|
||||||
|
MAX_ITEM_IN_CACHE: num({ default: 9999 }),
|
||||||
|
PORT: port({ default: 3333 }),
|
||||||
|
RAKUTEN_RAPID_API_KEY: str({ default: '' }),
|
||||||
|
REDIS_HOST: str({ default: 'localhost' }),
|
||||||
|
REDIS_PORT: port({ default: 6379 }),
|
||||||
|
ROOT_URL: str({ default: 'http://localhost:4200' })
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public get<K extends keyof Environment>(key: K): Environment[K] {
|
||||||
|
return this.environmentConfiguration[key];
|
||||||
|
}
|
||||||
|
}
|
@ -11,13 +11,15 @@ import {
|
|||||||
import { benchmarks, currencyPairs } from 'libs/helper/src';
|
import { benchmarks, currencyPairs } from 'libs/helper/src';
|
||||||
import { getUtc, resetHours } from 'libs/helper/src';
|
import { getUtc, resetHours } from 'libs/helper/src';
|
||||||
|
|
||||||
|
import { ConfigurationService } from './configuration.service';
|
||||||
import { DataProviderService } from './data-provider.service';
|
import { DataProviderService } from './data-provider.service';
|
||||||
import { PrismaService } from './prisma.service';
|
import { PrismaService } from './prisma.service';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class DataGatheringService {
|
export class DataGatheringService {
|
||||||
public constructor(
|
public constructor(
|
||||||
private dataProviderService: DataProviderService,
|
private readonly configurationService: ConfigurationService,
|
||||||
|
private readonly dataProviderService: DataProviderService,
|
||||||
private prisma: PrismaService
|
private prisma: PrismaService
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
@ -64,9 +66,11 @@ export class DataGatheringService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async gatherMax() {
|
public async gatherMax() {
|
||||||
const isDataGatheringNeeded = await this.isDataGatheringNeeded();
|
const isDataGatheringLocked = await this.prisma.property.findUnique({
|
||||||
|
where: { key: 'LOCKED_DATA_GATHERING' }
|
||||||
|
});
|
||||||
|
|
||||||
if (isDataGatheringNeeded) {
|
if (!isDataGatheringLocked) {
|
||||||
console.log('Max data gathering has been started.');
|
console.log('Max data gathering has been started.');
|
||||||
console.time('data-gathering');
|
console.time('data-gathering');
|
||||||
|
|
||||||
@ -174,6 +178,24 @@ export class DataGatheringService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private getBenchmarksToGather(startDate: Date) {
|
||||||
|
const benchmarksToGather = benchmarks.map((symbol) => {
|
||||||
|
return {
|
||||||
|
symbol,
|
||||||
|
date: startDate
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
if (this.configurationService.get('ENABLE_FEATURE_FEAR_AND_GREED_INDEX')) {
|
||||||
|
benchmarksToGather.push({
|
||||||
|
date: startDate,
|
||||||
|
symbol: 'GF.FEAR_AND_GREED_INDEX'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return benchmarksToGather;
|
||||||
|
}
|
||||||
|
|
||||||
private async getSymbols7D(): Promise<{ date: Date; symbol: string }[]> {
|
private async getSymbols7D(): Promise<{ date: Date; symbol: string }[]> {
|
||||||
const startDate = subDays(resetHours(new Date()), 7);
|
const startDate = subDays(resetHours(new Date()), 7);
|
||||||
|
|
||||||
@ -190,13 +212,6 @@ export class DataGatheringService {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
const benchmarksToGather = benchmarks.map((symbol) => {
|
|
||||||
return {
|
|
||||||
symbol,
|
|
||||||
date: startDate
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
const currencyPairsToGather = currencyPairs.map((symbol) => {
|
const currencyPairsToGather = currencyPairs.map((symbol) => {
|
||||||
return {
|
return {
|
||||||
symbol,
|
symbol,
|
||||||
@ -205,7 +220,7 @@ export class DataGatheringService {
|
|||||||
});
|
});
|
||||||
|
|
||||||
return [
|
return [
|
||||||
...benchmarksToGather,
|
...this.getBenchmarksToGather(startDate),
|
||||||
...currencyPairsToGather,
|
...currencyPairsToGather,
|
||||||
...distinctOrdersWithDate
|
...distinctOrdersWithDate
|
||||||
];
|
];
|
||||||
@ -220,13 +235,6 @@ export class DataGatheringService {
|
|||||||
select: { date: true, symbol: true }
|
select: { date: true, symbol: true }
|
||||||
});
|
});
|
||||||
|
|
||||||
const benchmarksToGather = benchmarks.map((symbol) => {
|
|
||||||
return {
|
|
||||||
symbol,
|
|
||||||
date: startDate
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
const currencyPairsToGather = currencyPairs.map((symbol) => {
|
const currencyPairsToGather = currencyPairs.map((symbol) => {
|
||||||
return {
|
return {
|
||||||
symbol,
|
symbol,
|
||||||
@ -234,7 +242,11 @@ export class DataGatheringService {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
return [...benchmarksToGather, ...currencyPairsToGather, ...distinctOrders];
|
return [
|
||||||
|
...this.getBenchmarksToGather(startDate),
|
||||||
|
...currencyPairsToGather,
|
||||||
|
...distinctOrders
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
private async isDataGatheringNeeded() {
|
private async isDataGatheringNeeded() {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import { Injectable } from '@nestjs/common';
|
import { Injectable } from '@nestjs/common';
|
||||||
import { isAfter, isBefore, parse } from 'date-fns';
|
import { isAfter, isBefore, parse } from 'date-fns';
|
||||||
|
|
||||||
|
import { ConfigurationService } from '../../configuration.service';
|
||||||
import { DataProviderInterface } from '../../interfaces/data-provider.interface';
|
import { DataProviderInterface } from '../../interfaces/data-provider.interface';
|
||||||
import { Granularity } from '../../interfaces/granularity.type';
|
import { Granularity } from '../../interfaces/granularity.type';
|
||||||
import {
|
import {
|
||||||
@ -9,13 +10,17 @@ import {
|
|||||||
} from '../../interfaces/interfaces';
|
} from '../../interfaces/interfaces';
|
||||||
import { IAlphaVantageHistoricalResponse } from './interfaces/interfaces';
|
import { IAlphaVantageHistoricalResponse } from './interfaces/interfaces';
|
||||||
|
|
||||||
const alphaVantage = require('alphavantage')({
|
|
||||||
key: process.env.ALPHA_VANTAGE_API_KEY
|
|
||||||
});
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class AlphaVantageService implements DataProviderInterface {
|
export class AlphaVantageService implements DataProviderInterface {
|
||||||
public constructor() {}
|
public alphaVantage;
|
||||||
|
|
||||||
|
public constructor(
|
||||||
|
private readonly configurationService: ConfigurationService
|
||||||
|
) {
|
||||||
|
this.alphaVantage = require('alphavantage')({
|
||||||
|
key: this.configurationService.get('ALPHA_VANTAGE_API_KEY')
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public async get(
|
public async get(
|
||||||
aSymbols: string[]
|
aSymbols: string[]
|
||||||
@ -40,7 +45,7 @@ export class AlphaVantageService implements DataProviderInterface {
|
|||||||
try {
|
try {
|
||||||
const historicalData: {
|
const historicalData: {
|
||||||
[symbol: string]: IAlphaVantageHistoricalResponse[];
|
[symbol: string]: IAlphaVantageHistoricalResponse[];
|
||||||
} = await alphaVantage.crypto.daily(
|
} = await this.alphaVantage.crypto.daily(
|
||||||
symbol.substring(0, symbol.length - 3).toLowerCase(),
|
symbol.substring(0, symbol.length - 3).toLowerCase(),
|
||||||
'usd'
|
'usd'
|
||||||
);
|
);
|
||||||
@ -73,6 +78,6 @@ export class AlphaVantageService implements DataProviderInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public search(aSymbol: string) {
|
public search(aSymbol: string) {
|
||||||
return alphaVantage.data.search(aSymbol);
|
return this.alphaVantage.data.search(aSymbol);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ import * as bent from 'bent';
|
|||||||
import { format, subMonths, subWeeks, subYears } from 'date-fns';
|
import { format, subMonths, subWeeks, subYears } from 'date-fns';
|
||||||
import { getToday, getYesterday } from 'libs/helper/src';
|
import { getToday, getYesterday } from 'libs/helper/src';
|
||||||
|
|
||||||
|
import { ConfigurationService } from '../../configuration.service';
|
||||||
import { DataProviderInterface } from '../../interfaces/data-provider.interface';
|
import { DataProviderInterface } from '../../interfaces/data-provider.interface';
|
||||||
import { Granularity } from '../../interfaces/granularity.type';
|
import { Granularity } from '../../interfaces/granularity.type';
|
||||||
import {
|
import {
|
||||||
@ -17,7 +18,9 @@ export class RakutenRapidApiService implements DataProviderInterface {
|
|||||||
|
|
||||||
private prisma: PrismaService;
|
private prisma: PrismaService;
|
||||||
|
|
||||||
public constructor() {}
|
public constructor(
|
||||||
|
private readonly configurationService: ConfigurationService
|
||||||
|
) {}
|
||||||
|
|
||||||
public async get(
|
public async get(
|
||||||
aSymbols: string[]
|
aSymbols: string[]
|
||||||
@ -127,7 +130,9 @@ export class RakutenRapidApiService implements DataProviderInterface {
|
|||||||
{
|
{
|
||||||
useQueryString: true,
|
useQueryString: true,
|
||||||
'x-rapidapi-host': 'fear-and-greed-index.p.rapidapi.com',
|
'x-rapidapi-host': 'fear-and-greed-index.p.rapidapi.com',
|
||||||
'x-rapidapi-key': process.env.RAKUTEN_RAPID_API_KEY
|
'x-rapidapi-key': this.configurationService.get(
|
||||||
|
'RAKUTEN_RAPID_API_KEY'
|
||||||
|
)
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
|
import { getYesterday } from '@ghostfolio/helper';
|
||||||
import { Injectable } from '@nestjs/common';
|
import { Injectable } from '@nestjs/common';
|
||||||
import { Currency } from '@prisma/client';
|
import { Currency } from '@prisma/client';
|
||||||
import { format } from 'date-fns';
|
import { format } from 'date-fns';
|
||||||
import { getYesterday } from 'libs/helper/src';
|
|
||||||
|
|
||||||
import { DataProviderService } from './data-provider.service';
|
import { DataProviderService } from './data-provider.service';
|
||||||
|
|
||||||
@ -15,6 +15,8 @@ export class ExchangeRateDataService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async initialize() {
|
public async initialize() {
|
||||||
|
this.pairs = [];
|
||||||
|
|
||||||
this.addPairs(Currency.CHF, Currency.EUR);
|
this.addPairs(Currency.CHF, Currency.EUR);
|
||||||
this.addPairs(Currency.CHF, Currency.GBP);
|
this.addPairs(Currency.CHF, Currency.GBP);
|
||||||
this.addPairs(Currency.CHF, Currency.USD);
|
this.addPairs(Currency.CHF, Currency.USD);
|
||||||
@ -25,11 +27,6 @@ export class ExchangeRateDataService {
|
|||||||
await this.loadCurrencies();
|
await this.loadCurrencies();
|
||||||
}
|
}
|
||||||
|
|
||||||
private addPairs(aCurrency1: Currency, aCurrency2: Currency) {
|
|
||||||
this.pairs.push(`${aCurrency1}${aCurrency2}`);
|
|
||||||
this.pairs.push(`${aCurrency2}${aCurrency1}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async loadCurrencies() {
|
public async loadCurrencies() {
|
||||||
const result = await this.dataProviderService.getHistorical(
|
const result = await this.dataProviderService.getHistorical(
|
||||||
this.pairs,
|
this.pairs,
|
||||||
@ -38,19 +35,34 @@ export class ExchangeRateDataService {
|
|||||||
getYesterday()
|
getYesterday()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const resultExtended = result;
|
||||||
|
|
||||||
|
Object.keys(result).forEach((pair) => {
|
||||||
|
const [currency1, currency2] = pair.match(/.{1,3}/g);
|
||||||
|
const [date] = Object.keys(result[pair]);
|
||||||
|
|
||||||
|
// Calculate the opposite direction
|
||||||
|
resultExtended[`${currency2}${currency1}`] = {
|
||||||
|
[date]: {
|
||||||
|
marketPrice: 1 / result[pair][date].marketPrice
|
||||||
|
}
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
this.pairs.forEach((pair) => {
|
this.pairs.forEach((pair) => {
|
||||||
this.currencies[pair] =
|
const [currency1, currency2] = pair.match(/.{1,3}/g);
|
||||||
result[pair]?.[format(getYesterday(), 'yyyy-MM-dd')]?.marketPrice || 1;
|
const date = format(getYesterday(), 'yyyy-MM-dd');
|
||||||
|
|
||||||
if (this.currencies[pair] === 1) {
|
this.currencies[pair] = resultExtended[pair]?.[date]?.marketPrice;
|
||||||
// Calculate the other direction
|
|
||||||
const [currency1, currency2] = pair.match(/.{1,3}/g);
|
|
||||||
|
|
||||||
|
if (!this.currencies[pair]) {
|
||||||
|
// Not found, calculate indirectly via USD
|
||||||
this.currencies[pair] =
|
this.currencies[pair] =
|
||||||
1 /
|
resultExtended[`${currency1}${Currency.USD}`][date].marketPrice *
|
||||||
result[`${currency2}${currency1}`]?.[
|
resultExtended[`${Currency.USD}${currency2}`][date].marketPrice;
|
||||||
format(getYesterday(), 'yyyy-MM-dd')
|
|
||||||
]?.marketPrice;
|
// Calculate the opposite direction
|
||||||
|
this.currencies[`${currency2}${currency1}`] = 1 / this.currencies[pair];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -60,6 +72,11 @@ export class ExchangeRateDataService {
|
|||||||
aFromCurrency: Currency,
|
aFromCurrency: Currency,
|
||||||
aToCurrency: Currency
|
aToCurrency: Currency
|
||||||
) {
|
) {
|
||||||
|
if (isNaN(this.currencies[`${Currency.USD}${Currency.CHF}`])) {
|
||||||
|
// Reinitialize if data is not loaded correctly
|
||||||
|
this.initialize();
|
||||||
|
}
|
||||||
|
|
||||||
let factor = 1;
|
let factor = 1;
|
||||||
|
|
||||||
if (aFromCurrency !== aToCurrency) {
|
if (aFromCurrency !== aToCurrency) {
|
||||||
@ -68,4 +85,9 @@ export class ExchangeRateDataService {
|
|||||||
|
|
||||||
return factor * aValue;
|
return factor * aValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private addPairs(aCurrency1: Currency, aCurrency2: Currency) {
|
||||||
|
this.pairs.push(`${aCurrency1}${aCurrency2}`);
|
||||||
|
this.pairs.push(`${aCurrency2}${aCurrency1}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
18
apps/api/src/services/interfaces/environment.interface.ts
Normal file
18
apps/api/src/services/interfaces/environment.interface.ts
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
import { CleanedEnvAccessors } from 'envalid';
|
||||||
|
|
||||||
|
export interface Environment extends CleanedEnvAccessors {
|
||||||
|
ACCESS_TOKEN_SALT: string;
|
||||||
|
ALPHA_VANTAGE_API_KEY: string;
|
||||||
|
CACHE_TTL: number;
|
||||||
|
ENABLE_FEATURE_FEAR_AND_GREED_INDEX: boolean;
|
||||||
|
ENABLE_FEATURE_SOCIAL_LOGIN: boolean;
|
||||||
|
GOOGLE_CLIENT_ID: string;
|
||||||
|
GOOGLE_SECRET: string;
|
||||||
|
JWT_SECRET_KEY: string;
|
||||||
|
MAX_ITEM_IN_CACHE: number;
|
||||||
|
PORT: number;
|
||||||
|
RAKUTEN_RAPID_API_KEY: string;
|
||||||
|
REDIS_HOST: string;
|
||||||
|
REDIS_PORT: number;
|
||||||
|
ROOT_URL: string;
|
||||||
|
}
|
@ -2,6 +2,7 @@
|
|||||||
<gf-header
|
<gf-header
|
||||||
class="position-fixed px-2 w-100"
|
class="position-fixed px-2 w-100"
|
||||||
[currentRoute]="currentRoute"
|
[currentRoute]="currentRoute"
|
||||||
|
[info]="info"
|
||||||
[user]="user"
|
[user]="user"
|
||||||
></gf-header>
|
></gf-header>
|
||||||
</header>
|
</header>
|
||||||
|
@ -7,8 +7,8 @@ import {
|
|||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
import { NavigationEnd, Router } from '@angular/router';
|
import { NavigationEnd, Router } from '@angular/router';
|
||||||
import { MaterialCssVarsService } from 'angular-material-css-vars';
|
import { MaterialCssVarsService } from 'angular-material-css-vars';
|
||||||
|
import { InfoItem } from 'apps/api/src/app/info/interfaces/info-item.interface';
|
||||||
import { User } from 'apps/api/src/app/user/interfaces/user.interface';
|
import { User } from 'apps/api/src/app/user/interfaces/user.interface';
|
||||||
import { formatDistanceToNow } from 'date-fns';
|
|
||||||
import { primaryColorHex, secondaryColorHex } from 'libs/helper/src';
|
import { primaryColorHex, secondaryColorHex } from 'libs/helper/src';
|
||||||
import { hasPermission, permissions } from 'libs/helper/src';
|
import { hasPermission, permissions } from 'libs/helper/src';
|
||||||
import { Subject } from 'rxjs';
|
import { Subject } from 'rxjs';
|
||||||
@ -28,8 +28,8 @@ export class AppComponent implements OnDestroy, OnInit {
|
|||||||
public canCreateAccount: boolean;
|
public canCreateAccount: boolean;
|
||||||
public currentRoute: string;
|
public currentRoute: string;
|
||||||
public currentYear = new Date().getFullYear();
|
public currentYear = new Date().getFullYear();
|
||||||
|
public info: InfoItem;
|
||||||
public isLoggedIn = false;
|
public isLoggedIn = false;
|
||||||
public lastDataGathering: string;
|
|
||||||
public user: User;
|
public user: User;
|
||||||
public version = environment.version;
|
public version = environment.version;
|
||||||
|
|
||||||
@ -47,10 +47,8 @@ export class AppComponent implements OnDestroy, OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ngOnInit() {
|
public ngOnInit() {
|
||||||
this.dataService.fetchInfo().subscribe(({ lastDataGathering }) => {
|
this.dataService.fetchInfo().subscribe((info) => {
|
||||||
this.lastDataGathering = lastDataGathering
|
this.info = info;
|
||||||
? formatDistanceToNow(new Date(lastDataGathering), { addSuffix: true })
|
|
||||||
: '';
|
|
||||||
});
|
});
|
||||||
|
|
||||||
this.router.events
|
this.router.events
|
||||||
|
@ -6,6 +6,7 @@ import {
|
|||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
import { MatDialog } from '@angular/material/dialog';
|
import { MatDialog } from '@angular/material/dialog';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
|
import { InfoItem } from 'apps/api/src/app/info/interfaces/info-item.interface';
|
||||||
import { User } from 'apps/api/src/app/user/interfaces/user.interface';
|
import { User } from 'apps/api/src/app/user/interfaces/user.interface';
|
||||||
import { hasPermission, permissions } from 'libs/helper/src';
|
import { hasPermission, permissions } from 'libs/helper/src';
|
||||||
import { EMPTY, Subject } from 'rxjs';
|
import { EMPTY, Subject } from 'rxjs';
|
||||||
@ -24,9 +25,11 @@ import { TokenStorageService } from '../../services/token-storage.service';
|
|||||||
})
|
})
|
||||||
export class HeaderComponent implements OnChanges {
|
export class HeaderComponent implements OnChanges {
|
||||||
@Input() currentRoute: string;
|
@Input() currentRoute: string;
|
||||||
|
@Input() info: InfoItem;
|
||||||
@Input() user: User;
|
@Input() user: User;
|
||||||
|
|
||||||
public canAccessAdminAccessControl: boolean;
|
public canAccessAdminAccessControl: boolean;
|
||||||
|
public hasPermissionToUseSocialLogin: boolean;
|
||||||
public impersonationId: string;
|
public impersonationId: string;
|
||||||
|
|
||||||
private unsubscribeSubject = new Subject<void>();
|
private unsubscribeSubject = new Subject<void>();
|
||||||
@ -52,6 +55,11 @@ export class HeaderComponent implements OnChanges {
|
|||||||
permissions.accessAdminControl
|
permissions.accessAdminControl
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.hasPermissionToUseSocialLogin = hasPermission(
|
||||||
|
this.info?.globalPermissions,
|
||||||
|
permissions.useSocialLogin
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public impersonateAccount(aId: string) {
|
public impersonateAccount(aId: string) {
|
||||||
@ -72,7 +80,10 @@ export class HeaderComponent implements OnChanges {
|
|||||||
public openLoginDialog(): void {
|
public openLoginDialog(): void {
|
||||||
const dialogRef = this.dialog.open(LoginWithAccessTokenDialog, {
|
const dialogRef = this.dialog.open(LoginWithAccessTokenDialog, {
|
||||||
autoFocus: false,
|
autoFocus: false,
|
||||||
data: { accessToken: '' },
|
data: {
|
||||||
|
accessToken: '',
|
||||||
|
hasPermissionToUseSocialLogin: this.hasPermissionToUseSocialLogin
|
||||||
|
},
|
||||||
width: '30rem'
|
width: '30rem'
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
></gf-line-chart>
|
></gf-line-chart>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="container p-0">
|
<div *ngIf="data.fearAndGreedIndex" class="container p-0">
|
||||||
<gf-fear-and-greed-index
|
<gf-fear-and-greed-index
|
||||||
class="d-flex flex-column justify-content-center"
|
class="d-flex flex-column justify-content-center"
|
||||||
[fearAndGreedIndex]="data.fearAndGreedIndex"
|
[fearAndGreedIndex]="data.fearAndGreedIndex"
|
||||||
|
@ -83,11 +83,17 @@ export class AdminPageComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public onGatherMax() {
|
public onGatherMax() {
|
||||||
this.adminService.gatherMax().subscribe(() => {
|
const confirmation = confirm(
|
||||||
setTimeout(() => {
|
'This action may take some time. Do you want to proceed?'
|
||||||
window.location.reload();
|
);
|
||||||
}, 300);
|
|
||||||
});
|
if (confirmation === true) {
|
||||||
|
this.adminService.gatherMax().subscribe(() => {
|
||||||
|
setTimeout(() => {
|
||||||
|
window.location.reload();
|
||||||
|
}, 300);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public formatDistanceToNow(aDateString: string) {
|
public formatDistanceToNow(aDateString: string) {
|
||||||
|
@ -34,11 +34,16 @@
|
|||||||
(click)="onFlushCache()"
|
(click)="onFlushCache()"
|
||||||
>
|
>
|
||||||
<ion-icon class="mr-1" name="close-circle-outline"></ion-icon>
|
<ion-icon class="mr-1" name="close-circle-outline"></ion-icon>
|
||||||
<span i18n>Reset</span>
|
<span i18n>Reset Data Gathering</span>
|
||||||
</button>
|
</button>
|
||||||
<button color="warn" mat-flat-button (click)="onGatherMax()">
|
<button
|
||||||
|
color="warn"
|
||||||
|
mat-flat-button
|
||||||
|
[disabled]="dataGatheringInProgress"
|
||||||
|
(click)="onGatherMax()"
|
||||||
|
>
|
||||||
<ion-icon class="mr-1" name="warning-outline"></ion-icon>
|
<ion-icon class="mr-1" name="warning-outline"></ion-icon>
|
||||||
<span i18n>Gather Max</span>
|
<span i18n>Gather All Data</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -39,6 +39,7 @@ export class HomePageComponent implements OnDestroy, OnInit {
|
|||||||
public deviceType: string;
|
public deviceType: string;
|
||||||
public fearAndGreedIndex: number;
|
public fearAndGreedIndex: number;
|
||||||
public hasImpersonationId: boolean;
|
public hasImpersonationId: boolean;
|
||||||
|
public hasPermissionToAccessFearAndGreedIndex: boolean;
|
||||||
public hasPermissionToReadForeignPortfolio: boolean;
|
public hasPermissionToReadForeignPortfolio: boolean;
|
||||||
public hasPositions = false;
|
public hasPositions = false;
|
||||||
public historicalDataItems: LineChartItem[];
|
public historicalDataItems: LineChartItem[];
|
||||||
@ -80,6 +81,10 @@ export class HomePageComponent implements OnDestroy, OnInit {
|
|||||||
.subscribe(() => {
|
.subscribe(() => {
|
||||||
this.dataService.fetchUser().subscribe((user) => {
|
this.dataService.fetchUser().subscribe((user) => {
|
||||||
this.user = user;
|
this.user = user;
|
||||||
|
this.hasPermissionToAccessFearAndGreedIndex = hasPermission(
|
||||||
|
user.permissions,
|
||||||
|
permissions.accessFearAndGreedIndex
|
||||||
|
);
|
||||||
this.hasPermissionToReadForeignPortfolio = hasPermission(
|
this.hasPermissionToReadForeignPortfolio = hasPermission(
|
||||||
user.permissions,
|
user.permissions,
|
||||||
permissions.readForeignPortfolio
|
permissions.readForeignPortfolio
|
||||||
@ -175,14 +180,16 @@ export class HomePageComponent implements OnDestroy, OnInit {
|
|||||||
this.cd.markForCheck();
|
this.cd.markForCheck();
|
||||||
});
|
});
|
||||||
|
|
||||||
this.dataService
|
if (this.hasPermissionToAccessFearAndGreedIndex) {
|
||||||
.fetchSymbolItem('GF.FEAR_AND_GREED_INDEX')
|
this.dataService
|
||||||
.pipe(takeUntil(this.unsubscribeSubject))
|
.fetchSymbolItem('GF.FEAR_AND_GREED_INDEX')
|
||||||
.subscribe(({ marketPrice }) => {
|
.pipe(takeUntil(this.unsubscribeSubject))
|
||||||
this.fearAndGreedIndex = marketPrice;
|
.subscribe(({ marketPrice }) => {
|
||||||
|
this.fearAndGreedIndex = marketPrice;
|
||||||
|
|
||||||
this.cd.markForCheck();
|
this.cd.markForCheck();
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
this.cd.markForCheck();
|
this.cd.markForCheck();
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import { ChangeDetectorRef, Component, OnDestroy, OnInit } from '@angular/core';
|
import { ChangeDetectorRef, Component, OnDestroy, OnInit } from '@angular/core';
|
||||||
import { MatDialog } from '@angular/material/dialog';
|
import { MatDialog } from '@angular/material/dialog';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
|
import { hasPermission, permissions } from '@ghostfolio/helper';
|
||||||
import { format } from 'date-fns';
|
import { format } from 'date-fns';
|
||||||
import { Subject } from 'rxjs';
|
import { Subject } from 'rxjs';
|
||||||
import { takeUntil } from 'rxjs/operators';
|
import { takeUntil } from 'rxjs/operators';
|
||||||
@ -276,7 +277,10 @@ export class LoginPageComponent implements OnDestroy, OnInit {
|
|||||||
authToken: string
|
authToken: string
|
||||||
): void {
|
): void {
|
||||||
const dialogRef = this.dialog.open(ShowAccessTokenDialog, {
|
const dialogRef = this.dialog.open(ShowAccessTokenDialog, {
|
||||||
data: { accessToken, authToken },
|
data: {
|
||||||
|
accessToken,
|
||||||
|
authToken
|
||||||
|
},
|
||||||
disableClose: true,
|
disableClose: true,
|
||||||
width: '30rem'
|
width: '30rem'
|
||||||
});
|
});
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
import { ChangeDetectionStrategy, Component, Inject } from '@angular/core';
|
import { ChangeDetectionStrategy, Component, Inject } from '@angular/core';
|
||||||
import { MAT_DIALOG_DATA } from '@angular/material/dialog';
|
import { MAT_DIALOG_DATA } from '@angular/material/dialog';
|
||||||
|
|
||||||
import { DataService } from '../../../services/data.service';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'login-with-access-token-dialog',
|
selector: 'login-with-access-token-dialog',
|
||||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||||
|
@ -1,13 +1,15 @@
|
|||||||
<h1 mat-dialog-title i18n>Sign in</h1>
|
<h1 mat-dialog-title i18n>Sign in</h1>
|
||||||
<div mat-dialog-content>
|
<div mat-dialog-content>
|
||||||
<div>
|
<div>
|
||||||
<div class="text-center">
|
<ng-container *ngIf="data.hasPermissionToUseSocialLogin">
|
||||||
<a color="accent" href="/api/auth/google" mat-flat-button
|
<div class="text-center">
|
||||||
><ion-icon class="mr-1" name="logo-google"></ion-icon
|
<a color="accent" href="/api/auth/google" mat-flat-button
|
||||||
><span i18n>Sign in with Google</span></a
|
><ion-icon class="mr-1" name="logo-google"></ion-icon
|
||||||
>
|
><span i18n>Sign in with Google</span></a
|
||||||
</div>
|
>
|
||||||
<div class="my-3 text-center text-muted" i18n>or</div>
|
</div>
|
||||||
|
<div class="my-3 text-center text-muted" i18n>or</div>
|
||||||
|
</ng-container>
|
||||||
<mat-form-field appearance="outline" class="w-100">
|
<mat-form-field appearance="outline" class="w-100">
|
||||||
<mat-label i18n>Security Token</mat-label>
|
<mat-label i18n>Security Token</mat-label>
|
||||||
<textarea
|
<textarea
|
||||||
|
@ -1,10 +1,5 @@
|
|||||||
import { ChangeDetectorRef, Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { resolveFearAndGreedIndex } from 'libs/helper/src';
|
|
||||||
import { Subject } from 'rxjs';
|
import { Subject } from 'rxjs';
|
||||||
import { takeUntil } from 'rxjs/operators';
|
|
||||||
|
|
||||||
import { DataService } from '../../services/data.service';
|
|
||||||
import { TokenStorageService } from '../../services/token-storage.service';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'gf-resources-page',
|
selector: 'gf-resources-page',
|
||||||
@ -12,41 +7,17 @@ import { TokenStorageService } from '../../services/token-storage.service';
|
|||||||
styleUrls: ['./resources-page.scss']
|
styleUrls: ['./resources-page.scss']
|
||||||
})
|
})
|
||||||
export class ResourcesPageComponent implements OnInit {
|
export class ResourcesPageComponent implements OnInit {
|
||||||
public currentFearAndGreedIndex: number;
|
|
||||||
public currentFearAndGreedIndexAsText: string;
|
|
||||||
public isLoggedIn: boolean;
|
|
||||||
|
|
||||||
private unsubscribeSubject = new Subject<void>();
|
private unsubscribeSubject = new Subject<void>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
public constructor(
|
public constructor() {}
|
||||||
private cd: ChangeDetectorRef,
|
|
||||||
private dataService: DataService,
|
|
||||||
private tokenStorageService: TokenStorageService
|
|
||||||
) {}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes the controller
|
* Initializes the controller
|
||||||
*/
|
*/
|
||||||
public ngOnInit() {
|
public ngOnInit() {}
|
||||||
this.isLoggedIn = !!this.tokenStorageService.getToken();
|
|
||||||
|
|
||||||
if (this.isLoggedIn) {
|
|
||||||
this.dataService
|
|
||||||
.fetchSymbolItem('GF.FEAR_AND_GREED_INDEX')
|
|
||||||
.pipe(takeUntil(this.unsubscribeSubject))
|
|
||||||
.subscribe(({ marketPrice }) => {
|
|
||||||
this.currentFearAndGreedIndex = marketPrice;
|
|
||||||
this.currentFearAndGreedIndexAsText = resolveFearAndGreedIndex(
|
|
||||||
this.currentFearAndGreedIndex
|
|
||||||
).text;
|
|
||||||
|
|
||||||
this.cd.markForCheck();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public ngOnDestroy() {
|
public ngOnDestroy() {
|
||||||
this.unsubscribeSubject.next();
|
this.unsubscribeSubject.next();
|
||||||
|
@ -7,16 +7,8 @@
|
|||||||
<h4 class="mb-3">Market</h4>
|
<h4 class="mb-3">Market</h4>
|
||||||
<div class="mb-5">
|
<div class="mb-5">
|
||||||
<div class="mb-4 media">
|
<div class="mb-4 media">
|
||||||
<!--<img src="" class="mr-3" />-->
|
|
||||||
<div class="media-body">
|
<div class="media-body">
|
||||||
<h5 class="mt-0">
|
<h5 class="mt-0">Fear & Greed Index</h5>
|
||||||
Fear & Greed Index<br class="d-block d-sm-none" />
|
|
||||||
<small *ngIf="currentFearAndGreedIndex">
|
|
||||||
(currently
|
|
||||||
<strong>{{ currentFearAndGreedIndexAsText }}</strong> at
|
|
||||||
<strong>{{ currentFearAndGreedIndex }}</strong>/100)</small
|
|
||||||
>
|
|
||||||
</h5>
|
|
||||||
<div class="mb-1">
|
<div class="mb-1">
|
||||||
The fear and greed index was developed by <i>CNNMoney</i> to
|
The fear and greed index was developed by <i>CNNMoney</i> to
|
||||||
measure the primary emotions (fear and greed) that influence
|
measure the primary emotions (fear and greed) that influence
|
||||||
@ -32,7 +24,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="media">
|
<div class="media">
|
||||||
<!--<img src="" class="mr-3" />-->
|
|
||||||
<div class="media-body">
|
<div class="media-body">
|
||||||
<h5 class="mt-0">Inflation Chart</h5>
|
<h5 class="mt-0">Inflation Chart</h5>
|
||||||
<div class="mb-1">
|
<div class="mb-1">
|
||||||
|
@ -2,20 +2,9 @@ import { Currency } from '.prisma/client';
|
|||||||
|
|
||||||
export const baseCurrency = Currency.CHF;
|
export const baseCurrency = Currency.CHF;
|
||||||
|
|
||||||
export const benchmarks = [
|
export const benchmarks = ['VOO'];
|
||||||
'CSSMIM.SW',
|
|
||||||
'GC=F',
|
|
||||||
'GF.FEAR_AND_GREED_INDEX',
|
|
||||||
'VOO',
|
|
||||||
'VTI',
|
|
||||||
'VWRD.L',
|
|
||||||
'VXUS'
|
|
||||||
];
|
|
||||||
|
|
||||||
export const currencyPairs = [
|
export const currencyPairs = [
|
||||||
`${Currency.EUR}${Currency.CHF}`,
|
|
||||||
`${Currency.GBP}${Currency.CHF}`,
|
|
||||||
`${Currency.GBP}${Currency.EUR}`,
|
|
||||||
`${Currency.USD}${Currency.EUR}`,
|
`${Currency.USD}${Currency.EUR}`,
|
||||||
`${Currency.USD}${Currency.GBP}`,
|
`${Currency.USD}${Currency.GBP}`,
|
||||||
`${Currency.USD}${Currency.CHF}`
|
`${Currency.USD}${Currency.CHF}`
|
||||||
|
@ -6,12 +6,14 @@ export function isApiTokenAuthorized(aApiToken: string) {
|
|||||||
|
|
||||||
export const permissions = {
|
export const permissions = {
|
||||||
accessAdminControl: 'accessAdminControl',
|
accessAdminControl: 'accessAdminControl',
|
||||||
|
accessFearAndGreedIndex: 'accessFearAndGreedIndex',
|
||||||
createAccount: 'createAccount',
|
createAccount: 'createAccount',
|
||||||
createOrder: 'createOrder',
|
createOrder: 'createOrder',
|
||||||
deleteOrder: 'deleteOrder',
|
deleteOrder: 'deleteOrder',
|
||||||
readForeignPortfolio: 'readForeignPortfolio',
|
readForeignPortfolio: 'readForeignPortfolio',
|
||||||
updateOrder: 'updateOrder',
|
updateOrder: 'updateOrder',
|
||||||
updateUserSettings: 'updateUserSettings'
|
updateUserSettings: 'updateUserSettings',
|
||||||
|
useSocialLogin: 'useSocialLogin'
|
||||||
};
|
};
|
||||||
|
|
||||||
export function hasPermission(
|
export function hasPermission(
|
||||||
|
@ -76,6 +76,7 @@
|
|||||||
"countup.js": "2.0.7",
|
"countup.js": "2.0.7",
|
||||||
"cryptocurrencies": "7.0.0",
|
"cryptocurrencies": "7.0.0",
|
||||||
"date-fns": "2.19.0",
|
"date-fns": "2.19.0",
|
||||||
|
"envalid": "7.1.0",
|
||||||
"http-status-codes": "2.1.4",
|
"http-status-codes": "2.1.4",
|
||||||
"ionicons": "5.5.1",
|
"ionicons": "5.5.1",
|
||||||
"lodash": "4.17.21",
|
"lodash": "4.17.21",
|
||||||
|
@ -5488,6 +5488,11 @@ env-paths@^2.2.0:
|
|||||||
resolved "https://registry.yarnpkg.com/env-paths/-/env-paths-2.2.1.tgz#420399d416ce1fbe9bc0a07c62fa68d67fd0f8f2"
|
resolved "https://registry.yarnpkg.com/env-paths/-/env-paths-2.2.1.tgz#420399d416ce1fbe9bc0a07c62fa68d67fd0f8f2"
|
||||||
integrity sha512-+h1lkLKhZMTYjog1VEpJNG7NZJWcuc2DDk/qsqSTRRCOXiLjeQ1d1/udrUGhqMxUgAlwKNZ0cf2uqan5GLuS2A==
|
integrity sha512-+h1lkLKhZMTYjog1VEpJNG7NZJWcuc2DDk/qsqSTRRCOXiLjeQ1d1/udrUGhqMxUgAlwKNZ0cf2uqan5GLuS2A==
|
||||||
|
|
||||||
|
envalid@7.1.0:
|
||||||
|
version "7.1.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/envalid/-/envalid-7.1.0.tgz#fccc499abb257e3992d73b02d014c867a85e2a69"
|
||||||
|
integrity sha512-C5rtCxfj+ozW5q79fBYKcBEf0KSNklKwZudjCzXy9ANT8Pz1MKxPBn6unZnYXXy6e+cqVgnEURQeXmdueG9/kA==
|
||||||
|
|
||||||
err-code@^1.0.0:
|
err-code@^1.0.0:
|
||||||
version "1.1.2"
|
version "1.1.2"
|
||||||
resolved "https://registry.yarnpkg.com/err-code/-/err-code-1.1.2.tgz#06e0116d3028f6aef4806849eb0ea6a748ae6960"
|
resolved "https://registry.yarnpkg.com/err-code/-/err-code-1.1.2.tgz#06e0116d3028f6aef4806849eb0ea6a748ae6960"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user