Skip to content

Commit c6bfa0d

Browse files
authored
Merge pull request #1 from mohammed7s/feat/get-all-commitments
add get all commitments functionality
2 parents 423f403 + 4e55bb3 commit c6bfa0d

File tree

5 files changed

+17
-6
lines changed

5 files changed

+17
-6
lines changed

.env.example

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
ubuntu@ubuntu-ThinkPad-E470:~/Dropbox/WEB/openBanking/revolut$ cat .env
21
CLIENT_ID=
32
REDIRECT_URI=
43
FINANCIAL_ID=001580000103UAvAAM
54
JWKS_ROOT_DOMAIN=mohammed7s.github.io
65
KID=2kiXQyo0tedjW2somjSgH7
7-

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,7 @@ create_jwt_url_parameter.py
6565
jwt_token_step3.txt
6666

6767

68-
!.env.example
68+
!.env.example
69+
70+
data
71+
commitments.sqlite

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
},
2626
"type": "module",
2727
"scripts": {
28-
"test": "NODE_OPTIONS=--experimental-vm-modules jest"
28+
"test": "NODE_OPTIONS=--experimental-vm-modules jest",
29+
"server": "node src/api_server.js"
2930
},
3031
"jest": {
3132
"transform": {

src/api_server.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import express from 'express';
22
import dotenv from 'dotenv';
33
import { initializePayment } from './paymentService.js';
4-
import { createCommitment, getCommitmentByHash } from './commitmentDb.js';
4+
import { createCommitment, getCommitmentByHash, getAllCommitments } from './commitmentDb.js';
55

66
dotenv.config();
77

src/commitmentDb.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const __dirname = path.dirname(__filename);
1010
// Create SQLite database
1111
const sequelize = new Sequelize({
1212
dialect: 'sqlite',
13-
storage: path.join(__dirname, 'commitments.sqlite'),
13+
storage: path.join(__dirname, "commitments.sqlite"),
1414
logging: false
1515
});
1616

@@ -60,5 +60,14 @@ export async function getCommitmentByHash(hash) {
6060
}
6161
}
6262

63+
export async function getAllCommitments() {
64+
try {
65+
return await Commitment.findAll();
66+
} catch (error) {
67+
console.error('Error retrieving all commitments:', error);
68+
throw error;
69+
}
70+
}
71+
6372
// Export for use in main server file
6473
export default Commitment;

0 commit comments

Comments
 (0)