-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3f491a2
commit c4dd976
Showing
17 changed files
with
315 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,4 +21,4 @@ go.work | |
.idea | ||
.DS_Store | ||
.env | ||
/db-data/ | ||
/app/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
SHELL=cmd.exe | ||
API_APP_BINARY=apiApp | ||
|
||
## up: starts all containers in the background without forcing build | ||
up: | ||
@echo Starting Docker images... | ||
docker-compose up -d | ||
@echo Docker images started! | ||
|
||
## up_build: stops docker-compose (if running), builds all projects and starts docker compose | ||
up_build: build_app | ||
@echo Stopping docker images (if running...) | ||
docker-compose down | ||
@echo Building (when required) and starting docker images... | ||
docker-compose up --build -d | ||
@echo Docker images built and started! | ||
|
||
## down: stop docker compose | ||
down: | ||
@echo Stopping docker compose... | ||
docker-compose down | ||
@echo Done! | ||
|
||
## build_app: builds the app binary as a linux executable | ||
build_broker: | ||
@echo Building app binary... | ||
chdir . && set GOOS=linux&& set GOARCH=amd64&& set CGO_ENABLED=0 && go build -o ${API_APP_BINARY} ./cmd/api | ||
@echo Done! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,72 @@ | ||
# genesis-api-project | ||
# Genesis API Project | ||
|
||
This service implements the following API: | ||
|
||
## API Endpoints | ||
|
||
### `GET` /rate | ||
|
||
This endpoint returns the current `USD to UAH` exchange rate using the Coinbase API. | ||
|
||
#### Parameters | ||
|
||
``No parameters`` | ||
|
||
#### Response Codes | ||
|
||
``` | ||
200: Returns the actual USD to UAH exchange rate. | ||
400: Invalid status value. | ||
``` | ||
|
||
--- | ||
|
||
### `POST` /subscribe | ||
|
||
This endpoint adds an email address to the database and automatically subscribes it to the USD to UAH exchange rate newsletter. | ||
|
||
_The code includes the ability to subscribe to other rates for future development, but this functionality is not currently used to fulfill the requirements._ | ||
|
||
#### Parameters | ||
|
||
``email`` **string** (formData): The email address to be added to the database and the mailing list. | ||
|
||
#### Response Codes | ||
|
||
``` | ||
200: The email address is added to the database and subscribed to the mailing list. | ||
409: The email address already exists. | ||
``` | ||
|
||
_Not mentioned in the task, but arose during the development process:_ | ||
``` | ||
400: The provided data (such as email address) is invalid. | ||
500: Internal error status. | ||
``` | ||
|
||
--- | ||
|
||
### `POST` /sendEmails | ||
|
||
This endpoint sends the current `USD to UAH` exchange rate to subscribed email addresses using goroutines. | ||
|
||
#### Parameters | ||
|
||
``No parameters`` | ||
|
||
#### Response Codes | ||
|
||
``` | ||
200: Emails were sent. | ||
``` | ||
|
||
## Usage: | ||
|
||
- Using Makefile | ||
``` | ||
git clone https://github.com/vladyslavpavlenko/genesis-api-project.git | ||
cd genesis-api-project | ||
make up_build | ||
``` | ||
|
||
Now you can reach an API using [`http://localhost:8080/`](http://localhost:8081/). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.