GithubHelp home page GithubHelp logo

http-api-rs's Introduction

HTTP API Rust template

Template for production ready HTTP servers in Rust.

Deploy to Render

  • HTTP Server: Axum
  • GraphQL Server: Async-Graphql
  • Database: Postgres
  • Identity: OAuth2 - RBAC
  • Observability: OpenTelemetry/Jaeger
  • Documentation: Openapi 3.0 / SwaggerUI
  • CI: GitHub Actions

Required dependencies

Environment

Create and fulfill environment files from config/env/*. For example:

cp config/env/.env.example config/env/.env
Environment variable Description Example Documentation
OAUTH_CLIENT_ID The client_id of the application from your oauth provider - Auth0
OAUTH_DOMAIN Your domain from your oauth provider https://auth.example.com Auth0
OAUTH_AUDIENCE Your API identifier as oauth resource https://api.example.com Auth0
OAUTH_AUTHORIZATION_URL OAuth Authorization URL of your application with the audience OAUTH_DOMAIN/authorize?audience=OAUTH_AUDIENCE Auth0
OAUTH_TOKEN_URL OAuth Token URL of your application OAUTH_DOMAIN/oauth/token Auth0

Run

Start server

cargo run --release
  • Axum HTTP Server will run on: :8080

Start server with Hot Reload

cargo install cargo-watch

cargo watch -w src -x run

Start infrastructure

docker compose up

Database seed is injected with tools/scripts/pg_init.sh.

  • Postgres will run on: :5432
  • Postgres GUI will run on: :5433
  • Jaeger will run on: :16686
  • Swagger will run on: :9000

Lint

cargo clippy -- -D warnings

Run rustup component add clippy if clippy is not installed yet in your system

Format

cargo fmt --all -- --check -v

Run rustup component add rustfmt if clippy is not installed yet in your system

Build

cargo build

Local Test

Start infrastructure

docker compose up

Execute Rust tests with Postgres Template Database

More info here.

export DATABASE_TEMPLATE=ecommerce_template

cargo test

# with coverage
cargo llvm-cov --open

Run cargo install cargo-llvm-cov if cargo-llvm-cov is not installed yet in your system

Screenshots

Swagger UI

swagger

Jaeger trace

jaeger

GraphQL

swagger

Postgres GUI

pgweb

llvm-cov

cov cov_2

http-api-rs's People

Contributors

caenguidanos avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.