Crate pokedex_rs
source ·Expand description
Rust Pokédex API 🦀
This project implements a simple web application that contains a CRUD API for a Pokédex - a database of Pokémons. It is meant as an experiment in building fully-working web applications in Rust.
This project includes several components usually found in modern web applications, including:
- A high-performance HTTP server to handle incoming requests
- A REST API with CRUD endpoints for Pokémon entities
- Automatic serialization/deserialization of Pokémon entities as JSON
- Automatic OpenAPI documentation including Swagger UI support (and others)
- An ORM-like interface to persist Pokémons in a Postgres database
- Support for managing and applying database migrations
- Validation of incoming data at the endpoint level
- Database connection pooling to improve performance
- Configurable logging using a simple logging facade
- Error handling with separation between service errors and their HTTP response counterparts
- Support for development and production environments
This documentation is for the private lib crate implementing the types and functions required to implement the CRUD REST API for the Pokedex. For more details about the project, see the project’s GitHub repository.
Notes
Pretty much everything in this crate is pub
lic. This would not normally be the case, but
it was done for demo purposes, so that it’s easier to document the various pieces.
Re-exports
Modules
- Types and functions used to implement the Pokedex REST API.
- Helpers to connect to the Pokedex database. Currently supports Postgres as backend only.
Error
type definition for our app.- Module containing various helper traits/functions/etc. used throughout the crate’s code.
- Definition of entity models for the Pokedex app.
- Information about the service’s runtime environment.
- Service types used in the Pokedex app.
Macros
- Macro to generate a struct used to insert or update a Pokemon in the database.
- Macro to generate
From
implementations for insert/update Pokemon structs. - Macro that expands to an
App
instance, initialized for our web application.
Functions
- Allows registration of the entire Pokedex API under the
/api
scope. - Returns the
JsonConfig
to use for our service. - Returns the
PathConfig
to use for our service. - Returns the
QueryConfig
to use for our service.