Giter Site home page Giter Site logo

contact-api's Introduction

Contact API

Contact API by using serverless/serverless: Serverless Framework – Build web, mobile and IoT applications with serverless architectures using AWS Lambda, Azure Functions, Google CloudFunctions & more! –.

Install

This manual is running at "dev" stage and "ap-northeast-1" region.

requires Node v4.

$ node -v
v4.2.1

1. Create a default AWS profile, if you don't have one set locally

see serverless/provider-account-setup.md at master · serverless/serverless.

2. Create SNS topic and subscription(Protocol is email).

3. Install Serverless Framework.

$ npm install [email protected] -g

$ sls -v
0.5.6

[Notice] Run only Serverless Framework version 0.5.x.

4. Git clone this repo.

$ git clone https://github.com/naotty/contact-api.git

5. Install npm packages.

$ cd contact-api
$ npm install

6. Project Init.

Create "dev" stage and select "ap-northeast-1" region.

$ sls project create -c true

7. Add variables.

Add S3 bucket name prefix.

$ vi _meta/variables/s-variables-dev.json

{
  "stage": "dev",
+  "bucketNamePrefix": "<your bucket name prefix>"
}

Add SNS topic arn.

$ vi _meta/variables/s-variables-dev-apnortheast1.json

{
  "region": "ap-northeast-1",
+  "snsTopicArn": "<your topic arn>"
}

8. Create CloudFormation resources.

$ sls resources deploy -s dev

9. Deploy Lambda Function.

$ sls function deploy -s dev

10. Deploy Endpoint to AWS API Gateway.

$ sls endpoint deploy -a -s dev

Serverless: Successfully deployed endpoints in "dev" to the following regions:
Serverless: ap-northeast-1 ------------------------
Serverless:   POST - v1/contacts - https://hogehoge.execute-api.ap-northeast-1.amazonaws.com/dev/v1/contacts
Serverless:   OPTIONS - v1/contacts - https://hogehoge.execute-api.ap-northeast-1.amazonaws.com/dev/v1/contacts

11. Set endpoint to js file.

$ vi client/dist/index.html

$.ajax({
-    url: "<your api gateway endpoint>",
+    url: "https://hogehoge.execute-api.ap-northeast-1.amazonaws.com/dev/v1/contacts",

11. Deploy contact form to S3 bucket.

$ sls client deploy -s dev

12. Access your contact form.

Url is http://<your bucket name prefix>-dev.s3-website-ap-northeast-1.amazonaws.com.

Uninstall

$ sls project remove -s dev

And remove API Gateway resources and Lambda functions, S3 bucket manually.

Licence

MIT

contact-api's People

Contributors

naotty avatar

Stargazers

Koichiro Nishijima avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.