/typescript-poc

Primary LanguageTypeScriptMozilla Public License 2.0MPL-2.0

typescript-poc

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

How to run

  1. Clone this repository
  2. Install dependencies with npm install
  3. Create a PostgreSQL database, there's a script in root folder to create the database and the tables
  4. Configure .env file with your database credentials
  5. Run npm run dev to start the server

Simple API Documentation

User Routes

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

Review Routes

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"
    }
]

Current Features

  • Create User
  • Login User
  • Delete User
  • List Users
  • Create Review
  • List Reviews
  • List Games
  • Add Games

Planned Features

  • Delete Reviews
  • Get Game Scores
  • Get Game Average Score