• Stars
    star
    260
  • Rank 157,189 (Top 4 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 8 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A serverless react boilerplate for offline development

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

More Repositories

1

serverless-dynamodb-local

Serverless Dynamodb Local Plugin - Allows to run dynamodb locally for serverless
JavaScript
624
star
2

boilerplatejs

Your own boilerplate code to start your next big javascript project. We incorporate the best design practices with best in market open source libraries.
JavaScript
278
star
3

first-born

Component library for React Native
JavaScript
271
star
4

emojicpp

Emoji 😄 for c++ developers 👍
C++
267
star
5

timercpp

Javascript like setTimeout and setInterval for c++ developers
C++
246
star
6

serverless-dynamodb-client

Serverless Dynamodb Client to automatically switch between AWS and Local instances
JavaScript
74
star
7

sinhala-express-js

එක්ස්ප්‍රස් ජේ. ඈස් සින්හල පරිවර්තනය
JavaScript
68
star
8

react-scaffolder

⚡ Scaffolding tool for React
JavaScript
44
star
9

dynamodb-localhost

Dynamodb localhost runner for development and testing
JavaScript
35
star
10

serverless-delivery-framework

This is a boilerplate for version release pipeline with serverless framework
JavaScript
31
star
11

steroidslibrary

Framework for simplifying microservices in TypeScript focusing on business logic
TypeScript
27
star
12

runn

Make your own terminal aliases easily!
JavaScript
21
star
13

dynamodb-migrations

Manage DynamoDB table creation and seed templates in your codebase
JavaScript
18
star
14

azure-jwt-verify

Verify jwt token issued from azure active directory b2c service
JavaScript
18
star
15

w3c-link-validator

Command line tool, identifying broken links, validate basic html standards and reporting
JavaScript
18
star
16

github-manager

🚀 Manage GitHub repositories with ease
JavaScript
17
star
17

dotitude

A community driven by 99X Technology with the collaboration of Universities and Industry to enlighten the future of undergraduates.
17
star
18

RadiumRest

A Portable Microframework for .NET
C#
16
star
19

CodeSpecJS

UI Automation Testing without writing a single line of code
TypeScript
15
star
20

scikit-recommender-api

Recommender system API service which runs as a simplified web service.
JavaScript
13
star
21

walk2win

Online Walking challenge for workplaces
TypeScript
12
star
22

emojideno

Emoji 😄 for deno developers 👍
TypeScript
12
star
23

aws-userpool-boilerplate

Getting started with AWS Cognito User Pool
JavaScript
11
star
24

simpletasks.js

Simple time based task queue for js
JavaScript
10
star
25

articles-of-the-week

Awesome articles weekly 📖
10
star
26

jira-journal

🎭 Bot that interacts as your bullet journal for JIRA worklogs.
JavaScript
9
star
27

dynamodb-schema-migrate

Easily Migrate a Existing Schema(Tables) from one Region to another Region
JavaScript
8
star
28

discourse-sdk

Node SDK for discourse forum software
JavaScript
8
star
29

protractor-starter

Protractor end to end testing boilerplate
JavaScript
7
star
30

pdf2-s3

This library will download a pdf from a given web url and upload it to a given s3 bucket.
JavaScript
7
star
31

serverless-dependency-install

Serverless plugin to manage dependencies.
JavaScript
7
star
32

any2pdf.js

This library contains functionality which can help convert documents to PDF using javascript on the browser.
JavaScript
6
star
33

architecture.99x.io

This repository contains the best practices and processes we use for architecture to share with the community
JavaScript
6
star
34

spec-handbook

Curated list of quality standards and opinionated implementation guides for software products
6
star
35

gulp-dependency-install

This gulp plugin provides commands to install npm dependencies in multiple package.json files with a single command. It also allows to define custom local dependencies inside package.json.
JavaScript
6
star
36

dependency-install

Install dependencies in multiple package.json files also allowing to define custom dependency paths
JavaScript
5
star
37

gsoc

All about 99xt GSoC organization
5
star
38

gh-code

Visual Studio code plugin to easily manage issues in a git hub repository
TypeScript
4
star
39

garray

G-array is a GoLang library, that contains the generic function to do the array operations.
Go
4
star
40

ConnectAPIBuddy

An API testing web tool
TypeScript
4
star
41

youtube-queuing-bot

A full screen web app to play youtube playlist videos (will be used for the RPI)
JavaScript
4
star
42

openhack

Official website of OpenHack '19
CSS
4
star
43

react-native-aws-cognito-userpools

Authenticating users using AWS cognito user pools
JavaScript
4
star
44

product-central-architectures

HTML
3
star
45

24sevenoffice-php-adapter

A PHP Adapter to use in integrations with 24sevenoffice.com
PHP
3
star
46

react-boilerplate

Unopinionated boilerplate for react, react-flux or react-redux.
JavaScript
3
star
47

hacktitude-web

Hacktitude website
CSS
3
star
48

covid19-whatsapp

WhatsApp Bot to provide information about the Covid19 Pandemic for Sri Lankan Citizens
Python
3
star
49

dynamodb-data-transform

Manage DynamoDB data transformation in your codebase
JavaScript
3
star
50

articlesoftheweek

Articles of the week website
HTML
3
star
51

owasp-cli

CLI for OWASP free and open software security community API
JavaScript
2
star
52

cla-bot

The bot manages signed contributors of an ORG
TypeScript
2
star
53

CodeSpecJSClient

A Web client for CodeSpecJS
JavaScript
2
star
54

avurudu-game

JavaScript
2
star
55

steroidsboilerplate

JavaScript
2
star
56

seranet.api

C#
2
star
57

hexweb

Official Website
HTML
2
star
58

realtime-toastr

This will give real time non-blocking notifications from server to client
JavaScript
2
star
59

wp-deploy

A WordPress deployment tool
Python
2
star
60

earnshark-sdk-ruby

This is a Ruby SDK to call https://app.earnshark.com API. Contains methods to call the EarnShark API making the application integration fast.
Ruby
2
star
61

promise-utils

TypeScript
2
star
62

callstatus-notifier

This application allows to trigger a IOT device when skype call is in progress
C#
2
star
63

Colombocamps

HTML
2
star
64

trendviewer

visualising sentiments on long term social trends - from social feeds like twitter , FB
XSLT
2
star
65

contributors-shield

Generate an image for the contributors of a repo
JavaScript
2
star
66

optimaxer-web

A lightweight JavaScript utility library designed for running local language models (LLMs) like Gemma 2B directly on edge devices. This project aims to provide developers with easy-to-use tools for integrating AI capabilities into web applications without relying on external servers.
TypeScript
2
star
67

aws-api-gateway-policy-generator

TypeScript
1
star
68

vue-boilerplate

JavaScript
1
star
69

mongodb-backup

Docker container for MongoDB Backups
Shell
1
star
70

udf-ios-boilerplate

Boilerplate IOS Application that uses UDF Architecture
Swift
1
star
71

earnshark-sdk-dot-net

C#
1
star
72

simple-rss-feed-reader

A simple rss feed reader which can be setup in local
1
star
73

social-media-day-2017

The official webpage for Social Media Day 2017 - #MyDreamITJob
CSS
1
star
74

canvasx

Canvas Component for React
TypeScript
1
star
75

symptom-inform

This repository contains a sample application to submit medical symptoms
JavaScript
1
star