π API Geo CR
API Geo CR is a REST API that provides up-to-date geographic information about Costa Rica, including its provinces, cantons and districts. Developed with hexagonal architecture (ports and adapters) to ensure a clean and maintainable design.
You can explore the API in action here: https://api-geo-cr.vercel.app/
- β¨ Query of all provinces of Costa Rica
- ποΈ Detailed information of cantons by province
- π Complete data of districts by canton
- π Search by ID for provinces, cantons and districts
- π Integrated pagination in all queries
- π Complete documentation with Swagger
- β‘ Quick answers with data in memory
- π§ͺ Complete test coverage
- NestJS - Node.js Framework
- TypeScript - Programming language
- Jest - Framework de pruebas
- Swagger/OpenAPI - DocumentaciΓ³n de API
You will need:
# Clone the repository
git clone https://github.com/anibalalpizar/api-geo-cr.git
# Install dependencies
npm install
# Configure environment variables
cp .env.example .env
Variable | Description | Possible Values | Default |
---|---|---|---|
NODE_ENV | Execution environment | development, production, test | development |
PORT | Application port | Any valid port | 3000 |
SWAGGER_ENABLED | Enable/disable Swagger | true, false | true |
# Development mode
npm run start:dev
# Debug mode
npm run start:debug
# Production mode
npm run start:prod
# Get all provinces
GET /provincias
# Obtaining cantons from a province
GET /provincias/{id}/cantones
# Get all cantons
GET /cantones
# Obtain districts from a canton
GET /cantones/{id}/distritos
# Get all districts
GET /distritos
All endpoints support pagination via query params:
GET /provincias?page=1&limit=2
{
"status": "success",
"statusCode": 200,
"message": "Provincias fetched successfully",
"data": [
{
"idProvincia": 1,
"descripcion": "San JosΓ©"
},
{
"idProvincia": 2,
"descripcion": "Alajuela"
}
],
"meta": {
"totalItems": 7,
"itemCount": 2,
"itemsPerPage": 2,
"totalPages": 4,
"currentPage": 1,
"timestamp": "2024-11-23T10:34:16.809Z"
}
}
Full API documentation is available in Swagger UI:
- Development: http://localhost:3000
- Production: API Documentation
src/
βββ application/ # Use cases
βββ domain/ # Entities and repositories
β βββ entities/
β βββ repositories/
βββ infrastructure/ # Concrete implementations
β βββ persistence/
βββ interfaces/ # Controllers and modules
# Running unit tests
npm run test
# Running tests with coverage
npm run test:cov
Contributions are welcome. Please follow these steps:
- Fork the repository
- Create a branch for your feature (
git checkout -b feature/AmazingFeature
) - Commit your changes (
git commit -m 'add some amazing feature'
) - Push to the branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.