Skip to content

A simple REST API using Axum for managing printer supplies, such as toners and drums.

License

Notifications You must be signed in to change notification settings

allansomensi/printer-supplies-api

Repository files navigation

Printer Supplies API 🖨️

A REST API using Axum for managing printer supplies, such as toners and drums. The project includes CRUD functionalities for various resources and inventory movement tracking.

Technologies Used

  • Axum: Asynchronous web framework for Rust.
  • SQLx: For interaction with the database and migrations.
  • Just: For utility scripts.
  • Docker: For database container.
  • Swagger: API documentation.

Features

  • CRUD operations for movements, printers, brands, drums, and toners.
  • Inventory management for toners and drums.
  • Docker Compose setup for easy deployment.
  • Database migrations included, executable via CLI or endpoint.
  • Error handling with thiserror for descriptive error responses.
  • Includes development, production, and test environments.
  • Includes unit and integration tests.
  • API documentation available with Swagger UI.

Getting Started 🎯

Prerequisites:

  • Rust (latest stable version)
  • Docker and Docker Compose
  • Just for scripts

1. Installation

git clone https://github.com/allansomensi/printer-supplies-api.git
cd printer-supplies-api

For the scripts:

cargo install just

2. Load environment variables

By default, the selected file is .env.development, so there's no need to run this command in a development environment. If you're running in a production environment, execute the command below to ensure the correct environment variables are loaded.

source scripts/set_env.sh

3. Build and run the Docker container:

just services-up

4. Run migrations:

just migrate-run

5. Start server 🚀 🚀

just serve

Running Tests 👨‍🔬

For once:

just test

For watching mode:

just test-watch

Endpoint tests 🧪

Endpoint tests are located at /tests folder

Test Status

API Documentation 📚

API endpoints and usage details are documented using Swagger UI and OpenAPI with Utoipa.

The full documentation is available in the openapi.json file, which can be accessed and imported as needed. Run the application and navigate to /swagger-ui to view the interactive Swagger documentation.