Update databases coursework
This commit is contained in:
@@ -0,0 +1 @@
|
|||||||
|
export DATABASE_URL="mysql://root:password@localhost:3306/repository"
|
||||||
@@ -1,4 +1,45 @@
|
|||||||
# Stuff that helped
|
# Information System "Package Repository"
|
||||||
|
|
||||||
|
## Setup
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Setup the database
|
||||||
|
docker compose up -d
|
||||||
|
|
||||||
|
# Get environment variables (optional)
|
||||||
|
source .envrc
|
||||||
|
|
||||||
|
# Compile and execute
|
||||||
|
cargo run
|
||||||
|
```
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
A user `test` with the password `testtest` is available (or you can register your own).
|
||||||
|
|
||||||
|
To search all packages enter a `%` in the search bar. Try searching `lib` for example.
|
||||||
|
|
||||||
|
When no input field is focused, the app supports UI scaling with `Ctrl-` and `Ctrl+`.
|
||||||
|
|
||||||
|
## Cleanup
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker compose down -v
|
||||||
|
cargo clean
|
||||||
|
```
|
||||||
|
|
||||||
|
## Showcase
|
||||||
|
|
||||||
|
### Login page
|
||||||
|

|
||||||
|
|
||||||
|
### Register page
|
||||||
|

|
||||||
|
|
||||||
|
### Search page
|
||||||
|

|
||||||
|
|
||||||
|
## Stuff that helped
|
||||||
|
|
||||||
* Architecture:
|
* Architecture:
|
||||||
- [How to apply hexagonal architecture to Rust](https://www.barrage.net/blog/technology/how-to-apply-hexagonal-architecture-to-rust)
|
- [How to apply hexagonal architecture to Rust](https://www.barrage.net/blog/technology/how-to-apply-hexagonal-architecture-to-rust)
|
||||||
|
|||||||
@@ -5,7 +5,10 @@ services:
|
|||||||
ports:
|
ports:
|
||||||
- "127.0.0.1:3306:3306"
|
- "127.0.0.1:3306:3306"
|
||||||
volumes:
|
volumes:
|
||||||
- ../../repo-database:/var/lib/mysql
|
- repo-database:/var/lib/mysql
|
||||||
- ./init:/docker-entrypoint-initdb.d/:ro
|
- ./sql:/docker-entrypoint-initdb.d/:ro
|
||||||
environment:
|
environment:
|
||||||
MYSQL_ROOT_PASSWORD: password # yes, I know
|
MYSQL_ROOT_PASSWORD: password # yes, I know
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
repo-database:
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
|
USE repository;
|
||||||
|
|
||||||
-- Insert Users
|
-- Insert Users
|
||||||
INSERT INTO Users (name, email, password, last_used) VALUES
|
INSERT INTO Users (name, email, password, last_used) VALUES
|
||||||
('alice', 'alice@example.com', 'password123', NOW()),
|
('alice', 'alice@example.com', 'password123', NOW()),
|
||||||
@@ -14,7 +16,9 @@ INSERT INTO Users (name, email, password, last_used) VALUES
|
|||||||
('oscar', 'oscar@example.com', 'oscarpass', NOW()),
|
('oscar', 'oscar@example.com', 'oscarpass', NOW()),
|
||||||
('peggy', 'peggy@example.com', 'peggypwd', NOW()),
|
('peggy', 'peggy@example.com', 'peggypwd', NOW()),
|
||||||
('trent', 'trent@example.com', 'trentpass', NOW()),
|
('trent', 'trent@example.com', 'trentpass', NOW()),
|
||||||
('victor', 'victor@example.com', 'victorpwd', NOW());
|
('victor', 'victor@example.com', 'victorpwd', NOW()),
|
||||||
|
('test', 'test@example.com', '$argon2id$v=19$m=19456,t=2,p=1$4POPE1A9A3evhePMYON7FQ$78A3OImH975IwugMikARwoEHkPixKJxJwPXgsCnQdY0', NOW());
|
||||||
|
|
||||||
|
|
||||||
-- Insert PackageBases
|
-- Insert PackageBases
|
||||||
INSERT INTO PackageBases (name, description) VALUES
|
INSERT INTO PackageBases (name, description) VALUES
|
||||||
@@ -58,13 +58,10 @@ impl Repository {
|
|||||||
let (main_id, open_task) = window::open(window::Settings::default());
|
let (main_id, open_task) = window::open(window::Settings::default());
|
||||||
// let (main_window, main_window_task) = MainWindow::new();
|
// let (main_window, main_window_task) = MainWindow::new();
|
||||||
|
|
||||||
let pool = MySqlPool::new(
|
let db_url = std::env::var("DATABASE_URL")
|
||||||
SqlxPool::connect_lazy(
|
.unwrap_or_else(|_| "mysql://root:password@localhost:3306/repository".into());
|
||||||
&std::env::var("DATABASE_URL")
|
|
||||||
.expect("environment variable `DATABASE_URL` should be set"),
|
let pool = MySqlPool::new(SqlxPool::connect_lazy(&db_url).unwrap());
|
||||||
)
|
|
||||||
.unwrap(),
|
|
||||||
);
|
|
||||||
|
|
||||||
let auth_service = Arc::new(Mutex::new(AuthenticationService::new(
|
let auth_service = Arc::new(Mutex::new(AuthenticationService::new(
|
||||||
AuthenticationAdapter::new(pool.clone()),
|
AuthenticationAdapter::new(pool.clone()),
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ npm run dev
|
|||||||
- OpenAPI spec is at <http://localhost:3000/apidoc/openapi.json>
|
- OpenAPI spec is at <http://localhost:3000/apidoc/openapi.json>
|
||||||
|
|
||||||
## Showcase
|
## Showcase
|
||||||
|
|
||||||
### Swagger UI
|
### Swagger UI
|
||||||

|

|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user