Jack Strycoff
asked on
aws lambda function with nodejs project
I have a Node project written in TypeScript where the application takes in user's input arguments and does some calculation and prints out the results. Take the example of a calculator the user inputs value of two numbers and it prints out the addition of two numbers. for example npm run calc 3 5. The application prints out 8.
The application is working but i want to make this an aws lambda function and deploy it in aws. The examples i see everywhere is hello lambda function. Can anyone help me how i can make a handler and deploy it to aws?
How do i convert the below hello function to a calc lambda function and deploy it to aws?
The application is working but i want to make this an aws lambda function and deploy it in aws. The examples i see everywhere is hello lambda function. Can anyone help me how i can make a handler and deploy it to aws?
How do i convert the below hello function to a calc lambda function and deploy it to aws?
export const hello: Handler = (event: APIGatewayEvent, context: Context, cb:
Callback) => {
const response = {
statusCode: 200,
body: JSON.stringify({
message: 'Go Serverless Webpack (Typescript) v1.0! Your function executed
successfully!',
input: event,
}),
};
cb(null, response);
}
This is my addition class
export class Calc {
public static add(){
console.log( this.addition( (process.argv[0] + process.argv[1] ));
}
public static addition(num1:number, num2:number)
{
return num1 + num2;
}
ASKER
Doesn't work. Thanks for your reply.
It wasn't posted as a solution - just a guideline. I have no way of testing it.
On EE the standard practice when something does not work is to supply more information. What you implemented, what errors you received (if any).
Your last response does not allow us to take this forward.
On EE the standard practice when something does not work is to supply more information. What you implemented, what errors you received (if any).
Your last response does not allow us to take this forward.
ASKER
When I invoke the handler , it doesn't recognize the Calc class and it gives the compiler errors. One of them is ";" is missing even when the syntax is correct.
If it is reporting errors then there are errors - you can't argue with the compiler - you will lose.
Are you importing the class correctly - is the path correct?
Are you importing the class correctly - is the path correct?
ASKER
Yes. It is not a coding error.
It is not a coding errorThen what sort of error is it - if it is not in code how do you expect to fix it?
This question needs an answer!
Become an EE member today
7 DAY FREE TRIALMembers can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Open in new window