This is the basic example of how to get started with serverless functions, API endpoints, and the Serverless Framework. This example uses NodeJS for the function.
This is the serverless.yml
file:
org: your-org
app: hello-world-endpoint
service: hello-world-endpoint
frameworkVersion: '2'
provider:
name: aws
runtime: nodejs12.x
lambdaHashingVersion: '20201221'
functions:
hello:
handler: handler.hello
events:
- httpApi:
path: /
method: get
This is the handler.js
file:
"use strict";
module.exports.hello = async (event) => {
return {
statusCode: 200,
body: JSON.stringify(
{
message: "Nice work! Have a high five 👋!",
input: event,
},
null,
2
),
};
};