diff --git a/docker-compose.yaml b/docker-compose.yaml index ff44fc4..791b5b6 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -20,6 +20,18 @@ services: retries: 30 interval: 15s + reporting-hub-bop-api-svc: + build: + context: . + environment: + - LOG_LEVEL=debug + volumes: + - ./config/default.json:/opt/reporting/config/default.json + ports: + - "3000:3000" + # Important to specify the network_mode as host to allow the service to connect to the host machine + network_mode: host + ## TODO: The following sections are provided as future proof and can be enabled later. ## Currently we can't query the event information from api service as there is no functionality in ml-core-test-harness to push the audit messages to kafka notification topic. ## When it's implemented, we can enable the following services to process and store the events and run queries on that data from api service. @@ -57,4 +69,4 @@ services: volumes: db-data: - driver: local \ No newline at end of file + driver: local diff --git a/prisma/base/centralLedger.prisma b/prisma/base/centralLedger.prisma index a96a1eb..0463472 100644 --- a/prisma/base/centralLedger.prisma +++ b/prisma/base/centralLedger.prisma @@ -1025,6 +1025,7 @@ model transferParticipant { participantCurrency participantCurrency? @relation(fields: [participantCurrencyId], references: [participantCurrencyId], onDelete: NoAction, onUpdate: NoAction, map: "transferparticipant_participantcurrencyid_foreign") transfer transfer @relation(fields: [transferId], references: [transferId], onDelete: NoAction, onUpdate: NoAction, map: "transferparticipant_transferid_foreign") transferParticipantRoleType transferParticipantRoleType @relation(fields: [transferParticipantRoleTypeId], references: [transferParticipantRoleTypeId], onDelete: NoAction, onUpdate: NoAction, map: "transferparticipant_transferparticipantroletypeid_foreign") + participant participant @relation(fields: [participantId], references: [participantId], onDelete: NoAction, onUpdate: NoAction, map: "participant_participantid_foreign") @@index([transferId, transferParticipantRoleTypeId, ledgerEntryTypeId], map: "getTransferInfoToChangePosition") @@index([ledgerEntryTypeId], map: "transferparticipant_ledgerentrytypeid_index") diff --git a/src/context.ts b/src/context.ts index 4e360e9..9260628 100644 --- a/src/context.ts +++ b/src/context.ts @@ -49,14 +49,14 @@ export interface Context { getRequestFields: typeof getRequestFields; } -const csMongoDBObj = new ConnectionString() +const csMongoDBObj = new ConnectionString(); csMongoDBObj.setDefaults({ protocol: 'mongodb', - hosts: [{ name: Config.EVENT_STORE_DB.HOST, port: Config.EVENT_STORE_DB.PORT}], + hosts: [{ name: Config.EVENT_STORE_DB.HOST, port: Config.EVENT_STORE_DB.PORT }], user: Config.EVENT_STORE_DB.USER, password: Config.EVENT_STORE_DB.PASSWORD, - path: [Config.EVENT_STORE_DB.DATABASE] -}) + path: [Config.EVENT_STORE_DB.DATABASE], +}); export const createContext = async (ctx: any): Promise => ({ ...ctx, diff --git a/src/index.ts b/src/index.ts index d1959fa..ec52c47 100755 --- a/src/index.ts +++ b/src/index.ts @@ -29,7 +29,11 @@ import bodyParser from 'body-parser'; const app = express(); const httpServer = http.createServer(app); -const authMiddleware = createAuthMiddleware(Config.USER_ID_HEADER, Config.ORY_KETO_READ_URL, Config.AUTH_CHECK_PARTICIPANTS); +const authMiddleware = createAuthMiddleware( + Config.USER_ID_HEADER, + Config.ORY_KETO_READ_URL, + Config.AUTH_CHECK_PARTICIPANTS +); const loggerPlugin = { // Fires whenever a GraphQL request is received from a client. @@ -43,17 +47,21 @@ const loggerPlugin = { const startServer = async () => { const server = new ApolloServer({ schema: applyMiddleware(schema, authMiddleware), - plugins: [ApolloServerPluginLandingPageGraphQLPlayground(), loggerPlugin, ApolloServerPluginDrainHttpServer({ httpServer })], + plugins: [ + ApolloServerPluginLandingPageGraphQLPlayground(), + loggerPlugin, + ApolloServerPluginDrainHttpServer({ httpServer }), + ], // healthCheckPath: '/health', }); await server.start(); const corsOptions = { origin: Config.CORS_WHITELIST, - credentials: Config.ALLOW_CREDENTIALS - } + credentials: Config.ALLOW_CREDENTIALS, + }; app.get('/health', (req, res) => { res.json({ - status: 'OK' + status: 'OK', }); }); app.use( @@ -65,13 +73,12 @@ const startServer = async () => { // an Apollo Server instance and optional configuration options expressMiddleware(server, { context: createContext, - }), + }) ); - + // Modified server startup await new Promise((resolve) => httpServer.listen({ port: Config.PORT }, resolve)); console.log(`🚀 Server ready at http://localhost:${Config.PORT}/`); +}; -} - -startServer() +startServer(); diff --git a/src/schema/Transfer/dataloaders/DFSP.ts b/src/schema/Transfer/dataloaders/DFSP.ts index 25c5640..e13fe1e 100644 --- a/src/schema/Transfer/dataloaders/DFSP.ts +++ b/src/schema/Transfer/dataloaders/DFSP.ts @@ -30,31 +30,20 @@ const findDfsps = async (ctx: Context, transferIds: string[], type: DFSPType) => }, select: { transferId: true, - participantCurrency: { - include: { - participant: true, - }, - }, + participant: true }, }); return Object.fromEntries( transferParticipant.map((t) => { - const p = t.participantCurrency?.participant; + const p = t.participant; return [ t.transferId, - p - ? { - id: p?.participantId, - name: p?.name, - description: p?.description, - active: p?.isActive, - } - : { - id: 0, - name: 'Unknown', - description: 'Unknown', - active: false, - }, + { + id: p?.participantId || 0, + name: p?.name || '-', + description: p?.description || '-', + active: p?.isActive || false, + }, ]; }) ); diff --git a/src/schema/TransferSummary/Query.ts b/src/schema/TransferSummary/Query.ts index a03e1dc..e92df79 100644 --- a/src/schema/TransferSummary/Query.ts +++ b/src/schema/TransferSummary/Query.ts @@ -49,12 +49,10 @@ const Query = extendType({ LEFT JOIN transferFulfilment tF ON t.transferId = tF.transferId LEFT JOIN transferParticipant tPPayer ON tPPayer.transferId = t.transferId AND tPPayer.transferParticipantRoleTypeId = (SELECT transferParticipantRoleTypeId from transferParticipantRoleType WHERE name = 'PAYER_DFSP') - LEFT JOIN participantCurrency pCPayer ON pCPayer.participantCurrencyId = tPPayer.participantCurrencyId - LEFT JOIN participant pPayer ON pPayer.participantId = pCPayer.participantId + LEFT JOIN participant pPayer ON pPayer.participantId = tPPayer.participantId LEFT JOIN transferParticipant tPPayee ON tPPayee.transferId = t.transferId AND tPPayee.transferParticipantRoleTypeId = (SELECT transferParticipantRoleTypeId from transferParticipantRoleType WHERE name = 'PAYEE_DFSP') - LEFT JOIN participantCurrency pCPayee ON pCPayee.participantCurrencyId = tPPayee.participantCurrencyId - LEFT JOIN participant pPayee ON pPayee.participantId = pCPayee.participantId + LEFT JOIN participant pPayee ON pPayee.participantId = tPPayee.participantId LEFT JOIN currency c on t.currencyId = c.currencyId LEFT JOIN transferError tE on t.transferId = tE.transferId WHERE TRUE diff --git a/src/schema/TransferSummary/TransferSummary.ts b/src/schema/TransferSummary/TransferSummary.ts index c7f9c3b..d31bc15 100644 --- a/src/schema/TransferSummary/TransferSummary.ts +++ b/src/schema/TransferSummary/TransferSummary.ts @@ -13,7 +13,7 @@ import { objectType } from 'nexus'; const TransferSummary = objectType({ name: 'TransferSummary', definition(t) { - t.nonNull.int('count'); + t.nonNull.bigInt('count'); t.nonNull.decimal('amount'); t.field('errorCode', { type: 'Int' }); t.field('payerDFSP', { type: 'String' });