kuo77122 / serverless-survey-forms

To create a google-style survey forms, authorized users could design surveys and collect anonymous feedbacks.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

serverless-survey-forms (still under construction)

Serverless Framework Build Status Coverage Status

To create a google-style survey forms, authorized users could design surveys and collect anonymous feedbacks.

Architecture Overview


Prerequisites

Development Environment

This project depends on the following modules, please make sure they're ready after [Installation].

  • NodeJS v8.16.0
  • serverless v1.47.0

To prevent from polluting your local environment, you may want run the Docker to isolate your development environment.

Build Docker Image

If you want to add more packages or modify the version numbers, just edit the Dockfile under the project root.

cd serverless-survey-form
sudo docker build -t "qustom-env" .

Service FQDN

You have to apply an FQDN first, survey.organization.com, for instance in the following instructions.

Prepare for Facebook Login

You need to apply a facebook app first and enable the FB OAuth.

Please visit https://developers.facebook.com/apps/ for more details.

After you create an app in success, you can find FACEBOOK_ID and FACEBOOK_SECRET in the app's main page. Set those as the environment variables.


Deploy to AWS

For the IAM regulation, you need to create an IAM user and generate its AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY. Please set those as the environment variables.

Deploy the survey-forms stack

First, create below environment variables.

STAGE=dev
REGION=us-west-2
WEB_DOMAIN=YOUR_FQDN
TOKEN_SECRET=YOUR_SECRET_TOKEN

Then use Docker to build and deploy the project to AWS. If this is the first time deploy, it will take time to create the resources.

sudo docker run \
-e AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID -e AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY \
-e FACEBOOK_ID=$FACEBOOK_ID -e FACEBOOK_SECRET=$FACEBOOK_SECRET -e TOKEN_SECRET=$TOKEN_SECRET \
-e WEB_DOMAIN=$WEB_DOMAIN -e REGION=$REGION \
-v $WORKSPACE:$WORKSPACE_IN_DOCKER qustom-dev:latest /bin/bash \
-c "cd $WORKSPACE_IN_DOCKER && sls deploy --stage $STAGE"

Deploy the survey-forms UI

sudo docker run \
-e AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID -e AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY \
-e FACEBOOK_ID=$FACEBOOK_ID -e FACEBOOK_SECRET=$FACEBOOK_SECRET -e TOKEN_SECRET=$TOKEN_SECRET \
-e WEB_DOMAIN=$WEB_DOMAIN -e REGION=$REGION \
-v $WORKSPACE:$WORKSPACE_IN_DOCKER qustom-dev:latest /bin/bash \
-c "cd $WORKSPACE_IN_DOCKER/web && npm install && npm run deploy && sls client deploy --no-confirm --stage $STAGE"

Run unit Test

Serverless site unit test

The steps below can be taken to verify the functionality.

cd serverless-survey-form
WORKSPACE=`pwd`
WORKSPACE_IN_DOCKER=`/serverless-survey-form`
sudo docker run \
-v $WORKSPACE:$WORKSPACE_IN_DOCKER qustom-env:latest /bin/bash \
-c "cd $WORKSPACE_IN_DOCKER && npm install && npm test"

You can define your WORKSPACE and WORKSPACE_IN_DOCKER as you want, just make sure WORKSPACE_IN_DOCKER point to the root path of the project.

Frontend site unit test

Frontend source code is under /web folder.

So far, due to the upgrade of the axios package, the unit test of the frontend is broken. We are now dealing with this issue.

cd serverless-survey-form
WORKSPACE=`pwd`
WORKSPACE_IN_DOCKER=`/serverless-survey-form`
sudo docker run \
-v $WORKSPACE:$WORKSPACE_IN_DOCKER qustom-env:latest /bin/bash \
-c "cd $WORKSPACE_IN_DOCKER/web && npm install && npm run test"

License

Licensed under the MIT License.

About

To create a google-style survey forms, authorized users could design surveys and collect anonymous feedbacks.

License:MIT License


Languages

Language:JavaScript 87.1%Language:CSS 12.9%Language:HTML 0.0%Language:Dockerfile 0.0%