Last active
September 29, 2023 11:16
-
-
Save kmkale/ae4d9e7dec346664d258d5dc3fd86625 to your computer and use it in GitHub Desktop.
Get Accounts Lambda Stub
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* getAccounts.js | |
This lambda returns a stubbed response for CDR Get Accounts API | |
https://consumerdatastandardsaustralia.github.io/standards/#get-accounts | |
*/ | |
exports.handler = async (event, context) => { | |
const response = { | |
statusCode: 200, | |
body: JSON.stringify({ | |
data: { | |
accounts: [ | |
{ | |
accountId: 'string', | |
creationDate: 'string', | |
displayName: 'string', | |
nickname: 'string', | |
openStatus: 'OPEN', | |
isOwned: true, | |
maskedNumber: 'string', | |
productCategory: 'TRANS_AND_SAVINGS_ACCOUNTS', | |
productName: 'string', | |
}, | |
], | |
}, | |
links: { | |
self: 'string', | |
first: 'string', | |
prev: 'string', | |
next: 'string', | |
last: 'string', | |
}, | |
meta: { | |
totalRecords: 1, | |
totalPages: 1, | |
}, | |
}), | |
}; | |
return response; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If anyone copies this into a lambda with Node.js 18.x. You might get internal server error and Cloudwatch will show:
2023-09-29T09:22:19.531Z undefined ERROR Uncaught Exception { "errorType": "ReferenceError", "errorMessage": "exports is not defined in ES module scope", "stack": [ "ReferenceError: exports is not defined in ES module scope", " at file:///var/task/index.mjs:1:1", " at ModuleJob.run (node:internal/modules/esm/module_job:194:25)" ] }
But its an easy fix. Just change:
exports.handler = async (event, context) => {
to
export const handler = async (event, context) => {