Docs
Table of Contents
Project Overview
This project leverages Redis for improved performance, utilizing Redis `SET` and `ZADD` commands to store and retrieve superhero data. By using Redis as an in-memory data store, we ensure that API response times are fast, with a return time of approximately ~0.001s for retrieving data. Redis provides the scalability needed to handle large volumes of requests efficiently.
Add Hero
POST /api/superheroesCreates a new superhero entry with a name, superpower, and humility score.
Body Parameters:
{
"name": "string",
"superpower": "string",
"humilityScore": "number"
}Response:
{
"message": "Superhero added successfully!",
"superhero": {
"id": 2,
"name": "Batman",
"superpower": "Intelligence",
"humilityScore": 7
}
}Get All Heroes
GET /api/superheroesRetrieves a list of all superheroes in the database, sorted by humility score.
Response:
{
"superheroes": [
{
"id": 2,
"name": "string",
"superpower": "string",
"humilityScore": 5
}
]
}Delete All Heroes
DELETE /api/superheroesDeletes all superheroes from the database. Use with caution as this action is irreversible.
Response:
{
"message": "All superheroes deleted successfully!"
}Delete Hero by Body
DELETE /api/superheroesDeletes a superhero entry from the database based on the provided request body containing superhero details.
Body Parameters:
{
"id": "number",
"name": "string",
"superpower": "string",
"humilityScore": "number"
}Response:
{
"message": "Superhero deleted successfully!"
}Update Hero
PUT /api/superheroesUpdates an existing superhero entry with the provided name, superpower, and humility score.
Body Parameters:
{
"id": "number",
"name": "string",
"superpower": "string",
"humilityScore": "number"
}Response:
{
"message": "Superhero updated successfully!"
}Initialize Superheroes
Function No parametersThis function initializes the superheroes by first checking if there are any existing heroes. If there are none, it adds some default heroes.
Response:
{
"message": "Superheroes initialized successfully!"
}