https://github.com/gustavo-zamai/ucl-api-node-ts-express
UEFA Champions League REST API using Node.js, TypeScript, Express, Prisma, PostgreSQL and ZOD. A backend project focused on learning and practicing API development.
https://github.com/gustavo-zamai/ucl-api-node-ts-express
api backend expressjs nodejs postgresql prisma rest-api typescript zod
Last synced: 2 months ago
JSON representation
UEFA Champions League REST API using Node.js, TypeScript, Express, Prisma, PostgreSQL and ZOD. A backend project focused on learning and practicing API development.
- Host: GitHub
- URL: https://github.com/gustavo-zamai/ucl-api-node-ts-express
- Owner: Gustavo-Zamai
- Created: 2025-06-08T15:19:37.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2025-06-21T01:15:20.000Z (about 1 year ago)
- Last Synced: 2025-06-21T02:25:45.292Z (about 1 year ago)
- Topics: api, backend, expressjs, nodejs, postgresql, prisma, rest-api, typescript, zod
- Language: TypeScript
- Homepage:
- Size: 803 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ๐๐
UCL API - Node.js + TypeScript + Express
This is a RESTful API for retrieving data about football clubs and players participating in the UEFA Champions League. It was built using Node.js, TypeScript, and Express, and includes endpoints to access information such as club name, city, badge (logo), players, stats, and more.
## ๐ Technologies Used
- Node.js
- TypeScript
- Express
- CORS
- Prisma
- ZOD
- PostgreSQL
## ๐ Project Structure
```bash
ucl-api-node-ts-express/
โโโ src/
โ โโโ controllers/
โ โโโ clubs-controller.ts
โ โโโ players-controller.ts
โ โโโ models/
โ โโโ club-model.ts
โ โโโ http-status-code.ts
โ โโโ player-model.ts
โ โโโ statistics.ts
โ โโโ repositories/
โ โโโ clubs-repository.ts
โ โโโ players-repository.ts
โ โโโ routes/
โ โโโ routes.ts
โ โโโ app.ts
โ โโโ server.ts
โโโ package.json
โโโ tsconfig.json
โโโ README.md
```
## ๐ฆ Installation
#### 1. Clone the repository:
```bash
git clone https://github.com/Gustavo-Zamai/ucl-api-node-ts-express.git
cd ucl-api-node-ts-express
```
#### 2. Install the dependencies:
```bash
npm install
```
#### 3. Start the development server:
```bash
npm run start:watch
```
#### 4. Open your browser at: `http://localhost:3000`
## ๐ Available Endpoints
### Clubs
- `GET /clubs` โ Returns all clubs
- `GET /clubs/:id` โ Returns a specific club by id
- `GET /clubs/name/:name` โ Returns a specific club by name, or part
- `GET /clubs/league/:league` โ Returns the clubs linked to league
- `POST /clubs` โ Adds a new club
- `DELETE /clubs/:id` โ Deletes a club
### Players
- `GET /players` โ Returns all players
- `GET /players/:id` โ Returns a specific player by id
- `GET /players/name/:name` โ Returns a specific player by name, or part
- `GET /players/clubs/:club` โ Returns players by their club
- `GET /players/position/:position` โ Returns players by their position
- `GET /players/nationality/:nationality` โ Returns players by their nationality
- `POST /players` โ Adds a new player
- `PATCH /players/:id` โ Updates stats of an player
- `DELETE /players/:id` โ Deletes a player
## ๐ Club Object Example
```json
{
"id": "ca57a6ed-1ca4-429f-8519-2c189be2bba7",
"name": "Bayern Munich",
"badge": "https://upload.wikimedia.org/wikipedia/commons/1/1b/FC_Bayern_M%C3%BCnchen_logo_%282017%29.svg",
"foundation": 1900,
"city": "Munich",
"league": "Bundesliga"
}
```
## ๐ Player Object Example
```json
{
"id": "1ef0962d-951c-4e8a-9d03-f99981eec7f3",
"name": "Erling Haaland",
"club": "Manchester City",
"nationality": "NOR",
"position": "ST",
"statistics": {
"Pace": 89,
"Overall": 91,
"Passing": 65,
"Physical": 88,
"Shooting": 94,
"Defending": 45,
"Dribbling": 80
}
}
```
## ๐ก CORS Middleware
The project uses the cors middleware to allow cross-origin requests, which is essential for frontend integrations hosted on separate domains.
```ts
import cors from 'cors';
app.use(cors());
```
## ๐ฎ Future Improvements
#### ๐ Authentication and Authorization with JWT
#### ๐ Real Database Integration (PostgreSQL, MongoDB, or MySQL) โ
#### ๐ Dynamic Filtering by nationality, league, or position โ
#### ๐ Advanced Stats and Player Rankings
#### ๐งช Automated Testing using Jest and Supertest
#### ๐ฑ Cloud Deployment (Render, Vercel, Railway, etc.)
#### ๐ผ Dynamic Image Uploads for players and clubs -- In Progress
#### ๐ณ Docker Support: -- In Progress
- Create a Dockerfile for the backend.
- Add docker-compose.yml to run with a real database.
- Make development setup and production deployment easier.
## ๐ License
- This project is licensed under the MIT License.
## ๐โโ๏ธ Author
#### Gustavo Zamai
[LinkedIn](https://www.linkedin.com/in/gustavo-sim%C3%A3o-zamai-664a5521a/) โข
[GitHub](https://github.com/Gustavo-Zamai)