All Projects → 99x → Serverless React Boilerplate

99x / Serverless React Boilerplate

Licence: mit
A serverless react boilerplate for offline development

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Serverless React Boilerplate

Jenkins Cli
Jenkins CLI allows you manage your Jenkins as an easy way
Stars: ✭ 245 (-2%)
Mutual labels:  hacktoberfest
Mycroft Android
Android companion app, sends commands from your Android device to your Mycroft system and returns the output as speech or other medium to the Android device.
Stars: ✭ 247 (-1.2%)
Mutual labels:  hacktoberfest
Gnuradio
GNU Radio – the Free and Open Software Radio Ecosystem
Stars: ✭ 3,297 (+1218.8%)
Mutual labels:  hacktoberfest
Openmu
This project aims to create an easy to use, extendable and customizable server for a MMORPG called "MU Online".
Stars: ✭ 243 (-2.8%)
Mutual labels:  hacktoberfest
Cleanenv
✨Clean and minimalistic environment configuration reader for Golang
Stars: ✭ 245 (-2%)
Mutual labels:  hacktoberfest
Vue Firebase Auth Vuex
Vue Firebase🔥 Authentication with Vuex
Stars: ✭ 248 (-0.8%)
Mutual labels:  hacktoberfest
Aboutlibraries
AboutLibraries automatically detects all dependencies of a project and collects their information including the license. Optionally visualising it via the provided ui components.
Stars: ✭ 2,777 (+1010.8%)
Mutual labels:  hacktoberfest
Nothing
A simple platformer about nothing
Stars: ✭ 249 (-0.4%)
Mutual labels:  hacktoberfest
Sp Dev Fx Controls React
Reusable React controls for SPFx solutions
Stars: ✭ 247 (-1.2%)
Mutual labels:  hacktoberfest
Doctl
The official command line interface for the DigitalOcean API.
Stars: ✭ 2,856 (+1042.4%)
Mutual labels:  hacktoberfest
Interrogate
Explain yourself! Interrogate a codebase for docstring coverage.
Stars: ✭ 245 (-2%)
Mutual labels:  hacktoberfest
Azurlshortener
An simple and easy Url Shortener
Stars: ✭ 247 (-1.2%)
Mutual labels:  hacktoberfest
Inav Configurator
Stars: ✭ 243 (-2.8%)
Mutual labels:  hacktoberfest
Stm32f1xx Hal
A Rust embedded-hal HAL impl for the STM32F1 family based on japarics stm32f103xx-hal
Stars: ✭ 245 (-2%)
Mutual labels:  hacktoberfest
Graphql Shield
🛡 A GraphQL tool to ease the creation of permission layer.
Stars: ✭ 3,121 (+1148.4%)
Mutual labels:  hacktoberfest
Instantwm
The window manager for instantOS
Stars: ✭ 244 (-2.4%)
Mutual labels:  hacktoberfest
Hacktoberfest2020
List of beginner-friendly | first-timers-only | up-for-grabs issues (repositories) for Hacktoberfest 2020 | Submit 4 PRs to earn a T-shirt
Stars: ✭ 248 (-0.8%)
Mutual labels:  hacktoberfest
Naucse.python.cz
Website with learning materials / Stránka s učebními materiály
Stars: ✭ 248 (-0.8%)
Mutual labels:  hacktoberfest
Testimo
Testimo is PowerShell module for running health checks for Active Directory (and later on any other server type) against a bunch of different tests
Stars: ✭ 249 (-0.4%)
Mutual labels:  hacktoberfest
Orange3
🍊 📊 💡 Orange: Interactive data analysis
Stars: ✭ 3,152 (+1160.8%)
Mutual labels:  hacktoberfest

serverless-react-boilerplate

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

Sample Todo App

screen shot 2017-08-29 at 4 49 58 am

Requirements

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

Features

  • Support serverless v1.26.0
  • Support offline development with dynamodb, lambda and API Gateway
  • Support local dynamodb seeds/migrations
  • Build automation in client and server to ease local development
  • Deploy to multiple API Services
  • Use of Environment variables
  • 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 api/todo/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

|──api
|  |──todo
|  |  |──lib
|  |  |  |──todo.js
|  |  |  |──helper.js
|  |  |  |──response.js
|  |  |──handler.js
|  |  |──database
|  |  |──dynamodb.js
|  |  |──offline
|  |  |  |──migrations
|  |  |  |  |──todo.yml
|  |  |  |  |──todo-seed.json
|  |  |──config.yml
|  |  |──serverless.yml
|  |  |──package.json
|──web
|  |──src
|  |  |──components
|  |  |──index.js
|  |──public
|  |  |──index.html
|  |──package.json
|──gulpfile.js
|──package.json


Installation & Usage

  • Clone this repo.
  • Make sure AWS credentials are setup properly. Otherwise refer this document
  aws configure --profile peter
  • Add the aws cli profile name and region on to serverless.yml file located at /api/todo/serverless.yml
  ...
  provider:
  name: aws
  runtime: nodejs6.10
  profile: peter
  stage: dev
  region: eu-west-2
  ...
  • Install serverless globally
 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 app with the local server
  npm run app
  • Browser will open the todo app at http://localhost:3001

Deploying to AWS

When you are ready to deploy your database and api to AWS, you can create multiple APIGateways for different service level stages. For example you can create "dev" and "production" stages. When you deploy to a specific stage, it will create a separate database tables for that stage.

Following command will deploy your lambda functions and APIGateway onto 'prod' stage.

cd api
cd todo
serverless deploy --stage prod

If you want to test your React app with the online API and Database, you may have to change the, BASE_URL of the react app found in web/src/App.js. Change its value from http://localhost:3000 to your APIGateway uri.

Application Secrets Keys

You can define application secret keys in config.yml file. For example if you need to have a database connection string and use it in your lambda function, define it as follows.

prod:
  DB_STRING: <my-db-connection-string>

Then in the serverless.yml file,

custom:
  DB_STRING: ${file(./config.yml):${self:custom.stage}.DB_STRING}

This will corretly select the DB_STRING corresponding to the defined stage.

You should NOT commit config.yml to your version control system

Deploying react web app

Once you have setup a S3 bucket with static web hosting enabled you can simply build your react app and deploy to that bucket. Make sure to change BASE_URL to refer your production APIGateway endpoint.

On the root level package.json file add that bucket name and your AWS profile name on the deploy-s3 task. After that run the following command.

  npm run deploy-s3

See following vidoes for a step by step guide to create a s3 bucket and configure static web hosting.

Video 01 - Hosting a website on AWS with S3, CloudFront and Route53

Video 02 - Hosting Angular, React and Vue.js applications on AWS

Contribution

Your contributions are much appriciated.

Release Log

  • Release v4.1.0 - Updated boilerplate to support Lambda Proxy
  • Release v4.0.0 - Added support for [email protected]
  • Release v3.0.0 - Added environment variables for database table names & Feature to deploy in multiple APIGateway service level stages.
  • Release v2.2.0 - Added foundation css framework for the react client
  • Release v2.1.1 - Improvements in react web app
  • Release v2.0.1 - Dynamodb local table creation bug fix
  • Release v2.0.0 - Added support for serverless v1.0 and Issues #24 #25
  • Release v1.0.3 - Fixed local dynamobd get packaged for deployment
  • Release v1.0.2 - Added support for [email protected]

Links

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].