Giter VIP home page Giter VIP logo

cocktails's Introduction

Cocktails World Build License

Cocktails World shows cocktail recipes and calculates needed ingredients based on selected cocktails. Built with React & Bootstrap and hosted in Heroku.

Animated demo of Cocktails World site

Development

Based on the create-react-app with a Node server on Heroku template, relevant sections of the README below.

Deploy to Heroku

git clone https://github.com/lauriharpf/cocktails
cd cocktails
heroku create
git push heroku master

This deployment will automatically:

  • detect Node buildpack
  • build the app with
    • npm install for the Node server
    • npm run build for create-react-app
  • launch the web process with npm start
    • serves ../react-ui/build/ as static files
    • customize by adding API, proxy, or route handlers/redirectors

Changes to dependencies in package.json take effect when the file is saved.

Runtime Config

create-react-app itself supports configuration with environment variables. These compile-time variables are embedded in the bundle during the build process, and may go stale when the app slug is promoted through a pipeline or otherwise changed without a rebuild. See create-react-app-buildpack's docs for further elaboration of compile-time vs runtime variables.

create-react-app-buildpack's runtime config makes it possible to dynamically change variables, no rebuild required. That runtime config technique may be applied to Node.js based apps such as this one.

  1. Add the inner buildpack to your app, so that the heroku/nodejs buildpack is last:

    heroku buildpacks:add -i 1 https://github.com/mars/create-react-app-inner-buildpack
    
    # Verify that create-react-app-inner-buildpack comes before nodejs
    heroku buildpacks
  2. Set the bundle location for runtime config injection:

    heroku config:set JS_RUNTIME_TARGET_BUNDLE='/app/react-ui/build/static/js/*.js'
  3. Now, build the app with this new setup:

    git commit --allow-empty -m 'Enable runtime config with create-react-app-inner-buildpack'
    git push heroku master

Local Development

Because this app is made of two npm projects, there are two places to run npm commands:

  1. Node API server at the root ./
  2. React UI in react-ui/ directory.

Run the API server

In a terminal:

# Initial setup
npm install

# Start the server
npm start

Install new npm packages for Node

npm install package-name --save

Run the React UI

The React app is configured to proxy backend requests to the local Node server. (See "proxy" config)

In a separate terminal from the API server, start the UI:

# Always change directory, first
cd react-ui/

# Initial setup
npm install

# Start the server
npm start

Install new npm packages for React UI

# Always change directory, first
cd react-ui/

npm install package-name --save

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.