Skip to content

An api that aims better the organization of different types of collective games. Where you can organize or join in event that already exist.

Notifications You must be signed in to change notification settings

VicterHuger/lets-play-api

Repository files navigation

Let's Play

Built With


Description

An api that aims better the organization of different types of collective games. Where you can organize or join events that already exist.


Table of Contents

Features

  • Sign Up
  • Login
  • Create/Update profile
  • Create/Get photos
  • Create/Get phones
  • Register in event lobbies
  • Create/Get lobbies
  • Create/Get local events
  • Create/Get address
  • Get all sportes

Getting Started

This Api can be used in two different ways: by cloning the project or by using your preferred client, such as Insomnia or Postman.

To clone the project, run the following command:

git clone https://github.com/VicterHuger/lets-play-api.git

Then, navigate to the project folder and run the following command:

npm install

Environment Variables

To run this project, you will need to create a .env file in root directory and add the following environment variables to your .env file

DATABASE_URL = postgres://<userName>:<password>@<hostname>:5432/<database>
PORT = <number> #recommended:5000
TOKEN_SECRET_KEY= <string>
TOKEN_EXPIRES_IN= <time> #recommended 1day

Finally, run the server locally with initial data:

npm run dev:full 

Or without inital data:

npm run dev:empty

You can now access the API's endpoints by navigating to http://localhost:<PORT>/

Test

To apply automatized test on this project, you will need to create a .env.test file in root directory and add the following environment variables to your .env.test file

DATABASE_URL = postgres://<userName>:<password>@<hostname>:5432/<database-of-test>
PORT = <same-as-in-.env>
TOKEN_SECRET_KEY= <same-as-in-.env>
TOKEN_EXPIRES_IN= <time> #recommended 1day

Finally, run the integration test

npm run test:integration 

API Reference

In this section, you will find the API's endpoints and their respective descriptions, along with the request and response examples. All data is sent and received as JSON.

Routes

Sign Up /sign-up

Sign In/sign-in

Profile /profile

Photo /photo

Phone /phone

Lobby /lobby

Event Local /eventLocal

Address /address

Sport /sports

Sign Up

  ‣   Register a new user

POST /sign-up

  ☰   Request

Body Type Description
email string Required. valid email
password string Required. valid password
confirmPassword string Required. equal password

Email Format: <string>@<string>.<string>

Password Format: password with 6 length with 1 number, 1 lowercase and 1 uppercase letters and 1 special character

Confirm Password Format: equal to password

Body Example

{
  "email": "teste@email.com",
  "password": "1qW@12",
  "confirmPassword": "1qW@12"
}

  ☰   Responses

Status Code Description Properties
201 Created data: { User }
409 Conflict error: { message, details }
422 Unprocessable Entity error: { message, details }
500 Internal Server Error error: { message, details }

Example User data:

{
	"id": "1",
	"email": "test@email.com",
	"isBanned": false,
	"createdAt": "2022-10-17T02:58:39.748Z",
  "updatedAt": "2022-10-17T02:58:39.748Z"
}

Sign In

  ‣   Login user

POST /sign-in

  ☰   Request

Body Type Description
email string Required. valid email
password string Required. valid password

Email Format: <string>@<string>.<string>

Password Format: <string>

Body Example

{
  "email": "teste@email.com",
  "password": "1qW@12",
}

  ☰   Responses

Status Code Description Properties
200 Created data: { jwt token }
401 Unauthorized error: { message, details }
422 Unprocessable Entity error: { message, details }
500 Internal Server Error error: { message, details }

Example jwt token:

{
	"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c"
}

Profile

  ‣   Create profile

POST /profile/create

  ☰   Headers

Headers Type Description
Authorization string Required. token

Authorization Format: Bearer <token>


  ☰   Request

Body Type Description
userName string Required. valid userName
name string Required. valid name
lastName string Required. equal name
birthday date Required. valid date
sex string Required. valid type
phoneId number Required. valid number
photoId number Required. valid number
addressId number Required. valid number

UserName Format: valid alphanumeric with optional . _

Name and Last Name Format: valid name with letters and spaces

