Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ajaen4/city-tags-api
API that makes available different tags for any city in the world with more that 40 k inhabitants.
https://github.com/ajaen4/city-tags-api
Last synced: 3 days ago
JSON representation
API that makes available different tags for any city in the world with more that 40 k inhabitants.
- Host: GitHub
- URL: https://github.com/ajaen4/city-tags-api
- Owner: ajaen4
- Created: 2024-05-20T08:32:48.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2024-09-11T12:56:02.000Z (2 months ago)
- Last Synced: 2024-09-11T19:55:56.001Z (2 months ago)
- Language: Go
- Size: 202 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# City Tags API
## Introduction
API to be able to consume tags on cities, for example if the humidity is "moderate" or "humid" or if the city is "small" or "big". Built with Go (Chi), Pulumi, AWS and Supabase.
## Architecture
A DNS record with an SSL certificate is used to be able to set up a connection through HTTPS. An Application Load Balancer (ALB) is registered as a target of this registry. The ALB redirects traffic to the ECS Service where the Go API is deployed. The ECS Service makes use of SSM Parameter Store for environment variables and of ECR to store the different container images of the API. Finally, the API queries the database, in this case Supabase, where the serverless Postgres database is.
The API follows the OpenAPI standard and has the documentation hosted on "/v0/swagger/" and it also has authentication through JWT.
You can test a simple call on the development environment with:
```bash
curl -H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJjaXR5LXRhZ3MtYXBpLmRldi5zaXR5ZXguY29tIiwiaWF0IjoxNzIwNzA3NjMxLCJleHAiOjcyNzQ2NzI0MzEsImF1ZCI6IiIsInN1YiI6ImFub255bW91c191c2VyIn0.Mu37OetnJFUvEf-kRtnMl6Yv4wvvAm2qpAcNrbr8UGY" https://city-tags-api.com/v0/cities?limit=5
```## Requirements
- You must own an AWS account and have an Access Key to be able to authenticate.
- Go v1.22.1
- Tools:
- psql==14.12
- goose==3.20.0
- air==1.52.1
- swag==1.16.3
- pre-commit==3.7.1
- bumpversion==1.0.1## Testing
### Unit tests
The unit tests developed in this repo test business logic only, testing that had external dependencies is done in the integration tests. To run the unit tests you can run the following command:
```bash
make unit-tests
```These tests are executed everytime a commit is created as part of the pre-commit workflow and also in the PR checks before merging.
### Integration tests
These tests have been developed to test all the functionality that interacts with the database. A test environment is set up with Docker Compose with the following containers:
- city-tags-api: API developed with Go.
- psql: postgres database that will simulate the Supabase database.
- integration-tests: container where the integration tests will run. Before running the tests in runs the goose migrations and initializes the database with test data.
To run the integration tests you can run the following command:
```bash
make integration-tests
```These tests are executed everytime a commit is created as part of the pre-commit workflow and also in the PR checks before merging.