Skip to content

Commit

Permalink
chore: setting up core connector template
Browse files Browse the repository at this point in the history
  • Loading branch information
elijah0kello committed Aug 28, 2024
1 parent a57c669 commit 0bd49cd
Show file tree
Hide file tree
Showing 18 changed files with 80 additions and 27 deletions.
5 changes: 5 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .idea/ml-reference-connectors.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ git clone https://github.com/mojaloop/ml-reference-connectors.git
To understand the code structure and how to refactor this code base for a new connector, please refer to the section for [code structure](#core-structure-and-architecture)

# Core structure and Architecture

Below is an output of the directory structure of the core connector template.

To use this template, you will need to understand it's structure, the changing components and the static components which you should not worry about.

```bash
.
├── Dockerfile
Expand Down Expand Up @@ -81,7 +86,8 @@ To understand the code structure and how to refactor this code base for a new co

12 directories, 15 files
```
<!-- todo: add code structure -->
# Components
The template contains the

# Configuration.
All configuration for any core connector should be put in environment variables.
Expand Down
12 changes: 9 additions & 3 deletions core-connector-template/.env.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# CBS Config

FINERACT_TENANT_ID=default
FINERACT_AUTH_MODE=basic
FINERACT_USERNAME=mifos
Expand All @@ -8,10 +10,14 @@ FINERACT_BANK_COUNTRY_CODE=UG
FINERACT_CHECK_DIGITS=68
FINERACT_LOCALE=en
FINERACT_PAYMENT_TYPE_ID=1
SDK_SERVER_HOST=0.0.0.0
SDK_SERVER_PORT=3003
DFSP_SERVER_HOST=0.0.0.0
DFSP_SERVER_PORT=3004
#Do not put the trailing slash on the url
FINERACT_BASE_URL=https://demo.mifos.io/fineract-provider/api/v1
SDK_BASE_URL=http://localhost:4010
SUPPORTED_ID_TYPE=MSISDN

#Mojaloop Connector
#Do not put the trailing slash on the url
SDK_BASE_URL=http://localhost:4010
SDK_SERVER_HOST=0.0.0.0
SDK_SERVER_PORT=3003
4 changes: 2 additions & 2 deletions core-connector-template/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 8 additions & 7 deletions core-connector-template/package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
{
"name": "@mojaloop/mifos-core-connector",
"name": "@mojaloop/core-connector-template",
"version": "1.3.0",
"description": "A connector that facilitates payments between a Mojaloop Connector (SDK Scheme Adapter) and a Core Banking system",
"main": "dist/index.js",
"scripts": {
"test": "npm run test:unit",
"test:functional": "jest --testMatch='**/func/**/*.test.ts' --coverage --collectCoverageFrom='**/src/**/*.ts' --detectOpenHandles",
"test:unit": "jest --testMatch='**/unit/**/*.test.ts'",
"test:int": "jest --testMatch='**/int/**/*.test.ts'",
"test:unit:cov": "npm run test:unit -- --coverage",
"prepare": "husky || true",
"clean": "npm run clean:npm; npm run clean:dist",
Expand All @@ -15,8 +16,8 @@
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"build": "tsc",
"build:docker": "docker build -t mifos-core-connector:local .",
"start:docker": "npm run build:docker && docker run -p 127.0.0.1:3000:3000/tcp mifos-core-connector:local",
"build:docker": "docker build -t core-connector-template:local .",
"start:docker": "npm run build:docker && docker run -p 127.0.0.1:3000:3000/tcp core-connector-template:local",
"watch": "tsc -w",
"start": "npm run start:no-build",
"start:no-build": "node dist/src/index.js",
Expand All @@ -30,17 +31,17 @@
},
"repository": {
"type": "git",
"url": "https://github.com/mojaloop/mifos-core-connector.git"
"url": "https://github.com/mojaloop/core-connector-template.git"
},
"keywords": [
"g2p"
],
"author": "Elijah Okello",
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/mojaloop/mifos-core-connector/issues"
"url": "https://github.com/mojaloop/core-connector-template/issues"
},
"homepage": "https://github.com/mojaloop/mifos-core-connector#readme",
"homepage": "https://github.com/mojaloop/core-connector-template#readme",
"devDependencies": {
"@commitlint/cli": "^18.6.1",
"@commitlint/config-conventional": "^18.6.3",
Expand Down Expand Up @@ -72,7 +73,7 @@
"typescript": "^5.3.3"
},
"dependencies": {
"@hapi/hapi": "^21.3.10",
"@hapi/hapi": "^21.3.10",
"@mojaloop/central-services-logger": "^11.3.1",
"axios": "^1.6.8",
"convict": "^6.2.4",
Expand Down
1 change: 1 addition & 0 deletions core-connector-template/src/config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import "dotenv/config";
import Convict from 'convict';
import { IdType, TFineractConfig } from './domain/CBSClient';
import { TSDKSchemeAdapterConfig } from './domain/SDKClient';
Expand Down
4 changes: 2 additions & 2 deletions core-connector-template/src/core-connector-svc/Service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import config from '../config';
import { CoreConnectorRoutes } from './coreConnectorRoutes';
import { loggerFactory } from '../infra/logger';
import { createPlugins } from '../plugins';
import { FineractClientFactory } from '../domain/CBSClient';
import { CBSClientFactory } from '../domain/CBSClient';
import { SDKClientFactory } from '../domain/SDKClient';
import { DFSPCoreConnectorRoutes } from './dfspCoreConnectorRoutes';

Expand All @@ -50,7 +50,7 @@ export class Service {
static async start(httpClient: IHTTPClient = AxiosClientFactory.createAxiosClientInstance()) {
this.httpClient = httpClient;
const fineractConfig = config.get('fineract');
const fineractClient = FineractClientFactory.createClient({
const fineractClient = CBSClientFactory.createClient({
fineractConfig: fineractConfig,
httpClient: this.httpClient,
logger: logger,
Expand Down
2 changes: 1 addition & 1 deletion core-connector-template/src/domain/CBSClient/CBSClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export const ROUTES = Object.freeze({
charges: 'charges',
});

export class FineractClient implements IFineractClient {
export class CBSClient implements IFineractClient {
fineractConfig: TFineractConfig;
httpClient: IHTTPClient;
logger: ILogger;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@
******/
'use strict';

import { FineractClient } from './FineractClient';
import { CBSClient } from './CBSClient';
import { TFineractClientFactoryDeps } from './types';

export class FineractClientFactory {
export class CBSClientFactory {
static createClient(finClientfactoryDeps: TFineractClientFactoryDeps) {
return new FineractClient(
return new CBSClient(
finClientfactoryDeps.fineractConfig,
finClientfactoryDeps.httpClient,
finClientfactoryDeps.logger,
Expand Down
4 changes: 2 additions & 2 deletions core-connector-template/src/domain/CBSClient/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
******/
'use strict';

export * from './FineractClientFactory';
export * from './FineractClient';
export * from './CBSClientFactory';
export * from './CBSClient';
export * from './errors';
export * from './types';
2 changes: 2 additions & 0 deletions core-connector-template/src/domain/CBSClient/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,3 +290,5 @@ export type TFineractCharge = {
};

export type TFineractGetChargeResponse = TFineractCharge[];


4 changes: 2 additions & 2 deletions core-connector-template/test/func/fineract_client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
******/
'use strict';

import { FineractClientFactory, TFineractConfig } from '../../src/domain/CBSClient';
import { CBSClientFactory, TFineractConfig } from '../../src/domain/CBSClient';
import { loggerFactory } from '../../src/infra/logger';
import config from '../../src/config';
import { AxiosClientFactory } from '../../src/infra/axiosHttpClient';
Expand All @@ -35,7 +35,7 @@ const logger = loggerFactory({ context: 'Mifos Core Connector Tests' });
const fineractConfig = config.get('fineract') as TFineractConfig;

const httpClient = AxiosClientFactory.createAxiosClientInstance();
const fineractClient = FineractClientFactory.createClient({
const fineractClient = CBSClientFactory.createClient({
fineractConfig,
httpClient,
logger,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import axios from 'axios';
import MockAdapter from 'axios-mock-adapter';

import { CoreConnectorAggregate, TtransferRequest, ValidationError } from '../../../src/domain';
import { FineractClientFactory, FineractError, IFineractClient } from '../../../src/domain/CBSClient';
import { CBSClientFactory, FineractError, IFineractClient } from '../../../src/domain/CBSClient';
import {
ISDKClient,
SDKClientError,
Expand Down Expand Up @@ -61,7 +61,7 @@ describe('CoreConnectorAggregate Tests -->', () => {
mockAxios.reset();
const httpClient = AxiosClientFactory.createAxiosClientInstance();
sdkClient = SDKClientFactory.getSDKClientInstance(logger, httpClient, SDK_URL);
fineractClient = FineractClientFactory.createClient({
fineractClient = CBSClientFactory.createClient({
fineractConfig,
httpClient,
logger,
Expand Down
4 changes: 2 additions & 2 deletions core-connector-template/test/unit/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import { randomUUID } from 'crypto';
import { AxiosClientFactory } from '../../src/infra/axiosHttpClient';
import config from '../../src/config';
import { FineractClientFactory } from '../../src/domain/CBSClient';
import { CBSClientFactory } from '../../src/domain/CBSClient';
import { TFineractConfig } from '../../src/domain/CBSClient';
import { loggerFactory } from '../../src/infra/logger';
import { CoreConnectorAggregate, TQuoteRequest, TtransferRequest } from '../../src/domain';
Expand All @@ -37,7 +37,7 @@ const logger = loggerFactory({ context: 'Mifos Core Connector Tests' });
const fineractConfig = config.get('fineract') as TFineractConfig;

const httpClient = AxiosClientFactory.createAxiosClientInstance();
const fineractClient = FineractClientFactory.createClient({
const fineractClient = CBSClientFactory.createClient({
fineractConfig,
httpClient,
logger,
Expand Down

0 comments on commit 0bd49cd

Please sign in to comment.