API
API quickly runs JSON-API compliant resources defined by using JSON-Schema attributes definition.
Badges
![TODOs](https://badgen.net/https/api.tickgit.com/badgen/github.com/moreandres/api)
Usage
docker build -t my-api .
docker run -p 8080:8080 -it --rm --name my-running-api my-api
Details
API will expose a compliant resource data including:
- Creating
POST /v1/resource
- Fetching
GET /v1/resource
GET /v1/resource?sort=-id&page=0&limit=10
GET /v1/resource/{id}
- Updating
PATCH /v1/resource/{id}
- Deleting
DELETE /v1/resource/{id}
API will also expose supporting resources for health check and profiling
- Health
GET /v1/health
- Profiling
GET /debug/pprof
API adds middleware to:
- Failover from failures
- Include service revision
- Limit concurrent connections
- Include basic security controls
- Restrict access
- Keep usage statistics
- Avoid CORS issues
- Support compression
- Include request ID
Check API tests for further usage details.
Configuration
API uses API_XXX environment variables or configuration files
- LogLevel (Info)
- SchemaName (objects.json)
- DbUri (file::memory:?cache=shared)
- HttpPort (8080)
- UseSSL (false)
- HttpsPort (8443)
- CertFile (api.cer)
- KeyFile (api.key)
- URL
- QueryLimit (512)
- JwtSecret (password)
- MaxAllowed (20)
- AccessCidr (0.0.0.0/0)
Implementation
API uses:
- sirupsen/logrus for logging.
- qri-io/jsonschema for JSON-Schema validation.
- cobra for reading configuration from environment and configuration files.
- gin as web framework to expose resources.
- gorm for ORM to store and retrieve data.
Deployment
API can be deployed using classic infrastructure. CloudWatch metrics and logs are enabled. Session Manager can be used to SSH into instances.
terraform init
terraform apply
terraform destroy
Windows Development
- Enable WSL 2
- Install chocolatey
- Install tooling
choco install git git-lfs github-desktop docker-desktop golang mingw packer terraform vscode python minikube vagrant virtualbox