This file contains hidden or 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(); | |
| const dotenv = require("dotenv"); | |
| dotenv.config(); | |
| const MY_PORT = process.env.PORT; | |
| const MY_APP_SECRET = process.env.APP_SECRET; | |
| app.get("/", (req, res) => { | |
| return res.send(MY_APP_SECRET); |
This file contains hidden or 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
| { | |
| "name": "dotenv-node-tutorial", | |
| "version": "1.0.0", | |
| "description": "A step by step guide to set up environment variables in your NodeJS Application using dotenv", | |
| "main": "index.js", | |
| "scripts": { | |
| "start": "node index.js" | |
| }, | |
| "repository": { | |
| "type": "git", |
This file contains hidden or 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
| //post request URL | |
| const URL = "http://localhost:9000/sendEmail"; | |
| //function to make a post request to lambda function using the fetch API | |
| const sendEmail = async (url, data = {}) => { | |
| // Default options are marked with * | |
| const response = await fetch(url, { | |
| method: "POST", | |
| body: JSON.stringify(data) | |
| }); |
This file contains hidden or 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
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8" /> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0" /> | |
| <meta http-equiv="X-UA-Compatible" content="ie=edge" /> | |
| <link | |
| rel="stylesheet" | |
| href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" | |
| integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" |
This file contains hidden or 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
| exports.handler = function(event, context, callback) { | |
| //import sendgrid mail npm package | |
| const sgMail = require("@sendgrid/mail"); | |
| //only listen to POST requests | |
| if (event.httpMethod === "POST") { | |
| //set sendgrid API Key which you created on the dashboard under settings | |
| sgMail.setApiKey( | |
| "YOUR_SENDGRID_API_KEY" | |
| ); |
This file contains hidden or 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
| exports.handler = function(event, context, callback) { | |
| //only listen to POST requests | |
| if (event.httpMethod === "POST") { | |
| callback(null, { | |
| statusCode: 200, | |
| body: "Hello Abdullah" | |
| }); | |
| } else { | |
| callback(null, { |
This file contains hidden or 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
| [build] | |
| functions = "lambda" |
This file contains hidden or 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
| { | |
| "name": "netlify_services_aws_lambda_tutorial", | |
| "version": "1.0.0", | |
| "description": "A tutorial to setup a serverless application that accepts payments using AWS lambda functions with Netlify", | |
| "main": "index.js", | |
| "scripts": { | |
| "lambda-serve": "netlify-lambda serve functions", | |
| "lambda-build": "netlify-lambda build functions" | |
| }, | |
| "repository": { |
This file contains hidden or 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
| //set up dependencies | |
| const express = require("express"); | |
| const redis = require("redis"); | |
| const axios = require("axios"); | |
| const bodyParser = require("body-parser"); | |
| //setup port constants | |
| const port_redis = process.env.PORT || 6379; | |
| const port = process.env.PORT || 5000; |
This file contains hidden or 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
| //set up dependencies | |
| const express = require("express"); | |
| const redis = require("redis"); | |
| const axios = require("axios"); | |
| const bodyParser = require("body-parser"); | |
| //setup port constants | |
| const port_redis = process.env.PORT || 6379; | |
| const port = process.env.PORT || 5000; |
NewerOlder