Skip to content

Commit

Permalink
Merge branch 'master' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
kaplanelad authored Jan 8, 2025
2 parents da42aa0 + 1eb04fb commit b92c656
Show file tree
Hide file tree
Showing 270 changed files with 7,960 additions and 2,412 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/loco-gen-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ jobs:
- name: Setup Rust cache
uses: Swatinem/rust-cache@v2

- name: Install seaorm cli
run: cargo install sea-orm-cli

- run: |
cargo install --path ../loco-new
Expand Down
11 changes: 5 additions & 6 deletions .github/workflows/loco-gen-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,9 @@ jobs:
DATABASE_URL: postgres://postgres:postgres@localhost:5432/postgres_test

- name: docker deployment
run: cargo run -- generate deployment
run: cargo run -- generate deployment --kind docker
working-directory: ./examples/demo
env:
LOCO_DEPLOYMENT_KIND: docker
REDIS_URL: redis://localhost:${{job.services.redis.ports[6379]}}
DATABASE_URL: postgres://postgres:postgres@localhost:5432/postgres_test

Expand Down Expand Up @@ -189,8 +188,8 @@ jobs:
double:double! \
decimal_null:decimal \
decimal:decimal! \
decimal_len_null:decimal_len \
decimal_len:decimal_len! \
decimal_len_null:decimal_len:8:24 \
decimal_len:decimal_len!:8:24 \
boolean_null:bool \
boolean:bool! \
timestamp_with_time_zone_null:tstz \
Expand Down Expand Up @@ -242,8 +241,8 @@ jobs:
double:double! \
decimal_null:decimal \
decimal:decimal! \
decimal_len_null:decimal_len \
decimal_len:decimal_len! \
decimal_len_null:decimal_len:8:24 \
decimal_len:decimal_len!:8:24 \
boolean_null:bool \
boolean:bool! \
timestamp_with_time_zone_null:tstz \
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/loco-new.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ on:
- master
paths:
- "loco-new/**"
- "loco-gen/**"
pull_request:
paths:
- "loco-new/**"
- "loco-gen/**"

env:
RUST_TOOLCHAIN: stable
Expand Down
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@

## Unreleased

