Coder Social home page Coder Social logo

mock-epl-api's Introduction

Mock EPL API

Coverage Status Build Status

An API that serves the latest scores of fixtures of matches in a “Mock Premier League”

Table of Contents

Technology Stack

  • Nodejs
  • PostgreSQL
  • Redis
  • Docker

Features

  • Users can
    • Sign in
    • view teams
    • view completed fixtures
    • view pending fixtures
    • search fixtures/teams
  • Admin can
    • Sign in
    • manage teams (add, remove, edit, view)
    • create fixtures (add, remove, edit, view)

Getting Started

To run this API locally simply follow the instructions below:

Prerequisites

You need to have or install the following:

  1. Git bash
  2. Npm
  3. Postman

Installation

  • clone repo

    git clone https://github.com/fegoworks/premier-league-api.git
    
  • navigate to api folder

  • run installation

    npm install
    
  • create a .env file with this template

    DB_URL='Your postgres database url'
    TEST_URL='Your postgres test database url'
    SECRET = 'Your secret phrase'
    
  • start app

    npm run start:dev
    
  • you can now make requests using postman to localhost:3000/api/v1/

Running Tests

To run tests simply run the following command in your git bash or command line

npm run test

API endpoints

Heroku: Mock-EPL-API Documentation: Mock-EPL-API-Docs

Endpoints Functionality
POST /auth/create-user Create new user account
POST /auth/signin Login a user
POST /teams Create a team
POST /fixtures Create a fixture
PATCH /teams/:teamId Edit a team
PATCH /fixtures/:fixtureId Edit a fixture
PATCH /fixtures/:fixtureId/scores Update a fixture with scores
DELETE /fixtures/:fixtureId Delete a specific fixture
DELETE /teams/:teamId Delete a specific team post
GET /fixtures/pending View pending fixtures
GET /fixtures/completed View completed fixtures
GET /fixtures/:fixtureId View a specific fixture
GET /teams/:teamId View a specific team

Sign up

Send a POST request to /api/v1/auth/create-user with the following JSON structure:

{
  "firstName": "Sensei",
  "lastName": "Saitama",
  "email": "[email protected]",
  "password": "password",
  "isAdmin": "true"
}

For admins isAdmin is provided with true while for users it is set to false. POST and PATCH requests are restricted to only the admin accounts. User accounts can perform GET requests.

Sign in with the user

Send a POST request to /api/v1/auth/signin, with the following:

{
	"email": ,
	"password":
}

When you signin you'll receive a Bearer token. You'll need this token to send any request related to teams and fixtures.

Frow now on, every request described here will require you send the Bearer token

Create a new team

Send a POST request to /api/v1/teams, with the following:

{
  "teamName": "Barcelona"
}

View a single team

Send a GET request to /api/v1/teams/:teamid

Edit a team

Send a PATCH request to /api/v1/teams/:teamid, with the following:

{
  "teamName": "Norwich"
}

Delete a team

Delete a team by placing its id in the DELETE request URL /api/v1/teams/:teamid.

Create a fixture

Send a POST request to /fixtures, with the following:

{
  "matchDate": "03/10/2020",
  "homeTeam": "Crystal Palace",
  "awayTeam": "Chelsea"
}

Edit a fixture

Send a PATCH request to /api/v1/fixtures/:fixtureId, with the following:

{
  "matchDate": "03/10/2020",
  "homeTeam": "Crystal Palace",
  "awayTeam": "Chelsea"
}

View a single fixture

Send a GET request to /api/v1/fixtures/:fixtureid

Delete a fixture

Delete a fixture by placing its id in the DELETE request URL /fixtures/:fixtureid.

Update a fixture with scores

Send a PATCH request to /api/v1/fixtures/:fixtureId/scores, with the following:

{
  "homeTeamScore": 5,
  "awayTeamScore": 2
}

View pending fixtures

Send a GET request to /api/v1/fixtures/pending/

View completed fixtures

Send a GET request to /api/v1/fixtures/completed

Author

Edafe Oghenefego @realFego

mock-epl-api's People

Contributors

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