This is a project that applies Typescript as a proof of concept in an API that aggregates videogame reviews. It applies a CRUD system to create users and reviews, list game reviews, update reviews and sessions, and delete users and reviews. It uses PostgreSQL as a database with the help with others technologies such as:
- Express
- Express Async Erros
- JOI
- Bcrypt
- JWT
- Clone this repository
- Install dependencies with
npm install
- Create a PostgreSQL database, there's a script in root folder to create the database and the tables
- Configure .env file with your database credentials
- Run
npm run dev
to start the server
POST
/users/signup
Body
{
"name": "Test",
"email": "test@email.com",
"password": "secret"
}
Response - 201 CREATED
PUT
/users/signin
Body
{
"email": "test@email.com",
"password": "secret"
}
Response - 200 OK
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6InRlc3RlQGVtYWlsLmNvbSIsImlhdCI6MTY4MTA1Mzc2N30.5ZUfRvvETQcJ57_PxF7v7mkdO-nZpa3C9QR1g1PEcXY"
}
GET
/users/
Response - 200 OK
{
"users": [
{
"id": 1,
"name": "teste"
},
{
"id": 2,
"name": "teste2"
}
]
}
DELETE
/user/delete/:id
Response - 204 No Content
POST
/reviews/add/:gameid?userid=
Body
{
"review": "Meh",
"grade": 6.5,
}
Response - 201 CREATED
{
"id": 3,
"user_id": 1,
"game_id": 2,
"grade": "6.5",
"review": "Meh",
}
GET
/reviews
Response - 200 OK
[
{
"id": 1,
"game_id": 4505,
"user_id": 1,
"review": "teste",
"grade": "9.5",
"users": {
"name": "gabe"
}
]
- Create User
- Login User
- Delete User
- List Users
- Create Review
- List Reviews
- List Games
- Add Games
- Delete Reviews
- Get Game Scores
- Get Game Average Score