git clone https://github.com/GatiAher/lagaan-football-pool-app.git
$ yarn
$ cd backend/ && yarn && cd ..
$ cd frontend/ && yarn && cd ..
$ cd admin/ && yarn && cd ..
$ touch backend/db/database.sqlite
frontend/.env.development
and add the following key-value pairs. Get the values REACT_APP_AUTH0_DOMAIN
and REACT_APP_AUTH0_CLIENT_ID
from Auth0 Dashboard.REACT_APP_API=http://localhost:3001
REACT_APP_AUTH0_DOMAIN=<xxx.us.auth0.com>
REACT_APP_AUTH0_CLIENT_ID=<yyy>
frontend/.env.development
and add the following key-value pairs.REACT_APP_API=http://localhost:3001
NODE_ENV=development
mode.yarn start
Or you could run each service independently
yarn start-server
yarn start-front
yarn start-admin
AWS PROCESS: In Route53 configure A-Record as type alias with target as ELB. Configure ELB as fail-over to the EC2. (fail-over mode requires health-check for fail-over configuration).
RATIONAL: Right now, only using one instance, hence the fail-over configuration. Using ELB in order to use AWS’s SSL. SSL is needed for OAuth used by frontend.
# install yarn
curl -o- -L https://yarnpkg.com/install.sh | bash
# install node version manager (nvm)
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash
. ~/.nvm/nvm.sh
# use nvm to install node
nvm install node
# install PM2 (Daemon Process Manager that keeps application online. Use it to run the backend)
yarn global add pm2
# install CentOS 7 EPEL and Nginx
sudo yum install epel-release
sudo yum install nginx
Git pull a version that works in development mode
Set up backend and start api using PM2.
cd backend && yarn && cd ..
pm2 start
This uses the ecosystem.config.js
file.
frontend/.env.production
with these key-value pairs.REACT_APP_API=/api
REACT_APP_AUTH0_DOMAIN=<xxx.us.auth0.com>
REACT_APP_AUTH0_CLIENT_ID=<yyy>
GENERATE_SOURCEMAP=false
Make frontend static build files.
cd frontend && yarn && yarn build && cd ..
admin/.env.production
with these key-value pairs.REACT_APP_API=/api
GENERATE_SOURCEMAP=false
Make admin static build files.
cd admin && yarn && yarn build && cd ..
cp nginx.conf /etc/nginx/nginx.conf
sudo service nginx restart
NOTE: provided nginx.conf
assumes that the path to lagaan-football-pool-app is /data/lagaan-football-pool-app
. Change if necessary. NOTE: you might need to use sudo
pm2 delete all
sudo service nginx stop
User goes to frontend and signs up. This adds the user to Auth0. A user registered with Auth0 but not registered with the Lagaan Admin will be able to access the rankings and pick pages but not see any data.
User clicks on top right menu (with username) and selects “Copy Id”. User can then send this to Lagaan Admin, who can create a new user with the given id using the Admin Dashboard.
User registered with both Auth0 and Lagaan system can access leaderboard and rankings.
Routes to edit game
, team
, and user
data
Method | API calls |
---|---|
getList |
GET http://my.api.url/user/posts?sort=["id","ASC"]&range=[0, 24]&filter={"id":"123"} |
getOne |
GET http://my.api.url/user/posts/123 |
create |
POST http://my.api.url/user/posts |
update |
PUT http://my.api.url/user/posts/123 |
delete |
DELETE http://my.api.url/user/posts/123 |
clear table |
DELETE http://my.api.url/user/clear |
reset table |
DELETE http://my.api.url/user/reset |
Routes to recalculate scores & ranks for team
, and user
data
Method | API calls |
---|---|
score users |
GET http://my.api.url/score/user |
score teams |
GET http://my.api.url/score/team |
Minor
Major
Minor
Medium
Major
Minor
Medium
Major
Author: GatiAher
Demo: https://www.lagaannfl.com/nfl_games
Source Code: https://github.com/GatiAher/lagaan-football-pool-app
#react #reactjs #javascript #game