Simple RESTful API of CRUD of games. Addicionally have JWT Auth and Swagger auto documentation. Default port: 3000
Simple JWT needed to access all routes expect /auth
- email = A valid user e-mail (required)
- password = User password (required)
Example:
{
"email" : "ewerton@eweti.com.br",
"password" : "123456"
}
Sucess response from a valid email/password: Example:
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MSwiZW1haWwiOiJld2VydG9uQGV3ZXRpLmNvbS5iciIsImlhdCI6MTY1MDg0Njg3OCwiZXhwIjoxNjUxMDE5Njc4fQ.ZwJUMgCA_rnOODP6inI9eVMMu1XgxVUohZ9KivfT1A8"
}
Rejection response when email or password is not provided: Example:
{
"err": "email/password are required"
}
Rejection response when email is ok but password is invalid: Example:
{
"err": "invalid password"
}
Rejection response when user not found by email: Example:
{
"err": "user not found"
}
Any server side error Example:
{
"err": "Description from a server side error"
}
This endpoint returns a list of all games
Bearer token Authorization needed Example:
{
Authorization: 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MSwiZW1haWwiOiJld2VydG9uQGV3ZXRpLmNvbS5iciIsImlhdCI6MTY1MDg0Njg3OCwiZXhwIjoxNjUxMDE5Njc4fQ.ZwJUMgCA_rnOODP6inI9eVMMu1XgxVUohZ9KivfT1A8'
}
When request is sucess, returns a list of all games Example:
[
{
"id": 1,
"title": "Tibia",
"year": 1998,
"price": 1233,
"createdAt": "2022-04-21T22:51:18.000Z",
"updatedAt": "2022-04-23T02:41:51.000Z"
},
{
"id": 4,
"title": "Doom 2 for Windows",
"year": 1992,
"price": 300,
"createdAt": "2022-04-21T23:08:07.000Z",
"updatedAt": "2022-04-24T22:21:32.000Z"
},
{
"id": 9,
"title": "Call Of Duty",
"year": 2010,
"price": 159.9,
"createdAt": "2022-04-23T01:24:44.000Z",
"updatedAt": "2022-04-23T02:30:37.000Z"
}
]
Rejection response when authorization token is not provided: Example:
{
"err": "authorization token is required"
}
Rejection response when authorization token is invalid or expires: Example:
{
"err": "invalid token"
}
Any server side error Example:
{
"err": "Description from a server side error"
}
This endpoint returns a single game by id
Bearer token Authorization needed Example:
{
Authorization: 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MSwiZW1haWwiOiJld2VydG9uQGV3ZXRpLmNvbS5iciIsImlhdCI6MTY1MDg0Njg3OCwiZXhwIjoxNjUxMDE5Njc4fQ.ZwJUMgCA_rnOODP6inI9eVMMu1XgxVUohZ9KivfT1A8'
}
- id = Id of game (required)
When request is sucess, returns a single game Example:
{
"id": 1,
"title": "Tibia",
"year": 1998,
"price": 1233,
"createdAt": "2022-04-21T22:51:18.000Z",
"updatedAt": "2022-04-23T02:41:51.000Z"
}
Rejection response when authorization token is not provided: Example:
{
"err": "authorization token is required"
}
Another possible response 400 occurs when query parameter id is not provided: Example:
{
"err": "parameter id is required"
}
Rejection response when authorization token is invalid or expires: Example:
{
"err": "invalid password"
}
Rejection response when game not found: Example:
{
"err": "game not found"
}
Any server side error Example:
{
"err": "Description from a server side error"
}
This endpoint creates a new game
Bearer token Authorization needed Example:
{
Authorization: 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MSwiZW1haWwiOiJld2VydG9uQGV3ZXRpLmNvbS5iciIsImlhdCI6MTY1MDg0Njg3OCwiZXhwIjoxNjUxMDE5Njc4fQ.ZwJUMgCA_rnOODP6inI9eVMMu1XgxVUohZ9KivfT1A8'
}
- title = Title of game (required)
- year = Release year (required)
- price = Price of game (required)
Example:
{
"title":"Tibia",
"year":1998,
"price":1233
}
When request is sucess, returns a created game Example:
{
"id": 18,
"title": "Tibia",
"year": 1998,
"price": 1233,
"updatedAt": "2022-04-25T01:14:35.167Z",
"createdAt": "2022-04-25T01:14:35.167Z"
}
Rejection response when authorization token is not provided: Example:
{
"err": "authorization token is required"
}
Another possible response 400 occurs when required parameters are not provided: Example:
{
"err": "notNull Violation: games.price cannot be null"
}
Any server side error Example:
{
"err": "Description from a server side error"
}
This endpoint updates a existing game
Bearer token Authorization needed Example:
{
Authorization: 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MSwiZW1haWwiOiJld2VydG9uQGV3ZXRpLmNvbS5iciIsImlhdCI6MTY1MDg0Njg3OCwiZXhwIjoxNjUxMDE5Njc4fQ.ZwJUMgCA_rnOODP6inI9eVMMu1XgxVUohZ9KivfT1A8'
}
- id = Id of game (required)
- title = Title of game (required)
- year = Release year (required)
- price = Price of game (required)
Example:
{
"title":"Tibia",
"year":1999,
"price":1233
}
When request is sucess, returns rows afecteds Example:
{
"updateCount": 1
}
Rejection response when authorization token is not provided: Example:
{
"err": "authorization token is required"
}
Another possible response 400 occurs when required query parameter id is not provided: Example:
{
"err": "parameter id is required"
}
Another possible response 400 occurs when required parameters are not provided: Example:
{
"err": "notNull Violation: games.price cannot be null"
}
Rejection response when game not found: Example:
{
"err": "game not found"
}
Any server side error Example:
{
"err": "Description from a server side error"
}
This endpoint delete a existing game
Bearer token Authorization needed Example:
{
Authorization: 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MSwiZW1haWwiOiJld2VydG9uQGV3ZXRpLmNvbS5iciIsImlhdCI6MTY1MDg0Njg3OCwiZXhwIjoxNjUxMDE5Njc4fQ.ZwJUMgCA_rnOODP6inI9eVMMu1XgxVUohZ9KivfT1A8'
}
- id = Id of game (required)
When request is sucess, returns count rows affected Example:
{
"deleteCount" : 1
}
Rejection response when authorization token is not provided: Example:
{
"err": "authorization token is required"
}
Another possible response 400 occurs when required query parameter id is not provided: Example:
{
"err": "parameter id is required"
}
Rejection response when game not found: Example:
{
"err": "game not found"
}
Any server side error Example:
{
"err": "Description from a server side error"
}