https://github.com/codewithalihamza/humble-superhero-backend
https://github.com/codewithalihamza/humble-superhero-backend
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/codewithalihamza/humble-superhero-backend
- Owner: codewithalihamza
- Created: 2025-02-07T18:03:13.000Z (over 1 year ago)
- Default Branch: develop
- Last Pushed: 2025-02-07T19:20:01.000Z (over 1 year ago)
- Last Synced: 2025-02-07T19:26:59.829Z (over 1 year ago)
- Language: TypeScript
- Size: 8.79 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## **π README for Backend (NestJS API)**
```md
# π¦ΈββοΈ Humble Superhero API (Backend)
This is the backend for the **Humble Superhero API**, built using **NestJS**. It allows users to add superheroes with a humility score and fetch them sorted by their humility.
---
## π Features
- **Add Superheroes:** API to add a superhero with a name, superpower, and humility score.
- **Fetch Superheroes:** API returns superheroes sorted by humility score.
- **Validation:** Ensures humility score is a number between **1 and 10**.
- **Simple In-Memory Database:** Stores data temporarily in an array.
---
## π οΈ Tech Stack
- **NestJS** - A progressive Node.js framework.
- **Node.js & TypeScript** - For backend development.
- **Jest** - For testing.
---
## π§ Installation & Running the Project
1. **Clone the Repository:**
```sh
https://github.com/codewithalihamza/humble-superhero-backend.git
```
2. **Install NestJS in the Existing Directory:**
```sh
npm install
```
3. **Start the API:**
```sh
npm run start
```
---
## π API Endpoints
### **1οΈβ£ Add a New Superhero**
**`POST /superheroes`**
π© **Request Body:**
```json
{
"name": "Captain Kindness",
"superpower": "Inspires humility",
"humilityScore": 9
}
```
π€ **Response:**
```json
{
"id": 1,
"name": "Captain Kindness",
"superpower": "Inspires humility",
"humilityScore": 9
}
```
---
### **2οΈβ£ Get All Superheroes (Sorted by Humility)**
**`GET /superheroes`**
π€ **Response:**
```json
[
{
"id": 1,
"name": "Captain Kindness",
"superpower": "Inspires humility",
"humilityScore": 9
},
{
"id": 2,
"name": "The Modest Marvel",
"superpower": "Lowers ego levels",
"humilityScore": 8
}
]
```
---
## β
**Technical Skills**
- **Code Quality:** Modular NestJS structure for scalability.
- **Validation:** Uses DTOs and validation for better data integrity.
- **Testing:** Basic Jest test included.
---
## π€ **Team Player Attitude**
> If working with a teammate, I would:
1. **Use Git Branches:** Feature branches (`feature/add-superhero`, `feature/tests`).
2. **PR Reviews:** Ensure best practices before merging.
3. **Task Division:** Backend & frontend teams work in parallel.
4. **Communication:** Use Slack or others for updates.
5. **Testing & Deployment:** Automate API tests before deployment.
---
## π§ **If I Had More Time...**
If I had more time, I would:
1. **Use a Database:** PostgreSQL or MongoDB instead of an in-memory array.
2. **Add Authentication:** Secure the API with JWT authentication.
3. **Rate Limiting:** Prevent spam requests using rate-limiting middleware.
4. **Deploy the API:** Host on **Heroku** or **Vercel**.
---
## π€ **Humility and Communication**
- **Code is well-documented** with clear comments.
- **README provides easy setup instructions.**
- **Project is structured for easy collaboration.**
---