Birthday Format: MM/DD/YYYY

Sex Format: must be "FEMALECISGENDER" | "FEMALETRANSGENDER" | "MALECISGENDER" | "MALETRANSGENDER"

PhoneId, PhotoId and AddressId Format: valid number

Body Example

{"userName": "user12",
"name": "Mario",
"lastName": "Fernandes",
"birthday": "03/23/1997",
"sex": "MALECISGENDER",
"phoneId": "1",
"photoId": "1",
"addressId": "1"
}

  ☰   Responses

Status Code Description Properties
201 Created data: { Profile }
401 Unauthorized error: { message, details }
404 Not Found error: { message, details }
409 Conflict error: { message, details }
422 Unprocessable Entity error: { message, details }
500 Internal Server Error error: { message, details }

Example Profile data:

{
	
  "id": 1,
  "userName": "user12",
  "name": "Mario",
  "lastName": "Fernandes",
  "birthday": "1997-03-23T03:00:00.000Z",
  "sex": "MALECISGENDER",
  "isPhoneVerified": false,
  "isEmailVerified": false,
  "score": 0,
  "createdAt": "2022-10-17T04:12:17.162Z",
  "updatedAt": "2022-10-17T04:12:17.162Z",
  "userId": 1,
  "phoneId": 1,
  "photoId": 1,
  "addressId": 1

}

  ‣   Update profile

PATCH /profile/:id

  ☰   Params

Param Type Description
id number Required. number

id Format: <number>


  ☰   Headers

Headers Type Description
Authorization string Required. token

Authorization Format: Bearer <token>


  ☰   Request

Body Type Description
userName string Required. valid userName
name string Required. valid name
lastName string Required. equal name
birthday date Required. valid date
sex string Required. valid type
phoneId number Required. valid number
photoId number Required. valid number
addressId number Required. valid number

UserName Format: valid alphanumeric with optional . _

Name and Last Name Format: valid name with letters and spaces

Birthday Format: MM/DD/YYYY

Sex Format: must be "FEMALECISGENDER" | "FEMALETRANSGENDER" | "MALECISGENDER" | "MALETRANSGENDER"

PhoneId, PhotoId and AddressId Format: valid number

Body Example

{"userName": "user12",
"name": "Mario",
"lastName": "Fernandes",
"birthday": "03/23/1997",
"sex": "MALECISGENDER",
"phoneId": "1",
"photoId": "1",
"addressId": "1"
}

  ☰   Responses

Status Code Description Properties
201 Created data: { Profile }
401 Unauthorized error: { message, details }
403 Forbidden error: { message, details }
404 Not Found error: { message, details }
422 Unprocessable Entity error: { message, details }
500 Internal Server Error error: { message, details }

Example Profile data:

{
	
  "id": 1,
  "userName": "user12",
  "name": "Mario",
  "lastName": "Fernandes",
  "birthday": "1997-03-23T03:00:00.000Z",
  "sex": "MALECISGENDER",
  "isPhoneVerified": false,
  "isEmailVerified": false,
  "score": 0,
  "createdAt": "2022-10-17T04:12:17.162Z",
  "updatedAt": "2022-10-17T04:12:17.162Z",
  "userId": 1,
  "phoneId": 1,
  "photoId": 1,
  "addressId": 1

}

Photo

  ‣   Register photo

POST /photo/create

  ☰   Headers

Headers Type Description
Authorization string Required. token

Authorization Format: Bearer <token>


  ☰   Request

Body Type Description
link string<uri> Required. valid image uri
description string Optional. valid description

Link Format: valid image link

Description Format: <string>

Body Example

{
  "link": "https://res.cloudinary.com/practicaldev/image/fetch/s--985QhLxv--/c_fill,f_auto,fl_progressive,h_50,q_auto,w_50/https://dev-to-uploads.s3.amazonaws.com/uploads/user/profile_image/325104/a7d59066-2713-48d2-aa92-6db649676a1f.jpeg",
  "description": "Nice photo"
}

  ☰   Responses

