Created
February 2, 2019 15:17
-
-
Save nazieb/3d65c8f0861e97696da9cce9d08a9e19 to your computer and use it in GitHub Desktop.
AWS Lambda-Express example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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..."); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const awsServerlessExpress = require("aws-serverless-express"); | |
const app = require("./app"); | |
const server = awsServerlessExpress.createServer(app); | |
exports.handler = (event, context) => { | |
awsServerlessExpress.proxy(server, event, context); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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