This project is a Medication API built with Go, MongoDB, and Docker. It provides endpoints to manage medications, including creating, reading, updating, and deleting medication records.
Before getting started, make sure you have the following prerequisites installed on your system:
- Go: The Go programming language.
- Docker: Docker is required if you wish to run the application in a container.
Follow the steps below to install the project in your development environment:
-
Clone the repository:
git clone https://github.com/MarcosMorelli/medications-api.git -
Navigate to the project directory:
cd medications-api -
Build the application using Docker Compose:
docker compose up
After installation, you can run the MedicationsAPI Go application with the following command (if you want to run it directly with Golang):
docker compose up -d mongo
go run main.go
The application will be accessible at http://localhost:8080.
The MedicationsAPI Go application offers REST endpoints for creating, listing, updating, and deleting users. You can use tools like curl or Postman to test the endpoints. Here are some curl command examples for testing the endpoints:
-
Create a medication:
curl -X POST http://localhost:8080/v1/medications -H "Content-Type: application/json" -d '{"name": "Paracetamol", "dosage": "500 mg", "form": "Tablet"}' -
Update a medication:
curl -X PUT http://localhost:8080/v1/medications/{id} -H "Content-Type: application/json" -d '{"name": "Paracetamol", "dosage": "500 mg", "form": "Tablet"}' -
Delete a medication:
curl -X DELETE http://localhost:8080/v1/medications/{id}
Remember to adjust the commands according to your needs and requirements.
- NoSQL database: MongoDB object data modeling using Go Mongo Driver
Validation: request data validation.TBD- Health Check: service and
db(TBD) health check - Logging: using golang native sLog
- Testing: unit and
integrationTBD Error handling: centralized error handling mechanismTBDAPI documentation: with SwaggerTBDAutomatic dependencies update: with DependabotTBD- Environment variables: using golang native os
Security: set security HTTP headersTBDSantizing: sanitize request data against xss and query injectionTBDCORS: Cross-Origin Resource-Sharing enabledTBDCompression: gzip compressionTBD- CI: continuous integration with Github Actions
- Docker support
- ~~Code coverage: TBD