-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.ts
More file actions
35 lines (31 loc) · 764 Bytes
/
index.ts
File metadata and controls
35 lines (31 loc) · 764 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import { APIGatewayProxyEvent, APIGatewayProxyResult } from "aws-lambda";
import isOdd from "is-odd";
export const handler = async (
event: APIGatewayProxyEvent
): Promise<APIGatewayProxyResult> => {
try {
const number = JSON.parse(event.body!).number;
const shouldIReturnTrue = isOdd(number);
if (shouldIReturnTrue)
return {
statusCode: 200,
body: JSON.stringify({
message: "The number is not odd!",
}),
};
return {
statusCode: 200,
body: JSON.stringify({
message: "The number is odd!",
}),
};
} catch (err) {
console.log(err);
return {
statusCode: 500,
body: JSON.stringify({
message: "some error happened",
}),
};
}
};