demo_loco_axum_tokio_rust

Demo of Loco.rs high-level web framework, Axum low-level web framework, Tokio asynchronous runtime, and Rust programming language

https://github.com/joelparkerhenderson/demo_loco_axum_tokio_rust

Science Score: 44.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (8.0%) to scientific vocabulary
Last synced: 8 months ago · JSON representation ·

Repository

Demo of Loco.rs high-level web framework, Axum low-level web framework, Tokio asynchronous runtime, and Rust programming language

Basic Info
  • Host: GitHub
  • Owner: joelparkerhenderson
  • Language: Rust
  • Default Branch: main
  • Size: 363 KB
Statistics
  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • Open Issues: 0
  • Releases: 0
Created over 1 year ago · Last pushed about 1 year ago
Metadata Files
Readme Citation

README.md

Demo Loco Axum Tokio Rust

Demonstration of:

  • Loco web application framework

  • Axum modular web framework

  • Tokio asynchronous runtime

  • Rust programming language

Create a new app

Install prerequisites

Install prerequisites of loco and sea-orm-cli (if you want a database).

sh $ cargo install loco $ cargo install sea-orm-cli

Create a new app

For this demo, we will create a new app with these settings:

  • Build a Software-as-a-Service (SaaS) app

  • Use server-side rendering. Other options include client-side rendering.

  • Database provider is PostgreSQL Other options include SQLite.

  • Background worker type is async i.e. in-process tokio async tasks. Other options include blocking.

Create a new app via prompts;

```sh $ loco new ✔ ❯ App name? · demo ✔ ❯ What would you like to build? · Saas App with server side rendering ✔ ❯ Select a DB Provider · Postgres ✔ ❯ Select your background worker type · Async (in-process tokio async tasks)

🚂 Loco app generated successfully in: /Users/jph/git/joelparkerhenderson/demo/demo_loco

  • database: You've selected postgres as your DB provider (you should have a postgres instance to connect to) ```

Create a new app via parameters:

sh $ loco new --name demo --db postgres --bg async --assets serverside

Build:

sh $ cd demo $ cargo build

Create a database

We use PostgreSQL to create a database, create a database administor role, and grant all privileges to the role.

SQL:

sql CREATE ROLE demo_owner WITH LOGIN ENCRYPTED PASSWORD 'secret'; CREATE DATABASE demo_development OWNER demo_owner; GRANT ALL PRIVILEGES ON DATABASE demo_development TO demo_owner;

Set an environment variable DATABASE_URL with the database connection URL:

sh $ export DATABASE_URL="postgres://demo_owner:secret@localhost:5432/demo_development"

Start

Start the loco app:

