Skip to content

Commit

Permalink
feat(api): implement /tpr/verifications and /tpr/authorizations (#60)
Browse files Browse the repository at this point in the history
* refactor(name): change repo name to thirdparty-api-svc

* feat(api): start adding latest thirdpartyRequests endpoints, remove old endpoints

* fix(build): node_modules breaks build

* feat(api): rebuild from template

* refactor: remove kafka config

* chore(refactor): clean up handlers dir structure

* refactor: remove kafka config

* refactor: remove kafka config

* chore: manual api changes while we wait for api-snippets fixes

* feat(authorizations): handle authorization error appropriately

* feat(api): implement verifications based on copypaste

* refactor(unit): tidy unit tests to match updated handler layout

* feat: update central-services-shared

* fix(build): add hapi/podium workaround

* fix(build): add hapi/podium workaround

* chore(deps): fix hapi type issue

* fix(unit): update tests after refactor

* feat: update authorizations handling

* feat: authorizations test and implementation

* fix: minor api issues

* chore: temp change to api-snippets branch

* feat(unit): finish tests for new resources

* feat(domain): authorizations tests

* fix(unit): authorizations domain tests

* fix(unit): all existing tests pass

* feat(domain): verifications tests

* feat(domain): verifications tests

* feat(handlers): authorizations test

* feat(handlers): verifications test

* chore: appease linting gods

* fix(vulns): run npm audit, fix and ignore unfixable low and moderate for 1 month

* fix(bdd): remove older bdd scenarios

* chore(cleanup): update to latest api-snippets, clean up jsdocs
  • Loading branch information
lewisdaly authored Aug 26, 2021
1 parent b52db91 commit 9b68d9d
Show file tree
Hide file tree
Showing 77 changed files with 2,999 additions and 2,531 deletions.
2 changes: 1 addition & 1 deletion .versionrc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = {
header: '# Changelog: [mojaloop/thirdparty-api-adapter](https://github.com/mojaloop/thirdparty-api-adapter)',
header: '# Changelog: [mojaloop/thirdparty-api-svc](https://github.com/mojaloop/thirdparty-api-svc)',
types: [
{ type: 'feat', section: 'Features' },
{ type: 'fix', section: 'Bug Fixes' },
Expand Down
162 changes: 81 additions & 81 deletions CHANGELOG.md

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
FROM node:14.3.0-alpine as builder
USER root

WORKDIR /opt/thirdparty-api-adapter
WORKDIR /opt/thirdparty-api-svc

RUN apk add --no-cache -t build-dependencies git make gcc g++ python libtool autoconf automake \
&& cd $(npm root -g)/npm \
&& npm config set unsafe-perm true \
&& npm install -g node-gyp

COPY package.json package-lock.json* /opt/thirdparty-api-adapter/
COPY package.json package-lock.json* /opt/thirdparty-api-svc/
RUN npm ci

# check in .dockerignore what is skipped during copy
Expand All @@ -18,7 +18,7 @@ COPY . .
RUN apk del build-dependencies

FROM node:14.3.0-alpine
WORKDIR /opt/thirdparty-api-adapter
WORKDIR /opt/thirdparty-api-svc

# Create empty log file & link stdout to the application log file
RUN mkdir ./logs && touch ./logs/combined.log
Expand All @@ -28,7 +28,7 @@ RUN ln -sf /dev/stdout ./logs/combined.log
RUN adduser -D ml-user
USER ml-user

COPY --chown=ml-user --from=builder /opt/thirdparty-api-adapter .
COPY --chown=ml-user --from=builder /opt/thirdparty-api-svc .

# skip this step for now - in the future we need to properly compile to js
# but before then, we still need ts-node and friends
Expand Down
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# thirdparty-api-adapter (Work in Progress)
[![Git Commit](https://img.shields.io/github/last-commit/mojaloop/thirdparty-api-adapter.svg?style=flat)](https://github.com/mojaloop/thirdparty-api-adapter/commits/master)
[![Git Releases](https://img.shields.io/github/release/mojaloop/thirdparty-api-adapter.svg?style=flat)](https://github.com/mojaloop/thirdparty-api-adapter/releases)
[![CircleCI](https://circleci.com/gh/mojaloop/thirdparty-api-adapter.svg?style=svg)](https://circleci.com/gh/mojaloop/thirdparty-api-adapter)
# thirdparty-api-svc (Work in Progress)
[![Git Commit](https://img.shields.io/github/last-commit/mojaloop/thirdparty-api-svc.svg?style=flat)](https://github.com/mojaloop/thirdparty-api-svc/commits/master)
[![Git Releases](https://img.shields.io/github/release/mojaloop/thirdparty-api-svc.svg?style=flat)](https://github.com/mojaloop/thirdparty-api-svc/releases)
[![CircleCI](https://circleci.com/gh/mojaloop/thirdparty-api-svc.svg?style=svg)](https://circleci.com/gh/mojaloop/thirdparty-api-svc)

The thirdparty-api-adapter service is used to handle HTTP requests from third parties.
The thirdparty-api-svc service is used to handle HTTP requests from third parties.

## Overview

Expand Down Expand Up @@ -32,23 +32,23 @@ When setting configuration using environment variables, the `THIRD_PARTY` enviro

### Clone repo
```bash
git clone git@github.com:mojaloop/thirdparty-api-adapter.git
git clone git@github.com:mojaloop/thirdparty-api-svc.git
```

### Improve local DNS resolver
Add the `127.0.0.1 thirdparty-api-adapter.local` entry in your `/etc/hosts` so the _thirdparty-api-adapter_ is reachable on `http://thirdparty-api-adapter.local:3008`. Elsewhere use `http://localhost:3008`
Add the `127.0.0.1 thirdparty-api-svc.local` entry in your `/etc/hosts` so the _thirdparty-api-svc_ is reachable on `http://thirdparty-api-svc.local:3008`. Elsewhere use `http://localhost:3008`

### Install service dependencies
```bash
cd thirdparty-api-adapter
cd thirdparty-api-svc
npm ci
```

### Run local dockerized _thirdparty-api-adapter_
### Run local dockerized _thirdparty-api-svc_
```bash
npm run docker:build
npm run docker:run
```

To check the thirdparty-api-adapter health visit [http://thirdparty-api-adapter.local:3008/health](http://thirdparty-api-adapter.local:3008/health)
To check the thirdparty-api-svc health visit [http://thirdparty-api-svc.local:3008/health](http://thirdparty-api-svc.local:3008/health)

2 changes: 1 addition & 1 deletion ambient.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ declare module '@mojaloop/central-services-metrics' {
* @returns {Histogram} - The Prometheus Histogram object
* @throws {Error} -
*/
getHistogram: (name: string, help?: string, labelNames?: string[], buckets?: number[]) => Histogram
getHistogram: (name: string, help?: string, labelNames?: string[], buckets?: number[]) => Histogram<string>

/**
* @function getMetricsForPrometheus
Expand Down
47 changes: 32 additions & 15 deletions audit-resolve.json
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@
},
"1500|@mojaloop/central-services-shared>widdershins>yargs>yargs-parser": {
"decision": "ignore",
"madeAt": 1623324897308,
"expiresAt": 1625916696951
"madeAt": 1629952647577,
"expiresAt": 1632544382596
},
"1594|@mojaloop/central-services-health>@mojaloop/central-services-shared>axios": {
"decision": "ignore",
Expand Down Expand Up @@ -227,17 +227,17 @@
},
"1675|@mojaloop/central-services-shared>shins>sanitize-html": {
"decision": "ignore",
"madeAt": 1623324898706,
"expiresAt": 1625916696951
"madeAt": 1629952654181,
"expiresAt": 1632544382596
},
"1676|@mojaloop/central-services-health>@mojaloop/central-services-shared>shins>sanitize-html": {
"decision": "fix",
"madeAt": 1623324716558
},
"1676|@mojaloop/central-services-shared>shins>sanitize-html": {
"decision": "ignore",
"madeAt": 1623324898707,
"expiresAt": 1625916696951
"madeAt": 1629952654182,
"expiresAt": 1632544382596
},
"1500|00unidentified>widdershins>yargs>yargs-parser": {
"decision": "ignore",
Expand Down Expand Up @@ -274,19 +274,16 @@
"expiresAt": 1625916696951
},
"1751|@mojaloop/central-services-shared>shins>chokidar>glob-parent": {
"decision": "ignore",
"madeAt": 1623324891098,
"expiresAt": 1625916696951
"decision": "fix",
"madeAt": 1629952395846
},
"1751|@typescript-eslint/eslint-plugin>@typescript-eslint/experimental-utils>@typescript-eslint/typescript-estree>globby>fast-glob>glob-parent": {
"decision": "ignore",
"madeAt": 1623324891098,
"expiresAt": 1625916696951
"decision": "fix",
"madeAt": 1629952395846
},
"1751|@typescript-eslint/parser>@typescript-eslint/typescript-estree>globby>fast-glob>glob-parent": {
"decision": "ignore",
"madeAt": 1623324891098,
"expiresAt": 1625916696951
"decision": "fix",
"madeAt": 1629952395846
},
"1753|@mojaloop/api-snippets>openapi-typescript>meow>trim-newlines": {
"decision": "ignore",
Expand All @@ -312,6 +309,26 @@
"decision": "ignore",
"madeAt": 1623324895920,
"expiresAt": 1625916696951
},
"1753|00unidentified>openapi-typescript>meow>trim-newlines": {
"decision": "fix",
"madeAt": 1629952409122
},
"1770|@mojaloop/event-sdk>grpc>@mapbox/node-pre-gyp>tar": {
"decision": "fix",
"madeAt": 1629952425105
},
"1771|@mojaloop/event-sdk>grpc>@mapbox/node-pre-gyp>tar": {
"decision": "fix",
"madeAt": 1629952425105
},
"1773|00unidentified>openapi-typescript>meow>read-pkg-up>read-pkg>normalize-package-data>resolve>path-parse": {
"decision": "fix",
"madeAt": 1629952641985
},
"1773|00unidentified>ttypescript>resolve>path-parse": {
"decision": "fix",
"madeAt": 1629952641985
}
},
"rules": {},
Expand Down
35 changes: 1 addition & 34 deletions config/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,44 +26,11 @@
"timeout": 5000,
"prefix": "moja_3p_api",
"defaultLabels": {
"serviceName": "thirdparty-api-adapter"
"serviceName": "thirdparty-api-svc"
}
}
}
},
"KAFKA": {
"TOPIC_TEMPLATES": {
"GENERAL_TOPIC_TEMPLATE": {
"TEMPLATE": "topic-{{functionality}}-{{action}}",
"REGEX": "topic-(.*)-(.*)"
}
},
"CONSUMER": [
{
"eventType": "notification",
"eventAction": "commit",
"options": {
"mode": 2,
"batchSize": 1,
"pollFrequency": 10,
"recursiveTimeout": 100,
"messageCharset": "utf8",
"messageAsJSON": true,
"sync": true,
"consumeTimeout": 1000
},
"rdkafkaConf": {
"client.id": "3p-con-notification-event",
"group.id": "3p-group-notification-event",
"metadata.broker.list": "localhost:9092",
"socket.keepalive.enable": true
},
"topicConf": {
"auto.offset.reset": "earliest"
}
}
]
},
"MOCK_CALLBACK": {
"transactionRequestId": "abc-12345",
"pispId": "pisp"
Expand Down
8 changes: 4 additions & 4 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# thirdparty-api-adapter/Docs
# thirdparty-api-svc/Docs

Documentation for the thirdparty-api-adapter service
Documentation for the thirdparty-api-svc service
## BDD

[jest-cucumber](https://github.com/bencompton/jest-cucumber) allows to use `jest` to execute Gherkin scenarios. Thanks to `jest` we are getting also code coverage for BDD Scenarios.
Expand Down Expand Up @@ -131,9 +131,9 @@ To run the image with attached the log output to your terminal
npm run docker:run
```

When the image is run you should be able to reach the dockerized _thirdparty-api-adapter_ exposed on `http://localhost:3008`.
When the image is run you should be able to reach the dockerized _thirdparty-api-svc_ exposed on `http://localhost:3008`.

If you already added the `127.0.0.1 thirdparty-api-adapter.local` entry in your `/etc/hosts` then the _thirdparty-api-adapter_ is reachable on `http://thirdparty-api-adapter.local:3008`.
If you already added the `127.0.0.1 thirdparty-api-svc.local` entry in your `/etc/hosts` then the _thirdparty-api-svc_ is reachable on `http://thirdparty-api-svc.local:3008`.

## `kafkacat` notes

Expand Down
Loading

0 comments on commit 9b68d9d

Please sign in to comment.