Status Code Description Properties
201 Created data: { Photo }
401 Unauthorized error: { message, details }
409 Conflict error: { message, details }
422 Unprocessable Entity error: { message, details }
500 Internal Server Error error: { message, details }

Example Photo data:

{
	
  "id": 1,
  "link": "https://res.cloudinary.com/practicaldev/image/fetch/s--985QhLxv--/c_fill,f_auto,fl_progressive,h_50,q_auto,w_50/https://dev-to-uploads.s3.amazonaws.com/uploads/user/profile_image/325104/a7d59066-2713-48d2-aa92-6db649676a1f.jpeg",
  "description": "Nice photo",
  "createdAt": "2022-10-17T04:12:17.162Z",
  "updatedAt": "2022-10-17T04:12:17.162Z",
 
}

  ‣   Get photo by id

GET /photo:id

  ☰   Params

Param Type Description
id number Required. number

id Format: <number>


  ☰   Headers

Headers Type Description
Authorization string Required. token

Authorization Format: Bearer <token>


  ☰   Responses

Status Code Description Properties
200 OK data: { Photo }
401 Unauthorized error: { message, details }
404 Not Found error: { message, details }
422 Unprocessable Entity error: { message, details }
500 Internal Server Error error: { message, details }

Example Photo data:

{
	
  "id": 1,
  "link": "https://res.cloudinary.com/practicaldev/image/fetch/s--985QhLxv--/c_fill,f_auto,fl_progressive,h_50,q_auto,w_50/https://dev-to-uploads.s3.amazonaws.com/uploads/user/profile_image/325104/a7d59066-2713-48d2-aa92-6db649676a1f.jpeg",
  "description": "Nice photo",
  "createdAt": "2022-10-17T04:12:17.162Z",
  "updatedAt": "2022-10-17T04:12:17.162Z",
 
}

  ‣   Get photo by link

GET /photo

  ☰   Headers

Headers Type Description
Authorization string Required. token

Authorization Format: Bearer <token>


  ☰   Request

Body Type Description
link string<uri> Required. valid image uri
description string Optional. valid description

Link Format: valid image link

Description Format: <string>

Body Example

{
  "link": "https://res.cloudinary.com/practicaldev/image/fetch/s--985QhLxv--/c_fill,f_auto,fl_progressive,h_50,q_auto,w_50/https://dev-to-uploads.s3.amazonaws.com/uploads/user/profile_image/325104/a7d59066-2713-48d2-aa92-6db649676a1f.jpeg",
  "description": "Nice photo"
}

  ☰   Responses

Status Code Description Properties
200 OK data: { Photo }
401 Unauthorized error: { message, details }
404 Not Found error: { message, details }
422 Unprocessable Entity error: { message, details }
500 Internal Server Error error: { message, details }

Example Photo data:

{
	
  "id": 1,
  "link": "https://res.cloudinary.com/practicaldev/image/fetch/s--985QhLxv--/c_fill,f_auto,fl_progressive,h_50,q_auto,w_50/https://dev-to-uploads.s3.amazonaws.com/uploads/user/profile_image/325104/a7d59066-2713-48d2-aa92-6db649676a1f.jpeg",
  "description": "Nice photo",
  "createdAt": "2022-10-17T04:12:17.162Z",
  "updatedAt": "2022-10-17T04:12:17.162Z",
 
}

Phone

  ‣   Register phone

POST /phone/create

  ☰   Headers

Headers Type Description
Authorization string Required. token

Authorization Format: Bearer <token>


  ☰   Request

Body Type Description
number string<numbers> Required. valid string with numbers

Number Format: DDI DDD XXXXXXXXX - Ex: 5521987456123

Body Example

{
  "number": "5521987456123"
}

  ☰   Responses

Status Code Description Properties
201 Created data: { Phone }
401 Unauthorized error: { message, details }
409 Conflict error: { message, details }
422 Unprocessable Entity error: { message, details }
500 Internal Server Error error: { message, details }

Example Phone data:

{
	
  "id": 1,
  "number": "5521987456123",
  "createdAt": "2022-10-17T04:12:17.162Z",
  "updatedAt": "2022-10-17T04:12:17.162Z",
 
}

  ‣   Get phone by id

