Skip to content
/ rustfulapi Public template
forked from robatipoor/rustfulapi

πŸš€ Reusable template for building REST Web Services in Rust. Uses Actix-web HTTP web framework and SQLX Toolkit

License

Notifications You must be signed in to change notification settings

rustyforks/rustfulapi

Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

23 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

RUSTfulapi

Reusable template for building REST Web Services in Rust. Uses Actix-Web HTTP web framework and SQLX Toolkit and PostgreSQL.

License Lines of code Format check Build Check Test Clippy Check Docker Image Test Coverage Codecov Dependency status RUSTfulapi-logo

Requirements

How to use this template

To use this template as your project starting point, click "Use this template" at the top of this page, or click here.

Feature highlights

  • Authentication. Based on jsonwebtoken
  • Layered configuration. Based on config-rs
  • Logs. Based on tracing
  • OpenAPI documentation utoipa
  • Error handling
  • Pagination
  • Profile base
  • E2E Tests
  • Postgres admin pgAdmin
  • CI based on Github actions
  • Sentry error tracking
  • Nginx as reverse proxy and secure connections with SSL certificates Nginx
  • Dependabot configuration

Running locally

./run.sh
# open swagger panel
xdg-open http://127.0.0.1:8080/api/v1/swagger-ui/
# manually testing your API routes with curl commands
curl -X GET http://127.0.0.1:8080/api/v1/server/health_check

Running via docker

cd ./docker/dev/ && ./up.sh

Running tests

Some of the integration tests use Docker to spin up dependencies on demand (e.g., a postgres db),so please ensure Docker is installed before running the tests.

./test.sh

RUSTfulapi grid

Configuration

This project uses config-rs to manage configuration.

Configure with toml files

settings
β”œβ”€β”€ base.toml # default config file 
β”œβ”€β”€ dev.toml # development config file 
β”œβ”€β”€ prod.toml # production config file
└── test.toml # test config file

Configure with environment variables

export APP_SERVER__PORT=8080
export APP_SERVER__ADDR=127.0.0.1

Switching profiles

export APP_PROFILE=prod # switch to production profile

Update sqlx data json

# https://crates.io/crates/sqlx-cli
cargo sqlx prepare --merged -- --all-features

Check code formatting and typo at commit time

cp ./scripts/git-hooks ./.git/hooks/

Update ERD (Entity-Relationship Diagram) use planter

planter postgres://postgres_user:postgres_pass@localhost:5432/postgres_db\?sslmode=disable -o docs/schema.puml

License

Licensed under either of

Contributing

Contributors are welcome! please fork and send pull requests, If you find a bug or have any ideas on how to improve this project please submit an issue.

See CONTRIBUTING.md.

About

πŸš€ Reusable template for building REST Web Services in Rust. Uses Actix-web HTTP web framework and SQLX Toolkit

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Rust 94.2%
  • Shell 3.9%
  • Other 1.9%