To create a google-style survey forms, authorized users could design surveys and collect anonymous feedbacks.
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.
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" .
You have to apply an FQDN first, survey.organization.com, for instance in the following instructions.
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.
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.
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"
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"
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 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"
Licensed under the MIT License.