Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified .DS_Store
Binary file not shown.
6,196 changes: 6,196 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

19 changes: 14 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,19 @@
"format": "prettier --write 'src/**/*.ts' --config ./.prettierrc",
"prepare": "husky"
},
"dependencies": {},
"dependencies": {
"aws-sdk": "^2.1691.0",
"axios": "^1.7.7",
"Eslint": "npm:eslint@^8.8.0",
"uuid": "^10.0.0"
},
"devDependencies": {
"@types/aws-lambda": "8.10.130",
"@types/aws-lambda": "^8.10.145",
"@types/jest": "29.5.5",
"@types/node": "20.14.1",
"@typescript-eslint/eslint-plugin": "6.9.1",
"@typescript-eslint/parser": "6.9.1",
"esbuild": "^0.14.54",
"eslint": "8.8.0",
"eslint-config-prettier": "8.3.0",
"eslint-plugin-prettier": "4.0.0",
Expand All @@ -24,7 +30,10 @@
"jest-mock-extended": "3.0.5",
"prettier": "3.0.3",
"ts-jest": "29.1.2",
"ts-node": "10.9.1",
"typescript": "4.7.4"
}
"ts-node": "^10.9.1",
"typescript": "^4.7.4"
},
"description": "## Descripción: Se requiere implementar un sistema el cual simule el abono de saldo a una cuenta y su posterios consulta. A continuación se muestran los diagramas correspondientes:",
"main": "jest.config.js",
"keywords": []
}
11 changes: 11 additions & 0 deletions samconfig.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version = 0.1
[default.deploy.parameters]
stack_name = "sam-app-rob"
resolve_s3 = true
s3_prefix = "sam-app-rob"
region = "us-east-2"
confirm_changeset = true
capabilities = "CAPABILITY_IAM"
disable_rollback = true
parameter_overrides = "PaymentGatewayName=\"payment-gateway\" StepFunctionName=\"execute-payment-stf\" ExecutePaymentFunctionName=\"execute-payment-fn\" UpdatePaymentFunctionName=\"update-account-fn\" ArnDynamoDBTableStream=\"arn:aws:dynamodb:us-east-2:361769566249:table/Transaction/stream/2024-09-09T16:50:03.138\" CheckAccountFunctionName=\"check-bank-account-fn\""
image_repositories = []
Binary file added src/.DS_Store
Binary file not shown.
38 changes: 38 additions & 0 deletions src/check-bank-account/checkAccountHandler.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { APIGatewayEvent, APIGatewayProxyHandler } from 'aws-lambda';
import { DynamoDB } from 'aws-sdk';
import { AccountRepository } from './repositories/accountRepository';
import { AccountService } from './services/accountService';
import { CheckAccountUseCase } from './useCases/checkAccountUseCase';
import * as dotenv from 'dotenv';
dotenv.config();

const dynamoDb = new DynamoDB.DocumentClient();
const accountRepository = new AccountRepository(dynamoDb, process.env.TABLE_NAME!);
const accountService = new AccountService(accountRepository);
const checkAccountStatusUseCase = new CheckAccountUseCase(accountService);

export const handler = async (event) => {
var accountId = event.queryStringParameters && event.queryStringParameters.accountId;
console.info("request accountId:" + accountId);
if (!accountId) {
return {
statusCode: 400,
body: JSON.stringify({ message: 'AccountId is required' }),
};
}

const account = await checkAccountStatusUseCase.execute(accountId);

if (account) {
return {
statusCode: 200,
body: JSON.stringify(account),
};
} else {
return {
statusCode: 404,
body: JSON.stringify({ message: 'Account not found' }),
};
}
};

4 changes: 4 additions & 0 deletions src/check-bank-account/models/account.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export interface Account {
id: string;
amount: number;
}
Loading