๐๏ธ 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 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 Variable | Default value | Description |
|---|---|---|
| IRON_GUARD_SECRET | test | The JWT signing secret. Must be set. |
| IRON_GUARD_DB_TYPE | mysql | Database Type. Options: mysql. |
| IRON_GUARD_DB_HOST | localhost | Database Host |
| IRON_GUARD_DB_PORT | 3306 | Database Port |
| IRON_GUARD_DB_USERNAME | root | Database Username |
| IRON_GUARD_DB_PASSWORD | [blank] | Database Password |
| IRON_GUARD_DB_DATABASE | iron_guard | Database Name |
| ROCKET_ADDRESS | 127.0.0.1 | HTTP Server Bind Address |
| ROCKET_PORT | 8000 | HTTP Server Port |
Run
cargo run
API
| Method | Path | Auth? | 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
tokenwith 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.