diff --git a/backend/.env.dist b/backend/.env.dist index fe9d5e566..f5308a4fa 100644 --- a/backend/.env.dist +++ b/backend/.env.dist @@ -1,4 +1,4 @@ PORT=4000 GRAPHIQL=false // LOGIN_API_URL=http://login-server:1201/ -// COMMUNITY_API_URL=http://localhost/api/ \ No newline at end of file +// COMMUNITY_API_URL=http://nginx/api/ \ No newline at end of file diff --git a/backend/src/config/index.ts b/backend/src/config/index.ts index 3cb239a1d..685ff698e 100644 --- a/backend/src/config/index.ts +++ b/backend/src/config/index.ts @@ -8,7 +8,7 @@ const server = { JWT_SECRET: process.env.JWT_SECRET || 'secret123', JWT_EXPIRES_IN: process.env.JWT_EXPIRES_IN || '10m', GRAPHIQL: process.env.GRAPHIQL === 'true' || false, - LOGIN_API_URL: process.env.LOGIN_API_URL || 'http://localhost/', // login_api/', + LOGIN_API_URL: process.env.LOGIN_API_URL || 'http://login-server:1201/', COMMUNITY_API_URL: process.env.COMMUNITY_API_URL || 'http://ngninx/api/', } diff --git a/backend/src/graphql/models/Balance.ts b/backend/src/graphql/models/Balance.ts new file mode 100644 index 000000000..2ba34ec75 --- /dev/null +++ b/backend/src/graphql/models/Balance.ts @@ -0,0 +1,26 @@ +import { Entity, BaseEntity, Column } from 'typeorm' +import { ObjectType, Field } from 'type-graphql' + +@Entity() +@ObjectType() +export class Balance extends BaseEntity { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + constructor(json: any) { + super() + this.balance = json.balance + this.decay = json.decay + this.decayDate = json.decay_date + } + + @Field(() => Number) + @Column() + balance: number + + @Field(() => Number) + @Column() + decay: number + + @Field(() => String) + @Column() + decayDate: string +} diff --git a/backend/src/graphql/resolvers/CommunityTransactionResolver.ts b/backend/src/graphql/resolvers/CommunityTransactionResolver.ts index 1578f61e2..7eb7a9921 100644 --- a/backend/src/graphql/resolvers/CommunityTransactionResolver.ts +++ b/backend/src/graphql/resolvers/CommunityTransactionResolver.ts @@ -1,6 +1,7 @@ import { Resolver, Query, /* Mutation, */ Args, Arg } from 'type-graphql' import CONFIG from '../../config' import {} from '../models/Transaction' +import { Balance } from '../models/Balance' import { TransactionCreateArgs, TransactionInput, @@ -10,11 +11,12 @@ import { apiPost, apiGet } from '../../apis/loginAPI' @Resolver() export class CommunityTransactionResolver { - @Query(() => String) - async balance(@Arg('sessionId') sessionId: number): Promise { + @Query(() => Balance) + async balance(@Arg('sessionId') sessionId: number): Promise { // eslint-disable-next-line no-console console.log('IN BALANCE: URL: ' + CONFIG.COMMUNITY_API_URL + 'getBalance/' + sessionId) - return apiGet(CONFIG.COMMUNITY_API_URL + 'getBalance/' + sessionId) + const result = await apiGet(CONFIG.COMMUNITY_API_URL + 'getBalance/' + sessionId) + return new Balance(result.result.data) } @Query(() => String) diff --git a/docker-compose.override.yml b/docker-compose.override.yml index 092cd9db1..8a0295d61 100644 --- a/docker-compose.override.yml +++ b/docker-compose.override.yml @@ -30,6 +30,7 @@ services: target: development networks: - external-net + - internal-net environment: - NODE_ENV="development" volumes: