๐Ÿ—ƒ๏ธ Iron Guard Server

March 5, 2023 ยท View on GitHub

Iron Guard Server is an inventory management system server written in Rust.


Author: Afaan Bilal


Run with Docker Docker

docker run --rm -it -p 8000:8000 \
    -e ROCKET_ADDRESS=0.0.0.0 \
    -e IRON_GUARD_SECRET=[RANDOM SECRET] \
    -e IRON_GUARD_DB_HOST=host.docker.internal \
    -e IRON_GUARD_DB_PORT=3306 \
    -e IRON_GUARD_DB_USERNAME=[DB USERNAME] \
    -e IRON_GUARD_DB_PASSWORD=[DB PASSWORD] \
    afaanbilal/iron-guard-server

Configuration

The following environment variables configure the server.

Environment VariableDefault valueDescription
IRON_GUARD_SECRETtestThe JWT signing secret. Must be set.
IRON_GUARD_DB_TYPEmysqlDatabase Type. Options: mysql.
IRON_GUARD_DB_HOSTlocalhostDatabase Host
IRON_GUARD_DB_PORT3306Database Port
IRON_GUARD_DB_USERNAMErootDatabase Username
IRON_GUARD_DB_PASSWORD[blank]Database Password
IRON_GUARD_DB_DATABASEiron_guardDatabase Name
ROCKET_ADDRESS127.0.0.1HTTP Server Bind Address
ROCKET_PORT8000HTTP Server Port

Run

cargo run

API

MethodPathAuth?Description
GET/โฌœIndex. Returns Iron Guard.
POST/auth/sign-inโฌœReturns a JWT on success.
GET/dashboardโœ…Get the dashboard information.
GET/meโœ…Get the authenticated user's profile.
PUT/meโœ…Update the authenticated user's profile.
GET/categoriesโœ…Get a list of categories.
POST/categoriesโœ…Create a category.
GET/categories/{uuid}โœ…Get a category with matching the uuid.
PUT/categories/{uuid}โœ…Update the category matching the uuid.
DELETE/categories/{uuid}โœ…Delete the category matching the uuid.
GET/itemsโœ…Get a list of items.
POST/itemsโœ…Create a item.
GET/items/{uuid}โœ…Get a item with matching the uuid.
PUT/items/{uuid}โœ…Update the item matching the uuid.
DELETE/items/{uuid}โœ…Delete the item matching the uuid.
GET/usersโœ…[admin] Get a list of users.
POST/usersโœ…[admin] Create a user.
GET/users/{uuid}โœ…[admin] Get a user with matching the uuid.
PUT/users/{uuid}โœ…[admin] Update the user matching the uuid.
DELETE/users/{uuid}โœ…[admin] Delete the user matching the uuid.

Authentication

  • All auth required requests: Add header token with the JWT as the value.
  • Token lifetime: 4 hours.

Test

cargo test

Entity Generation

sea-orm-cli generate entity -o src/entities -u mysql://root:@localhost:3306/iron_guard

Contributing

All contributions are welcome. Please create an issue first for any feature request or bug. Then fork the repository, create a branch and make any changes to fix the bug or add the feature and create a pull request. That's it! Thanks!


License

Iron Guard Server is released under the MIT License. Check out the full license here.