Code Monkey home page Code Monkey logo

refcard-backend's Introduction

Stack

Infos

PUT request body

To enable PUT request body BodyParamsMiddleware is used in config/pipeline.php

$app->pipe(BodyParamsMiddleware::class);

Use from subdirectory

To use from subdirecotory mtymek/blast-base-url is used in config/pipeline.php

$app->pipe(\Blast\BaseUrl\BaseUrlMiddleware::class);

Refcard API

[API.md]

Based on https://github.com/gothinkster/realworld/tree/master/api

  1. Leagues
    1. Get one
    2. Get all
    3. Create
    4. Update
    5. Delete
  2. Teams
    1. List
    2. Create
    3. Read
    4. Update
    5. Delete
  3. Players
    1. Create
    2. Read
    3. Update
    4. Delete

General

Success returns 200 OK

Failure returns 404 Not Found

Leagues

Get one

Request:

GET /api/leagues/:id

Response on SUCCESS:

200 OK
{
  "id": 1,
  "name": "Pruszkowska Liga Szóstek Piłkarskich",
  "city": "Pruszków"
}

Response on FAILURE:

404 Not Found

Get all

Request:

GET /api/leagues

Response on SUCCESS:

200 OK
[
  {
    "id": 1,
    "name": "Pruszkowska Liga Szóstek Piłkarskich",
    "city": "Pruszków"
  },
  {
    "id": 2,
    "name": "Nowodworka Liga Piłki Nożnej",
    "city": "Nowy Dwór Mazowiecki"
  }
]

Response on FAILURE or EMPTY:

404 Not Found

Create

Request:

POST /api/leagues
{
  "name": "Pruszkowska Liga Szóstek Piłkarskich",
  "city": "Pruszków"
}

Response on SUCCESS:

200 OK
{
  "id": 1,
  "name": "Pruszkowska Liga Szóstek Piłkarskich",
  "city": "Pruszków"
}

Response on FAILURE:

404 Not Found

Update

Request:

PUT /api/leagues/:id
{
  "name": "Pruszkowska Liga Szóstek Piłkarskich",
  "city": "Pruszków"
}

Response on SUCCESS:

200 OK
{
  "id": 1,
  "name": "Pruszkowska Liga Szóstek Piłkarskich",
  "city": "Pruszków"
}

Response on FAILURE:

404 Not Found

Delete

Request:

DELETE /api/leagues/:id

Response on SUCCESS:

200 OK

Response on FAILURE:

404 Not Found

Teams - TODO

List Teams

GET /api/:league_slug/teams

RESPONSE:

{
  "teams": [
    { "id": 0, "name": "Mantika", "numberOfPlayers": 12 },
    { "id": 1, "name": "Megameble", "numberOfPlayers": 9 }
  ]
}

Create Team

POST /api/:league_slug/team

REQUEST:

{
"team": { "name": "Sznajder" }
}

RESPONSE: returns Team

Read Team

GET /api/:league_slug/team/:team_id

RESPONSE:

{
  "name": "Megameble",
  "team": { "id": 1, "name": "Megameble" },
  "players": [
    { "id": 0, "name": "Czerny Konrad" },
    { "id": 1, "name": "Czerny Krzysztof" },
    { "id": 2, "name": "Jerdal Rafał" },
    { "id": 3, "name": "Maciejec Kuba" },
    { "id": 4, "name": "Sterlus Paweł" },
    { "id": 5, "name": "Sztyk Mateusz" },
    { "id": 6, "name": "Sztyk Piotr" },
    { "id": 7, "name": "Zalewski Piotrek" },
    { "id": 8, "name": "Łata Tomasz" }
  ]
}

Update Team

PUT /api/:leage_slug/team/:team_id

REQUEST:

{
  "team": { "name": "Megameble" }
}

RESPONSE: returns Team

Accept fields: name

Delete Team

DELETE /api/:league_slug/team/:team_id

Player

Create

POST /api/:league_slug/player/:team_id

REQUEST:

{
  "player": { "name": "Czerny Konrad" }
}

RESPONSE: returns Player

Read

GET /api/:league_slug/player/:player_id

RESPONESE:

{
  "player": { "id": 0, "name": "Czerny Konrad" }
}

Update

PUT /api/:leage_slug/player

REQUEST:

{
  "player": { "name": "Czerny Konrad" }
}

RESPONSE: returns Player

Accept fields: name

Delete

DELETE /api/:league_slug/player/:player_id

refcard-backend's People

Contributors

romualdk 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.