Skip to content

Commit

Permalink
updated handlers to only use permitted params
Browse files Browse the repository at this point in the history
  • Loading branch information
hhassan01 committed Aug 30, 2024
1 parent 7fef705 commit df68555
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
9 changes: 7 additions & 2 deletions src/handlers/createAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,13 @@ const createAccountHandler = async (
await connectToDatabase()
const accountsService = new AccountsService()

const createAccountDto: CreateAccountDto = JSON.parse(event.body || '{}')
const account = await accountsService.createAccount(createAccountDto)
const { accountNumber, customerId, currencies }: CreateAccountDto =
JSON.parse(event.body || '{}')
const account = await accountsService.createAccount({
accountNumber,
customerId,
currencies,
})

return {
statusCode: 201,
Expand Down
12 changes: 7 additions & 5 deletions src/handlers/updateAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ const updateAccountHandler = async (

const accountsService = new AccountsService()
const accountId = event.pathParameters?.accountId
const updateAccountDto: UpdateAccountDto = JSON.parse(event.body || '{}')
const { customerId, accountNumber, currencies }: UpdateAccountDto =
JSON.parse(event.body || '{}')

const updatedAccount = await accountsService.updateAccount(
accountId!,
updateAccountDto,
)
const updatedAccount = await accountsService.updateAccount(accountId!, {
customerId,
accountNumber,
currencies,
})
return {
statusCode: 200,
body: JSON.stringify(updatedAccount),
Expand Down

0 comments on commit df68555

Please sign in to comment.