Skip to content

Commit

Permalink
Merge pull request #1 from frmscoe/0.2.0
Browse files Browse the repository at this point in the history
Moved to Kafka
  • Loading branch information
Lenbkr authored Feb 21, 2023
2 parents 1882805 + c71d18d commit 1a9326e
Show file tree
Hide file tree
Showing 28 changed files with 2,967 additions and 853 deletions.
22 changes: 14 additions & 8 deletions .env.template
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,19 @@ FUNCTION_NAME=payment_platfrom_adapter
PORT=3000
TMS_ENDPOINT='http://openfaas:8080/function/off-frm-tms-service.frm/monitor/transaction'

# ELASTIC APM
APM_LOGGING=true
APM_SERVICE_NAME=payment-platfrom-adapter
APM_URL=127.0.0.1:4857
APM_SECRET_TOKEN=secrettokenhere
TMS_PAIN001_ENDPOINT=https://openfaas:8080/function/off-transaction-monitoring-service-rel-1-0-0/execute
TMS_PAIN013_ENDPOINT=https://openfaas:8080/function/off-transaction-monitoring-service-rel-1-0-0/quoteReply
TMS_PACS002_ENDPOINT=https://openfaas:8080/function/off-transaction-monitoring-service-rel-1-0-0/transfer-response
TMS_PACS008_ENDPOINT=https://openfaas:8080/function/off-transaction-monitoring-service-rel-1-0-0/transfer

NODE_ENV=dev
# kafka
KAFKA_URI=127.0.0.1:9092
KAFKA_CLIENT_ID=example-producer
KAFKA_CONSUMER_GROUP=test-group
KAFKA_TOPIC_TO_CONSUME=test-topic

LOGSTASH_HOST=127.0.0.1
LOGSTASH_PORT=8080
# redis
REDIS_URL=127.0.0.1
REDIS_PORT=6379

NODE_ENV=dev
17 changes: 14 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
version: "2"
version: "3"
services:
redis:
payment-platform-adapter:
build:
context: .
dockerfile: Dockerfile
image: ppa
container_name: ppa
restart: unless-stopped
env_file: .env
depends_on:
- ppa-redis
ppa-redis:
image: redis
container_name: ppa-redis
ports:
- "6379:6379"
- "6379:6379"
22 changes: 14 additions & 8 deletions dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ RUN addgroup -S app && adduser -S -g app app

RUN apk --no-cache add curl ca-certificates

RUN apk add --no-cache -t build-dependencies git make gcc g++ python libtool autoconf automake yarn
RUN apk add --no-cache -t build-dependencies git make gcc g++ python3 libtool autoconf automake yarn

# Turn down the verbosity to default level.
ENV NPM_CONFIG_LOGLEVEL warn
Expand Down Expand Up @@ -55,14 +55,20 @@ ENV prefix_logs="false"

ENV FUNCTION_NAME=payment-platfrom-adapter
ENV PORT=3000
ENV TMS_ENDPOINT=http://gateway.frm:8080/function/off-transaction-monitoring-service.frm-meshed/execute
ENV APM_LOGGING=true
ENV APM_SERVICE_NAME=payment-platfrom-adapter
ENV APM_URL=http://apm-server-apm-server.frm:8200
ENV APM_SECRET_TOKEN=

ENV TMS_ENDPOINT=TMS_ENDPOINT
ENV TMS_PAIN001_ENDPOINT=TMS_PAIN001_ENDPOINT
ENV TMS_PAIN013_ENDPOINT=TMS_PAIN013_ENDPOINT
ENV TMS_PACS002_ENDPOINT=TMS_PACS002_ENDPOINT
ENV TMS_PACS008_ENDPOINT=TMS_PACS008_ENDPOINT

ENV KAFKA_URI=KAFKA_URI
ENV KAFKA_CLIENT_ID=KAFKA_CLIENT_ID
ENV KAFKA_CONSUMER_GROUP=KAFKA_CONSUMER_GROUP
ENV KAFKA_TOPIC_TO_CONSUME=KAFKA_TOPIC_TO_CONSUME
ENV REDIS_URL=REDIS_URL
ENV REDIS_PORT=REDIS_PORT
ENV NODE_ENV=dev
ENV LOGSTASH_HOST=my-release-logstash.frm-meshed
ENV LOGSTASH_PORT=8080

HEALTHCHECK --interval=3s CMD [ -e /tmp/.lock ] || exit 1

