- Notifications
You must be signed in to change notification settings - Fork0
Rust Full Stack App covering Auth flow & CRUD with Rust/Axum and Supabase and Frontend with Yew.rs
License
emarifer/axum-auth-crud-yew-app
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
In addition to having Rust installed on your machine, you must install the bundler for Yew.rs, called Trunk, and the target for WebAssembly:
$ rustup target add wasm32-unknown-unknown
and:
$ cargo install trunk
In the environment variables file, you must also set the settings you got when creating your project in Supabase:
// .env file# Database settingsSUPABASE_URL=xxxxSUPABASE_ANON_KEY=xxxx# Jsonwebtoken settingsJWT_SECRET=my_ultra_secure_secretJWT_EXPIRED_IN=60mJWT_MAXAGE=60
In your project database in Supabase, you have to create 2 tables (users and tasks). For this purpose, you can use the SQL editor and paste the content of the "migrations" file:
// migrations filecreate table public.users ( id uuid not null defaultgen_random_uuid (), created_at timestamp withtime zone not null defaultnow(), username text not null, email text not null, password text not null, constraint user_pkey primary key (id), constraint user_email_key unique (email) ) tablespace pg_default;create table public.tasks ( id uuid not null defaultgen_random_uuid (), created_at timestamp withtime zone not null defaultnow(), title text not null, completed boolean null default false, description text not null, user_id uuid not null, constraint task_pkey primary key (id), constraint tasks_user_id_fkey foreign key (user_id) references users (id) ) tablespace pg_default;
Once these requirements are met, to run the application, you must first compile the code, both the backend and the frontend:
$cd client/&& trunk build --release&& cd..&& cargo run
The application will be available athttp://localhost:8080.
If you deploy the application in production, in addition to passing the Supabase credentials as environment variables to the service you use to deploy it, you must previously compile the frontend by passing the deployment base address as environment variable:
API_ROOT=https://your-address.com trunk build --release