dkatz23238 / actix-mongo-jwt-api

Simple extensible JSON API backend written in Rust

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Actix Web Service with JWT Authentication and MongoDB

[dependencies]
actix-web = "2"
actix-rt = "1"
serde = "1.0.103"
futures = "0.3.4"
dotenv = "0.15.0"
env_logger = "0.7"
validator = "0.10"
validator_derive = "0.10"
actix-web-validator = "1.0.0"
bcrypt = "0.8"
jsonwebtoken = "7.2.0"
chrono = "0.4.15"
regex = "1.3.9"
lazy_static = "1.4.0"

Important

This application uses some pregenerated RSA keys. Do not use these keys in production. Make sure to generate new .pem format RSA256 key pair.

About

This is a simple HTTP API written in Rust using the actix-web framework.

Actix web is a highly performant strongly and soundly typed web framework for building all types of web applications.

For simplicity is uses MongoDB as the database and only uses the sync API's within MongoDB to keep it simple. Async implementations are welcome via Pull requests.

Designed to be modular and extensible.

Environment Variables

  • MONGO_DB_NAME=myapp
  • MONGO_COLLECTION_NAME=mycollection
  • PUBLIC_KEY_PATH=./keys/rsa_public.pem
  • PRIVATE_KEY_PATH=./keys/rsa_private.pem
  • RUST_BACKTRACE=1

Start database locally

docker run --name mongodb  -p 27017:27017 -e ALLOW_EMPTY_PASSWORD=yes -e MONGODB_EXTRA_FLAGS='--wiredTigerCacheSizeGB=2' bitnami/mongodb:latest

Run Tests

cargo test

Run tests with docker-compose

docker-compose -f tests.docker-compose.yml up

Run Web Server

Restart or use a new database when running as the tests will seed the database with unwanted data.

cargo run

Run Python Integration Test

cd python_tests && pytest .

About

Simple extensible JSON API backend written in Rust


Languages

Language:Rust 84.7%Language:Python 9.8%Language:Dockerfile 4.7%Language:Shell 0.8%