Starting project template for Rust Axum backend and Svelte frontend. Simple Single-Page-App (SPA) example. Does not use SvelteKit.
- migration of
axum-sessionstotower-sessionssee pr#14 - removal of secret key warning due to migration
- bumped version on backend;
axumto 0.6.20,axum-sessionsto 0.5,tower-httpto 0.4 - bumped versions on front-end;
vite-plugin-svelteto 2.4.2,svelteto 4.0.5,viteto 4.4.5 - backend changed how servedir works from
tower-httpfor serving front end static assets
- updated to
axum0.6 - changes to State usage; how its setup with route and called from middleware
- changes to ordering of parameters in functions; last parameter can consume request body
- eliminated
axum::extract::RequestPartswith help from update onaxum-sessions - updated to
axum-sessions0.4 to match - incremented
tokioversion to 1.24 - old
axum0.5 version is kept under branchv0.3_Axum0.5
- We currently have a build script that builds the full stack concurrently for Linux. We would appreciate alternatives for Mac (should be minor tweak of Linux build script) and Windows.
- Must have cargo generate installed:
cargo install cargo-generate - Then use
cargo generate jbertovic/svelte-axum-project -n <your-project-name>
- you can also just hit the "use this template" button in green on top of the repo
- if you have gh cli installed check out
--templateoption
- located in
./back_end - serves front end directory
- middleware for checking authorization header
- middleware for checking session that user exists
- store example that holds token secret for authorization
- /api route example using authorization header
- /secure route example using sessions for authorization
Note there is no persistance beyond what's held in memory while the application is running
run as cargo run from parent directory and not needed to run inside ./back_end folder
- Located in
./front_end - navbar with login and logout
- secure page that shows session information once logged in
- api fetch example, log in not required
run as npm run build from inside the ./front_end directory to build the static serve file directory.
Install the following NodeJs - Install Rust - Install
Clone the repository
- cd repository
- inside the
./front_endfolder runnpm installto download all module dependencies inside root directory of project - inside the
./front_endfolder runnpm run buildto bundle the js/svelte code into public folder - inside the top level folder run
cargo runto start the the server - access in browser at http://localhost:8080/
In case you need to build both at once and use Linux, run ./build-fullstack.sh

