View the live site at allstate.io
- install brew (if not installed):
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
- install MySQL (on a mac) with:
brew install mysql
- start MySQL with:
mysql.server start
- access MySQL with:
mysql -u root
- inside of MySQL run the following command to create the databases that this app uses:
create database sentiment; create database sentiment_test;
- exit mysql CLI:
exit
- install yarn (if not installed):
brew install yarn
- install server and client packages:
yarn installBoth
- Run migrations to create table and add test data to the DB:
yarn knex:migrate
andNODE_ENV=test yarn knex:migrate
- If fail due to "Client does not support authentication protocol requested by server; consider upgrading MySQL client", then run following in mysql:
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '';
flush privileges;
- Create a
.env
file at the top level and add theTWITTER_BEARER_TOKEN
prop with a valid twitter bearer token
Note: If a proxy is required, ensure the YARN_PROXY
env variable is set
Note2: If you keep getting self signed cert in chain run the followinng command export NODE_TLS_REJECT_UNAUTHORIZED="0"
Note: May need to give the build:prod
script permissions to execute (chmod +x ./build.sh
)
- Run locally in watch mode:
yarn local
- Run all tests:
yarn test
- Start server:
yarn start
- Start server w/ watch mode:
yarn start:watch
- Build and package into a zip:
yarn build:prod
- Create new knex migration:
yarn knex:create <MIGRATION_NAME>
- Run knex migrations:
yarn knex:migrate
- Run knex migrations for test DB:
NODE_ENV=test yarn knex:migrate
- Rollback knex migrations:
yarn knex:rollback
- Rollback knex migrations for test DB:
NODE_ENV=test yarn knex:rollback
- Set
SENTIMENT_DB_SERVER
,SENTIMENT_DB_USERNAME
, andSENTIMENT_DB_PASSWORD
env vars - Run knex migrations for Azure MSSQL DB:
NODE_ENV=production yarn knex:migrate
- Start server:
yarn start:prod
- Build the container
docker build -t sentiment-analysis .
- export
SENTIMENT_DB_SERVER
,SENTIMENT_DB_USERNAME
, andSENTIMENT_DB_PASSWORD
env vars locally - Run the container
docker run --privileged -p 8088:443 --env SENTIMENT_DB_SERVER --env SENTIMENT_DB_USERNAME --env SENTIMENT_DB_PASSWORD --name sentiment-analysis -d sentiment-analysis
- Visit http://localhost:8088 to view the app
- SSH into container:
docker exec -it sentiment-analysis bash
- Stop container:
docker stop sentiment-analysis
- Remove container:
docker rm sentiment-analysis
- View container logs:
docker logs sentiment-analysis
- Remove dangling images:
docker image prune
- This project uses semistandard eslint setup
yarn test
runs the linter and all tests- Husky pre-commit hook requires the
test
script to pass - Run
yarn lint:fix
to fix lint issues