Skip to content

Commit

Permalink
🐛 (gocardless) fix banksync - create singleton client
Browse files Browse the repository at this point in the history
  • Loading branch information
MatissJanis committed Nov 15, 2023
1 parent a6c1443 commit 8a3433f
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/app-gocardless/services/gocardless-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,22 @@ import { SecretName, secretsService } from '../../services/secrets-service.js';

const GoCardlessClient = nordigenNode.default;

const getGocardlessClient = () =>
new GoCardlessClient({
const clients = new Map();

const getGocardlessClient = () => {
const secrets = {
secretId: secretsService.get(SecretName.nordigen_secretId),
secretKey: secretsService.get(SecretName.nordigen_secretKey),
});
};

const hash = JSON.stringify(secrets);

if (!clients.has(hash)) {
clients.set(hash, new GoCardlessClient(secrets));
}

return clients.get(hash);
};

export const handleGoCardlessError = (response) => {
switch (response.status_code) {
Expand Down

0 comments on commit 8a3433f

Please sign in to comment.