API

Intro

   

About

API made in nodejs connected through mongoose to a mongodb database hosted in a mongodb Atlas cluster.

Project hosted in Heroku.

Color code

RGB #a61a5e rgb(166, 26, 94) / sRGB #c21360 rgb(194, 19, 96)

Used

  • Nodejs
  • MongoDB Atas Cluster - site
  • Heroku - site
  • Discord OAuth2

Other

  • Robo3T
  • MongoDB Compass
  • Postman
  • CircleCI

Dependencies

  • Express
  • body-parser
  • dotenv
  • btoa
  • dotenv - docs
  • mongoose
  • nanoid - docs
  • nodemon - site

Check page

https://api.disboard.team

Repository private

https://github.com/Qu4k3/disboard-api

Players

Resource description /players

METHOD PATH DESCRIPTION
GET /players Retrieve a list of all players
GET /players/:playerId Retrieve a specific player by it's ID *check note
POST /players Add a new player to database
PUT /players/:playerId Edit information from a specific player
DEL /players/:playerId Delete a player

NOTE

:playerId can be both the user's ID provided by the app or its Discord unique ID

PERMISSIONS

Some routes are autenticated and will not be available for public

Endpoints and methods /players

Parameters /players

Request example /players

Response example and schema /players

{
    "player_id" : String, // Player ID
    "player_name" : String, // Player nickname
    "player_team" : String, // Refer to team's Id
    "country" : {
        "name" : String, // Country
        "code" : String // Country code
    },
    "player_registry" : [
        {
            "role" : String, // Role type (ex: member, ally, trial)
            "in" : Date, // join date
            "out" : Date, // leave date
        }
    ],
    "discord" : {
        "unique_id" : String, // Discord unique Id
        "user_tag" : String, // Discord user tag
        "avatar_url" : String, // Discord's user profile picture
        "roles" : [
            {
                "role" : String, // Discord role
                "role_color" : String // Discord role color in hexadecimal
            }
        ]
    },
    "switch_fc" : String, // Nintendo Switch's friend code
    "mkc_player_profile" : String // mkc team link (ex: https://www.mariokartcentral.com/mkc/players/10)
}

Teams

Resource description /teams

METHOD PATH DESCRIPTION
GET /teams Retrieve a list of all teams
GET /teams/{teamId} Retrieve a specific team by it's ID
POST /teams Add a new team to database
PUT /teams/{teamId} Edit information from a specific team
DEL /teams/{teamId} Delete a team

PERMISSIONS

Some routes are autenticated and will not be available for public

Endpoints and methods /teams

Parameters /teams

Request example /teams

Response example and schema /teams

{
    "team_id" : String, // Team unique ID
    "team_name" : String, // Team name
    "team_tag" : String, // Team tag
    "team_logo" : String, // direct image link
    "mkc_team_profile" : String // mkc team link (ex: https://www.mariokartcentral.com/mkc/teams/42)
}

s

Resource description /wars

METHOD PATH DESCRIPTION
GET /wars Retrieve a list of all wars
GET /wars/:warId Retrieve a specific war by it's ID
POST /wars Add a new war to database
PUT /wars/:warId Edit inforamation
DEL /wars/:warId Delete a war

PERMISSIONS

Some routes are autenticated and will not be available for public

Endpoints and methods /wars

Parameters /wars

Request example /wars

Response example and schema /wars

{
    "war_id": String, // War unique ID
    "played_at" : Date, // Date where the war was played
    "game" : {
        "name" : String, // Game's code --default: MK8D
        "mode" : String // Game's mode code --default: 150cc
    },
    "type" : String, // Type of game played --default: friendly
    "tags" : [
        String // Tags to make wars groups or associations
    ],
    "results" : [
        {
            "team" : ObjectId, // Refer to team Id
            "host" : Boolean, // Define if the team is hosting the game
            "score" : Number, // Team final score
            "penality" : Number, // Penality points
            "players" : [
                {
                    "player" : ObjectId, // Refer to player Id
                    "score" : Number // player score
                }
            ]
        },
        {
            "team" : ObjectId, // Refer to team's Id
            "host" : Boolean, // Define if the team is hosting the game
            "score" : Number, // Team final score
            "penality" : Number, // Penality points
            "players" : [
                {
                    "player" : String, // Player name
                    "score" : Number // player score
                }
            ]
        }
    ]
}
Last Updated: 6/14/2020, 2:59:37 AM