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 Nov 27, 2024
2 parents 976c92d + e1b0392 commit 75fd97e
Show file tree
Hide file tree
Showing 44 changed files with 291 additions and 279 deletions.
26 changes: 26 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,32 @@

## Unreleased

## v0.13.2

* static fallback now returns 200 and not 404 [https://github.com/loco-rs/loco/pull/991](https://github.com/loco-rs/loco/pull/991)
* cache system now has expiry [https://github.com/loco-rs/loco/pull/1006](https://github.com/loco-rs/loco/pull/1006)
* fixed: http interface binding [https://github.com/loco-rs/loco/pull/1007](https://github.com/loco-rs/loco/pull/1007)
* JWT claims now editable and public [https://github.com/loco-rs/loco/issues/988](https://github.com/loco-rs/loco/issues/988)
* CORS now not enabled in dev mode to avoid friction [https://github.com/loco-rs/loco/pull/1009](https://github.com/loco-rs/loco/pull/1009)
* fixed: task code generation now injects in all cases [https://github.com/loco-rs/loco/pull/1012](https://github.com/loco-rs/loco/pull/1012)

**BREAKING**
In your `app.rs` add the following injection comment at the bottom:

```rust
fn register_tasks(tasks: &mut Tasks) {
tasks.register(tasks::user_report::UserReport);
tasks.register(tasks::seed::SeedData);
tasks.register(tasks::foo::Foo);
// tasks-inject (do not remove)
}
```
* fix: seeding now sets autoincrement fields in the relevant DBs [https://github.com/loco-rs/loco/pull/1014](https://github.com/loco-rs/loco/pull/1014)
* fix: avoid generating entities from queue tables when the queue backend is database based [https://github.com/loco-rs/loco/issues/1013](https://github.com/loco-rs/loco/issues/1013)
* removed: channels moved to an initializer [https://github.com/loco-rs/loco/issues/892](https://github.com/loco-rs/loco/issues/892)
**BREAKING**
See how this looks like in [https://github.com/loco-rs/chat-rooms](https://github.com/loco-rs/chat-rooms)

## v0.13.0

* Added SQLite background job support [https://github.com/loco-rs/loco/pull/969](https://github.com/loco-rs/loco/pull/969)
Expand Down
18 changes: 4 additions & 14 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ license = "Apache-2.0"

[package]
name = "loco-rs"
version = "0.13.1"
version = "0.13.2"
description = "The one-person framework for Rust"
homepage = "https://loco.rs/"
documentation = "https://docs.rs/loco-rs"
Expand All @@ -35,7 +35,6 @@ auth_jwt = ["dep:jsonwebtoken"]
cli = ["dep:clap"]
testing = ["dep:axum-test"]
with-db = ["dep:sea-orm", "dep:sea-orm-migration", "loco-gen/with-db"]
channels = ["dep:socketioxide"]
# Storage features
all_storage = ["storage_aws_s3", "storage_azure", "storage_gcp"]
storage_aws_s3 = ["object_store/aws"]
Expand All @@ -48,7 +47,7 @@ bg_pg = ["dep:sqlx", "dep:ulid"]
bg_sqlt = ["dep:sqlx", "dep:ulid"]

[dependencies]
loco-gen = { version = "0.13.0", path = "./loco-gen" }
loco-gen = { version = "0.13.2", path = "./loco-gen" }
backtrace_printer = { version = "1.3.0" }

# cli
Expand Down Expand Up @@ -82,6 +81,7 @@ regex = { workspace = true }
fs-err = "2.11.0"
# mailer
tera = "1.19.1"
thousands = "0.2.0"
heck = "0.4.0"
lettre = { version = "0.11.4", default-features = false, features = [
"builder",
Expand Down Expand Up @@ -120,10 +120,6 @@ cfg-if = "1"

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

# A socket.io server implementation
socketioxide = { version = "0.14.0", features = ["state"], optional = true }


# File Upload
object_store = { version = "0.11.0", default-features = false }

Expand Down Expand Up @@ -185,16 +181,10 @@ features = [
features = ["testing"]

[dev-dependencies]
cargo_metadata = "0.18.1"
loco-rs = { path = ".", features = ["testing"] }
rstest = "0.21.0"
insta = { version = "1.34.0", features = ["redactions", "yaml", "filters"] }
tree-fs = { version = "0.1.0" }
tree-fs = { version = "0.2.1" }
reqwest = { version = "0.12.7" }
serial_test = "3.1.1"
tower = { workspace = true, features = ["util"] }

# generator tests
tempfile = "3"
duct_sh = { version = "0.13.7" }
syn = { version = "2", features = ["full"] }
87 changes: 0 additions & 87 deletions docs-site/content/docs/extras/channels.md

This file was deleted.

19 changes: 19 additions & 0 deletions docs-site/content/docs/extras/websocket.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
+++
title = "Websocket"
description = ""
date = 2024-01-21T18:20:00+00:00
updated = 2024-01-21T18:20:00+00:00
draft = false
weight = 2
sort_by = "weight"
template = "docs/page.html"

[extra]
lead = ""
toc = true
top = false
flair =[]
+++

## Chat Room Example
For a simple example of a chat room implementation with [socketioxide](https://github.com/Totodore/socketioxide), refer to this [link](https://github.com/loco-rs/chat-rooms).
1 change: 0 additions & 1 deletion docs-site/content/docs/getting-started/guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ Here's a rundown of what Loco creates for you by default:
| `tasks/` | Contains your day to day business-oriented tasks such as sending emails, producing business reports, db maintenance, etc. |
| `tests/` | Your app-wide tests: models, requests, etc. |
| `config/` | A stage-based configuration folder: development, test, production |
| `channels/` | Contains all channels routes. |
## Hello, Loco!
Expand Down
7 changes: 7 additions & 0 deletions docs-site/content/docs/the-app/views.md
Original file line number Diff line number Diff line change
Expand Up @@ -301,3 +301,10 @@ impl Hooks for App {
}
// ...
```

### Tera Built-ins

Loco includes Tera with its [built-ins](https://keats.github.io/tera/docs/#built-ins) functions. In addition, Loco introduces the following custom built-in functions:

To see Loco built-in function:
* [numbers](https://docs.rs/loco-rs/latest/loco_rs/controller/views/tera_builtins/filters/number/index.html)
4 changes: 2 additions & 2 deletions loco-gen/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "loco-gen"
version = "0.13.0"
version = "0.13.2"
description = "Loco generators"
license.workspace = true
edition.workspace = true
Expand All @@ -27,5 +27,5 @@ dialoguer = "0.11"
duct = "0.13"

[dev-dependencies]
tempfile = "3"
tree-fs = { version = "0.2.1" }
syn = { version = "2", features = ["full"] }
5 changes: 2 additions & 3 deletions loco-gen/src/testutil.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ use std::{
};

use regex::Regex;
use tempfile::tempdir;

// Define the custom struct to encapsulate file content
pub struct FileContent {
Expand Down Expand Up @@ -249,8 +248,8 @@ where
let previous = env::current_dir()?; // Get the current directory
println!("Current directory: {previous:?}");

let temp_dir = tempdir()?; // Create a temporary directory
let current = temp_dir.path();
let tree_fs = tree_fs::TreeBuilder::default().drop(true).create()?; // Create a temporary directory
let current = &tree_fs.root;

println!("Temporary directory: {current:?}");
env::set_current_dir(current)?; // Set the current directory to the temp directory
Expand Down
2 changes: 1 addition & 1 deletion loco-new/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[package]
name = "loco"
version = "0.13.2"
version = "0.13.3"
edition = "2021"
description = "Loco new app generator"
license = "Apache-2.0"
Expand Down
2 changes: 1 addition & 1 deletion loco-new/base_template/config/development.yaml.t
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ mailer:
# Database Configuration
database:
# Database connection URI
uri: {% raw %}{{{% endraw %} get_env(name="DATABASE_URL", default="{{settings.db.endpoint}}") {% raw %}}}{% endraw %}
uri: {% raw %}{{{% endraw %} get_env(name="DATABASE_URL", default="{{settings.db.endpoint | replace(from='NAME', to=settings.package_name) | replace(from='ENV', to='development')}}") {% raw %}}}{% endraw %}
# When enabled, the sql query will be logged.
enable_logging: false
# Set the timeout duration when acquiring a connection.
Expand Down
2 changes: 1 addition & 1 deletion loco-new/base_template/config/test.yaml.t
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ mailer:
# Database Configuration
database:
# Database connection URI
uri: {% raw %}{{{% endraw %} get_env(name="DATABASE_URL", default="{{settings.db.endpoint}}") {% raw %}}}{% endraw %}
uri: {% raw %}{{{% endraw %} get_env(name="DATABASE_URL", default="{{settings.db.endpoint | replace(from='NAME', to=settings.package_name) | replace(from='ENV', to='test')}}") {% raw %}}}{% endraw %}
# When enabled, the sql query will be logged.
enable_logging: false
# Set the timeout duration when acquiring a connection.
Expand Down
2 changes: 1 addition & 1 deletion loco-new/devnew.sh
Original file line number Diff line number Diff line change
@@ -1 +1 @@
LOCO_DEV_MODE_PATH=../../ loco new
LOCO_DEV_MODE_PATH=../../ cargo run -- new
2 changes: 1 addition & 1 deletion loco-new/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pub mod wizard;
pub type Result<T> = std::result::Result<T, Error>;

/// Matching minimal Loco version.
pub const LOCO_VERSION: &str = "0.13";
pub const LOCO_VERSION: &str = "0.13.2";

#[derive(thiserror::Error, Debug)]
pub enum Error {
Expand Down
4 changes: 2 additions & 2 deletions loco-new/src/wizard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ impl DBOption {
#[must_use]
pub const fn endpoint_config(&self) -> &str {
match self {
Self::Sqlite => "sqlite://loco_app.sqlite?mode=rwc",
Self::Postgres => "postgres://loco:loco@localhost:5432/loco_app",
Self::Sqlite => "sqlite://NAME_ENV.sqlite?mode=rwc",
Self::Postgres => "postgres://loco:loco@localhost:5432/NAME_ENV",
Self::None => "",
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
source: loco-new/tests/templates/auth.rs
source: tests/templates/auth.rs
expression: "std::fs::read_to_string(generator.path(\"src/app.rs\")).expect(\"could not open file\")"
snapshot_kind: text
---
use async_trait::async_trait;
use loco_rs::{
Expand Down Expand Up @@ -51,5 +52,6 @@ impl Hooks for App {
Ok(())
}
fn register_tasks(_tasks: &mut Tasks) {
// tasks-inject (do not remove)
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
source: loco-new/tests/templates/auth.rs
source: tests/templates/auth.rs
expression: "std::fs::read_to_string(generator.path(\"src/app.rs\")).expect(\"could not open file\")"
snapshot_kind: text
---
use async_trait::async_trait;
use loco_rs::{
Expand Down Expand Up @@ -51,5 +52,6 @@ impl Hooks for App {
Ok(())
}
fn register_tasks(_tasks: &mut Tasks) {
// tasks-inject (do not remove)
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
source: loco-new/tests/templates/background.rs
source: tests/templates/background.rs
expression: "std::fs::read_to_string(generator.path(\"src/app.rs\")).expect(\"could not open file\")"
snapshot_kind: text
---
use async_trait::async_trait;
use loco_rs::{
Expand Down Expand Up @@ -54,5 +55,6 @@ impl Hooks for App {
Ok(())
}
fn register_tasks(_tasks: &mut Tasks) {
// tasks-inject (do not remove)
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
source: loco-new/tests/templates/background.rs
source: tests/templates/background.rs
expression: "std::fs::read_to_string(generator.path(\"src/app.rs\")).expect(\"could not open file\")"
snapshot_kind: text
---
use async_trait::async_trait;
use loco_rs::{
Expand Down Expand Up @@ -54,5 +55,6 @@ impl Hooks for App {
Ok(())
}
fn register_tasks(_tasks: &mut Tasks) {
// tasks-inject (do not remove)
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
source: loco-new/tests/templates/background.rs
source: tests/templates/background.rs
expression: "std::fs::read_to_string(generator.path(\"src/app.rs\")).expect(\"could not open file\")"
snapshot_kind: text
---
use async_trait::async_trait;
use loco_rs::{
Expand Down Expand Up @@ -51,5 +52,6 @@ impl Hooks for App {
Ok(())
}
fn register_tasks(_tasks: &mut Tasks) {
// tasks-inject (do not remove)
}
}
Loading

0 comments on commit 75fd97e

Please sign in to comment.