* feat: smart migration generator. you can now generate migration based on naming them for creating a table, adding columns, references, join tables and more. [https://github.com/loco-rs/loco/pull/1086](https://github.com/loco-rs/loco/pull/1086)
* feat: `cargo loco routes` will now pretty-print routes
* fix: guard jwt error behind feature flag. [https://github.com/loco-rs/loco/pull/1032](https://github.com/loco-rs/loco/pull/1032)
* fix: logger file_appender not using the seperated format setting. [https://github.com/loco-rs/loco/pull/1036](https://github.com/loco-rs/loco/pull/1036)
* seed cli command. [https://github.com/loco-rs/loco/pull/1046](https://github.com/loco-rs/loco/pull/1046)
* Updated validator to 0.19. [https://github.com/loco-rs/loco/pull/993](https://github.com/loco-rs/loco/pull/993)
### Breaking Changes
Bump validator to 0.19 in your local `Cargo.toml`
* Testing helpers: simplified function calls + adding html selector. [https://github.com/loco-rs/loco/pull/1047](https://github.com/loco-rs/loco/pull/1047)
### Breaking Changes
#### Updated Import Paths
Expand All @@ -31,6 +34,20 @@
let boot = boot_test::<App>().await.unwrap();
```
* implement commands to manage background jobs. [https://github.com/loco-rs/loco/pull/1071](https://github.com/loco-rs/loco/pull/1071)
* magic link. [https://github.com/loco-rs/loco/pull/1085](https://github.com/loco-rs/loco/pull/1085)
* infer migration. [https://github.com/loco-rs/loco/pull/1086](https://github.com/loco-rs/loco/pull/1086)
* Remove unnecessary calls to 'register_tasks' functions in scheduler. [https://github.com/loco-rs/loco/pull/1100](https://github.com/loco-rs/loco/pull/1100)
* implement commands to manage background jobs. [https://github.com/loco-rs/loco/pull/1071](https://github.com/loco-rs/loco/pull/1071)
* expose hello_name for SMTP client config. [https://github.com/loco-rs/loco/pull/1057](https://github.com/loco-rs/loco/pull/1057)
* use reqwest with rustls rather than openssl. [https://github.com/loco-rs/loco/pull/1058](https://github.com/loco-rs/loco/pull/1058)
* more flexible config, take more values from ENV. [https://github.com/loco-rs/loco/pull/1058](https://github.com/loco-rs/loco/pull/1058)
* refactor: Use opendal to replace object_store. [https://github.com/loco-rs/loco/pull/897](https://github.com/loco-rs/loco/pull/897)
* allow override loco template. [https://github.com/loco-rs/loco/pull/1102](https://github.com/loco-rs/loco/pull/1102)
* support custom config folder. [https://github.com/loco-rs/loco/pull/1081](https://github.com/loco-rs/loco/pull/1081)
* feat: upgrade to Axum 8. [https://github.com/loco-rs/loco/pull/1130](https://github.com/loco-rs/loco/pull/1130)
* create load config hook. [https://github.com/loco-rs/loco/pull/1143](https://github.com/loco-rs/loco/pull/1143)
* initial impl new migration dsl. [https://github.com/loco-rs/loco/pull/1125](https://github.com/loco-rs/loco/pull/1125)
* allow disable limit_payload middleware. [https://github.com/loco-rs/loco/pull/1113](https://github.com/loco-rs/loco/pull/1113)


## v0.13.2
Expand Down
24 changes: 14 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ testing = ["dep:axum-test", "dep:scraper"]
with-db = ["dep:sea-orm", "dep:sea-orm-migration", "loco-gen/with-db"]
# Storage features
all_storage = ["storage_aws_s3", "storage_azure", "storage_gcp"]
storage_aws_s3 = ["object_store/aws"]
storage_azure = ["object_store/azure"]
storage_gcp = ["object_store/gcp"]
storage_aws_s3 = ["opendal/services-s3"]
storage_azure = ["opendal/services-azblob"]
storage_gcp = ["opendal/services-gcs"]
# Cache feature
cache_inmem = ["dep:moka"]
bg_redis = ["dep:rusty-sidekiq", "dep:bb8"]
Expand All @@ -54,7 +54,7 @@ backtrace_printer = { version = "1.3.0" }

# cli
clap = { version = "4.4.7", features = ["derive"], optional = true }
colored = "2"
colored = { workspace = true }
reqwest = { version = "0.12.7", features = [
"charset",
"http2",
Expand Down Expand Up @@ -85,13 +85,14 @@ toml = "0.8"
async-trait = { workspace = true }

axum = { workspace = true }
axum-extra = { version = "0.9", features = ["cookie"] }
axum-extra = { version = "0.10", features = ["cookie"] }
regex = { workspace = true }
fs-err = "2.11.0"
# mailer
tera = "1.19.1"
thousands = "0.2.0"
heck = "0.4.0"
cruet = "0.13.0"
lettre = { version = "0.11.4", default-features = false, features = [
"builder",
"hostname",
Expand Down Expand Up @@ -122,15 +123,18 @@ bytes = "1.1"
ipnetwork = "0.20.0"
semver = "1"

axum-test = { version = "16.1.0", optional = true }
axum-test = { version = "17.0.1", optional = true }

chrono = { workspace = true }
cfg-if = "1"

uuid = { version = "1.10.0", features = ["v4", "fast-rng"] }

# File Upload
object_store = { version = "0.11.0", default-features = false }
opendal = { version = "0.50.2", default-features = false, features = [
"services-memory",
"services-fs",
] }

# cache
moka = { version = "0.12.7", features = ["sync"], optional = true }
Expand All @@ -152,18 +156,18 @@ ulid = { version = "1", optional = true }
rusty-sidekiq = { version = "0.11.0", default-features = false, optional = true }
bb8 = { version = "0.8.1", optional = true }

scraper = { version = "0.21.0", optional = true }
scraper = { version = "0.21.0", features = ["deterministic"], optional = true }

[workspace.dependencies]

colored = { version = "2" }
chrono = { version = "0.4", features = ["serde"] }
tracing = "0.1.40"
regex = "1"
thiserror = "1"
serde = "1"
serde_json = "1"
async-trait = { version = "0.1.74" }
axum = { version = "0.7.5", features = ["macros"] }
axum = { version = "0.8.1", features = ["macros"] }
tower = "0.4"
tower-http = { version = "0.6.1", features = [
"trace",
Expand Down
2 changes: 1 addition & 1 deletion DEVELOPMENT.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## Blessed depdenencies maintenance and `loco doctor`
## Blessed dependencies maintenance and `loco doctor`

Loco contain a few major and "blessed" dependencies, these appear **both** in an app that was generated at the surface level in their `Cargo.toml` and in the core Loco framework.

Expand Down
2 changes: 1 addition & 1 deletion docs-site/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ pub async fn get_one(
pub fn routes() -> Routes {
Routes::new()
.prefix("notes")
.add("/:id", get(get_one))
.add("/{id}", get(get_one))
}
```
'''
Expand Down
17 changes: 7 additions & 10 deletions docs-site/content/docs/extras/authentication.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ $ cargo loco routes
[POST] /api/auth/login
[POST] /api/auth/register
[POST] /api/auth/reset
[POST] /api/auth/verify
[GET] /api/user/current
[GET] /api/auth/verify
[GET] /api/auth/current
.
.
.
Expand Down Expand Up @@ -101,11 +101,8 @@ Upon user registration, an email with a verification link is sent. Visiting this
#### Example Curl request:

```sh
curl --location '127.0.0.1:5150/api/auth/verify' \
--header 'Content-Type: application/json' \
--data '{
"token": "TOKEN"
}'
curl --location --request GET '127.0.0.1:5150/api/auth/verify/TOKEN' \
--header 'Content-Type: application/json'
```

### Reset Password Flow
Expand Down Expand Up @@ -144,7 +141,7 @@ curl --location '127.0.0.1:5150/api/auth/reset' \
This endpoint is protected by auth middleware.

```sh
curl --location --request GET '127.0.0.1:5150/api/user/current' \
curl --location --request GET '127.0.0.1:5150/api/auth/current' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer TOKEN'
```
Expand Down Expand Up @@ -195,8 +192,8 @@ $ cargo loco routes
[POST] /api/auth/login
[POST] /api/auth/register
[POST] /api/auth/reset
[POST] /api/auth/verify
[GET] /api/user/current
[GET] /api/auth/verify
[GET] /api/auth/current
.
.
.
Expand Down
1 change: 0 additions & 1 deletion docs-site/content/docs/getting-started/axum-users.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ In Loco you:
server:
middlewares:
limit_payload:
enable: true
body_limit: 5mb
# .. more middleware below ..
```
Expand Down
14 changes: 7 additions & 7 deletions docs-site/content/docs/getting-started/guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -582,9 +582,9 @@ pub fn routes() -> Routes {
.prefix("api/articles")
.add("/", get(list))
.add("/", post(add))
.add("/:id", get(get_one))
.add("/:id", delete(remove))
.add("/:id", patch(update))
.add("/{id}", get(get_one))
.add("/{id}", delete(remove))
.add("/{id}", patch(update))
}
```
Expand Down Expand Up @@ -674,9 +674,9 @@ pub fn routes() -> Routes {
.prefix("api/comments")
.add("/", post(add))
// .add("/", get(list))
// .add("/:id", get(get_one))
// .add("/:id", delete(remove))
// .add("/:id", patch(update))
// .add("/{id}", get(get_one))
// .add("/{id}", delete(remove))
// .add("/{id}", patch(update))
}
```
Expand All @@ -702,7 +702,7 @@ Now we need to fetch a relation in `src/controllers/articles.rs`. Add the follow
pub fn routes() -> Routes {
// ..
// ..
.add("/:id/comments", get(comments))
.add("/{id}/comments", get(comments))
}
```
Expand Down
27 changes: 16 additions & 11 deletions docs-site/content/docs/the-app/controller.md
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ This is the stack in `development` mode:
```sh
$ cargo loco middleware --config

limit_payload {"enable":true,"body_limit":2000000}
limit_payload {"body_limit":{"Limit":1000000}}
cors {"enable":true,"allow_origins":["any"],"allow_headers":["*"],"allow_methods":["*"],"max_age":null,"vary":["origin","access-control-request-method","access-control-request-headers"]}
catch_panic {"enable":true}
etag {"enable":true}
Expand All @@ -294,8 +294,6 @@ Take what ever is enabled, and use `enable: false` with the relevant field. If `
```yaml
server:
middlewares:
limit_payload:
enable: false
cors:
enable: false
catch_panic:
Expand All @@ -317,7 +315,6 @@ $ cargo loco middleware --config
powered_by {"ident":"loco.rs"}


limit_payload (disabled)
cors (disabled)
catch_panic (disabled)
etag (disabled)
Expand Down Expand Up @@ -354,7 +351,7 @@ The result:
```sh
$ cargo loco middleware --config

limit_payload {"enable":true,"body_limit":2000000}
limit_payload {"body_limit":{"Limit":1000000}}
cors {"enable":true,"allow_origins":["any"],"allow_headers":["*"],"allow_methods":["*"],"max_age":null,"vary":["origin","access-control-request-method","access-control-request-headers"]}
catch_panic {"enable":true}
etag {"enable":true}
Expand All @@ -372,7 +369,6 @@ Let's change the request body limit to `5mb`. When overriding a middleware confi
```yaml
middlewares:
limit_payload:
enable: true
body_limit: 5mb
```
Expand All @@ -381,7 +377,7 @@ The result:
```sh
$ cargo loco middleware --config

limit_payload {"enable":true,"body_limit":5000000}
limit_payload {"body_limit":{"Limit":5000000}}
cors {"enable":true,"allow_origins":["any"],"allow_headers":["*"],"allow_methods":["*"],"max_age":null,"vary":["origin","access-control-request-method","access-control-request-headers"]}
catch_panic {"enable":true}
etag {"enable":true}
Expand Down Expand Up @@ -480,19 +476,28 @@ To disable the middleware edit the configuration as follows:
## Limit Payload
Restricts the maximum allowed size for HTTP request payloads.
The middleware by default is enabled and configured to 2MB.
The Limit Payload middleware restricts the maximum allowed size for HTTP request payloads. By default, it is enabled and configured with a 2MB limit.
You can disable or customize this behavior in your config file. You can set a few options:
You can customize or disable this behavior through your configuration file.
### Set a custom limit
```yaml
#...
middlewares:
limit_payload:
enable: true
body_limit: 5mb
```
### Disable payload size limitation
To remove the restriction entirely, set `body_limit` to `disable`:
```yaml
#...
middlewares:
limit_payload:
body_limit: disable
```


##### Usage
In your controller parameters, use `axum::body::Bytes`.
```rust
Expand Down
Loading

0 comments on commit b92c656

Please sign in to comment.