From 2cbd9c8c6d8680ff80bdfbadb5e4c086f4b70e67 Mon Sep 17 00:00:00 2001 From: Elad Kaplan Date: Sun, 26 May 2024 12:35:33 +0300 Subject: [PATCH 1/7] improve docs with snipdoc --- .github/workflows/docs.yml | 33 ++++ README.md | 152 +++++++++--------- .../docs/getting-started/tour/index.md | 139 ++++++++-------- src/lib.rs | 119 ++++++++++++-- 4 files changed, 289 insertions(+), 154 deletions(-) create mode 100644 .github/workflows/docs.yml diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml new file mode 100644 index 000000000..b2eac0eb5 --- /dev/null +++ b/.github/workflows/docs.yml @@ -0,0 +1,33 @@ +name: docs + +on: + push: + branches: + - master + pull_request: + +env: + RUST_TOOLCHAIN: stable + TOOLCHAIN_PROFILE: minimal + +jobs: + check: + name: Check + runs-on: ubuntu-latest + + permissions: + contents: read + + steps: + - name: Checkout the code + uses: actions/checkout@v4 + - uses: actions-rs/toolchain@v1 + with: + profile: ${{ env.TOOLCHAIN_PROFILE }} + toolchain: ${{ env.RUST_TOOLCHAIN }} + override: true + components: rustfmt + - run: cargo install snipdoc + - run: snipdoc check + + \ No newline at end of file diff --git a/README.md b/README.md index ae98e8ee3..fb0abe151 100644 --- a/README.md +++ b/README.md @@ -1,103 +1,111 @@ + +
-![Loco.rs](https://github.com/loco-rs/loco/assets/83390/992d215a-3cd3-42ee-a1c7-de9fd25a5bac) -[![Current Crates.io Version](https://img.shields.io/crates/v/loco-rs.svg)](https://crates.io/crates/loco-rs) -[![Discord channel](https://img.shields.io/badge/discord-Join-us)](https://discord.gg/fTvyBzwKS8) + -# Welcome to Loco! +

Loco

-https://loco.rs +

๐Ÿš‚ Loco is "Rust on Rails".

+ [![crate](https://img.shields.io/crates/v/loco-rs.svg)](https://crates.io/crates/loco-rs) + [![docs](https://docs.rs/loco-rs/badge.svg)](https://docs.rs/loco-rs) + [![Discord channel](https://img.shields.io/badge/discord-Join-us)](https://discord.gg/fTvyBzwKS8) -Loco is "Rust on Rails". +
-Loco is strongly inspired by Rails. If you know Rails and Rust, you'll feel at home. If you only know Rails and new to Rust, you'll find Loco refreshing. We do not assume you know Rails. + # Loco + #### Loco is strongly inspired by Rails. If you know Rails and Rust, you'll feel at home. If you only know Rails and new to Rust, you'll find Loco refreshing. We do not assume you know Rails. -## Quick Start + ## Quick Start + ```sh + $ cargo install loco-cli + $ cargo install sea-orm-cli # Only when DB is needed + ``` -```sh -$ cargo install loco-cli -``` + Now you can create your new app (choose "SaaS app"). -Now you can create your new app (choose "SaaS app"). + ```sh + $ loco new + โœ” โฏ App name? ยท myapp + ? โฏ What would you like to build? โ€บ + lightweight-service (minimal, only controllers and views) + Rest API (with DB and user auth) + โฏ SaaS app (with DB and user auth) + ๐Ÿš‚ Loco app generated successfully in: + myapp + ``` -```sh -$ loco new -โฏ App name? [myapp]: -โฏ SaaS app (with DB and user auth) - Stateless service (minimal, no db) -๐Ÿš‚ Loco app generated successfully in: -myapp -``` +
+ To configure a database , please run a local postgres database with + loco:loco and a db named is the [insert app]_development. +
-To configure a database , please run a local postgres database with loco:loco and a db named [insert app]_development. + You can use Docker to run a Postgres instance: -``` -$ docker run -d -p 5432:5432 -e POSTGRES_USER=loco -e POSTGRES_DB=myapp_development -e POSTGRES_PASSWORD="loco" postgres:15.3-alpine -``` + When generating a starter, the database name incorporates your application + name and the environment. For instance, if you include `myapp`, the database + name in the `test.yaml`configuration will be `myapp_test`, and in the + `development.yaml` configuration, it will be `myapp_development`. -Now `cd` into your `myapp` and start your app: -``` -$ cd myapp -$ cargo loco start -Finished dev [unoptimized + debuginfo] target(s) in 21.63s - Running `target/debug/myapp start` + A more advanced set of `docker-compose.yml` and `Dockerfiles` that include Redis and the `mailtutan` mailer are available for [each starter on GitHub](https://github.com/loco-rs/loco/blob/master/starters/saas/.devcontainer/docker-compose.yml). - : - : - : + Now `cd` into your `myapp` and start your app: -controller/app_routes.rs:203: [Middleware] Adding log trace id + ``` + $ cd myapp + $ cargo loco start + Finished dev [unoptimized + debuginfo] target(s) in 21.63s + Running `target/debug/myapp start` - โ–„ โ–€ - โ–€ โ–„ - โ–„ โ–€ โ–„ โ–„ โ–„โ–€ - โ–„ โ–€โ–„โ–„ - โ–„ โ–€ โ–€ โ–€โ–„โ–€โ–ˆโ–„ - โ–€โ–ˆโ–„ -โ–„โ–„โ–„โ–„โ–„โ–„โ–„ โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„ โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„ โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„ โ–€โ–€โ–ˆ - โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–€โ–ˆ - โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–€โ–€โ–€ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–„โ–ˆโ–„ - โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–„ - โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–„โ–„โ–„ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ - โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–€ - โ–€โ–€โ–€โ–ˆโ–ˆโ–„ โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€ โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€ โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€ โ–ˆโ–ˆโ–€ - โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€ + : + : + : -started on port 3000 -``` + controller/app_routes.rs:203: [Middleware] Adding log trace id -## Project Status + โ–„ โ–€ + โ–€ โ–„ + โ–„ โ–€ โ–„ โ–„ โ–„โ–€ + โ–„ โ–€โ–„โ–„ + โ–„ โ–€ โ–€ โ–€โ–„โ–€โ–ˆโ–„ + โ–€โ–ˆโ–„ + โ–„โ–„โ–„โ–„โ–„โ–„โ–„ โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„ โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„ โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„ โ–€โ–€โ–ˆ + โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–€โ–ˆ + โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–€โ–€โ–€ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–„โ–ˆโ–„ + โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–„ + โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–„โ–„โ–„ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ + โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–€ + โ–€โ–€โ–€โ–ˆโ–ˆโ–„ โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€ โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€ โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€ โ–ˆโ–ˆโ–€ + โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€ -Loco is feature complete, but features are still being added rapidly. + started on port 3000 + ``` -### What can you build? +
+ You don't have to run things through `cargo` but in development it's highly + recommended. If you build `--release`, your binary contains everything + including your code and `cargo` or Rust is not needed.
-- Stateless APIs -- Complete SaaS products with user authentication -- Purpose-built services such as ML inference endpoints -- Full stack projects with separate frontend project integrated with Loco -- Hobby projects full-stack with backend and HTML frontend + ## Project Status + + Stateless APIs + + Complete SaaS products with user authentication + + Purpose-built services such as ML inference endpoints + + Full stack projects with separate frontend project integrated with Loco + + Hobby projects full-stack with backend and HTML frontend -### What's being done now? + ## Powered by Loco + + [SpectralOps](https://spectralops.io) - various services powered by Loco + framework + + [Nativish](https://nativi.sh) - app backend powered by Loco framework -- View [issues](https://github.com/loco-rs/loco/issues) for what we plan next and what we work on (you're welcome to submit PRs!) -- View [CHANGELOG](https://github.com/loco-rs/loco/blob/master/CHANGELOG.md) for what we already added + ## Contributors โœจ -## Powered by Loco - -* [SpectralOps](https://spectralops.io) - various services powered by Loco framework -* [Nativish](https://nativi.sh) - app backend powered by Loco framework - -[open an issue to add yourself here](https://github.com/loco-rs/loco/issues) - - -## Contributors โœจ - -Thanks goes to these wonderful people: + Thanks goes to these wonderful people: + \ No newline at end of file diff --git a/docs-site/content/docs/getting-started/tour/index.md b/docs-site/content/docs/getting-started/tour/index.md index 30de93b77..af9c7a2ba 100644 --- a/docs-site/content/docs/getting-started/tour/index.md +++ b/docs-site/content/docs/getting-started/tour/index.md @@ -19,73 +19,78 @@ flair =[]
Let's create a blog backend on `loco` in 4 commands. First install `loco-cli` and `sea-orm-cli`: -```sh -$ cargo install loco-cli -$ cargo install sea-orm-cli -``` - -Now you can create your new app (choose "SaaS app"). - -```sh -$ loco new -โœ” โฏ App name? ยท myapp -? โฏ What would you like to build? โ€บ - lightweight-service (minimal, only controllers and views) - Rest API (with DB and user auth) -โฏ SaaS app (with DB and user auth) -๐Ÿš‚ Loco app generated successfully in: -myapp -``` - -
-To configure a database , please run a local postgres database with loco:loco and a db named is the [insert app]_development. -
- -You can use Docker to run a Postgres instance: - -When generating a starter, the database name incorporates your application name and the environment. For instance, if you include `myapp`, the database name in the `test.yaml`configuration will be `myapp_test`, and in the `development.yaml` configuration, it will be `myapp_development`. - -``` -$ docker run -d -p 5432:5432 -e POSTGRES_USER=loco -e POSTGRES_DB=myapp_development -e POSTGRES_PASSWORD="loco" postgres:15.3-alpine -``` - -A more advanced set of `docker-compose.yml` and `Dockerfiles` that include Redis and the `mailtutan` mailer are available for [each starter on GitHub](https://github.com/loco-rs/loco/blob/master/starters/saas/.devcontainer/docker-compose.yml). - -Now `cd` into your `myapp` and start your app: - -``` -$ cd myapp -$ cargo loco start -Finished dev [unoptimized + debuginfo] target(s) in 21.63s - Running `target/debug/myapp start` - - : - : - : - -controller/app_routes.rs:203: [Middleware] Adding log trace id - - โ–„ โ–€ - โ–€ โ–„ - โ–„ โ–€ โ–„ โ–„ โ–„โ–€ - โ–„ โ–€โ–„โ–„ - โ–„ โ–€ โ–€ โ–€โ–„โ–€โ–ˆโ–„ - โ–€โ–ˆโ–„ -โ–„โ–„โ–„โ–„โ–„โ–„โ–„ โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„ โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„ โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„ โ–€โ–€โ–ˆ - โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–€โ–ˆ - โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–€โ–€โ–€ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–„โ–ˆโ–„ - โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–„ - โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–„โ–„โ–„ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ - โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–€ - โ–€โ–€โ–€โ–ˆโ–ˆโ–„ โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€ โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€ โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€ โ–ˆโ–ˆโ–€ - โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€ - -started on port 3000 -``` - -
-You don't have to run things through `cargo` but in development it's highly recommended. If you build `--release`, your binary contains everything including your code and `cargo` or Rust is not needed. -
+ + ```sh + $ cargo install loco-cli + $ cargo install sea-orm-cli # Only when DB is needed + ``` + + Now you can create your new app (choose "SaaS app"). + + ```sh + $ loco new + โœ” โฏ App name? ยท myapp + ? โฏ What would you like to build? โ€บ + lightweight-service (minimal, only controllers and views) + Rest API (with DB and user auth) + โฏ SaaS app (with DB and user auth) + ๐Ÿš‚ Loco app generated successfully in: + myapp + ``` + +
+ To configure a database , please run a local postgres database with + loco:loco and a db named is the [insert app]_development. +
+ + You can use Docker to run a Postgres instance: + + When generating a starter, the database name incorporates your application + name and the environment. For instance, if you include `myapp`, the database + name in the `test.yaml`configuration will be `myapp_test`, and in the + `development.yaml` configuration, it will be `myapp_development`. + + + + A more advanced set of `docker-compose.yml` and `Dockerfiles` that include Redis and the `mailtutan` mailer are available for [each starter on GitHub](https://github.com/loco-rs/loco/blob/master/starters/saas/.devcontainer/docker-compose.yml). + + Now `cd` into your `myapp` and start your app: + + ``` + $ cd myapp + $ cargo loco start + Finished dev [unoptimized + debuginfo] target(s) in 21.63s + Running `target/debug/myapp start` + + : + : + : + + controller/app_routes.rs:203: [Middleware] Adding log trace id + + โ–„ โ–€ + โ–€ โ–„ + โ–„ โ–€ โ–„ โ–„ โ–„โ–€ + โ–„ โ–€โ–„โ–„ + โ–„ โ–€ โ–€ โ–€โ–„โ–€โ–ˆโ–„ + โ–€โ–ˆโ–„ + โ–„โ–„โ–„โ–„โ–„โ–„โ–„ โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„ โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„ โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„ โ–€โ–€โ–ˆ + โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–€โ–ˆ + โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–€โ–€โ–€ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–„โ–ˆโ–„ + โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–„ + โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–„โ–„โ–„ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ + โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–€ + โ–€โ–€โ–€โ–ˆโ–ˆโ–„ โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€ โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€ โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€ โ–ˆโ–ˆโ–€ + โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€ + + started on port 3000 + ``` + +
+ You don't have to run things through `cargo` but in development it's highly + recommended. If you build `--release`, your binary contains everything + including your code and `cargo` or Rust is not needed.
+ ## Adding a CRUD API diff --git a/src/lib.rs b/src/lib.rs index e127af7d1..0ccdd815e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,30 +1,119 @@ #![allow(clippy::missing_const_for_fn)] #![allow(clippy::module_name_repetitions)] -//! ## Starting A New Project +// +//!
//! -//! To start a new project, you can use cargo-generate: +//! +//! +//!

Loco

+//! +//!

๐Ÿš‚ Loco is "Rust on Rails".

+//! +//! [![crate](https://img.shields.io/crates/v/loco-rs.svg)](https://crates.io/crates/loco-rs) +//! [![docs](https://docs.rs/loco-rs/badge.svg)](https://docs.rs/loco-rs) +//! [![Discord channel](https://img.shields.io/badge/discord-Join-us)](https://discord.gg/fTvyBzwKS8) +//! +//!
+//! +//! # Loco +//! +//! #### Loco is strongly inspired by Rails. If you know Rails and Rust, you'll feel at home. If you only know Rails and new to Rust, you'll find Loco refreshing. We do not assume you know Rails. +//! +//! ## Quick Start +// +//! ```sh +//! $ cargo install loco-cli +//! $ cargo install sea-orm-cli # Only when DB is needed +//! ``` +//! +//! Now you can create your new app (choose "SaaS app"). //! //! ```sh -//! cargo install loco-cli -//! โฏ loco new +//! $ loco new //! โœ” โฏ App name? ยท myapp //! ? โฏ What would you like to build? โ€บ -//! โฏ lightweight-service (minimal, only controllers and views) +//! lightweight-service (minimal, only controllers and views) //! Rest API (with DB and user auth) -//! SaaS app (with DB and user auth) +//! โฏ SaaS app (with DB and user auth) +//! ๐Ÿš‚ Loco app generated successfully in: +//! myapp +//! ``` +//! +//!
+//! To configure a database , please run a local postgres database with +//! loco:loco and a db named is the [insert app]_development. +//!
+//! +//! You can use Docker to run a Postgres instance: +//! +//! When generating a starter, the database name incorporates your application +//! name and the environment. For instance, if you include `myapp`, the database +//! name in the `test.yaml`configuration will be `myapp_test`, and in the +//! `development.yaml` configuration, it will be `myapp_development`. +//! +//! +//! +//! A more advanced set of `docker-compose.yml` and `Dockerfiles` that include Redis and the `mailtutan` mailer are available for [each starter on GitHub](https://github.com/loco-rs/loco/blob/master/starters/saas/.devcontainer/docker-compose.yml). +//! +//! Now `cd` into your `myapp` and start your app: +//! +//! ``` +//! $ cd myapp +//! $ cargo loco start +//! Finished dev [unoptimized + debuginfo] target(s) in 21.63s +//! Running `target/debug/myapp start` +//! +//! : +//! : +//! : +//! +//! controller/app_routes.rs:203: [Middleware] Adding log trace id +//! +//! โ–„ โ–€ +//! โ–€ โ–„ +//! โ–„ โ–€ โ–„ โ–„ โ–„โ–€ +//! โ–„ โ–€โ–„โ–„ +//! โ–„ โ–€ โ–€ โ–€โ–„โ–€โ–ˆโ–„ +//! โ–€โ–ˆโ–„ +//! โ–„โ–„โ–„โ–„โ–„โ–„โ–„ โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„ โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„ โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„ โ–€โ–€โ–ˆ +//! โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–€โ–ˆ +//! โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–€โ–€โ–€ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–„โ–ˆโ–„ +//! โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–„ +//! โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–„โ–„โ–„ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ +//! โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–€ +//! โ–€โ–€โ–€โ–ˆโ–ˆโ–„ โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€ โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€ โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€ โ–ˆโ–ˆโ–€ +//! โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€ +//! +//! started on port 3000 //! ``` //! -//! ## Available Features +//!
+//! You don't have to run things through `cargo` but in development it's highly +//! recommended. If you build `--release`, your binary contains everything +//! including your code and `cargo` or Rust is not needed.
+//
+//! +//! ## Project Status +//! + Stateless APIs +//! + Complete SaaS products with user authentication +//! + Purpose-built services such as ML inference endpoints +//! + Full stack projects with separate frontend project integrated with Loco +//! + Hobby projects full-stack with backend and HTML frontend //! -//! To avoid compiling unused dependencies, loco gates certain features. +//! ## Powered by Loco +//! + [SpectralOps](https://spectralops.io) - various services powered by Loco +//! framework +//! + [Nativish](https://nativi.sh) - app backend powered by Loco framework //! -//! | Feature | Default | Description | -//! |------------|---------|-----------------------------| -//! | `auth_jwt` | true | Enable user authentication. | -//! | `cli` | true | Expose Cli commands. | -//! | `testing | false | Test Utilities Module. | -//! | `with-db` | true | with-db. | -//! | `channels` | false | Enable socket channels. | +//! ## Contributors โœจ +//! +//! Thanks goes to these wonderful people: +//! +//! +//! +//! +//
+ pub use self::errors::Error; mod banner; From 3cf52a8a8ff90f64bd596c96cb6ef732092aa778 Mon Sep 17 00:00:00 2001 From: Elad Kaplan Date: Sun, 26 May 2024 12:42:00 +0300 Subject: [PATCH 2/7] validate ci --- src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 0ccdd815e..a62787694 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -26,7 +26,7 @@ //! $ cargo install sea-orm-cli # Only when DB is needed //! ``` //! -//! Now you can create your new app (choose "SaaS app"). +//! Now you can create your new app (choose "`SaaS` app"). //! //! ```sh //! $ loco new @@ -95,7 +95,7 @@ //! //! ## Project Status //! + Stateless APIs -//! + Complete SaaS products with user authentication +//! + Complete `SaaS` products with user authentication //! + Purpose-built services such as ML inference endpoints //! + Full stack projects with separate frontend project integrated with Loco //! + Hobby projects full-stack with backend and HTML frontend From a1140ebaa1bc58fbeac5f130f1a667762019767d Mon Sep 17 00:00:00 2001 From: Elad Kaplan Date: Sun, 26 May 2024 12:43:59 +0300 Subject: [PATCH 3/7] alignment --- README.md | 4 ++-- docs-site/content/docs/getting-started/tour/index.md | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index fb0abe151..17d1d5e08 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ $ cargo install sea-orm-cli # Only when DB is needed ``` - Now you can create your new app (choose "SaaS app"). + Now you can create your new app (choose "`SaaS` app"). ```sh $ loco new @@ -91,7 +91,7 @@ ## Project Status + Stateless APIs - + Complete SaaS products with user authentication + + Complete `SaaS` products with user authentication + Purpose-built services such as ML inference endpoints + Full stack projects with separate frontend project integrated with Loco + Hobby projects full-stack with backend and HTML frontend diff --git a/docs-site/content/docs/getting-started/tour/index.md b/docs-site/content/docs/getting-started/tour/index.md index af9c7a2ba..2330ec501 100644 --- a/docs-site/content/docs/getting-started/tour/index.md +++ b/docs-site/content/docs/getting-started/tour/index.md @@ -25,7 +25,7 @@ Let's create a blog backend on `loco` in 4 commands. First install `loco-cli` an $ cargo install sea-orm-cli # Only when DB is needed ``` - Now you can create your new app (choose "SaaS app"). + Now you can create your new app (choose "`SaaS` app"). ```sh $ loco new From 0bf15914ea0b5f96d97fabcc02f3d51499b71628 Mon Sep 17 00:00:00 2001 From: Elad Kaplan Date: Mon, 27 May 2024 09:14:23 +0300 Subject: [PATCH 4/7] snipdoc --- README.md | 147 ++++++++---------- docs-site/content/blog/frontend-website.md | 1 - docs-site/content/docs/getting-started/cli.md | 26 ++-- .../content/docs/getting-started/config.md | 26 ++-- .../docs/getting-started/deployment.md | 113 ++++++++++---- .../content/docs/getting-started/guide.md | 71 +++++---- .../content/docs/getting-started/starters.md | 15 +- .../docs/getting-started/tour/index.md | 106 ++++++++----- docs-site/templates/shortcodes/get_env.html | 0 examples/demo/config/development.yaml | 15 ++ snipdoc.yml | 124 +++++++++++++++ src/lib.rs | 114 +------------- 12 files changed, 436 insertions(+), 322 deletions(-) create mode 100644 docs-site/templates/shortcodes/get_env.html create mode 100644 snipdoc.yml diff --git a/README.md b/README.md index 17d1d5e08..e2fb037ea 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,14 @@ -

Loco

-

๐Ÿš‚ Loco is "Rust on Rails".

+

+ +๐Ÿš‚ Loco is Rust on Rails. + +

[![crate](https://img.shields.io/crates/v/loco-rs.svg)](https://crates.io/crates/loco-rs) [![docs](https://docs.rs/loco-rs/badge.svg)](https://docs.rs/loco-rs) @@ -18,94 +21,82 @@ #### Loco is strongly inspired by Rails. If you know Rails and Rust, you'll feel at home. If you only know Rails and new to Rust, you'll find Loco refreshing. We do not assume you know Rails. ## Quick Start - ```sh - $ cargo install loco-cli - $ cargo install sea-orm-cli # Only when DB is needed - ``` + +```sh +cargo install loco-cli +cargo install sea-orm-cli # Only when DB is needed +``` + Now you can create your new app (choose "`SaaS` app"). - ```sh - $ loco new - โœ” โฏ App name? ยท myapp - ? โฏ What would you like to build? โ€บ - lightweight-service (minimal, only controllers and views) - Rest API (with DB and user auth) - โฏ SaaS app (with DB and user auth) - ๐Ÿš‚ Loco app generated successfully in: - myapp - ``` - -
- To configure a database , please run a local postgres database with - loco:loco and a db named is the [insert app]_development. -
+ +```sh +โฏ loco new +โœ” โฏ App name? ยท myapp +โœ” โฏ What would you like to build? ยท SaaS app (with DB and user auth) - You can use Docker to run a Postgres instance: +๐Ÿš‚ Loco app generated successfully in: +myapp +``` + - When generating a starter, the database name incorporates your application - name and the environment. For instance, if you include `myapp`, the database - name in the `test.yaml`configuration will be `myapp_test`, and in the - `development.yaml` configuration, it will be `myapp_development`. +To configure a database , please run a local postgres database with loco:loco and a db named [insert app]_development. + +```sh +docker run -d -p 5432:5432 \ + -e POSTGRES_USER=loco \ + -e POSTGRES_DB=myapp_development \ + -e POSTGRES_PASSWORD="loco" \ + postgres:15.3-alpine +``` + A more advanced set of `docker-compose.yml` and `Dockerfiles` that include Redis and the `mailtutan` mailer are available for [each starter on GitHub](https://github.com/loco-rs/loco/blob/master/starters/saas/.devcontainer/docker-compose.yml). Now `cd` into your `myapp` and start your app: - ``` - $ cd myapp - $ cargo loco start - Finished dev [unoptimized + debuginfo] target(s) in 21.63s - Running `target/debug/myapp start` - - : - : - : - - controller/app_routes.rs:203: [Middleware] Adding log trace id - - โ–„ โ–€ - โ–€ โ–„ - โ–„ โ–€ โ–„ โ–„ โ–„โ–€ - โ–„ โ–€โ–„โ–„ - โ–„ โ–€ โ–€ โ–€โ–„โ–€โ–ˆโ–„ - โ–€โ–ˆโ–„ - โ–„โ–„โ–„โ–„โ–„โ–„โ–„ โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„ โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„ โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„ โ–€โ–€โ–ˆ - โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–€โ–ˆ - โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–€โ–€โ–€ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–„โ–ˆโ–„ - โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–„ - โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–„โ–„โ–„ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ - โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–€ - โ–€โ–€โ–€โ–ˆโ–ˆโ–„ โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€ โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€ โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€ โ–ˆโ–ˆโ–€ - โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€ - - started on port 3000 - ``` - -
- You don't have to run things through `cargo` but in development it's highly - recommended. If you build `--release`, your binary contains everything - including your code and `cargo` or Rust is not needed.
- - ## Project Status - + Stateless APIs - + Complete `SaaS` products with user authentication - + Purpose-built services such as ML inference endpoints - + Full stack projects with separate frontend project integrated with Loco - + Hobby projects full-stack with backend and HTML frontend - - ## Powered by Loco - + [SpectralOps](https://spectralops.io) - various services powered by Loco - framework - + [Nativish](https://nativi.sh) - app backend powered by Loco framework - - ## Contributors โœจ - - Thanks goes to these wonderful people: + +```sh +$ cargo loco start + + โ–„ โ–€ + โ–€ โ–„ + โ–„ โ–€ โ–„ โ–„ โ–„โ–€ + โ–„ โ–€โ–„โ–„ + โ–„ โ–€ โ–€ โ–€โ–„โ–€โ–ˆโ–„ + โ–€โ–ˆโ–„ +โ–„โ–„โ–„โ–„โ–„โ–„โ–„ โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„ โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„ โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„ โ–€โ–€โ–ˆ +โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–€โ–ˆ +โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–€โ–€โ–€ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–„โ–ˆโ–„ +โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–„ +โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–„โ–„โ–„ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ +โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–€ + โ–€โ–€โ–€โ–ˆโ–ˆโ–„ โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€ โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€ โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€ โ–ˆโ–ˆโ–€ + โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€ + https://loco.rs + +listening on port 3000 +``` + + +## Project Status ++ Stateless APIs ++ Complete `SaaS` products with user authentication ++ Purpose-built services such as ML inference endpoints ++ Full stack projects with separate frontend project integrated with Loco ++ Hobby projects full-stack with backend and HTML frontend + +## Powered by Loco ++ [SpectralOps](https://spectralops.io) - various services powered by Loco + framework ++ [Nativish](https://nativi.sh) - app backend powered by Loco framework + +## Contributors โœจ +Thanks goes to these wonderful people: - - \ No newline at end of file + \ No newline at end of file diff --git a/docs-site/content/blog/frontend-website.md b/docs-site/content/blog/frontend-website.md index bba39181e..b3b70fff5 100644 --- a/docs-site/content/blog/frontend-website.md +++ b/docs-site/content/blog/frontend-website.md @@ -147,7 +147,6 @@ server: ``` Now, run the Loco server again and you should see frontend app serving via Loco - ```sh $ cargo loco start ``` diff --git a/docs-site/content/docs/getting-started/cli.md b/docs-site/content/docs/getting-started/cli.md index 480edb1f0..4d7c4a7bf 100644 --- a/docs-site/content/docs/getting-started/cli.md +++ b/docs-site/content/docs/getting-started/cli.md @@ -16,18 +16,24 @@ flair =[] Create your starter app: -```rust -$ cargo install loco-cli -$ loco new -< follow the guide > + +```sh +โฏ loco new +โœ” โฏ App name? ยท myapp +โœ” โฏ What would you like to build? ยท SaaS app (with DB and user auth) + +๐Ÿš‚ Loco app generated successfully in: +myapp ``` + Now `cd` into your app, set up a convenience `rr` alias and try out the various commands: + +```sh +cargo loco --help ``` -$ cd myapp -$ cargo loco --help -``` + You can now drive your development through the CLI: @@ -49,9 +55,11 @@ $ cargo test To run you app, run: + +```sh +cargo loco start ``` -$ cargo loco start -``` + ## Background workers diff --git a/docs-site/content/docs/getting-started/config.md b/docs-site/content/docs/getting-started/config.md index 80d6a381d..4c460cb44 100644 --- a/docs-site/content/docs/getting-started/config.md +++ b/docs-site/content/docs/getting-started/config.md @@ -61,27 +61,23 @@ config/ ``` To run the application using the 'qa' environment, execute the following command: - -``` -$ LOCO_ENV=qa cargo loco start + +```sh +LOCO_ENV=qa cargo loco start ``` + ## Settings -The configuration files contain knobs to set up your Loco app. You can also have your custom settings, with the `settings:` section. - - -```yaml -# in config/development.yaml -# add the `settings:` section -settings: +The configuration files contain knobs to set up your Loco app. You can also have your custom settings, with the `settings:` section. in `config/development.yaml` add the `settings:` section + +```yaml + settings: allow_list: - google.com - - apple.com - -logger: - # ... -``` + - apple.com + ``` + These setting will appear in `ctx.config.settings` as `serde_json::Value`. You can create your strongly typed settings by adding a struct: diff --git a/docs-site/content/docs/getting-started/deployment.md b/docs-site/content/docs/getting-started/deployment.md index 9b107c936..77e6aa959 100644 --- a/docs-site/content/docs/getting-started/deployment.md +++ b/docs-site/content/docs/getting-started/deployment.md @@ -17,9 +17,11 @@ Deployment is super simple in Loco, and this is why this guide is super short. A To deploy, build your production binary for your relevant server architecture: + +```sh +cargo build --release ``` -$ cargo build --release -``` + And copy your binary along with your `config/` folder to the server. You can then run `myapp start` on your server. @@ -33,63 +35,114 @@ There are a few configuration sections that are important to review and set acco - Logger: -```yaml + +```yaml + # Application logging configuration logger: - level: -``` + # Enable or disable logging. + enable: true + # Enable pretty backtrace (sets RUST_BACKTRACE=1) + pretty_backtrace: true + # Log level, options: trace, debug, info, warn or error. + level: debug + # Define the logging format. options: compact, pretty or Json + format: compact + # By default the logger has filtering only logs that came from your code or logs that came from `loco` framework. to see all third party libraries + # Uncomment the line below to override to see all third party libraries you can enable this config and override the logger filters. + # override_filter: trace + ``` + + - Server: - -```yaml -server: + +```yaml + server: # Port on which the server will listen. the server binding is 0.0.0.0:{PORT} - port: 3000 + port: {{get_env(name="NODE_PORT", default=3000)}} # The UI hostname or IP address that mailers will point to. host: http://localhost -``` + # Out of the box middleware configuration. to disable middleware you can changed the `enable` field to `false` of comment the middleware block + ``` + -- Database: -```yaml -database: +- Database: + +```yaml + database: # Database connection URI - uri: postgres://loco:loco@localhost:5432/loco_app -``` + uri: {{get_env(name="DATABASE_URL", default="postgres://loco:loco@localhost:5432/loco_app")}} + # When enabled, the sql query will be logged. + enable_logging: false + # Set the timeout duration when acquiring a connection. + connect_timeout: 500 + # Set the idle duration before closing a connection. + idle_timeout: 500 + # Minimum number of connections for a pool. + min_connections: 1 + # Maximum number of connections for a pool. + max_connections: 1 + # Run migration up when application loaded + auto_migrate: true + # Truncate database when application loaded. This is a dangerous operation, make sure that you using this flag only on dev environments or test mode + dangerously_truncate: false + # Recreating schema when application loaded. This is a dangerous operation, make sure that you using this flag only on dev environments or test mode + dangerously_recreate: false + ``` + -- Mailer: -```yaml -mailer: +- Mailer: + +```yaml + mailer: # SMTP mailer configuration. smtp: # Enable/Disable smtp mailer. enable: true # SMTP server host. e.x localhost, smtp.gmail.com host: localhost -``` + # SMTP server port + port: 1025 + # Use secure connection (SSL/TLS). + secure: false + # auth: + # user: + # password: + ``` + - Redis: - -``` -redis: + +```yaml + redis: # Redis connection URI - uri: redis://127.0.0.1/ -``` + uri: {{get_env(name="REDIS_URL", default="redis://127.0.0.1")}} + # Dangerously flush all data in Redis on startup. dangerous operation, make sure that you using this flag only on dev environments or test mode + dangerously_flush: false + ``` + - JWT secret: - -```yaml -auth: + +```yaml + auth: # JWT authentication jwt: # Secret key for token generation and verification - secret: ... -``` + secret: PqRwLF2rhHe8J22oBeHy + # Token expiration time in seconds + expiration: 604800 # 7 days + ``` + + ## Generate Loco offers a deployment template enabling the creation of a deployment infrastructure. + ```sh cargo loco generate deployment ? โฏ Choose your deployment โ€บ @@ -102,6 +155,8 @@ cargo loco generate deployment skipped (exists): "dockerfile" added: ".dockerignore" ``` + + Deployment Options: diff --git a/docs-site/content/docs/getting-started/guide.md b/docs-site/content/docs/getting-started/guide.md index cba50f50f..5201e8d46 100644 --- a/docs-site/content/docs/getting-started/guide.md +++ b/docs-site/content/docs/getting-started/guide.md @@ -43,24 +43,29 @@ You can follow this guide for a step-by-step "bottom up" learning, or you can ju ### Installing + ```sh -$ cargo install loco-cli +cargo install loco-cli +cargo install sea-orm-cli # Only when DB is needed ``` + + ### Creating a new Loco app Now you can create your new app (choose "SaaS app" for built-in authentication). + ```sh -$ loco new +โฏ loco new โœ” โฏ App name? ยท myapp -? โฏ What would you like to build? โ€บ - lightweight-service (minimal, only controllers and views) - Rest API (with DB and user auth) -โฏ SaaS app (with DB and user auth) +โœ” โฏ What would you like to build? ยท SaaS app (with DB and user auth) + ๐Ÿš‚ Loco app generated successfully in: myapp ``` + + You can now switch to to `myapp`: @@ -79,9 +84,15 @@ To configure a database, please run a local postgres database with loco:lo This docker command start up postgresql database server. + ```sh -docker run -d -p 5432:5432 -e POSTGRES_USER=loco -e POSTGRES_DB=myapp_development -e POSTGRES_PASSWORD="loco" postgres:15.3-alpine +docker run -d -p 5432:5432 \ + -e POSTGRES_USER=loco \ + -e POSTGRES_DB=myapp_development \ + -e POSTGRES_PASSWORD="loco" \ + postgres:15.3-alpine ``` + This docker command start up redis server: @@ -91,14 +102,16 @@ docker run -p 6379:6379 -d redis redis-server Use doctor command to check the needed resources: -``` + +```sh $ cargo loco doctor Finished dev [unoptimized + debuginfo] target(s) in 0.32s - Running `target/debug/myapp-cli doctor` + Running `target/debug/myapp-cli doctor` โœ… SeaORM CLI is installed โœ… DB connection: success โœ… Redis connection: success ``` + Here's a rundown of what Loco creates for you by default: @@ -125,27 +138,11 @@ Let's get some responses quickly. For this, we need to start up the server. ### Starting the server + ```sh -$ cargo loco start - - โ–„ โ–€ - โ–€ โ–„ - โ–„ โ–€ โ–„ โ–„ โ–„โ–€ - โ–„ โ–€โ–„โ–„ - โ–„ โ–€ โ–€ โ–€โ–„โ–€โ–ˆโ–„ - โ–€โ–ˆโ–„ -โ–„โ–„โ–„โ–„โ–„โ–„โ–„ โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„ โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„ โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„ โ–€โ–€โ–ˆ - โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–€โ–ˆ - โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–€โ–€โ–€ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–„โ–ˆโ–„ - โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–„ - โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–„โ–„โ–„ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ - โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–€ - โ–€โ–€โ–€โ–ˆโ–ˆโ–„ โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€ โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€ โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€ โ–ˆโ–ˆโ–€ - โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€ - https://loco.rs - -listening on port 3000 +cargo loco start ``` + And now, let's see that it's alive: @@ -205,9 +202,11 @@ pub fn routes() -> Routes { Start the server: + ```sh -$ cargo loco start +cargo loco start ``` + Now, let's test it out: @@ -276,9 +275,11 @@ impl Hooks for App { That's it. Kill the server and bring it up again: + +```sh +cargo loco start ``` -$ cargo loco start -``` + And hit `/home/hello`: @@ -523,9 +524,11 @@ pub fn routes() -> Routes { Now, start the app: + ```sh -$ cargo loco start +cargo loco start ``` + And make a request: @@ -628,9 +631,11 @@ The order of the extractors is important, as changing the order of them can lead You can now test that it works, start the app: + ```sh -$ cargo loco start +cargo loco start ``` + Add a new article: diff --git a/docs-site/content/docs/getting-started/starters.md b/docs-site/content/docs/getting-started/starters.md index f9b9e17c6..4f6bb519a 100644 --- a/docs-site/content/docs/getting-started/starters.md +++ b/docs-site/content/docs/getting-started/starters.md @@ -15,20 +15,25 @@ flair =[] Simplify your project setup with Loco's predefined boilerplates, designed to make your development journey smoother. To get started, install our CLI and choose the template that suits your needs. + ```sh cargo install loco-cli +cargo install sea-orm-cli # Only when DB is needed ``` + Create a starter: + ```sh -loco new +โฏ loco new โœ” โฏ App name? ยท myapp -? โฏ What would you like to build? โ€บ -โฏ lightweight-service (minimal, only controllers and views) - Rest API (with DB and user auth) - SaaS app (with DB and user auth) +โœ” โฏ What would you like to build? ยท SaaS app (with DB and user auth) + +๐Ÿš‚ Loco app generated successfully in: +myapp ``` + ## Available Starters diff --git a/docs-site/content/docs/getting-started/tour/index.md b/docs-site/content/docs/getting-started/tour/index.md index 2330ec501..074a3e8db 100644 --- a/docs-site/content/docs/getting-started/tour/index.md +++ b/docs-site/content/docs/getting-started/tour/index.md @@ -19,11 +19,13 @@ flair =[]
Let's create a blog backend on `loco` in 4 commands. First install `loco-cli` and `sea-orm-cli`: - - ```sh - $ cargo install loco-cli - $ cargo install sea-orm-cli # Only when DB is needed - ``` + +```sh +cargo install loco-cli +cargo install sea-orm-cli # Only when DB is needed +``` + + Now you can create your new app (choose "`SaaS` app"). @@ -50,47 +52,50 @@ Let's create a blog backend on `loco` in 4 commands. First install `loco-cli` an name in the `test.yaml`configuration will be `myapp_test`, and in the `development.yaml` configuration, it will be `myapp_development`. + +```sh +docker run -d -p 5432:5432 \ + -e POSTGRES_USER=loco \ + -e POSTGRES_DB=myapp_development \ + -e POSTGRES_PASSWORD="loco" \ + postgres:15.3-alpine +``` + A more advanced set of `docker-compose.yml` and `Dockerfiles` that include Redis and the `mailtutan` mailer are available for [each starter on GitHub](https://github.com/loco-rs/loco/blob/master/starters/saas/.devcontainer/docker-compose.yml). Now `cd` into your `myapp` and start your app: - ``` - $ cd myapp - $ cargo loco start - Finished dev [unoptimized + debuginfo] target(s) in 21.63s - Running `target/debug/myapp start` - - : - : - : - - controller/app_routes.rs:203: [Middleware] Adding log trace id - - โ–„ โ–€ - โ–€ โ–„ - โ–„ โ–€ โ–„ โ–„ โ–„โ–€ - โ–„ โ–€โ–„โ–„ - โ–„ โ–€ โ–€ โ–€โ–„โ–€โ–ˆโ–„ - โ–€โ–ˆโ–„ - โ–„โ–„โ–„โ–„โ–„โ–„โ–„ โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„ โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„ โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„ โ–€โ–€โ–ˆ - โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–€โ–ˆ - โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–€โ–€โ–€ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–„โ–ˆโ–„ - โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–„ - โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–„โ–„โ–„ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ - โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–€ - โ–€โ–€โ–€โ–ˆโ–ˆโ–„ โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€ โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€ โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€ โ–ˆโ–ˆโ–€ - โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€ - - started on port 3000 - ``` + +```sh +$ cargo loco start + + โ–„ โ–€ + โ–€ โ–„ + โ–„ โ–€ โ–„ โ–„ โ–„โ–€ + โ–„ โ–€โ–„โ–„ + โ–„ โ–€ โ–€ โ–€โ–„โ–€โ–ˆโ–„ + โ–€โ–ˆโ–„ +โ–„โ–„โ–„โ–„โ–„โ–„โ–„ โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„ โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„ โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„ โ–€โ–€โ–ˆ +โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–€โ–ˆ +โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–€โ–€โ–€ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–„โ–ˆโ–„ +โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–„ +โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–„โ–„โ–„ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ +โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–€ + โ–€โ–€โ–€โ–ˆโ–ˆโ–„ โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€ โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€ โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€ โ–ˆโ–ˆโ–€ + โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€ + https://loco.rs + +listening on port 3000 +``` + +
You don't have to run things through `cargo` but in development it's highly recommended. If you build `--release`, your binary contains everything including your code and `cargo` or Rust is not needed.
- ## Adding a CRUD API @@ -115,10 +120,29 @@ injected: "tests/requests/mod.rs" Your database have been migrated and model, entities, and a full CRUD controller have been generated automatically. Start your app: - + ```sh $ cargo loco start + + โ–„ โ–€ + โ–€ โ–„ + โ–„ โ–€ โ–„ โ–„ โ–„โ–€ + โ–„ โ–€โ–„โ–„ + โ–„ โ–€ โ–€ โ–€โ–„โ–€โ–ˆโ–„ + โ–€โ–ˆโ–„ +โ–„โ–„โ–„โ–„โ–„โ–„โ–„ โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„ โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„ โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„ โ–€โ–€โ–ˆ +โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–€โ–ˆ +โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–€โ–€โ–€ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–„โ–ˆโ–„ +โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–„ +โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–„โ–„โ–„ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ +โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–€ + โ–€โ–€โ–€โ–ˆโ–ˆโ–„ โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€ โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€ โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€ โ–ˆโ–ˆโ–€ + โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€ + https://loco.rs + +listening on port 3000 ``` + Next, try adding a `post` with `curl`: @@ -152,20 +176,24 @@ To authenticate, you will need a running redis server. This docker command starts up a redis server: -``` + +```sh docker run -p 6379:6379 -d redis redis-server ``` + Use doctor command to check the needed resources: -``` + +```sh $ cargo loco doctor Finished dev [unoptimized + debuginfo] target(s) in 0.32s - Running `target/debug/myapp-cli doctor` + Running `target/debug/myapp-cli doctor` โœ… SeaORM CLI is installed โœ… DB connection: success โœ… Redis connection: success ``` + ### Registering a New User diff --git a/docs-site/templates/shortcodes/get_env.html b/docs-site/templates/shortcodes/get_env.html new file mode 100644 index 000000000..e69de29bb diff --git a/examples/demo/config/development.yaml b/examples/demo/config/development.yaml index f932a6338..9e3949834 100644 --- a/examples/demo/config/development.yaml +++ b/examples/demo/config/development.yaml @@ -1,10 +1,13 @@ # Loco configuration file documentation +# settings: allow_list: - google.com - apple.com +# +# # Application logging configuration logger: # Enable or disable logging. @@ -18,14 +21,17 @@ logger: # By default the logger has filtering only logs that came from your code or logs that came from `loco` framework. to see all third party libraries # Uncomment the line below to override to see all third party libraries you can enable this config and override the logger filters. # override_filter: trace +# # Web server configuration +# server: # Port on which the server will listen. the server binding is 0.0.0.0:{PORT} port: {{get_env(name="NODE_PORT", default=3000)}} # The UI hostname or IP address that mailers will point to. host: http://localhost # Out of the box middleware configuration. to disable middleware you can changed the `enable` field to `false` of comment the middleware block +# middlewares: # Allows to limit the payload size request. payload that bigger than this file will blocked the request. limit_payload: @@ -80,6 +86,7 @@ workers: mode: BackgroundQueue # Mailer Configuration. +# mailer: # SMTP mailer configuration. smtp: @@ -94,6 +101,7 @@ mailer: # auth: # user: # password: +# # Initializers Configuration # initializers: @@ -104,6 +112,7 @@ mailer: # Database Configuration +# database: # Database connection URI uri: {{get_env(name="DATABASE_URL", default="postgres://loco:loco@localhost:5432/loco_app")}} @@ -123,15 +132,19 @@ database: dangerously_truncate: false # Recreating schema when application loaded. This is a dangerous operation, make sure that you using this flag only on dev environments or test mode dangerously_recreate: false +# # Redis Configuration +# redis: # Redis connection URI uri: {{get_env(name="REDIS_URL", default="redis://127.0.0.1")}} # Dangerously flush all data in Redis on startup. dangerous operation, make sure that you using this flag only on dev environments or test mode dangerously_flush: false +# # Authentication Configuration +# auth: # JWT authentication jwt: @@ -139,3 +152,5 @@ auth: secret: PqRwLF2rhHe8J22oBeHy # Token expiration time in seconds expiration: 604800 # 7 days +# + diff --git a/snipdoc.yml b/snipdoc.yml new file mode 100644 index 000000000..1a7f61b14 --- /dev/null +++ b/snipdoc.yml @@ -0,0 +1,124 @@ +snippets: + description: + content: ๐Ÿš‚ Loco is Rust on Rails. + kind: Yaml + path: ./snipdoc.yml + loco-help-command: + content: |- + ```sh + cargo loco --help + ``` + kind: Yaml + path: ./snipdoc.yml + loco-build-command: + content: |- + ```sh + cargo build --release + ``` + kind: Yaml + path: ./snipdoc.yml + quick-installation-command: + content: |- + ```sh + cargo install loco-cli + cargo install sea-orm-cli # Only when DB is needed + ``` + kind: Yaml + path: ./snipdoc.yml + loco-cli-new-from-template: + content: |- + ```sh + โฏ loco new + โœ” โฏ App name? ยท myapp + โœ” โฏ What would you like to build? ยท SaaS app (with DB and user auth) + + ๐Ÿš‚ Loco app generated successfully in: + myapp + ``` + kind: Yaml + path: ./snipdoc.yml + postgres-run-docker-command: + content: |- + ```sh + docker run -d -p 5432:5432 \ + -e POSTGRES_USER=loco \ + -e POSTGRES_DB=myapp_development \ + -e POSTGRES_PASSWORD="loco" \ + postgres:15.3-alpine + ``` + kind: Yaml + path: ./snipdoc.yml + redis-run-docker-command: + content: |- + ```sh + docker run -p 6379:6379 -d redis redis-server + ``` + kind: Yaml + path: ./snipdoc.yml + starting-the-server-command: + content: |- + ```sh + cargo loco start + ``` + kind: Yaml + path: ./snipdoc.yml + starting-the-server-command-with-environment-env-var: + content: |- + ```sh + LOCO_ENV=qa cargo loco start + ``` + kind: Yaml + path: ./snipdoc.yml + starting-the-server-command-with-output: + content: |- + ```sh + $ cargo loco start + + โ–„ โ–€ + โ–€ โ–„ + โ–„ โ–€ โ–„ โ–„ โ–„โ–€ + โ–„ โ–€โ–„โ–„ + โ–„ โ–€ โ–€ โ–€โ–„โ–€โ–ˆโ–„ + โ–€โ–ˆโ–„ + โ–„โ–„โ–„โ–„โ–„โ–„โ–„ โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„ โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„ โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„ โ–€โ–€โ–ˆ + โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–€โ–ˆ + โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–€โ–€โ–€ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–„โ–ˆโ–„ + โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–„ + โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–„โ–„โ–„ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ + โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–€ + โ–€โ–€โ–€โ–ˆโ–ˆโ–„ โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€ โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€ โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€ โ–ˆโ–ˆโ–€ + โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€ + https://loco.rs + + listening on port 3000 + ``` + kind: Yaml + path: ./snipdoc.yml + doctor-command: + content: |- + ```sh + $ cargo loco doctor + Finished dev [unoptimized + debuginfo] target(s) in 0.32s + Running `target/debug/myapp-cli doctor` + โœ… SeaORM CLI is installed + โœ… DB connection: success + โœ… Redis connection: success + ``` + kind: Yaml + path: ./snipdoc.yml + generate-deployment-command: + content: |- + ```sh + cargo loco generate deployment + ? โฏ Choose your deployment โ€บ + โฏ Docker + โฏ Shuttle + โฏ Nginx + + .. + โœ” โฏ Choose your deployment ยท Docker + skipped (exists): "dockerfile" + added: ".dockerignore" + ``` + kind: Yaml + path: ./snipdoc.yml diff --git a/src/lib.rs b/src/lib.rs index a62787694..29f47c3b8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,118 +1,6 @@ #![allow(clippy::missing_const_for_fn)] #![allow(clippy::module_name_repetitions)] -// -//!
-//! -//! -//! -//!

Loco

-//! -//!

๐Ÿš‚ Loco is "Rust on Rails".

-//! -//! [![crate](https://img.shields.io/crates/v/loco-rs.svg)](https://crates.io/crates/loco-rs) -//! [![docs](https://docs.rs/loco-rs/badge.svg)](https://docs.rs/loco-rs) -//! [![Discord channel](https://img.shields.io/badge/discord-Join-us)](https://discord.gg/fTvyBzwKS8) -//! -//!
-//! -//! # Loco -//! -//! #### Loco is strongly inspired by Rails. If you know Rails and Rust, you'll feel at home. If you only know Rails and new to Rust, you'll find Loco refreshing. We do not assume you know Rails. -//! -//! ## Quick Start -// -//! ```sh -//! $ cargo install loco-cli -//! $ cargo install sea-orm-cli # Only when DB is needed -//! ``` -//! -//! Now you can create your new app (choose "`SaaS` app"). -//! -//! ```sh -//! $ loco new -//! โœ” โฏ App name? ยท myapp -//! ? โฏ What would you like to build? โ€บ -//! lightweight-service (minimal, only controllers and views) -//! Rest API (with DB and user auth) -//! โฏ SaaS app (with DB and user auth) -//! ๐Ÿš‚ Loco app generated successfully in: -//! myapp -//! ``` -//! -//!
-//! To configure a database , please run a local postgres database with -//! loco:loco and a db named is the [insert app]_development. -//!
-//! -//! You can use Docker to run a Postgres instance: -//! -//! When generating a starter, the database name incorporates your application -//! name and the environment. For instance, if you include `myapp`, the database -//! name in the `test.yaml`configuration will be `myapp_test`, and in the -//! `development.yaml` configuration, it will be `myapp_development`. -//! -//! -//! -//! A more advanced set of `docker-compose.yml` and `Dockerfiles` that include Redis and the `mailtutan` mailer are available for [each starter on GitHub](https://github.com/loco-rs/loco/blob/master/starters/saas/.devcontainer/docker-compose.yml). -//! -//! Now `cd` into your `myapp` and start your app: -//! -//! ``` -//! $ cd myapp -//! $ cargo loco start -//! Finished dev [unoptimized + debuginfo] target(s) in 21.63s -//! Running `target/debug/myapp start` -//! -//! : -//! : -//! : -//! -//! controller/app_routes.rs:203: [Middleware] Adding log trace id -//! -//! โ–„ โ–€ -//! โ–€ โ–„ -//! โ–„ โ–€ โ–„ โ–„ โ–„โ–€ -//! โ–„ โ–€โ–„โ–„ -//! โ–„ โ–€ โ–€ โ–€โ–„โ–€โ–ˆโ–„ -//! โ–€โ–ˆโ–„ -//! โ–„โ–„โ–„โ–„โ–„โ–„โ–„ โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„ โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„ โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„ โ–€โ–€โ–ˆ -//! โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–€โ–ˆ -//! โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–€โ–€โ–€ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–„โ–ˆโ–„ -//! โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–„ -//! โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–„โ–„โ–„ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ -//! โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–€ -//! โ–€โ–€โ–€โ–ˆโ–ˆโ–„ โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€ โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€ โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€ โ–ˆโ–ˆโ–€ -//! โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€ -//! -//! started on port 3000 -//! ``` -//! -//!
-//! You don't have to run things through `cargo` but in development it's highly -//! recommended. If you build `--release`, your binary contains everything -//! including your code and `cargo` or Rust is not needed.
-//
-//! -//! ## Project Status -//! + Stateless APIs -//! + Complete `SaaS` products with user authentication -//! + Purpose-built services such as ML inference endpoints -//! + Full stack projects with separate frontend project integrated with Loco -//! + Hobby projects full-stack with backend and HTML frontend -//! -//! ## Powered by Loco -//! + [SpectralOps](https://spectralops.io) - various services powered by Loco -//! framework -//! + [Nativish](https://nativi.sh) - app backend powered by Loco framework -//! -//! ## Contributors โœจ -//! -//! Thanks goes to these wonderful people: -//! -//! -//! -//! -//
+#![doc = include_str!("../README.md")] pub use self::errors::Error; From 77306dc341297cede1996a9f3fb92ce3e96ad2ea Mon Sep 17 00:00:00 2001 From: Elad Kaplan Date: Mon, 27 May 2024 14:24:49 +0300 Subject: [PATCH 5/7] update docs --- docs-site/content/docs/getting-started/deployment.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs-site/content/docs/getting-started/deployment.md b/docs-site/content/docs/getting-started/deployment.md index 77e6aa959..b1e1cab69 100644 --- a/docs-site/content/docs/getting-started/deployment.md +++ b/docs-site/content/docs/getting-started/deployment.md @@ -113,10 +113,10 @@ logger: ``` -- Redis: +- Queue: ```yaml - redis: + queue: # Redis connection URI uri: {{get_env(name="REDIS_URL", default="redis://127.0.0.1")}} # Dangerously flush all data in Redis on startup. dangerous operation, make sure that you using this flag only on dev environments or test mode From 7246c028f8eace9d0e958ded989138c51d747bf1 Mon Sep 17 00:00:00 2001 From: Elad Kaplan Date: Mon, 27 May 2024 14:32:03 +0300 Subject: [PATCH 6/7] update docs --- CONTRIBUTING.md | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4dcc0fa4c..c40fa52a7 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -64,9 +64,19 @@ In case of cli changes we snapshot the binary commands. in case of changes run t LOCO_CI_MODE=true TRYCMD=overwrite cargo test ``` -## Running Docs website -The documentation website based on [zola](https://www.getzola.org/), and you can see the docs [here](./docs-site/). -then cd to `docs-site` and run `zola serve` +## Docs + +The documentation consists of two main components: + ++ The [loco.rs website](https://loco.rs) with its source code available [here](./docs-site/). ++ RustDocs. + +To reduce duplication in documentation and examples, we use [snipdoc](https://github.com/kaplanelad/snipdoc). As part of our CI process, we ensure that the documentation remains consistent. + +Updating the Documentation ++ Download [snipdoc](https://github.com/kaplanelad/snipdoc). ++ Create the snippet in the [yaml file](./snipdoc.yml) or inline the code. ++ Run `snipdoc run`. ## Open A Pull Request From 9179d3dbcc769ddaa6a106a313e8b1376d26d48f Mon Sep 17 00:00:00 2001 From: Elad Kaplan Date: Mon, 27 May 2024 15:00:53 +0300 Subject: [PATCH 7/7] more changes --- docs-site/content/docs/getting-started/cli.md | 2 +- docs-site/content/docs/getting-started/config.md | 2 +- .../content/docs/getting-started/deployment.md | 14 +++++++------- examples/demo/config/development.yaml | 14 +++++++------- snipdoc.yml | 16 ++-------------- 5 files changed, 18 insertions(+), 30 deletions(-) diff --git a/docs-site/content/docs/getting-started/cli.md b/docs-site/content/docs/getting-started/cli.md index 4d7c4a7bf..873760991 100644 --- a/docs-site/content/docs/getting-started/cli.md +++ b/docs-site/content/docs/getting-started/cli.md @@ -29,7 +29,7 @@ myapp Now `cd` into your app, set up a convenience `rr` alias and try out the various commands: - + ```sh cargo loco --help ``` diff --git a/docs-site/content/docs/getting-started/config.md b/docs-site/content/docs/getting-started/config.md index 4c460cb44..70f9cd305 100644 --- a/docs-site/content/docs/getting-started/config.md +++ b/docs-site/content/docs/getting-started/config.md @@ -70,7 +70,7 @@ LOCO_ENV=qa cargo loco start ## Settings The configuration files contain knobs to set up your Loco app. You can also have your custom settings, with the `settings:` section. in `config/development.yaml` add the `settings:` section - + ```yaml settings: allow_list: diff --git a/docs-site/content/docs/getting-started/deployment.md b/docs-site/content/docs/getting-started/deployment.md index b1e1cab69..bd127be30 100644 --- a/docs-site/content/docs/getting-started/deployment.md +++ b/docs-site/content/docs/getting-started/deployment.md @@ -17,7 +17,7 @@ Deployment is super simple in Loco, and this is why this guide is super short. A To deploy, build your production binary for your relevant server architecture: - + ```sh cargo build --release ``` @@ -35,7 +35,7 @@ There are a few configuration sections that are important to review and set acco - Logger: - + ```yaml # Application logging configuration logger: @@ -55,7 +55,7 @@ logger: - Server: - + ```yaml server: # Port on which the server will listen. the server binding is 0.0.0.0:{PORT} @@ -68,7 +68,7 @@ logger: - Database: - + ```yaml database: # Database connection URI @@ -94,7 +94,7 @@ logger: - Mailer: - + ```yaml mailer: # SMTP mailer configuration. @@ -114,7 +114,7 @@ logger: - Queue: - + ```yaml queue: # Redis connection URI @@ -125,7 +125,7 @@ logger: - JWT secret: - + ```yaml auth: # JWT authentication diff --git a/examples/demo/config/development.yaml b/examples/demo/config/development.yaml index 64a258cc9..ceb527184 100644 --- a/examples/demo/config/development.yaml +++ b/examples/demo/config/development.yaml @@ -1,13 +1,13 @@ # Loco configuration file documentation -# +# settings: allow_list: - google.com - apple.com # -# +# # Application logging configuration logger: # Enable or disable logging. @@ -24,7 +24,7 @@ logger: # # Web server configuration -# +# server: # Port on which the server will listen. the server binding is 0.0.0.0:{PORT} port: {{get_env(name="NODE_PORT", default=3000)}} @@ -86,7 +86,7 @@ workers: mode: BackgroundQueue # Mailer Configuration. -# +# mailer: # SMTP mailer configuration. smtp: @@ -112,7 +112,7 @@ mailer: # Database Configuration -# +# database: # Database connection URI uri: {{get_env(name="DATABASE_URL", default="postgres://loco:loco@localhost:5432/loco_app")}} @@ -135,7 +135,7 @@ database: # # Queue Configuration -# +# queue: # Redis connection URI uri: {{get_env(name="REDIS_URL", default="redis://127.0.0.1")}} @@ -144,7 +144,7 @@ queue: # # Authentication Configuration -# +# auth: # JWT authentication jwt: diff --git a/snipdoc.yml b/snipdoc.yml index 1a7f61b14..0883e2855 100644 --- a/snipdoc.yml +++ b/snipdoc.yml @@ -1,21 +1,18 @@ snippets: description: content: ๐Ÿš‚ Loco is Rust on Rails. - kind: Yaml path: ./snipdoc.yml - loco-help-command: + help-command: content: |- ```sh cargo loco --help ``` - kind: Yaml path: ./snipdoc.yml - loco-build-command: + build-command: content: |- ```sh cargo build --release ``` - kind: Yaml path: ./snipdoc.yml quick-installation-command: content: |- @@ -23,7 +20,6 @@ snippets: cargo install loco-cli cargo install sea-orm-cli # Only when DB is needed ``` - kind: Yaml path: ./snipdoc.yml loco-cli-new-from-template: content: |- @@ -35,7 +31,6 @@ snippets: ๐Ÿš‚ Loco app generated successfully in: myapp ``` - kind: Yaml path: ./snipdoc.yml postgres-run-docker-command: content: |- @@ -46,28 +41,24 @@ snippets: -e POSTGRES_PASSWORD="loco" \ postgres:15.3-alpine ``` - kind: Yaml path: ./snipdoc.yml redis-run-docker-command: content: |- ```sh docker run -p 6379:6379 -d redis redis-server ``` - kind: Yaml path: ./snipdoc.yml starting-the-server-command: content: |- ```sh cargo loco start ``` - kind: Yaml path: ./snipdoc.yml starting-the-server-command-with-environment-env-var: content: |- ```sh LOCO_ENV=qa cargo loco start ``` - kind: Yaml path: ./snipdoc.yml starting-the-server-command-with-output: content: |- @@ -92,7 +83,6 @@ snippets: listening on port 3000 ``` - kind: Yaml path: ./snipdoc.yml doctor-command: content: |- @@ -104,7 +94,6 @@ snippets: โœ… DB connection: success โœ… Redis connection: success ``` - kind: Yaml path: ./snipdoc.yml generate-deployment-command: content: |- @@ -120,5 +109,4 @@ snippets: skipped (exists): "dockerfile" added: ".dockerignore" ``` - kind: Yaml path: ./snipdoc.yml