diff --git a/Makefile b/Makefile index d8949dd..b1a6878 100644 --- a/Makefile +++ b/Makefile @@ -7,18 +7,20 @@ watch: watch\:uninstall: cargo uninstall cargo-watch -db-up: - make db-down +db\:up: + make db\:down docker-compose up -d --remove-orphans -db-down: +db\:down: docker-compose down +db\:destroy: + docker-compose down -v -migration-install: +migration\:install: cargo install sqlx-cli -migration-up: +migration\:up: sqlx migrate run -docs-open-swagger: +docs\:open\:swagger: open http://localhost:$(PORT)/swagger-ui -docs-open-rapidoc: +docs\:open\:rapidoc: open http://localhost:$(PORT)/rapidoc diff --git a/README.md b/README.md index 8b6beab..de7971f 100644 --- a/README.md +++ b/README.md @@ -21,13 +21,14 @@ A Rust example of a todo application with axum and sqlx. - dotenv - chrono - utoipa +- askama (for frontend with tailwindcss) ## Run the Application ### Docker ```sh -$ docker-compose up -d +$ make db:up # make db:down to stop and db:destroy to remove ``` ### Database Setup @@ -43,6 +44,13 @@ $ sqlx migrate run # run migrations $ cargo run ``` +If you want to watch for file changes, you can use `cargo watch`: + +```sh +$ make watch:install # Install cargo-watch +$ make watch +``` + ### Run (Production) ```sh @@ -71,3 +79,21 @@ This project includes a CLI to add users to the database. $ cargo run --bin add-user -- --email=user@example.com --nickname=user --password=1234 Successfully registered user User { id: 1, email: "user@example.com", password: "1234", nickname: "user", created_at: 2024-04-19T17:14:54.358424Z, updated_at: 2024-04-19T17:14:54.358424Z, deleted_at: None } ``` + +## Frontend + + + +This project uses askama to render HTML templates. + +If you need to access the frontend, you can run the following command: + +```sh +$ npm install +$ npm run tailwind:build # or npm run tailwind:watch to watch for changes +``` + +Go to index page at [`/`](http://localhost:8000/) and login +at [`/login`](http://localhost:8000/login). + +You can add, edit and delete todos. diff --git a/package.json b/package.json index a4432d5..05ab55f 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,8 @@ "main": "index.js", "scripts": { "format": "prettier --write --ignore-unknown .", - "watch:tailwind": "npx tailwindcss -i styles/tailwind.css -o assets/main.css --watch" + "tailwind:build": "npx tailwindcss -i styles/tailwind.css -o assets/main.css", + "tailwind:watch": "npx tailwindcss -i styles/tailwind.css -o assets/main.css --watch" }, "repository": { "type": "git",