Skip to content

Laravel + GraphQL API endpoint for a coffee distributor

Notifications You must be signed in to change notification settings

analia-mok/broast

Repository files navigation

Broast

A Laravel-based GraphQL endpoint meant to serve a front-end application for a coffee distribution company.

For an example front-end, visit https://github.com/AnaliaMok/broast-front-end

Stack

  • Laravel 5.8
  • Postgres 10
  • Redis (For as the Queue Driver) - May or may not be used

Packages Worth Noting

  • Laravel Nova
    • WARNING: If you would like to take advantage of the Nova resources provided, you will need a valid Nova 2.0 or lower license. Otherwise, check the Nova docs to remove the appropriate lines from the composer.json file.
  • Lighthouse PHP
    • Package used to configure and serve the graphql endpoint

Setup

  1. Have Lando rc-2+ and Docker installed on your machine
  2. Simply clone this repo and run lando start from this project's root directory
  3. Next run lando composer install and then provide your Laravel Nova account credentials
  4. Duplicate the given .env.example to create your .env file
    • Given that lando ships with the same credentials, the correct credentials have already been configured in the example file.
  5. Next, generate a new APP_KEY with lando artisan key:generate
  6. Next, generate the symlink to the local storage folder using lando artisan storage:link (Will add to lando recipe as an event)
  7. Run lando artisan migrate to generate all tables.
  8. To generate sample content, run the available seeders with lando artisan db:seed
  9. Visit https://broast.lndo.site. You should see a "Welcome to the Broast API" screen.

Connecting A Front-End

A custom CORS policy middleware has been implemented to restrict access to specific request origins and request methods (POST and GET only). To allow access to your specific front-end, supply your request origin in the CONSUMER_ORIGIN key in your .env file.

Feel free to extend this security measure to something a little stronger like with JWT.

Links

Happy Hacking!

About

Laravel + GraphQL API endpoint for a coffee distributor

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published