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
let name = document.querySelector("#name"); | |
let email = document.querySelector("#email"); | |
let message = document.querySelector("#message"); | |
let error = document.querySelector(".error"); | |
let btn = document.querySelector("button"); | |
let success = document.querySelector(".success"); | |
btn.addEventListener("click", submit); | |
function submit(e) { |
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
*{ | |
box-sizing: border-box; | |
padding: 0; | |
margin: 0 | |
} | |
body{ | |
font-family: sans-serif; | |
} |
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"> | |
<title>Contact us</title> | |
<link rel="stylesheet" href="style.css"> | |
</head> |
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
service: contact-form | |
provider: | |
name: aws | |
runtime: nodejs8.10 | |
region: us-east-1 | |
iamRoleStatements: | |
- Effect: "Allow" |
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 serverless = require("serverless-http"); | |
const AWS = require("aws-sdk"); | |
const express = require("express"); | |
const cors = require("cors"); | |
const bodyParser = require("body-parser"); | |
const app = express(); | |
if (!AWS.config.region) { | |
AWS.config.update({ |
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 emailParams = { | |
Source: "[email protected]", // Your Verified Email | |
Destination: { | |
ToAddresses: ["[email protected]"] // Your verfied Email | |
}, | |
ReplyToAddresses: [req.body.email], | |
Message: { | |
Body: { | |
Text: { | |
Charset: "UTF-8", |
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 serverless = require("serverless-http"); | |
const AWS = require("aws-sdk"); | |
const express = require("express"); | |
const cors = require("cors"); | |
const bodyParser = require("body-parser"); | |
const app = express(); | |
if (!AWS.config.region) { | |
AWS.config.update({ |
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 serverless = require("serverless-http"); | |
const express = require("express"); | |
const bodyParser = require("body-parser"); | |
const cors = require("cors"); | |
const mongoose = require("mongoose"); | |
const User = require("./models/data"); | |
const app = express(); | |
mongoose | |
.connect("mongodb://tests:[email protected]:53958/myapiproject") |
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
app.get("/user", function(req, res) { | |
User.find({}) | |
.then(data => { | |
res.status(200).send(data); | |
}) | |
.catch(err => res.send("Something Went Wrong")); | |
}); | |
app.post("/user", function(req, res) { | |
const name = req.body.name; |
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
service: rest-api # NOTE: update this with your service name | |
provider: | |
name: aws | |
runtime: nodejs8.10 | |