+ [![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 loco-cli
+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
-โฏ App name? [myapp]:
-โฏ SaaS app (with DB and user auth)
- Stateless service (minimal, no db)
+โฏ loco new
+โ โฏ App name? ยท myapp
+โ โฏ What would you like to build? ยท 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 [insert app]_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
```
-$ docker run -d -p 5432:5432 -e POSTGRES_USER=loco -e POSTGRES_DB=myapp_development -e POSTGRES_PASSWORD="loco" postgres:15.3-alpine
-```
+
-Now `cd` into your `myapp` and start your app:
+ 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).
-```
-$ cd myapp
-$ cargo loco start
-Finished dev [unoptimized + debuginfo] target(s) in 21.63s
- Running `target/debug/myapp start`
-
- :
- :
- :
+ Now `cd` into your `myapp` and start your app:
-controller/app_routes.rs:203: [Middleware] Adding log trace id
+
+```sh
+$ cargo loco start
โ โ
- โ โ
+ โ โ
โ โ โ โ โโ
โ โโโ
โ โ โ โโโโโ
โโโ
โโโโโโโ โโโโโโโโโ โโโโโโโโโโโ โโโโโโโโโ โโโ
- โโโโโโ โโโโโ โโโ โโโโโ โโโ โโโโโ โโโ โโ
- โโโโโโ โโโโโ โโโ โโโโโ โโโ โโโโโ โโโ โโโ
- โโโโโโ โโโโโ โโโ โโโโโ โโโโโ โโโ โโโโโ
- โโโโโโ โโโโโ โโโ โโโโโ โโโ โโโโโ โโโ โโโโโ
- โโโโโโ โโโโโ โโโ โโโโ โโโ โโโโโ โโโ โโโโโ
- โโโโโโ โโโโโโโโโโ โโโโโโโโโโ โโโโโโโโโโ โโโ
- โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
-
-started on port 3000
+โโโโโโ โโโโโ โโโ โโโโโ โโโ โโโโโ โโโ โโ
+โโโโโโ โโโโโ โโโ โโโโโ โโโ โโโโโ โโโ โโโ
+โโโโโโ โโโโโ โโโ โโโโโ โโโโโ โโโ โโโโโ
+โโโโโโ โโโโโ โโโ โโโโโ โโโ โโโโโ โโโ โโโโโ
+โโโโโโ โโโโโ โโโ โโโโ โโโ โโโโโ โโโ โโโโโ
+ โโโโโโ โโโโโโโโโโ โโโโโโโโโโ โโโโโโโโโโ โโโ
+ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
+ https://loco.rs
+
+listening on port 3000
```
+
## Project Status
-
-Loco is feature complete, but features are still being added rapidly.
-
-### What can you build?
-
-- 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?
-
-- 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
++ 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
-
-[open an issue to add yourself here](https://github.com/loco-rs/loco/issues)
-
++ [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
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..873760991 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..70f9cd305 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..bd127be30 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
-```
-
-- Redis:
-
-```
-redis:
+ # SMTP server port
+ port: 1025
+ # Use secure connection (SSL/TLS).
+ secure: false
+ # auth:
+ # user:
+ # password:
+ ```
+
+
+- Queue:
+
+```yaml
+ queue:
# 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 c43841c48..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:
@@ -190,7 +187,7 @@ pub async fn echo(req_body: String) -> String {
req_body
}
-pub async fn hello(State(_ctx): State) -> Result {
+pub async fn hello(State(_ctx): State) -> Result {
// do something with context (database, etc)
format::text("hello")
}
@@ -205,14 +202,16 @@ pub fn routes() -> Routes {
Start the server:
+
```sh
-$ cargo loco start
+cargo loco start
```
+
Now, let's test it out:
```sh
-$ curl localhost:3000/api/guide
+$ curl localhost:3000/guide
hello
```
@@ -238,12 +237,12 @@ Next, set up a _hello_ route, this is the contents of `home.rs`:
use loco_rs::prelude::*;
// _ctx contains your database connection, as well as other app resource that you'll need
-async fn hello(State(_ctx): State) -> Result {
+async fn hello(State(_ctx): State) -> Result {
format::text("ola, mundo")
}
pub fn routes() -> Routes {
- Routes::new().prefix("api/home").add("/hello", get(hello))
+ Routes::new().prefix("home").add("/hello", get(hello))
}
```
@@ -276,14 +275,16 @@ 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`:
```sh
-$ curl localhost:3000/api/home/hello
+$ curl localhost:3000/home/hello
ola, mundo
```
@@ -297,7 +298,7 @@ $ cargo loco routes
[POST] /api/auth/register
[POST] /api/auth/reset
[POST] /api/auth/verify
-[GET] /api/home/hello <---- this is our new route!
+[GET] /home/hello <---- this is our new route!
[GET] /api/notes
[POST] /api/notes
..
@@ -523,14 +524,16 @@ pub fn routes() -> Routes {
Now, start the app:
+
```sh
-$ cargo loco start
+cargo loco start
```
+
And make a request:
```sh
-$ curl localhost:3000/api/articles
+$ curl localhost:3000/articles
[{"created_at":"...","updated_at":"...","id":1,"title":"how to build apps in 3 steps","content":"use Loco: https://loco.rs"}]
```
@@ -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:
@@ -638,14 +643,14 @@ Add a new article:
$ curl -X POST -H "Content-Type: application/json" -d '{
"title": "Your Title",
"content": "Your Content xxx"
-}' localhost:3000/api/articles
+}' localhost:3000/articles
{"created_at":"...","updated_at":"...","id":2,"title":"Your Title","content":"Your Content xxx"}
```
Get a list:
```sh
-$ curl localhost:3000/api/articles
+$ curl localhost:3000/articles
[{"created_at":"...","updated_at":"...","id":1,"title":"how to build apps in 3 steps","content":"use Loco: https://loco.rs"},{"created_at":"...","updated_at":"...","id":2,"title":"Your Title","content":"Your Content xxx"}
```
@@ -752,14 +757,14 @@ Now let's add a comment to Article `1`:
$ curl -X POST -H "Content-Type: application/json" -d '{
"content": "this rocks",
"article_id": 1
-}' localhost:3000/api/comments
+}' localhost:3000/comments
{"created_at":"...","updated_at":"...","id":4,"content":"this rocks","article_id":1}
```
And, fetch the relation:
```sh
-$ curl localhost:3000/api/articles/1/comments
+$ curl localhost:3000/articles/1/comments
[{"created_at":"...","updated_at":"...","id":4,"content":"this rocks","article_id":1}]
```
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 990351953..074a3e8db 100644
--- a/docs-site/content/docs/getting-started/tour/index.md
+++ b/docs-site/content/docs/getting-started/tour/index.md
@@ -19,73 +19,83 @@ 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
+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
-```
+ Now you can create your new app (choose "`SaaS` app").
-
-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? โบ
+ 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
+ ```
-You can use Docker to run a Postgres instance:
+
+ To configure a database , please run a local postgres database with
+ loco:loco and a db named is the [insert app]_development.
+
-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`.
+ 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`.
+
+
+```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
-```
+
-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:
+ 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).
-```
-$ cd myapp
-$ cargo loco start
-Finished dev [unoptimized + debuginfo] target(s) in 21.63s
- Running `target/debug/myapp start`
+ Now `cd` into your `myapp` and start your app:
- :
- :
- :
-
-controller/app_routes.rs:203: [Middleware] Adding log trace id
+
+```sh
+$ cargo loco start
โ โ
- โ โ
+ โ โ
โ โ โ โ โโ
โ โโโ
โ โ โ โโโโโ
โโโ
โโโโโโโ โโโโโโโโโ โโโโโโโโโโโ โโโโโโโโโ โโโ
- โโโโโโ โโโโโ โโโ โโโโโ โโโ โโโโโ โโโ โโ
- โโโโโโ โโโโโ โโโ โโโโโ โโโ โโโโโ โโโ โโโ
- โโโโโโ โโโโโ โโโ โโโโโ โโโโโ โโโ โโโโโ
- โโโโโโ โโโโโ โโโ โโโโโ โโโ โโโโโ โโโ โโโโโ
- โโโโโโ โโโโโ โโโ โโโโ โโโ โโโโโ โโโ โโโโโ
- โโโโโโ โโโโโโโโโโ โโโโโโโโโโ โโโโโโโโโโ โโโ
- โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
-
-started on port 3000
+โโโโโโ โโโโโ โโโ โโโโโ โโโ โโโโโ โโโ โโ
+โโโโโโ โโโโโ โโโ โโโโโ โโโ โโโโโ โโโ โโโ
+โโโโโโ โโโโโ โโโ โโโโโ โโโโโ โโโ โโโโโ
+โโโโโโ โโโโโ โโโ โโโโโ โโโ โโโโโ โโโ โโโโโ
+โโโโโโ โโโโโ โโโ โโโโ โโโ โโโโโ โโโ โโโโโ
+ โโโโโโ โโโโโโโโโโ โโโโโโโโโโ โโโโโโโโโโ โโโ
+ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
+ 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.
-
+
+ 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
@@ -110,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`:
@@ -121,13 +150,13 @@ Next, try adding a `post` with `curl`:
$ curl -X POST -H "Content-Type: application/json" -d '{
"title": "Your Title",
"content": "Your Content xxx"
-}' localhost:3000/api/posts
+}' localhost:3000/posts
```
You can list your posts:
```sh
-$ curl localhost:3000/api/posts
+$ curl localhost:3000/posts
```
For those counting -- the commands for creating a blog backend were:
@@ -147,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/content/docs/the-app/cache.md b/docs-site/content/docs/the-app/cache.md
new file mode 100644
index 000000000..ec590f161
--- /dev/null
+++ b/docs-site/content/docs/the-app/cache.md
@@ -0,0 +1,41 @@
++++
+title = "Cache"
+description = ""
+date = 2024-02-07T08:00:00+00:00
+updated = 2024-02-07T08:00:00+00:00
+draft = false
+weight = 20
+sort_by = "weight"
+template = "docs/page.html"
+
+[extra]
+lead = ""
+toc = true
+top = false
+flair =[]
++++
+
+`Loco` provides an cache layer to improve application performance by storing frequently accessed data.
+
+## Default Behavior
+
+By default, `Loco` initializes a `Null` cache driver. This means any interaction with the cache will return an error, effectively bypassing the cache functionality.
+
+## Enabling Caching
+
+To enable caching and configure a specific cache driver, you can replace the default `Null` driver with your preferred implementation.
+
+In your `app.rs` file, define a function named `after_context` function as a Hook in the `app.rs` file and import the `cache` module from `loco_rs`.
+
+Here's an example using an in-memory cache driver:
+
+```rust
+use loco_rs::cache;
+
+async fn after_context(ctx: AppContext) -> Result {
+ Ok(AppContext {
+ cache: cache::Cache::new(cache::drivers::inmem::new()).into(),
+ ..ctx
+ })
+}
+```
\ No newline at end of file
diff --git a/docs-site/content/docs/the-app/models.md b/docs-site/content/docs/the-app/models.md
index ecdf07416..70635dc55 100644
--- a/docs-site/content/docs/the-app/models.md
+++ b/docs-site/content/docs/the-app/models.md
@@ -103,9 +103,9 @@ For schema data types, you can use the following mapping to understand the schem
("int", "integer_null"),
("int!", "integer"),
("int^", "integer_uniq"),
-("big_integer", "big_integer_null"),
-("big_integer!", "big_integer"),
-("big_integer^", "big_integer_uniq"),
+("big_int", "big_integer_null"),
+("big_int!", "big_integer"),
+("big_int^", "big_integer_uniq"),
("float", "float_null"),
("float!", "float"),
("double", "double_null"),
diff --git a/docs-site/content/docs/the-app/storage.md b/docs-site/content/docs/the-app/storage.md
index 52284c81c..665fcb247 100644
--- a/docs-site/content/docs/the-app/storage.md
+++ b/docs-site/content/docs/the-app/storage.md
@@ -25,17 +25,17 @@ By default, in-memory and disk storage come out of the box. To work with cloud p
- `storage_gcp`
- `all_storage`
+By default loco initialize a `Null` provider, meaning any work with the storage will return an error.
+
## Setup
-Add the `storage` function as a Hook in the `app.rs` file and import the `storage` module from `loco_rs`.
+Add the `after_context` function as a Hook in the `app.rs` file and import the `storage` module from `loco_rs`.
```rust
use loco_rs::storage;
-impl Hooks for App {
- async fn storage(_config: &Config, environment: &Environment) -> Result