GET /phone/:id

  ☰   Params

Param Type Description
id number Required. number

id Format: <number>


  ☰   Headers

Headers Type Description
Authorization string Required. token

Authorization Format: Bearer <token>


  ☰   Responses

Status Code Description Properties
200 OK data: { Phone }
401 Unauthorized error: { message, details }
404 Not Found error: { message, details }
422 Unprocessable Entity error: { message, details }
500 Internal Server Error error: { message, details }

Example Phone data:

{
	
  "id": 1,
  "number": "5521987456123",
  "createdAt": "2022-10-17T04:12:17.162Z",
  "updatedAt": "2022-10-17T04:12:17.162Z",
 
}

  ‣   Get phone by number

GET /phone

  ☰   Params

Param Type Description
id number Required. number

id Format: <number>


  ☰   Headers

Headers Type Description
Authorization string Required. token

Authorization Format: Bearer <token>


  ☰   Request

Body Type Description
number string<numbers> Required. valid string with numbers

Number Format: DDI DDD XXXXXXXXX - Ex: 5521987456123

Body Example

{
  "number": "5521987456123"
}

  ☰   Responses

Status Code Description Properties
200 OK data: { Phone }
401 Unauthorized error: { message, details }
404 Not Found error: { message, details }
422 Unprocessable Entity error: { message, details }
500 Internal Server Error error: { message, details }

Example Phone data:

{
	
  "id": 1,
  "number": "5521987456123",
  "createdAt": "2022-10-17T04:12:17.162Z",
  "updatedAt": "2022-10-17T04:12:17.162Z",
 
}

Register in a Lobby

  ‣   Register user in a lobby

POST /lobbyUser/create/:lobbyId

  ☰   Params

Param Type Description
lobbyId number Required. number

lobbyId Format: <number>


  ☰   Headers

Headers Type Description
Authorization string Required. token

Authorization Format: Bearer <token>


  ☰   Responses

Status Code Description Properties
201 Created data: { LobbyUser }
401 Unauthorized error: { message, details }
409 Conflict error: { message, details }
422 Unprocessable Entity error: { message, details }
500 Internal Server Error error: { message, details }

Example LobbyUser data:

{
  "id": 1,
  "userId": 1,
  "lobbyId":1,
  "createdAt": "2022-10-17T04:12:17.162Z",
  "updatedAt": "2022-10-17T04:12:17.162Z",
}

Lobby

  ‣   Create a lobby

POST /lobby/create

  ☰   Headers

Headers Type Description
Authorization string Required. token

Authorization Format: Bearer <token>


  ☰   Request

Body Type Description
title string Required. valid string
description string Optional. valid string
eventDate Date Required. valid date
eventTimeStart string Required. valid string
eventTimeEnd string Required. valid string
minParticipants number Required. valid positive number not null
maxParticipants number Required. valid positive number not null
allowedParticipants string Required. valid string type "MEN"
status string Required. valid string type "OPEN"
sportId number Required. valid positive number not null
eventLocalId number Required. valid positive number not null

Title Format: text string min of 10 characteres and maximum of 50

Description Format: text string max of 255 characteres

EventDate Format: MM/DD/YYYY

EventTimeStart Format: hh:mm - 24h format

EventTimeEnd Format: hh:mm - 24h format

MinParticipants Format: not null positive number

MaxParticipants Format: not null positive number

AllowedParticipants Format: Must be MEN" , "WOMEN" or "MIXED

Status Format: Must be OPEN", "ONGOING", "CLOSED" or "FULL"

SportId Format: not null positive number

EventLocalId Format: not null positive number


Body Example

{
  "title": "Futebol na Manet",
  "status": "OPEN",
  "eventDate": "10/09/2022",
  "eventTimeStart": "01:00",
  "eventTimeEnd": "06:00",
  "minParticipants":"8",
  "maxParticipants": "24",
  "allowedParticipants": "MIXED",
  "sportId":"1",
  "eventLocalId": "1"
}

  ☰   Responses

