Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
26 changes: 26 additions & 0 deletions examples/with-lambda/index.ts
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer single quotes over double quotes.

Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { server } from "@stackpress/ingest/fetch";
import { APIGatewayProxyEvent, APIGatewayProxyResult } from "aws-lambda";

// server starter
const app = server();

app.get("/", (req, res) => {
res.setHTML("<h1>Hello, World from Lambda!</h1>");
});

// AWS Lambda handler
export const handler = async (event: APIGatewayProxyEvent): Promise<APIGatewayProxyResult> => {
return {
statusCode: 200,
headers: { "Content-Type": "text/html" },
body: "<h1>Hello, World from Lambda!</h1>",
};
};

// local server starter for testing
if (process.env.LAMBDA_LOCAL === "true") {
app.create().listen(3000, () => {
console.log("Server is running on port 3000");
console.log("------------------------------");
});
}
Loading