Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sheroz/axum-web-api-kickstart
Kick-start template for building REST API Web service in Rust using axum, JSON Web Tokens (JWT), SQLx, PostgreSQL, and Redis
https://github.com/sheroz/axum-web-api-kickstart
cors docker jwt logging postgres redis rest-api web-service
Last synced: about 2 hours ago
JSON representation
Kick-start template for building REST API Web service in Rust using axum, JSON Web Tokens (JWT), SQLx, PostgreSQL, and Redis
- Host: GitHub
- URL: https://github.com/sheroz/axum-web-api-kickstart
- Owner: sheroz
- License: mit
- Created: 2023-11-09T15:25:52.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-01-14T18:36:45.000Z (10 months ago)
- Last Synced: 2024-01-16T02:27:50.072Z (10 months ago)
- Topics: cors, docker, jwt, logging, postgres, redis, rest-api, web-service
- Language: Rust
- Homepage:
- Size: 104 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Getting started with REST API Web Services in Rust
[![build & test](https://github.com/sheroz/axum-web/actions/workflows/ci.yml/badge.svg)](https://github.com/sheroz/axum-web/actions/workflows/ci.yml)
[![MIT](https://img.shields.io/github/license/sheroz/axum-web)](https://github.com/sheroz/axum-web/tree/main/LICENSE)Kick-start template for building REST API Web service in Rust using `axum`, `JSON Web Tokens (JWT)`, `PostgreSQL`, and `Redis`
The project covers:
- REST API based on `axum`
- routing
- api versioning
- CORS settings
- basic error handling
- graceful shutdown
- `JSON Web Tokens (JWT)` based authentication & authorization
- login, logout, refresh, and revoking operations
- role based authorization
- generating and validating of access and refresh tokens
- setting the tokens expiry time (based on configuration)
- using the refresh tokens rotation technique
- revoking the issued tokens by using `Redis` (based on configuration)
- revoke all tokens issued until the current time
- revoke tokens belonging to a user issued until the current time
- cleanup of revoked tokens
- `PostgreSQL`database with `SQLx` driver
- database migrations
- async connection pooling
- async CRUD operations
- `Redis` in-memory storage
- async operations
- `.env` based configuration parsing
- `tracing` based logs
- `docker-compose` configuration
- `Redis` service
- `PostgreSQL` service
- Tests
- `docker` based end-to-end tests
- GitHub CI configuration for running tests## Run
Running the REST API service:
```text
docker-compose up -d
cargo run
```Running the service in test configuration:
```text
ENV_TEST=1 cargo run
```## Tests
REST API tests: [/tests](/tests)
REST API parameters: [tests/endpoints.http](/tests/endpoints.http)
Running the API tests:
```text
docker-compose up -d
cargo test
```## Logging
Setting the `RUST_LOG` - logging level on the launch:
```text
RUST_LOG=info,hyper=debug,axum_web=trace cargo run
```## Project Stage
**Development**: this project is under development, you should not expect stability yet.