MyGit

jbertovic/svelte-axum-project

Fork: 12 Star: 160 (更新于 2024-11-18 04:25:05)

license: MPL-2.0

Language: Rust .

Starting project template for Rust Axum backend and Svelte frontend

最后发布版本: v0.4.2 ( 2023-10-09 00:56:22)

GitHub网址

svelte-axum-project

Starting project template for Rust Axum backend and Svelte frontend. Simple Single-Page-App (SPA) example. Does not use SvelteKit.

New Version 0.4.2

  • migration of axum-sessions to tower-sessions see pr#14
  • removal of secret key warning due to migration

New Version 0.4.1

  • bumped version on backend; axum to 0.6.20, axum-sessions to 0.5, tower-http to 0.4
  • bumped versions on front-end; vite-plugin-svelte to 2.4.2, svelte to 4.0.5, vite to 4.4.5
  • backend changed how servedir works from tower-http for serving front end static assets

New Version 0.4.0

  • updated to axum 0.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::RequestParts with help from update on axum-sessions
  • updated to axum-sessions 0.4 to match
  • incremented tokio version to 1.24
  • old axum 0.5 version is kept under branch v0.3_Axum0.5

Help

  • 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.

Template

Using Cargo

  • Must have cargo generate installed: cargo install cargo-generate
  • Then use cargo generate jbertovic/svelte-axum-project -n <your-project-name>

Using git template

  • 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 --template option

Back end - Rust Axum

  • 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

Front end - Svelte

  • 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.

Setup

Install the following NodeJs - Install Rust - Install

Clone the repository

  • cd repository
  • inside the ./front_end folder run npm install to download all module dependencies inside root directory of project
  • inside the ./front_end folder run npm run build to bundle the js/svelte code into public folder
  • inside the top level folder run cargo run to 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

最近版本更新:(数据更新于 2024-10-03 15:15:07)

2023-10-09 00:56:22 v0.4.2

2023-08-14 04:58:55 v0.4.1

2023-01-09 01:22:48 v0.4.0

2022-11-28 09:12:08 v0.3.0

2022-10-20 03:51:59 v0.2.0

2022-07-31 21:19:24 v0.1.1

2022-07-19 09:13:54 v0.1.0

主题(topics):

axum, backend, rust, svelte

jbertovic/svelte-axum-project同语言 Rust最近更新仓库

2024-11-22 05:42:56 lanyeeee/jmcomic-downloader

2024-11-19 23:39:15 gleam-lang/gleam

2024-11-19 08:50:55 lapce/lapce

2024-11-11 22:51:00 tauri-apps/tauri

2024-11-11 07:55:30 dani-garcia/vaultwarden

2024-11-09 16:42:37 rustdesk/rustdesk