A simple API REST with a Pokemon battle algorithm with (Sequelize, Express, MSSQL or PostgreSQL)

Summary

Introduction

A simple API REST pokemon battle.

Minimal Requirements

NodeJs 12.x

Install

$ git clone https://github.com/gabriel-roque/pokemon-api

Configure API

$ cp .env.example .env

1. Configure your .env

APP_URL= DB_DIALECT= DB_HOST= DB_USERNAME= DB_PASSWORD= DB_NAME= DB_NAME_SCHEMA=

2. Run migrations in database

$ sequelize db:migrate

3. Run your app

$ npm run dev or $ npm start

Check in development at http://localhost:3333/v1/api/

Check in production at https://pokemon-api-challanger.herokuapp.com/v1/api

Resource Pokemons

GET /v1/api/pokemons

Response HTTP Code 200 - OK

[ { "id" : 1 , "tipo" : " pikachu " , "treinador" : " Gabriel " , "nivel" : 12 }, { "id" : 2 , "tipo" : " charizard " , "treinador" : " Anderson " , "nivel" : 11 } ]

back to top

POST /v1/api/pokemons

Request

Attribute Type tipo String [mewtwo / charizard / pikachu] treinador String

{ "tipo" : " pikachu " , "treinador" : " Gabriel " , }

Response HTTP Code 200 - OK

{ "id" : 1 , "tipo" : " pikachu " , "treinador" : " Gabriel " , "nivel" : 12 },

back to top

PUT /v1/api/pokemons/:id

Request

Attribute Type treinador String

{ "treinador" : " Anderson " , }

Response HTTP Code 204 - No Content

back to top

DELETE /v1/api/pokemons/:id

Response HTTP Code 204 - No Content

back to top

Resource Battle

POST /v1/api/batalhar/:pokemonAId/:pokemonBId

Response HTTP Code 200 - OK

{ "vencedor" : { "id" : 1 , "tipo" : " pikachu " , "treinador" : " Anderson " , "nivel" : 2 }, "perdedor" : { "id" : 2 , "tipo" : " charizard " , "treinador" : " Gabriel " , "nivel" : 0 } }

back to top

Author

Contributing

Contributions, issues and feature requests are welcome!

Feel free to check issues page.

Show your support

Give a if this project helped you!

Comentarios

Entradas populares de este blog

An OpenAPI demo specification to integrate Qualtrics XM into Microsoft Power Platform

Official Notion JavaScript Client

The Open Movie Database API omdb