To Test This
Type yarn to install all the required dependency
CREATE TABLE fighters (
fighter_id SERIAL PRIMARY KEY,
first_name VARCHAR(255) NOT NULL,
last_name VARCHAR(255) NOT NULL,
nationality VARCHAR(255) NOT NULL,
weight_class VARCHAR(255) NOT NULL,
team VARCHAR(255),
wins INTEGER DEFAULT 0,
losses INTEGER DEFAULT 0,
knockouts INTEGER DEFAULT 0,
submissions INTEGER DEFAULT 0
);
CREATE TABLE events (
event_id SERIAL PRIMARY KEY,
event_name VARCHAR(255) NOT NULL,
location VARCHAR(255) NOT NULL,
date TIMESTAMP NOT NULL
);
CREATE TABLE fights (
fight_id SERIAL PRIMARY KEY,
event_id INTEGER REFERENCES events(event_id),
fighter1_id INTEGER REFERENCES fighters(fighter_id),
fighter2_id INTEGER REFERENCES fighters(fighter_id),
winner_id INTEGER REFERENCES fighters(fighter_id),
outcome_description TEXT NOT NULL
);
Attributes: fighter_id, first_name, last_name, nationality, weight_class, team, wins, losses, knockouts, submissions Relationships: One-to-Many with Fight Entity (fights_as_fighter1 and fights_as_fighter2)
Attributes: event_id, event_name, location, date Relationships: One-to-Many with Fight Entity (fights)
Attributes: fight_id, event_id, fighter1_id, fighter2_id, winner_id, outcome_description Relationships: Many-to-One with Event Entity (event) Many-to-One with Fighter Entity (fighter1 and fighter2) Many-to-One with Fighter Entity (winner)
Attributes: ranking_id, weight_class, fighter_id, rank Relationships: Many-to-One with Fighter Entity (fighter)
Get All Fighters Retrieve a list of all fighters.
Endpoint: POST /fighters
Request Body:
{ "first_name": "John", "last_name": "Doe", "nationality": "US", "weight_class": "Middleweight", "team": "Team A", "wins": 10, "losses": 5, "knockouts": 3, "submissions": 2 }
Response:
{ "fighter_id": 1, "first_name": "John", "last_name": "Doe", "nationality": "US", "weight_class": "Middleweight", "team": "Team A", "wins": 10, "losses": 5, "knockouts": 3, "submissions": 2 }
Endpoint: GET /fighters
Response:
[ { "fighter_id": 1, "first_name": "John", "last_name": "Doe", "nationality": "US", "weight_class": "Middleweight", "team": "Team A", "wins": 10, "losses": 5, "knockouts": 3, "submissions": 2 } ]
Get Fighter Details Retrieve details of a specific fighter.
Endpoint: GET /fighters/:id
Response:
{ "fighter_id": 1, "first_name": "John", "last_name": "Doe", "nationality": "US", "weight_class": "Middleweight", "team": "Team A", "wins": 10, "losses": 5, "knockouts": 3, "submissions": 2 }Events API Get Upcoming Events Retrieve a list of upcoming events. Endpoint: GET /events/upcoming
Response: [ { "event_id": 1, "event_name": "UFC Fight Night", "location": "Las Vegas, NV", "date": "2023-08-30T18:00:00.000Z" }, ]
Create Event Create a new event.
Endpoint: POST /events
Request Body:
{ "event_name": "UFC Fight Night", "location": "Las Vegas, NV", "date": "2023-08-30T18:00:00Z" }
Response:
{ "event_id": 1, "event_name": "UFC Fight Night", "location": "Las Vegas, NV", "date": "2023-08-30T18:00:00.000Z" }