Skip to content

Instantly share code, notes, and snippets.

@nazieb
Created February 2, 2019 15:17
Show Gist options
  • Save nazieb/3d65c8f0861e97696da9cce9d08a9e19 to your computer and use it in GitHub Desktop.
Save nazieb/3d65c8f0861e97696da9cce9d08a9e19 to your computer and use it in GitHub Desktop.
AWS Lambda-Express example
const express = require("express");
const app = express();
app.get("/hello", (req, res) => {
res.json({
message: "Hello, World",
});
});
app.post("/ping", (req, res) => {
res.json({
message: "Pong",
});
});
module.export = app;
const express = require("express");
const app = express();
app.get("/hello", (req, res) => {
res.json({
message: "Hello, World",
});
});
app.post("/ping", (req, res) => {
res.json({
message: "Pong",
});
});
app.listen(process.env.PORT, () => {
console.log("App is running...");
});
const awsServerlessExpress = require("aws-serverless-express");
const app = require("./app");
const server = awsServerlessExpress.createServer(app);
exports.handler = (event, context) => {
awsServerlessExpress.proxy(server, event, context);
}
const app = require("./app");
app.listen(process.env.PORT, () => {
console.log("App is running...");
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment