+
Skip to content

alexichepura/lapa

Repository files navigation

Lapa Logo

Lapa - Leptos Axum starter with Admin dashboard and SSR/SPA website

Status

This project is under active development.
Recently migrated from Prisma ORM to SQL first approach with Clorinde.
Also added integration with Slate.js for rich text editor because we don't have a good one in Rust yet.\


Intro: https://youtu.be/6eMWAI1D-XA
Demo site: https://lapa.chepura.space


Screenshots below are outdated and to be updated.

Site Home Site Home Admin Dashboard Admin Posts Admin Post Admin Post Admin Settings Admin Mobile

Motivation

I want to have practical full-stack setup to build websites and services.
Utilising type safety and performance of Rust opens the door for new era of web dev, that is taking off.
Ecosystem and standardized approach is helpful to develop scalable and future-proof apps.
Some benefits:

  • strict types
  • enforced error and value management (Result and Option)
  • predictable performance (no garbage collector)
  • native performance
  • single bundler (cargo)
  • straight path to WebAssembly

Leptos

https://leptos.dev
leptos-rs/leptos
A cutting-edge, high-performance frontend framework SSR+SPA. Using reactive signals.

Axum

tokio-rs/axum
Backend framework built with Tokio, Tower, and Hyper. Focuses on ergonomics and modularity.

Features

  • project
    • SEO site
    • admin dashboard
    • CLI with clap: settings-init, user-add
    • ops scripts: build, upload, run (site, admin, cli)
  • site
    • SSR + SPA hydrated
    • open graph meta tags
  • prod features
  • admin auth and session with
  • rich text content editor integration with ianstormtaylor/slatejs
  • post
    • CRUDL
    • publish_at
  • product
    • CRUDL
    • publish_at
    • product images
      • preview and upload
      • resize and convert on backend
      • order
      • is_hero flag
      • delete and alt update in "dialog"
  • settings
    • robots.txt, site_url
    • home_text
  • css
    • based on https://open-props.style
    • dark and light themes
    • mobile first
    • sass, @custom-media, @container, see notes on css below
  • components
    • forms, inputs and response messages
    • input datetime-local usage with chrono library
    • RoutingProgress
    • Favicons

Run

Generate db client

clorinde schema ./schema.sql

Build rich text editor

cd slate && npm run build && cd -

Local DB

Simplified with postgres user.

psql postgres
# create database lapa;
psql -h 127.0.0.1 -U postgres -p 5432 -d lapa < "schema.sql"
# .env
PG__URL="postgresql://postgres:postgres@localhost:5432/lapa"

Init

RUST_LOG="debug" cargo cli settings-init
RUST_LOG="debug" cargo cli user-add

Dev

RUST_LOG="info,admin=debug" cargo leptos watch -p admin
RUST_LOG="info,site=debug" cargo leptos watch -p site

Tip to enable tower_http debug

RUST_LOG="info,tower_http=debug,admin=debug" cargo leptos watch -p admin
RUST_LOG="info,tower_http=debug,site=debug" cargo leptos watch -p site

Prod

See relevant tutorial and demo project. https://github.com/alexichepura/leptos_axum_prisma_sozu https://www.youtube.com/watch?v=KLg8Hcd3K_U

cargo leptos build --release

Production with compress and ratelimit

cargo leptos build --release --features="compression,ratelimit"
# or
cargo leptos build --release --features="prod"

Ops

./ops folder contains example scripts to prepare production build and deploy it on server. Check .env.example Requires https://github.com/ryanfowler/precompress

./ops/site-deploy.sh && ./ops/site-run.sh # build, deploy and run site
./ops/admin-deploy.sh && ./ops/admin-run.sh # build, deploy and run admin
./ops/cli-deploy.sh # upload cli to server

Notes on CSS

Modern CSS is quite cool. Nesting, custom media, container queries. All that was used here before, but required cargo-leptos fork. As well another cli step to bundle everything into one css. For now returning to SASS. Considering return back to CSS if/when cargo-leptos will support lightningcss config and bundling.

Sass PR #24. Ligntningcss bundle with cli proof of concept #23.

License

This project is licensed under the terms of the MIT license.

About

Leptos Axum starter with Admin dashboard and SSR/SPA website

Topics

Resources

License

Stars

Watchers

Forks

点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载