Status Code Description Properties
201 Created data: { LobbyResponse }
401 Unauthorized error: { message, details }
409 Conflict error: { message, details }
422 Unprocessable Entity error: { message, details }
500 Internal Server Error error: { message, details }

Example LobbyResponse data:

{
  "id": 1,
  "title": "Futebol na Manet",
  "status": "OPEN",
  "description": "No description",
  "eventDate": "2022-10-09T03:00:00.000Z",
  "eventTimeStart": "01:00",
  "eventTimeEnd": "06:00",
  "minParticipants": 8,
  "maxParticipants": 24,
  "allowedParticipants": "MIXED",
  "createdAt": "2022-10-17T15:07:35.359Z",
  "updatedAt": "2022-10-17T15:07:35.359Z",
  "userHostId": 2,
  "sportId": 1,
  "eventLocalId": 1,
  "lobbiesUsers": [
    {
      "id": 1,
      "createdAt": "2022-10-17T15:07:35.359Z",
      "updatedAt": "2022-10-17T15:07:35.359Z",
      "userId": 2,
      "lobbyId": 1
    }
}

  ‣   Get a lobby by id

GET /lobby/:id

  ☰   Params

Param Type Description
id number Required. number

id Format: not null positive number


  ☰   Headers

Headers Type Description
Authorization string Required. token

Authorization Format: Bearer <token>


  ☰   Responses

Status Code Description Properties
200 OK data: { LobbyResponse }
401 Unauthorized error: { message, details }
404 Not Found error: { message, details }
422 Unprocessable Entity error: { message, details }
500 Internal Server Error error: { message, details }

Example LobbyResponse data:

{
  "id": 1,
  "title": "Futebol na Van Gogh",
  "description": "No description",
  "eventDate": "2022-10-09T03:00:00.000Z",
  "eventTimeStart": "01:00",
  "eventTimeEnd": "06:00",
  "minParticipants": 8,
  "maxParticipants": 24,
  "allowedParticipants": "MIXED",
  "createdAt": "2022-10-17T15:07:35.359Z",
  "updatedAt": "2022-10-17T15:07:35.359Z",
  "userHost": {
    "createdAt": "2022-10-17T04:11:31.456Z",
    "profiles": [
      {
        "userId": 2,
        "userName": "jeniferMoura1",
        "sex": "FEMALECISGENDER",
        "score": 0,
        "photo": {
          "description": "no description",
          "link": "https://ssl.gstatic.com/calendar/images/dynamiclogo_2020q4/calendar_3_2x.png"
        }
      }
    ]
  },
  "sport": {
    "name": "Basketball"
  },
  "eventLocal": {
    "name": "Praça Van Gogh",
    "isPublic": false,
    "isOutdoor": false,
    "photo": {
      "description": "no description",
      "link": "https://ssl.gstatic.com/calendar/images/dynamiclogo_2020q4/calendar_3_2x.png"
    },
    "address": {
      "street": "Rua Qualquer de Guimarães",
      "number": "no number",
      "complement": "no complement",
      "zipCode": "11111111",
      "city": {
        "name": "Rio de Janeiro",
        "state": {
          "name": "Rio de Janeiro"
        }
      }
    }
  },
  "lobbiesUsers": []
}

  ‣   Get all lobbies

GET /lobbies

  ☰   Headers

Headers Type Description
Authorization string Required. token

Authorization Format: Bearer <token>


  ☰   Responses

Status Code Description Properties
200 OK data: { LobbyResponse }
401 Unauthorized error: { message, details }
500 Internal Server Error error: { message, details }

Example LobbyResponse data:

[
  {
    "id": 1,
    "title": "Futebol na Manet",
    "description": "No description",
    "eventDate": "2022-10-09T03:00:00.000Z",
    "eventTimeStart": "01:00",
    "eventTimeEnd": "06:00",
    "minParticipants": 8,
    "maxParticipants": 24,
    "allowedParticipants": "MIXED",
    "createdAt": "2022-10-17T15:07:35.359Z",
    "updatedAt": "2022-10-17T15:07:35.359Z",
    "userHost": {
      "createdAt": "2022-10-17T04:11:31.456Z",
      "profiles": [
        {
          "userId": 2,
          "userName": "fernand22",
          "sex": "FEMALECISGENDER",
          "score": 0,
          "photo": {
            "description": "no description",
            "link": "https://ssl.gstatic.com/calendar/images/dynamiclogo_2020q4/calendar_3_2x.png"
          }
        }
      ]
    },
    "sport": {
      "name": "Basketball"
    },
    "eventLocal": {
      "name": "Praça Manet",
      "isPublic": false,
      "isOutdoor": false,
      "photo": {
        "description": "no description",
        "link": "https://ssl.gstatic.com/calendar/images/dynamiclogo_2020q4/calendar_3_2x.png"
      },
      "address": {
        "street": "5th avenue",
        "number": "no number",
        "complement": "no complement",
        "zipCode": "99987789",
        "city": {
          "name": "Rio de Janeiro",
          "state": {
            "name": "Rio de Janeiro"
          }
        }
      }
    },
    "lobbiesUsers": []
  }
]

Event Local

  ‣   Create event local

POST /eventLocal/create

  ☰   Headers

Headers Type Description
Authorization string Required. token

Authorization Format: Bearer <token>


  ☰   Request

Body Type Description
name string Required. valid string
isPublic boolean Optional. valid boolean
isOutdoor boolean Optional. valid boolean
photoId number Required. valid positive number not null
addressId number Required. valid positive number not null

Name Format: text string min of 10 characteres and maximum of 50

isOutdoor Format: true or false

isPublic Format: true or false

PhotoId Format: not null positive number

AddressId Format: not null positive number


Body Example

{
  "name": "Praça Manet",
  "addressId": "1",
  "photoId": "1"
}

  ☰   Responses

Status Code Description Properties
201 Created data: { EventLocal }
401 Unauthorized error: { message, details }
409 Conflict error: { message, details }
422 Unprocessable Entity error: { message, details }
500 Internal Server Error error: { message, details }

Example EventLocal data:

{
  "id": 2,
  "name": "Engenhão  Portão Norte",
  "isPublic": false,
  "isOutdoor": false,
  "createdAt": "2022-10-17T15:45:29.469Z",
  "updatedAt": "2022-10-17T15:45:29.469Z",
  "addressId": 2,
  "photoId": 1
}

  ‣   Get event local by address id

GET /eventLocal/address/:addressId

  ☰   Params

Param Type Description
addressId number Required. number

addressId Format: not null positive number


  ☰   Headers

Headers Type Description
Authorization string Required. token

Authorization Format: Bearer <token>


  ☰   Responses

Status Code Description Properties
200 OK data: { EventLocal }
401 Unauthorized error: { message, details }
404 Not Found error: { message, details }
422 Unprocessable Entity error: { message, details }
500 Internal Server Error error: { message, details }

Example EventLocal data:

{
  "id": 2,
  "name": "Engenhão  Portão Norte",
  "isPublic": false,
  "isOutdoor": false,
  "createdAt": "2022-10-17T15:45:29.469Z",
  "updatedAt": "2022-10-17T15:45:29.469Z",
  "addressId": 2,
  "photoId": 1
}

  ‣   Get event local by id

GET /eventLocal/:id'

  ☰   Params

Param Type Description
id number Required. number

id Format: not null positive number


  ☰   Headers

Headers Type Description
Authorization string Required. token

Authorization Format: Bearer <token>


  ☰   Responses

Status Code Description Properties
200 OK data: { EventLocal }
401 Unauthorized error: { message, details }
404 Not Found error: { message, details }
422 Unprocessable Entity error: { message, details }
500 Internal Server Error error: { message, details }

Example EventLocal data:

{
  "id": 2,
  "name": "Engenhão  Portão Norte",
  "isPublic": false,
  "isOutdoor": false,
  "createdAt": "2022-10-17T15:45:29.469Z",
  "updatedAt": "2022-10-17T15:45:29.469Z",
  "addressId": 2,
  "photoId": 1
}

Address

  ‣   Create address

POST /address/create

  ☰   Headers

Headers Type Description
Authorization string Required. token

Authorization Format: Bearer <token>


  ☰   Request

Body Type Description
zipCode string Required. valid string with only numbers
number string Optional. valid string with only numbers
complement string Optional. valid string
neighborhood string Optional. valid string
street string Optional. valid string

ZipCode Format: 8 digits length - XXXXXXXX (X=Number)

Number Format: Only numbers

Complement Format: Any string

Neighborhood Format: Any string

Street Format: Any String


Body Example

{
  "zipCode": "18147000",
  "neighborhood": "Centro",
  "street": "Rua da Igreja"
}

  ☰   Responses

Status Code Description Properties
201 Created data: { Address }
401 Unauthorized error: { message, details }
409 Conflict error: { message, details }
422 Unprocessable Entity error: { message, details }
500 Internal Server Error error: { message, details }

Example Address data:

{
  "id": 5,
  "street": "Rua da Igreja",
  "number": "1",
  "complement": "no complement",
  "zipCode": "18147000",
  "neighborhood": "Centro",
  "createdAt": "2022-10-17T17:09:36.555Z",
  "updatedAt": "2022-10-17T17:09:36.555Z",
  "cityId": 9715
}

  ‣   Get address

GET /address'

  ☰   Headers

Headers Type Description
Authorization string Required. token

Authorization Format: Bearer <token>


  ☰   Request

Body Type Description
zipCode string Required. valid string with only numbers
number string Optional. valid string with only numbers
complement string Optional. valid string

ZipCode Format: 8 digits length - XXXXXXXX (X=Number)

Number Format: Only numbers

Complement Format: Any string


Body Example

{
  "zipCode": "18147000"
}

  ☰   Responses

Status Code Description Properties
200 OK data: { Address }
401 Unauthorized error: { message, details }
404 Not Found error: { message, details }
422 Unprocessable Entity error: { message, details }
500 Internal Server Error error: { message, details }

Example Address data:

{
  "id": 2,
  "name": "Engenhão  Portão Norte",
  "isPublic": false,
  "isOutdoor": false,
  "createdAt": "2022-10-17T15:45:29.469Z",
  "updatedAt": "2022-10-17T15:45:29.469Z",
  "addressId": 2,
  "photoId": 1
}

Sport

  ‣   Get all sports

GET /sports

  ☰   Headers

Headers Type Description
Authorization string Required. token

Authorization Format: Bearer <token>


  ☰   Responses

Status Code Description Properties
200 OK data: [ Sports ]
401 Unauthorized error: { message, details }
500 Internal Server Error error: { message, details }

Example Sports data:

[
  {
    "id": 19,
    "name": "Altinha",
    "createdAt": "2022-10-06T19:57:35.422Z",
    "updatedAt": "2022-10-06T19:57:35.422Z"
  },
  {
    "id": 1,
    "name": "Basketball",
    "createdAt": "2022-10-06T19:57:35.422Z",
    "updatedAt": "2022-10-06T19:57:35.422Z"
  },
  {
    "id": 26,
    "name": "Bowling",
    "createdAt": "2022-10-06T19:57:35.422Z",
    "updatedAt": "2022-10-06T19:57:35.422Z"
  },
  {
    "id": 22,
    "name": "Cycling Urban",
    "createdAt": "2022-10-06T19:57:35.422Z",
    "updatedAt": "2022-10-06T19:57:35.422Z"
  },
  {
    "id": 20,
    "name": "Fencing",
    "createdAt": "2022-10-06T19:57:35.422Z",
    "updatedAt": "2022-10-06T19:57:35.422Z"
  },
  {
    "id": 3,
    "name": "Football",
    "createdAt": "2022-10-06T19:57:35.422Z",
    "updatedAt": "2022-10-06T19:57:35.422Z"
  },
  {
    "id": 6,
    "name": "Golf",
    "createdAt": "2022-10-06T19:57:35.422Z",
    "updatedAt": "2022-10-06T19:57:35.422Z"
  },
  {
    "id": 16,
    "name": "Handball",
    "createdAt": "2022-10-06T19:57:35.422Z",
    "updatedAt": "2022-10-06T19:57:35.422Z"
  },
  {
    "id": 9,
    "name": "Hockey",
    "createdAt": "2022-10-06T19:57:35.422Z",
    "updatedAt": "2022-10-06T19:57:35.422Z"
  },
  {
    "id": 25,
    "name": "Ice Skating",
    "createdAt": "2022-10-06T19:57:35.422Z",
    "updatedAt": "2022-10-06T19:57:35.422Z"
  },
  {
    "id": 11,
    "name": "Kickball",
    "createdAt": "2022-10-06T19:57:35.422Z",
    "updatedAt": "2022-10-06T19:57:35.422Z"
  },
  {
    "id": 53,
    "name": "Other",
    "createdAt": "2022-10-06T20:26:33.032Z",
    "updatedAt": "2022-10-06T20:26:33.032Z"
  },
  {
    "id": 7,
    "name": "Pickleball",
    "createdAt": "2022-10-06T19:57:35.422Z",
    "updatedAt": "2022-10-06T19:57:35.422Z"
  },
  {
    "id": 24,
    "name": "Roller Skate",
    "createdAt": "2022-10-06T19:57:35.422Z",
    "updatedAt": "2022-10-06T19:57:35.422Z"
  },
  {
    "id": 12,
    "name": "Rugby",
    "createdAt": "2022-10-06T19:57:35.422Z",
    "updatedAt": "2022-10-06T19:57:35.422Z"
  },
  {
    "id": 10,
    "name": "Running",
    "createdAt": "2022-10-06T19:57:35.422Z",
    "updatedAt": "2022-10-06T19:57:35.422Z"
  },
  {
    "id": 23,
    "name": "Skateboarding",
    "createdAt": "2022-10-06T19:57:35.422Z",
    "updatedAt": "2022-10-06T19:57:35.422Z"
  },
  {
    "id": 21,
    "name": "Slack Line",
    "createdAt": "2022-10-06T19:57:35.422Z",
    "updatedAt": "2022-10-06T19:57:35.422Z"
  },
  {
    "id": 2,
    "name": "Soccer",
    "createdAt": "2022-10-06T19:57:35.422Z",
    "updatedAt": "2022-10-06T19:57:35.422Z"
  },
  {
    "id": 17,
    "name": "Soccer Beach",
    "createdAt": "2022-10-06T19:57:35.422Z",
    "updatedAt": "2022-10-06T19:57:35.422Z"
  },
  {
    "id": 13,
    "name": "Softball",
    "createdAt": "2022-10-06T19:57:35.422Z",
    "updatedAt": "2022-10-06T19:57:35.422Z"
  },
  {
    "id": 14,
    "name": "Swimming",
    "createdAt": "2022-10-06T19:57:35.422Z",
    "updatedAt": "2022-10-06T19:57:35.422Z"
  },
  {
    "id": 8,
    "name": "Tennis",
    "createdAt": "2022-10-06T19:57:35.422Z",
    "updatedAt": "2022-10-06T19:57:35.422Z"
  },
  {
    "id": 5,
    "name": "Ultimate Frisbee",
    "createdAt": "2022-10-06T19:57:35.422Z",
    "updatedAt": "2022-10-06T19:57:35.422Z"
  },
  {
    "id": 4,
    "name": "Volleyball",
    "createdAt": "2022-10-06T19:57:35.422Z",
    "updatedAt": "2022-10-06T19:57:35.422Z"
  },
  {
    "id": 18,
    "name": "Volleyball Beach",
    "createdAt": "2022-10-06T19:57:35.422Z",
    "updatedAt": "2022-10-06T19:57:35.422Z"
  },
  {
    "id": 15,
    "name": "Yoga",
    "createdAt": "2022-10-06T19:57:35.422Z",
    "updatedAt": "2022-10-06T19:57:35.422Z"
  }
]



Lessons Learned

In this project I learned a lot about how to structure an API with TypeScript, apply Prisma ( ORM ) to manage migrations and database, test the API with automatized tests with Jest and Supertest


Acknowledgements


Authors


About

An api that aims better the organization of different types of collective games. Where you can organize or join in event that already exist.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published