GithubHelp home page GithubHelp logo

britishpearl / bpapi-demo-app Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 791 KB

British Pearl API Demo App

License: MIT License

Dockerfile 1.30% TypeScript 90.44% Shell 0.98% HTML 2.76% CSS 3.43% JavaScript 1.09%

bpapi-demo-app's Introduction

British Pearl API Demo

This is a simple project demonstrating how to connect to British Pearl API and make authorized requests to retrieve user's data.

The project consists of a backend Node.js application and a frontend React application, both written in Typescript.

You can run the applications in three ways:

  • locally via yarn commands
  • locally via docker-compose
  • remotely on Heroku using Heroku CLI

Running the apps locally using yarn

Backend

cd backend
yarn install
BPAPI_CLIENT_ID=xxx BPAPI_CLIENT_SECRET=yyy BPAPI_REDIRECT_URI=http://example.com yarn start

Frontend

cd frontend
yarn install
yarn start

You can view the frontend app in the browser under http://localhost:3000.

Running the apps locally using Docker Compose

Copy environment variables definition file required for docker-compose command.

cp demo.env .env

Edit the .env files to reflect your desired configuration.

docker-compose up --build -d

You can view the frontend app in the browser under http://localhost:3000.

Deploying onto Heroku

Heroku authentication

heroku login
heroku container:login

Backend

heroku create YOUR_BACKEND_APP_NAME
heroku config:set --app=YOUR_BACKEND_APP_NAME \
    BPAPI_CLIENT_ID="---Please request this from British Pearl" \
    BPAPI_CLIENT_SECRET="---Please request this from British Pearl" \
    BPAPI_REDIRECT_URI="https://YOUR_FRONTEND_APP_NAME.herokuapp.com/cb-bpapi"
cd backend/
heroku container:push web --app=YOUR_BACKEND_APP_NAME
heroku container:release web --app=YOUR_BACKEND_APP_NAME

You can verify the app is running by viewing logs:

heroku logs --tail --app=YOUR_BACKEND_APP_NAME

Frontend

heroku create YOUR_FRONTEND_APP_NAME
heroku config:set --app=YOUR_FRONTEND_APP_NAME INTERNAL_API_URL="https://YOUR_BACKEND_APP_NAME.herokuapp.com"
cd frontend/
heroku container:push web --app=YOUR_FRONTEND_APP_NAME
heroku container:release web --app=YOUR_FRONTEND_APP_NAME

You can verify the app is running by viewing logs:

heroku logs --tail --app=YOUR_FRONTEND_APP_NAME

reCAPTCHA

You can also optionally enable Google reCAPTCHA by setting proper environment variables in the backend and frontend app.

heroku config:set --app YOUR_BACKEND_APP_NAME GOOGLE_RECAPTCHA_SECRET_KEY="YOUR SECRET KEY"
heroku config:set --app YOUR_FRONTEND_APP_NAME REACT_APP_GOOGLE_SITE_KEY="YOUR SITE KEY"

bpapi-demo-app's People

Contributors

pawellipski avatar britishpearl avatar dependabot[bot] avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.