``sh $ cargo loco start Finisheddevprofile [unoptimized + debuginfo] target(s) in 0.69s Runningtarget/debug/demo-cli start INFO app: loco_rs::config: loading environment from selected_path="config/development.yaml" environment=development WARN app: loco_rs::boot: pretty backtraces are enabled (this is great for development but has a runtime cost for production. disable withlogger.prettybacktrace` in your config yaml) environment=development INFO app: locors::db: auto migrating environment=development INFO app: seaormmigration::migrator: Applying all pending migrations environment=development INFO app: seaormmigration::migrator: Applying migration 'm20220101000001users' environment=development INFO app: seaormmigration::migrator: Migration 'm20220101000001users' has been applied environment=development INFO app: locors::boot: initializers loaded initializers="view-engine" environment=development INFO app: locors::controller::approutes: [GET] /ping environment=development INFO app: locors::controller::approutes: [GET] /health environment=development INFO app: locors::controller::approutes: [POST] /api/auth/register environment=development INFO app: locors::controller::approutes: [POST] /api/auth/verify environment=development INFO app: locors::controller::approutes: [POST] /api/auth/login environment=development INFO app: locors::controller::approutes: [POST] /api/auth/forgot environment=development INFO app: locors::controller::approutes: [POST] /api/auth/reset environment=development INFO app: locors::controller::approutes: [GET] /api/auth/current environment=development INFO app: locors::controller::approutes: +middleware name="limitpayload" environment=development INFO app: locors::controller::approutes: +middleware name="catchpanic" environment=development INFO app: locors::controller::approutes: +middleware name="etag" environment=development INFO app: locors::controller::approutes: +middleware name="static" environment=development INFO app: locors::controller::approutes: +middleware name="logger" environment=development INFO app: locors::controller::approutes: +middleware name="requestid" environment=development INFO app: locors::controller::approutes: +middleware name="fallback" environment=development INFO app: locors::controller::approutes: +middleware name="poweredby" environment=development INFO app: demo::initializers::viewengine: locales loaded environment=development

                  ▄     ▀
                             ▀  ▄
              ▄       ▀     ▄  ▄ ▄▀
                                ▄ ▀▄▄
                    ▄     ▀    ▀  ▀▄▀█▄
                                      ▀█▄

▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄▄ ▀▀█ ██████ █████ ███ █████ ███ █████ ███ ▀█ ██████ █████ ███ █████ ▀▀▀ █████ ███ ▄█▄ ██████ █████ ███ █████ █████ ███ ████▄ ██████ █████ ███ █████ ▄▄▄ █████ ███ █████ ██████ █████ ███ ████ ███ █████ ███ ████▀ ▀▀▀██▄ ▀▀▀▀▀▀▀▀▀▀ ▀▀▀▀▀▀▀▀▀▀ ▀▀▀▀▀▀▀▀▀▀ ██▀ ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀ https://loco.rs

environment: development database: automigrate logger: debug compilation: debug modes: server

listening on http://localhost:5150 ```

Fix

If you get this optimization message about "pretty backtraces", then that's fine, and you can optimize it later:

txt INFO app: loco_rs::config: loading environment from selected_path="config/development.yaml" environment=development WARN app: loco_rs::boot: pretty backtraces are enabled (this is great for development but has a runtime cost for production. disable with `logger.pretty_backtrace` in your config yaml) environment=development

If you get this error message about "PgDatabaseError", then it means that your environment variable DATABASE_URL is not connecting to your database correctly, so you'll need to fix either the variable or the your database server or your database connection:

txt Error: DB(Conn(SqlxError(Database(PgDatabaseError { severity: Fatal, code: "28000", message: "role \"loco\" does not exist", detail: None, hint: None, position: None, where: None, schema: None, table: None, column: None, data_type: None, constraint: None, file: Some("miscinit.c"), line: Some(752), routine: Some("InitializeSessionUserId") }))))

Welcome to Loco :train:

Loco is a web and API framework running on Rust.

This is the SaaS starter which includes a User model and authentication based on JWT.

It also include configuration sections that help you pick either a frontend or a server-side template set up for your fullstack server.

Quick Start

sh cargo loco start

``sh $ cargo loco start Finished dev [unoptimized + debuginfo] target(s) in 21.63s Runningtarget/debug/myapp start`

:
:
:

controller/app_routes.rs:203: [Middleware] Adding log trace id

                  ▄     ▀
                             ▀  ▄
              ▄       ▀     ▄  ▄ ▄▀
                                ▄ ▀▄▄
                    ▄     ▀    ▀  ▀▄▀█▄
                                      ▀█▄

▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄▄ ▀▀█ ██████ █████ ███ █████ ███ █████ ███ ▀█ ██████ █████ ███ █████ ▀▀▀ █████ ███ ▄█▄ ██████ █████ ███ █████ █████ ███ ████▄ ██████ █████ ███ █████ ▄▄▄ █████ ███ █████ ██████ █████ ███ ████ ███ █████ ███ ████▀ ▀▀▀██▄ ▀▀▀▀▀▀▀▀▀▀ ▀▀▀▀▀▀▀▀▀▀ ▀▀▀▀▀▀▀▀▀▀ ██▀ ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀ https://loco.rs

environment: development database: automigrate logger: debug compilation: debug modes: server

listening on http://localhost:5150 ```

Full Stack Serving

You can check your configuration to pick either frontend setup or server-side rendered template, and activate the relevant configuration sections.

Getting help

Check out a quick tour or the complete guide.

Owner

  • Name: Joel Parker Henderson
  • Login: joelparkerhenderson
  • Kind: user
  • Location: California

Software developer. Technology consultant. Creator of GitAlias.com, NumCommand.com, SixArm.com, and many open source projects.

Citation (CITATION.cff)

cff-version: 1.2.0
title: Demo Loco Axum Tokio Rust
message: >-
  If you use this work and you want to cite it,
  then you can use the metadata from this file.
type: software
authors:
  - given-names: Joel Parker
    family-names: Henderson
    email: joel@joelparkerhenderson.com
    affiliation: joelparkerhenderson.com
    orcid: 'https://orcid.org/0009-0000-4681-282X'
identifiers:
  - type: url
    value: 'https://github.com/joelparkerhenderson/demo_loco_axum_tokio_rust/'
    description: Demo Loco Axum Tokio Rust
repository-code: 'https://github.com/joelparkerhenderson/demo_loco_axum_tokio_rust/'
abstract: >-
  Demo Loco Axum Tokio Rust
license: See license file

GitHub Events

Total
  • Watch event: 1
  • Push event: 3
  • Create event: 2
Last Year
  • Watch event: 1
  • Push event: 3
  • Create event: 2

Committers

Last synced: 9 months ago

All Time
  • Total Commits: 5
  • Total Committers: 1
  • Avg Commits per committer: 5.0
  • Development Distribution Score (DDS): 0.0
Past Year
  • Commits: 5
  • Committers: 1
  • Avg Commits per committer: 5.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Joel Parker Henderson j****l@j****m 5
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 9 months ago

All Time
  • Total issues: 0
  • Total pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Total issue authors: 0
  • Total pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels

Dependencies

.github/workflows/ci.yaml actions
  • Swatinem/rust-cache v2 composite
  • actions-rs/cargo v1 composite
  • actions/checkout v4 composite
  • dtolnay/rust-toolchain stable composite
  • postgres * docker
  • redis * docker
Cargo.lock cargo
  • 547 dependencies
Cargo.toml cargo
  • insta 1.34.0 development
  • rstest 0.21.0 development
  • serial_test 3.1.1 development
  • async-trait 0.1.74
  • axum 0.7.5
  • chrono 0.4
  • fluent-templates 0.8.0
  • include_dir 0.7
  • sea-orm 1.1.0
  • serde 1
  • serde_json 1
  • tokio 1.33.0
  • tracing 0.1.40
  • tracing-subscriber 0.3.17
  • unic-langid 0.9.4
  • uuid 1.6.0
  • validator 0.18
migration/Cargo.toml cargo
frontend/package.json npm
  • @biomejs/biome ^1 development
  • @rsbuild/core ^1 development
  • @rsbuild/plugin-react ^1 development
  • @types/react ^18 development
  • @types/react-dom ^18 development
  • typescript ^5 development
  • react ^18
  • react-dom ^18