Giter VIP home page Giter VIP logo

serverless-react-boilerplate's Introduction

serverless-react-boilerplate

serverless license Join the chat at https://gitter.im/99xt/serverless-react-boilerplate

Requirements

  • Java Runtime Engine (JRE) version 6.x or newer to run dynamodb locally

Features

  • Support offline development with dynamodb, lambda and API Gateway
  • Support local dynamodb seeds/migrations
  • Build automation in client and server to ease local development
  • Rich request template
  • Lambda CRUD operations for a Todo application with live reload
  • React web application to utilize the API

How to develop and test offline?

We have used serverless-offline plugin and serverless-dynamodb-local plugin in this boilerplate. You can declare your table templates and seeds in offline/migrations folder just like the todo.json template. When you spin up the offline server, these tables will be used as the datasources for your lambda functions.

Production vs Offline

Thanks to the offline plugin's environment variable IS_OFFLINE we can select between local dynamodb and aws dynamodb.

var dynamodbOfflineOptions = {
        region: "localhost",
        endpoint: "http://localhost:8000"
    },
    isOffline = () => process.env.IS_OFFLINE;

var client = isOffline() ? new AWS.DynamoDB.DocumentClient(dynamodbOfflineOptions) :  new AWS.DynamoDB.DocumentClient();

###Directory structure

|──serverless
|  |──handlers
|  |  |──todo
|  |  |  |──lib
|  |  |  |  |──todo.js
|  |  |  |  |──helper.js
|  |  |  |──handler.js
|  |──database
|  |  |──dynamodb.js
|  |──offline
|  |  |──migrations
|  |  |  |  |──todo.json
|  |──resources
|  |──test
|  |──event.json
|  |──templates.yml
|  |──serverless.yml
|  |──package.json
|──web
|  |──src
|  |  |──components
|  |  |──index.js
|  |──index.html
|  |──package.json
|  |──webpack.config.js
|──gulpfile.js
|──package.json


Installation & Usage

  • Clone this repo.
  • Make sure AWS credentials are setup properly. Otherwise refer this document
  • Install webpack and serverless globally.
 npm i -g webpack webpack-dev-server
 
 npm i -g serverless
  • Install project dependencies. cd serverless-react-boilerplate and type,
  npm install 
  • Install dynamodb local. (Make sure you have Java runtime 6.x or newer)
  npm run db-setup
  • Run the client and server
 npm run app
  • Visit http://localhost:8080

Deploying to AWS

  • Run npm run deploy

Contribution

Your contributions are much appriciated.

Release Log

  • Release v1.2 - added support for [email protected]
  • Release v1.3 - fixed local dynamobd get packaged for deployment

Links

License

MIT

serverless-react-boilerplate's People

Contributors

ashanfernando avatar gitter-badger avatar mjzone avatar obie avatar pelhage avatar

Watchers

 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.