The Humble Superhero API is a simple Node.js application that allows users to add superheroes, specifying their name, superpower, and humility score. The API then retrieves a list of superheroes sorted by humility score in increasing order.
Additionally, a React-based frontend is provided to interact with the API in real-time. View the Repository
- Backend (NestJS/Node.js)
- Add new superheroes with
POST /superheroes - Retrieve the sorted list with
GET /superheroes - In-memory database for simplicity
- Input validation for name (string), superpower (string), humility score (1-10)
- Jest test for both endpoint
- Add new superheroes with
- Node.js (v20+ recommended)
- npm
- Clone the repository:
git clone https://github.com/alexpap98/humble-superhero-client.git cd humble-superhero-api - Install dependencies:
npm install
- Run the application:
npm run start
- API will be available at
http://localhost:8080
Description: Adds a new superhero.
- Request Body:
{ "name": "Spider-Man", "superpower": "Web-Slinging", "humilityScore": 9 } - Response:
{ "id": 1, "name": "Spider-Man", "superpower": "Web-Slinging", "humilityScore": 9 }
Description: Retrieves the list of superheroes sorted by humility score.
- Response:
[ { "name": "Superman", "superpower": "Flight", "humilityScore": 10 }, { "name": "Spider-Man", "superpower": "Web-Slinging", "humilityScore": 9 } ]
To run Jest tests:
npm run testMIT