League teamfinder API
Golang api for a league of legends teamfinder project
Table of Contents
Introduction
The following documentation assumes previous knowledge of:
- Docker containers
- General API usage (call a route, differences between get, post, patch operations, send a request with body or with data on headers, process a response...)
- Understanding of the purpose of the API; being able to answer the questions:
- What the API has ben built for?
- What resources are managed by it
Getting Started
Prerequisites
- Install golang from the reference guide
- Install docker from the official site
- Optional: vscode addons for golang
Installation
-
Open a terminal and navigate to your golang working directory
cd PATH/TO/YOUR/GOLANG/WORK/DIRECTORY
-
Run the command on the terminal to clone the project from the gitlab repository
git clone https://gitlab.com/lol_fashion/lol-api.git
Run locally
-
You will find a folder named lol-api, navigate inside the folder with the command
cd ./lol-api`
-
Run this command to install all the necessary golang packages
go get -v ./...
-
Paste the following data into the .env file inside the folder and update the variables
version: "3.7" services: lol-api: build: ./lol-api image: lol-api:latest restart: always container_name: lol-api depends_on: environment: PORT: your_db_port GO_ENV: development SERVER_LOGS_PATH: logs/server_info.log FRONT_LOGS_PATH: logs/front_info.log CORS_ALLOWED_ORIGINS: your_allowed_url_1, your_allowed_url_2 ACCESS_CONTROL_ALLOW_CREDENTIALS: your_allowed_url_1, your_allowed_url_2 CORS_ADMIN_ORIGINS: your_allowed_url_1, your_allowed_url_2 DB_ENV: dev DB_PORT: your_rethinkdb_port DB_HOST: your_rethinkdb_host MAIL_SEND_TO: your_email MAIL_USER: your_email_user MAIL_PASS: your_email_pass volumes: - ./mounted/logs:/go/src/lol-api/logs ports: - "8082:81"
-
After completing the 3 previous steps, the project should be configured and ready to run, in order to launch it execute the following command, which will start the server and will show the logs on the terminal
go run app.go
Run with docker
-
Create a file called
docker-compose.yml
in the same directory of the lol-api folder -
Paste the following content into the
docker-compose.yml
file:version: "3.7" services: lol-api: build: ./lol-api image: lol-api:latest restart: always container_name: lol-api depends_on: environment: PORT: your_db_port GO_ENV: development SERVER_LOGS_PATH: logs/server_info.log FRONT_LOGS_PATH: logs/front_info.log CORS_ALLOWED_ORIGINS: your_allowed_url_1, your_allowed_url_2 ACCESS_CONTROL_ALLOW_CREDENTIALS: your_allowed_url_1, your_allowed_url_2 CORS_ADMIN_ORIGINS: your_allowed_url_1, your_allowed_url_2 DB_ENV: dev DB_PORT: your_rethinkdb_port DB_HOST: your_rethinkdb_host MAIL_SEND_TO: your_email MAIL_USER: your_email_user MAIL_PASS: your_email_pass volumes: - ./mounted/logs:/go/src/lol-api/logs ports: - "8082:81"
-
To launch the container and have the system running, execute the following command on the terminal:
sudo docker-compose up --build -d
This command will build the project, copy the resulting executable into the docker container and launch it
-
To monitor the system is running, execute the following command which will display the logs
sudo docker-compose logs -t -f
Callable routes
Those are the core resources of the REST API and the routes used to modify them
Resource | Route | Method | Information | Params |
---|---|---|---|---|
duos | /api/v1/duo |
GET | Returns the information of duos. | |
duos | /api/v1/duo |
POST | Create a new duo. | |
duos | /api/v1/duo/
|
DELETE | Delete a duo. | collection_id |
test | /api/v1/5JUSUk/3fj48f |
GET | Returns three items fron new collections. | |
test | /api/v1/test |
GET | Returns styng ideas of a user. | |
test | /api/v1/test |
POST | Creates test resource. | |
test | /api/v1/test/
|
GET | Returns test resource by id. | collection_id |
test | /api/v1/test/
|
PATCH | Updates test resource by id. | collection_id |
ideas | /api/v1/test/
|
DELETE | Deletes test resource. | collection_id |
License
Provide your license information here and link to your LICENSE.md file.
Citation
Explain how other people can cite your project.
Make sure you provide a BibTeX formatted reference e.g.:
@misc{yourlabel,
author = {Name of the authors},
title = {Your project's title},
publisher = {Your publisher},
year = {2019},
}
Contact
Put here your contact details so contributors and team members can reach out to you if they have open questions (or want to compliment you).