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§
- api
- Types and functions used to implement the Pokedex REST API.
- db
- Helpers to connect to the Pokedex database. Currently supports Postgres as backend only.
- error
Error
type definition for our app.- helpers
- Module containing various helper traits/functions/etc. used throughout the crate’s code.
- models
- Definition of entity models for the Pokedex app.
- service_
env - Information about the service’s runtime environment.
- services
- Service types used in the Pokedex app.
Macros§
- forward_
from - Generates
From
implementations that can be used to forwardInto
requests two level deep. - implement_
pokemon_ upsert - Macro to generate a struct used to insert or update a Pokemon in the database.
- implement_
pokemon_ upsert_ from - Macro to generate
From
implementations for insert/update Pokemon structs. - pokedex_
app - Macro that expands to an
App
instance, initialized for our web application.
Functions§
- configure_
api - Allows registration of the entire Pokedex API under the
/api
scope. - get_
json_ config - Returns the
JsonConfig
to use for our service. - get_
path_ config - Returns the
PathConfig
to use for our service. - get_
query_ config - Returns the
QueryConfig
to use for our service.