Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed POST to GET #11

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
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
8 changes: 1 addition & 7 deletions handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Parameters } from "./src/types";
export const main: Handler = (event: any) => {
let response: { statusCode: number; body: any; };

if (event.requestContext.http.method === 'POST') {
if (event.requestContext.http.method === 'GET') {
const payload: Parameters = event.body ? JSON.parse(event.body) : {};
const { propertyPrice, downPayment, nominalInterestRate, amortization, paymentSchedule } = payload;
const errors = validate(propertyPrice, downPayment, nominalInterestRate, amortization, paymentSchedule);
Expand All @@ -14,12 +14,6 @@ export const main: Handler = (event: any) => {
? { statusCode: 400, body: JSON.stringify(errors.map(error => JSON.parse(error.message))) }
: { statusCode: 200, body: JSON.stringify(calculate(propertyPrice, downPayment, nominalInterestRate, amortization, paymentSchedule)) }

} else if (event.requestContext.http.method === 'GET') {
response = {
statusCode: 200,
body: JSON.stringify({ message: `Hello World!`, input: event }, null, 2),
};

} else {
response = {
statusCode: 405,
Expand Down
2 changes: 1 addition & 1 deletion mocks/success_event.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"domainName": "offlineContext_domainName",
"domainPrefix": "offlineContext_domainPrefix",
"http": {
"method": "POST",
"method": "GET",
"path": "/mortgage",
"protocol": "HTTP/1.1",
"sourceIp": "127.0.0.1",
Expand Down