Giter Club home page Giter Club logo

recipes-api's Introduction

Recipes API

Simple Recipe API using Laravel as it's quick to setup and has REST friendly features.

Not implemented, but to support returning different JSON depending on the client or the user role, I would research something around the setVisible/setHidden methods on models to show/hide properties based on the user role, a custom header or other conditions. Other serializers such as JMS allow serialization groups for this purpose but this can be cumbersome to maintain so I'd investigate other approaches beforehand.

Other suggested improvements are listed below

Setup

I was using Laravel Homestead but can theoretically run using Laravel's php artisan serve, though I'm using Sqlite which I couldn't get to work on my Windows host due to the path.

cp .env.example .env # change sqlite path as needed
touch database/database.sqlite
php artisan migrate:fresh
php artisan db:seed

Example endpoints

Paginated Index: http://recipes.test/api/recipes

Paginated Index filtered by cuisine: http://recipes.test/api/recipes?cuisine=british

Single Recipe: http://recipes.test/api/recipes/1

Tests

Functional tests are found in RecipeControllerTest, run by calling phpunit

Improvements

  • Validate data when creating/updating recipes
  • Authentication on routes e.g. prevent non-admin users from editing recipes
  • Return different json depending on user role
  • Move ratings into a separate related recipe_rating table so who rated, when and the average rating can be recorded

recipes-api's People

Contributors

shrwdflrst avatar

Watchers

 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.