Expand Down
2 changes: 2 additions & 0 deletions jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@ export default {
// Setting this value to "fake" allows the use of fake timers for functions such as "setTimeout"
// timers: "real",

testTimeout: 30000,

// A map from regular expressions to paths to transformers
// transform: undefined,

Expand Down
13 changes: 8 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
{
"name": "payment-platform-adapter",
"version": "0.1.0",
"version": "0.2.0",
"description": "payment-platform-adapter",
"main": "build/index.js",
"scripts": {
"dev": "nodemon",
"build": "tsc",
"start": "node build/index.js",
"cleanup": "rm -rf build template jest.config.js jest.config.js.map node_modules",
"cleanup": "rm -rf build template jest.config.js jest.config.js.map",
"cleanupAll": "rm -rf build template jest.config.js jest.config.js.map node_modules",
"fix": "yarn fix:prettier && yarn fix:eslint",
"fix:eslint": "eslint --fix \"**/*.ts\"",
"fix:prettier": "prettier --write \"**/*.ts\"",
Expand All @@ -31,17 +32,19 @@
{
"name": "Joey Goksu",
"email": "[email protected]"
},
{
"name": "Len Bekker",
"email": "[email protected]"
}
],
"license": "ISC",
"dependencies": {
"@log4js-node/logstash-http": "^1.1.0",
"@log4js-node/logstashudp": "^1.2.1",
"@types/uuid": "^8.3.1",
"arangojs": "^7.5.0",
"axios": "^0.21.1",
"dotenv": "8.2.0",
"elastic-apm-node": "^3.14.0",
"kafkajs": "^1.15.0",
"koa": "^2.13.1",
"koa-bodyparser": "^4.3.0",
"koa-router": "^10.0.0",
Expand Down
16 changes: 10 additions & 6 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,15 @@ export const configuration: IConfig = {
functionName: <string>process.env.FUNCTION_NAME,
port: parseInt(process.env.PORT!, 10),
tmsEndpoint: <string>process.env.TMS_ENDPOINT,
apmLogging: <boolean>(process.env.APM_LOGGING === 'true'),
apmServiceName: <string>process.env.APM_SERVICE_NAME,
apmSecretToken: <string>process.env.APM_SECRET_TOKEN,
apmURL: <string>process.env.APM_URL,
tmsPain001Endpoint: <string>process.env.TMS_PAIN001_ENDPOINT,
tmsPain013Endpoint: <string>process.env.TMS_PAIN013_ENDPOINT,
tmsPacs002Endpoint: <string>process.env.TMS_PACS002_ENDPOINT,
tmsPacs008Endpoint: <string>process.env.TMS_PACS008_ENDPOINT,
kafkaURI: <string>process.env.KAFKA_URI,
kafkaClientId: <string>process.env.KAFKA_CLIENT_ID,
kafkaConsumerGroup: <string>process.env.KAFKA_CONSUMER_GROUP,
kafkaTopic: <string>process.env.KAFKA_TOPIC_TO_CONSUME,
redisURL: <string>process.env.REDIS_URL,
redisPort: parseInt(process.env.REDIS_PORT!, 10),
dev: <string>process.env.NODE_ENV,
logstashHost: <string>process.env.LOGSTASH_HOST,
logstashPort: parseInt(process.env.LOGSTASH_PORT!, 10),
};
7 changes: 7 additions & 0 deletions src/constants/event-types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export const eventType = {
AUDIT: 'audit',
UNSUPPORTED: 'Unsupported',
QUOTE: 'Quote',
TRANSFER: 'Transfer',
SETTLEMENT: 'Settlement',
};
26 changes: 26 additions & 0 deletions src/constants/quote-constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
export const quotesConstants = [
'qs_quote_handleQuoteRequest',
'qs_quote_forwardQuoteRequest',
'qs_quote_forwardQuoteRequestResend',
'qs_quote_handleQuoteUpdate',
'qs_quote_forwardQuoteUpdate',
'qs_quote_forwardQuoteUpdateResend',
'qs_quote_handleQuoteError',
'qs_quote_forwardQuoteGet',
'qs_quote_sendErrorCallback',

'qs_bulkquote_forwardBulkQuoteRequest',
'qs_quote_forwardBulkQuoteUpdate',
'qs_quote_forwardBulkQuoteGet',
'qs_quote_forwardBulkQuoteError',
'qs_bulkQuote_sendErrorCallback',

'QuotesErrorByIDPut',
'QuotesByIdGet',
'QuotesByIdPut',
'QuotesPost',
'BulkQuotesErrorByIdPut',
'BulkQuotesByIdGet',
'BulkQuotesByIdPut',
'BulkQuotesPost',
];
7 changes: 7 additions & 0 deletions src/constants/transfer-constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export const transferConstants = [
'ml_transfer_prepare',
'ml_transfer_fulfil',
'ml_transfer_abort',
'ml_transfer_getById',
'ml_notification_event',
];
Loading

0 comments on commit 1a9326e

Please sign in to comment.