From fe9df7958e0c6ed82ea0b7910da2bbc8a2ccb4d7 Mon Sep 17 00:00:00 2001 From: Gbadebo Bello Date: Wed, 5 Nov 2025 18:15:42 +0100 Subject: [PATCH 1/3] commit --- .postman/config.json | 14 + ...rgalactic Bank API.postman_collection.json | 298 ++++++++++++++++++ .../globals/workspace.postman_globals.json | 7 + postman/specs/intergalactic-bank-api.yaml | 5 + 4 files changed, 324 insertions(+) create mode 100644 .postman/config.json create mode 100644 postman/collections/Intergalactic Bank API.postman_collection.json create mode 100644 postman/globals/workspace.postman_globals.json create mode 100644 postman/specs/intergalactic-bank-api.yaml diff --git a/.postman/config.json b/.postman/config.json new file mode 100644 index 0000000..61fb7a3 --- /dev/null +++ b/.postman/config.json @@ -0,0 +1,14 @@ +{ + "workspace": { + "id": "8100975d-142b-42a0-81da-fd8423d7c2b5" + }, + "entities": { + "collections": [], + "environments": [], + "specs": [ + "../postman/specs/intergalactic-bank-api.yaml" + ], + "flows": [], + "globals": [] + } +} \ No newline at end of file diff --git a/postman/collections/Intergalactic Bank API.postman_collection.json b/postman/collections/Intergalactic Bank API.postman_collection.json new file mode 100644 index 0000000..2beeeb7 --- /dev/null +++ b/postman/collections/Intergalactic Bank API.postman_collection.json @@ -0,0 +1,298 @@ +{ + "info": { + "_postman_id": "f1122f9b-029f-478a-b420-03e6e66358fc", + "name": "Intergalactic Bank API", + "description": "Collection generated from Intergalactic Bank API OpenAPI specification.", + "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" + }, + "item": [ + { + "name": "Admin", + "item": [ + { + "name": "Generate API key", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "const response = pm.response.json();", + "", + "pm.collectionVariables.set(\"apiKey\", response.apiKey);" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "url": { + "raw": "http://localhost:3000/api/v1/auth", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "3000", + "path": [ + "api", + "v1", + "auth" + ] + } + } + } + ], + "description": "Administrative operations including API key management" + }, + { + "name": "Accounts", + "item": [ + { + "name": "List all accounts", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", + "});", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "x-api-key", + "value": "{{apiKey}}", + "type": "text" + } + ], + "url": { + "raw": "http://localhost:3000/api/v1/accounts", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "3000", + "path": [ + "api", + "v1", + "accounts" + ] + } + } + }, + { + "name": "Create new account", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 201 (Created)\", function () {", + " pm.response.to.have.status(201);", + "});", + "", + "pm.test(\"Response time is less than 2000 ms\", function () {", + " pm.expect(pm.response.responseTime).to.be.below(2000);", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{apiKey}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"owner\": \"Nova Newman\",\n \"balance\": 500,\n \"currency\": \"COSMIC_COINS\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "http://localhost:3000/api/v1/accounts", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "3000", + "path": [ + "api", + "v1", + "accounts" + ] + } + } + } + ], + "description": "Account management operations. An account at the Intergalactic Bank allows you to store funds. Use these endpoints to list, create, update, and delete accounts." + }, + { + "name": "Transactions", + "item": [ + { + "name": "List all transactions", + "request": { + "method": "GET", + "header": [ + { + "key": "x-api-key", + "value": "{{apiKey}}", + "type": "text" + } + ], + "url": { + "raw": "http://localhost:3000/api/v1/transactions", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "3000", + "path": [ + "api", + "v1", + "transactions" + ] + } + } + }, + { + "name": "Create new transaction", + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + }, + { + "key": "x-api-key", + "value": "{{apiKey}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"fromAccountId\": \"12345678\",\n \"toAccountId\": \"87654321\",\n \"amount\": 10000,\n \"currency\": \"COSMIC_COINS\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "http://localhost:3000/api/v1/transactions", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "3000", + "path": [ + "api", + "v1", + "transactions" + ] + } + } + }, + { + "name": "Get transaction by ID", + "request": { + "method": "GET", + "header": [ + { + "key": "x-api-key", + "value": "{{apiKey}}", + "type": "text" + } + ], + "url": { + "raw": "http://localhost:3000/api/v1/transactions/1", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "3000", + "path": [ + "api", + "v1", + "transactions", + "1" + ] + } + } + } + ], + "description": "Transaction operations. A transaction records money moving in or out of an account. Transactions at the Galactic Bank follow a blockchain-like approach. Once created, they cannot be updated or deleted." + } + ], + "auth": { + "type": "apikey", + "apikey": [ + { + "key": "value", + "value": "{{apiKey}}", + "type": "string" + }, + { + "key": "key", + "value": "x-api-key", + "type": "string" + } + ] + }, + "variable": [ + { + "key": "apiKey", + "value": "" + } + ] +} \ No newline at end of file diff --git a/postman/globals/workspace.postman_globals.json b/postman/globals/workspace.postman_globals.json new file mode 100644 index 0000000..b854449 --- /dev/null +++ b/postman/globals/workspace.postman_globals.json @@ -0,0 +1,7 @@ +{ + "id": "ba1aa6f9-4f00-4fc9-82ce-c21923ba9e17", + "name": "Globals", + "values": [], + "_postman_variable_scope": "globals", + "_postman_exported_at": "2025-11-05T17:03:43.656Z" +} \ No newline at end of file diff --git a/postman/specs/intergalactic-bank-api.yaml b/postman/specs/intergalactic-bank-api.yaml new file mode 100644 index 0000000..382fe09 --- /dev/null +++ b/postman/specs/intergalactic-bank-api.yaml @@ -0,0 +1,5 @@ +openapi: '3.0.0' +info: + title: Intergalactic Bank API + version: '1.0.0' +paths: {} \ No newline at end of file From 8ad8aed28866d2f124fc5a694081bf9c74debede Mon Sep 17 00:00:00 2001 From: Gbadebo Bello Date: Wed, 5 Nov 2025 18:16:24 +0100 Subject: [PATCH 2/3] added a new route --- src/routes/accounts.js | 48 +++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/src/routes/accounts.js b/src/routes/accounts.js index 6165297..e29f1c2 100644 --- a/src/routes/accounts.js +++ b/src/routes/accounts.js @@ -40,33 +40,33 @@ router.get('/', validateApiKey, (req, res) => { * GET /api/v1/accounts/:accountId * Get a specific account by ID */ -// router.get('/:accountId', validateApiKey, (req, res) => { -// try { -// const { accountId } = req.params; +router.get('/:accountId', validateApiKey, (req, res) => { + try { + const { accountId } = req.params; -// const account = db.getAccountById(accountId); + const account = db.getAccountById(accountId); -// if (!account) { -// return res.status(404).json({ -// error: { -// name: 'instanceNotFoundError', -// message: 'The specified account does not exist.' -// } -// }); -// } + if (!account) { + return res.status(404).json({ + error: { + name: 'instanceNotFoundError', + message: 'The specified account does not exist.' + } + }); + } -// res.status(200).json({ -// account: account.toJSON() -// }); -// } catch (error) { -// res.status(500).json({ -// error: { -// name: 'serverError', -// message: 'Failed to retrieve account' -// } -// }); -// } -// }); + res.status(200).json({ + account: account.toJSON() + }); + } catch (error) { + res.status(500).json({ + error: { + name: 'serverError', + message: 'Failed to retrieve account' + } + }); + } +}); /** * POST /api/v1/accounts From f496348c1a79838ee689499aa4cb34be049247b2 Mon Sep 17 00:00:00 2001 From: Gbadebo Bello Date: Mon, 10 Nov 2025 16:23:36 +0100 Subject: [PATCH 3/3] commit --- .github/workflows/postman.yaml | 1 - .postman/config.json | 14 - ...rgalactic Bank API.postman_collection.json | 298 ------------------ .../globals/workspace.postman_globals.json | 7 - postman/specs/intergalactic-bank-api.yaml | 5 - src/routes/accounts.js | 48 +-- 6 files changed, 24 insertions(+), 349 deletions(-) delete mode 100644 .postman/config.json delete mode 100644 postman/collections/Intergalactic Bank API.postman_collection.json delete mode 100644 postman/globals/workspace.postman_globals.json delete mode 100644 postman/specs/intergalactic-bank-api.yaml diff --git a/.github/workflows/postman.yaml b/.github/workflows/postman.yaml index dce81b6..842b908 100644 --- a/.github/workflows/postman.yaml +++ b/.github/workflows/postman.yaml @@ -87,7 +87,6 @@ jobs: ls -la postman/environments/ - name: Push workspace to Postman - if: github.event_name != 'pull_request' run: postman workspace push -y - name: Confirm sync success diff --git a/.postman/config.json b/.postman/config.json deleted file mode 100644 index 61fb7a3..0000000 --- a/.postman/config.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "workspace": { - "id": "8100975d-142b-42a0-81da-fd8423d7c2b5" - }, - "entities": { - "collections": [], - "environments": [], - "specs": [ - "../postman/specs/intergalactic-bank-api.yaml" - ], - "flows": [], - "globals": [] - } -} \ No newline at end of file diff --git a/postman/collections/Intergalactic Bank API.postman_collection.json b/postman/collections/Intergalactic Bank API.postman_collection.json deleted file mode 100644 index 2beeeb7..0000000 --- a/postman/collections/Intergalactic Bank API.postman_collection.json +++ /dev/null @@ -1,298 +0,0 @@ -{ - "info": { - "_postman_id": "f1122f9b-029f-478a-b420-03e6e66358fc", - "name": "Intergalactic Bank API", - "description": "Collection generated from Intergalactic Bank API OpenAPI specification.", - "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" - }, - "item": [ - { - "name": "Admin", - "item": [ - { - "name": "Generate API key", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "const response = pm.response.json();", - "", - "pm.collectionVariables.set(\"apiKey\", response.apiKey);" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "url": { - "raw": "http://localhost:3000/api/v1/auth", - "protocol": "http", - "host": [ - "localhost" - ], - "port": "3000", - "path": [ - "api", - "v1", - "auth" - ] - } - } - } - ], - "description": "Administrative operations including API key management" - }, - { - "name": "Accounts", - "item": [ - { - "name": "List all accounts", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {", - " pm.response.to.have.status(200);", - "});", - "" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [ - { - "key": "x-api-key", - "value": "{{apiKey}}", - "type": "text" - } - ], - "url": { - "raw": "http://localhost:3000/api/v1/accounts", - "protocol": "http", - "host": [ - "localhost" - ], - "port": "3000", - "path": [ - "api", - "v1", - "accounts" - ] - } - } - }, - { - "name": "Create new account", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 201 (Created)\", function () {", - " pm.response.to.have.status(201);", - "});", - "", - "pm.test(\"Response time is less than 2000 ms\", function () {", - " pm.expect(pm.response.responseTime).to.be.below(2000);", - "});" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [ - { - "key": "Content-Type", - "value": "application/json", - "type": "text" - }, - { - "key": "x-api-key", - "value": "{{apiKey}}", - "type": "text" - } - ], - "body": { - "mode": "raw", - "raw": "{\n \"owner\": \"Nova Newman\",\n \"balance\": 500,\n \"currency\": \"COSMIC_COINS\"\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "http://localhost:3000/api/v1/accounts", - "protocol": "http", - "host": [ - "localhost" - ], - "port": "3000", - "path": [ - "api", - "v1", - "accounts" - ] - } - } - } - ], - "description": "Account management operations. An account at the Intergalactic Bank allows you to store funds. Use these endpoints to list, create, update, and delete accounts." - }, - { - "name": "Transactions", - "item": [ - { - "name": "List all transactions", - "request": { - "method": "GET", - "header": [ - { - "key": "x-api-key", - "value": "{{apiKey}}", - "type": "text" - } - ], - "url": { - "raw": "http://localhost:3000/api/v1/transactions", - "protocol": "http", - "host": [ - "localhost" - ], - "port": "3000", - "path": [ - "api", - "v1", - "transactions" - ] - } - } - }, - { - "name": "Create new transaction", - "request": { - "method": "POST", - "header": [ - { - "key": "Content-Type", - "value": "application/json", - "type": "text" - }, - { - "key": "x-api-key", - "value": "{{apiKey}}", - "type": "text" - } - ], - "body": { - "mode": "raw", - "raw": "{\n \"fromAccountId\": \"12345678\",\n \"toAccountId\": \"87654321\",\n \"amount\": 10000,\n \"currency\": \"COSMIC_COINS\"\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "http://localhost:3000/api/v1/transactions", - "protocol": "http", - "host": [ - "localhost" - ], - "port": "3000", - "path": [ - "api", - "v1", - "transactions" - ] - } - } - }, - { - "name": "Get transaction by ID", - "request": { - "method": "GET", - "header": [ - { - "key": "x-api-key", - "value": "{{apiKey}}", - "type": "text" - } - ], - "url": { - "raw": "http://localhost:3000/api/v1/transactions/1", - "protocol": "http", - "host": [ - "localhost" - ], - "port": "3000", - "path": [ - "api", - "v1", - "transactions", - "1" - ] - } - } - } - ], - "description": "Transaction operations. A transaction records money moving in or out of an account. Transactions at the Galactic Bank follow a blockchain-like approach. Once created, they cannot be updated or deleted." - } - ], - "auth": { - "type": "apikey", - "apikey": [ - { - "key": "value", - "value": "{{apiKey}}", - "type": "string" - }, - { - "key": "key", - "value": "x-api-key", - "type": "string" - } - ] - }, - "variable": [ - { - "key": "apiKey", - "value": "" - } - ] -} \ No newline at end of file diff --git a/postman/globals/workspace.postman_globals.json b/postman/globals/workspace.postman_globals.json deleted file mode 100644 index b854449..0000000 --- a/postman/globals/workspace.postman_globals.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "id": "ba1aa6f9-4f00-4fc9-82ce-c21923ba9e17", - "name": "Globals", - "values": [], - "_postman_variable_scope": "globals", - "_postman_exported_at": "2025-11-05T17:03:43.656Z" -} \ No newline at end of file diff --git a/postman/specs/intergalactic-bank-api.yaml b/postman/specs/intergalactic-bank-api.yaml deleted file mode 100644 index 382fe09..0000000 --- a/postman/specs/intergalactic-bank-api.yaml +++ /dev/null @@ -1,5 +0,0 @@ -openapi: '3.0.0' -info: - title: Intergalactic Bank API - version: '1.0.0' -paths: {} \ No newline at end of file diff --git a/src/routes/accounts.js b/src/routes/accounts.js index e29f1c2..6165297 100644 --- a/src/routes/accounts.js +++ b/src/routes/accounts.js @@ -40,33 +40,33 @@ router.get('/', validateApiKey, (req, res) => { * GET /api/v1/accounts/:accountId * Get a specific account by ID */ -router.get('/:accountId', validateApiKey, (req, res) => { - try { - const { accountId } = req.params; +// router.get('/:accountId', validateApiKey, (req, res) => { +// try { +// const { accountId } = req.params; - const account = db.getAccountById(accountId); +// const account = db.getAccountById(accountId); - if (!account) { - return res.status(404).json({ - error: { - name: 'instanceNotFoundError', - message: 'The specified account does not exist.' - } - }); - } +// if (!account) { +// return res.status(404).json({ +// error: { +// name: 'instanceNotFoundError', +// message: 'The specified account does not exist.' +// } +// }); +// } - res.status(200).json({ - account: account.toJSON() - }); - } catch (error) { - res.status(500).json({ - error: { - name: 'serverError', - message: 'Failed to retrieve account' - } - }); - } -}); +// res.status(200).json({ +// account: account.toJSON() +// }); +// } catch (error) { +// res.status(500).json({ +// error: { +// name: 'serverError', +// message: 'Failed to retrieve account' +// } +// }); +// } +// }); /** * POST /api/v1/accounts