- Fix
cargo fmterror inloco-new(#1669) - Fix UUID pattern in form field generation (#1665)
- Add tests for auth extractor (#1671)
- Fix Clippy warnings for Rust 1.92 (#1705)
- Add email headers support to mailer (#1700)
- Wrap
TeraViewinArcto reduce runtime memory usage (#1703) - Allow overriding a secure header (#1659)
- Add βcreate userβ task (#1670)
- Add
UuidUniqWithDefaultandUuidWithDefaulttypes (#1642) - Refactor users model to reuse
find_by_api_keyinAuthenticable(#1706) - Split error detail generic parameters (#1709)
- Update
loco-newfor new Rhai version (#1704)
In file src/initializers/view_engine.rs, modify the code lines in after_routes:
Before
async fn after_routes(&self, router: AxumRouter, _ctx: &AppContext) -> Result<AxumRouter> {
:
engines::TeraView::build()?.post_process(move |tera| {
:After (use build_with_post_process instead of post_process)
async fn after_routes(&self, router: AxumRouter, _ctx: &AppContext) -> Result<AxumRouter> {
:
engines::TeraView::build_with_post_process(move |tera| {
:
}- Feat: decouple JWT authentication from database dependency. #1546
- Fix: add sqlx dependency to with-db feature. #1557
- Remove the deprecated
--linkgenerate command and fix the table name creation. #1556 - Support underscore for migration join table. #1562
- Fix: resolve deployment CLI argument parsing issue. #1566
- Add database enum support (Postgres only). https://github.com/loco-rs/loco/pull/1593
- Remove duplicated #[async_trait::async_trait]. https://github.com/loco-rs/loco/pull/1593
- Clippy fixes for Rust 1.89. #1593
- Improvement: do not hot-reload unless files have changed. #1552
- Feat: add --without-tz flag for controlling timestamp generation. #1592
- Support extra fields when generating the join table migration. #1595
- Convert validator to trait-based API (add ValidatorTrait, keep derive adapter, update docs). #1597
- Rename dockerfile to Dockerfile. #1574
- Enable edit CORS expose headers. #1599
- Adding new imports about multipart. #1600
- Adding readiness default endpoint. #1563
- Add Route methods to make collecting and nesting easier. #1608
- Add streaming support for both download and upload. #1610
- Fix Clippy for Rust 1.90. #1630
- Loco CLI: Update rhai version. #1631
- Support nullable foreign keys with
references?syntax. #1544 - HOTFIX: Breaking changes Fixed a critical issue introduced in version
v0.16.2that causedcargo build --releaseto fail after merging #1540. #1551 - Add an API to re-send verification mail. #1456
- Adding to ci cargo build --release. #1553
In file src/initializers/view_engine.rs, modify the method after_routes:
Before
async fn after_routes(&self, router: AxumRouter, _ctx: &AppContext) -> Result<AxumRouter> {
#[allow(unused_mut)]
let mut tera_engine = engines::TeraView::build()?;
if std::path::Path::new(I18N_DIR).exists() {
let arc = ArcLoader::builder(&I18N_DIR, unic_langid::langid!("en-US"))
.shared_resources(Some(&[I18N_SHARED.into()]))
.customize(|bundle| bundle.set_use_isolating(false))
.build()
.map_err(|e| Error::string(&e.to_string()))?;
#[cfg(debug_assertions)]
tera_engine
.tera
.lock()
.expect("lock")
.register_function("t", FluentLoader::new(arc));
#[cfg(not(debug_assertions))]
tera_engine
.tera
.register_function("t", FluentLoader::new(arc));
info!("locales loaded");
}
Ok(router.layer(Extension(ViewEngine::from(tera_engine))))
}After (use post_process to add i18n initialization code)
async fn after_routes(&self, router: AxumRouter, _ctx: &AppContext) -> Result<AxumRouter> {
let tera_engine = if std::path::Path::new(I18N_DIR).exists() {
let arc = std::sync::Arc::new(
ArcLoader::builder(&I18N_DIR, unic_langid::langid!("en-US"))
.shared_resources(Some(&[I18N_SHARED.into()]))
.customize(|bundle| bundle.set_use_isolating(false))
.build()
.map_err(|e| Error::string(&e.to_string()))?,
);
info!("locales loaded");
engines::TeraView::build()?.post_process(move |tera| {
tera.register_function("t", FluentLoader::new(arc.clone()));
Ok(())
})?
} else {
engines::TeraView::build()?
};
Ok(router.layer(Extension(ViewEngine::from(tera_engine))))
}- Update auth import in the Authentication document. #1531
- Adding cache control header to the static asset middleware. #1535
- Fix borrow checker when sending config to handle_job_command when feature with-db is off. #1536
- feat: add initializer health checks to doctor command. #1537
- Update shuttle template to 0.56. #1518
- Encapsulate post-processing into Tera engine creation. #1540
- Adding QueryValidateWithMessage. #1521
- Add S3 driver with credentials and endpoint support. #1539
- fix clippy result_large_err. #1496
- chore: remove async-std. #1492
- fix: Bump shuttle version to 0.55.0. #1488
- Change the Docker building image to 1.87. #1475
- Fix Clippy warnings for Rust 1.88 stable. #1519
- Remove Migrator from boot_test_* doc comments. #1512
- fix: use rust-lld linker on Windows. #1508
- Fix precompressed in static assets. #1524
- Support multiple JWT locations. #1497
Note: For detailed upgrade steps for breaking changes, see the upgrade guide.
- chore: improve readability and performance by using map_err in Model. #1311
- Allow testing the controller by passing a cookie. #1326
- Support BigInt in the scaffold Array. #1304
- Add
escapeTera function to the scaffold list template. #1337 - Return a specific error when logging in with a non-existent email. #1336
- Return a specific error when trying to verify with an invalid token. #1340
- Clippy 1.86. #1353
- Fix the DB creation. #1352
- YAML responses. #1360
- Swap to the validators' built-in email validation. #1359
- Cancellation tokens for the Postgres and SQLite background workers. #1365
- docs: testing auth routes. #1303
- Add comprehensive tests for the task module. #1386
- Add comprehensive test coverage for the data module. #1387
- Add validator extractors test suite. #1388
- Breaking changes Replace sidekiq job management: existing Redis jobs incompatible. #1384
- Breaking changes Add generic type support to the Cache API: cache method calls need type parameters. #1385
- Adding cache redis driver + configuration instead of enabling from code. #1389
- Ability to configure pragma for SQLite. #1346
- Breaking changes swap to validators builtin email validation: custom email validator syntax changed. #1359
- Optimize worker tag filtering string handling. #1396
- Add test coverage for db.rs. #1400
- Allow storage of arbitrary custom objects in AppContext. #1404
- Improve deployment generator CLI. #1413
- Move auth and validate to the extractor folder. #1414
- Hot reload on extended Tera templates. #1416
- Breaking changes Update the
init_loggerto useAppContextinstead of config: function signature changed. #1418 - Support embedded assets. #1427
- Removed dependencies:
- Dependency updates:
- Support custom flags from
sea-orm entity. #1442 - Better
loco newcleanup folders. #1429 - Remove legacy mailer derive macro code. #1472
- Make extract_token and get_jwt_from_config fn public. #1495
- Added total_items to pagination view & response. #1197
- Flatten (de)serialization of custom user claims. #1159
- Updated validator to 0.20. #1199
- Scaffold v2. #1209
- Fix generator Docker deployment to support both server-side and client-side rendering. #1227
- Docs: num_workers worker configuration. #1242
- Smoother model validations. #1233
- Docs: num_workers worker configuration. #1242
- Ignore SQLite WAL and SHM files and update Cargo watch crate docs. #1254
- Remove fs-err crate. #1253
- Allows to run scheduler as part of cargo loco start. #1247
- Added prefix and route nesting to AppRoutes. #1241
- Replace hyper crate with axum. #1258
- Remove mime crate. #1256
- Support async tests. #1237
- Change job queue status from cli. #1228
- Handle panics in queue worker. #1274
- Schema with defaults. #1273
- Add data subsystem. #1267
- Add "endpoint" arg to azure storage builder.#1317
- Improve readability and performance by using map_err in Model. #1311
In module loco_rs::auth::jwt in struct JWT, the impl method generate_token signature has changed.
Migration:
Before
jwt.generate_token(&expiration, pid.clone(), None);After
jwt.generate_token(expiration, pid.clone(), Map::new());
// ^ no "&" ^ serde_json::map (doesn't allocate in constructor)- Fix: bump shuttle to 0.51.0. #1169
- Return 422 status code for JSON rejection errors. #1173
- Address clippy warnings for Rust stable 1.84. #1168
- Bump shuttle to 0.51.0. #1169
- Return 422 status code for JSON rejection errors. #1173
- Return json validation details response. #1174
- Fix example command after generating schedule. #1176
- Fixed independent features. #1177
- Custom response header for redirect. #1186
- Added run_on_start feature to scheduler. #1184
- feat: public jwt extractor from non-mutable reference to parts. #1190
-
feat: smart migration generator. you can now generate migration based on naming them for creating a table, adding columns, references, join tables and more. #1086
-
feat:
cargo loco routeswill now pretty-print routes -
fix: guard jwt error behind feature flag. #1032
-
fix: logger file_appender not using the seperated format setting. #1036
-
seed cli command. #1046
-
Updated validator to 0.19. #993
Bump validator to 0.19 in your local
Cargo.toml -
Testing helpers: simplified function calls + adding html selector. #1047
The testing module import path has been updated. To adapt your code, update imports from:
use loco_rs::testing;
to:
use testing::prelude::*;
Function calls within the testing module no longer require the testing:: prefix. Update your code accordingly. For example:
Before:
let boot = testing::boot_test::<App>().await.unwrap();
After:
let boot = boot_test::<App>().await.unwrap();
-
implement commands to manage background jobs. #1071
-
magic link. #1085
-
infer migration. #1086
-
Remove unnecessary calls to 'register_tasks' functions in scheduler. #1100
-
implement commands to manage background jobs. #1071
-
expose hello_name for SMTP client config. #1057
-
use reqwest with rustls rather than openssl. #1058
-
more flexible config, take more values from ENV. #1058
-
refactor: Use opendal to replace object_store. #897
-
allow override loco template. #1102
-
support custom config folder. #1081
-
feat: upgrade to Axum 8. #1130
-
create load config hook. #1143
-
initial impl new migration dsl. #1125
-
allow disable limit_payload middleware. #1113
- static fallback now returns 200 and not 404 #991
- cache system now has expiry #1006
- fixed: http interface binding #1007
- JWT claims now editable and public #988
- CORS now not enabled in dev mode to avoid friction #1009
- fixed: task code generation now injects in all cases #1012
BREAKING
In your app.rs add the following injection comment at the bottom:
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 #1014
- fix: avoid generating entities from queue tables when the queue backend is database based #1013
- removed: channels moved to an initializer #892 BREAKING See how this looks like in https://github.com/loco-rs/chat-rooms
- Added SQLite background job support #969
- Added automatic updating of
updated_aton change #962 - fixed codegen injection point in migrations #952
NOTE: update your migration listing module like so:
// migrations/src/lib.rs
vec![
Box::new(m20220101_000001_users::Migration),
Box::new(m20231103_114510_notes::Migration),
Box::new(m20240416_071825_roles::Migration),
Box::new(m20240416_082115_users_roles::Migration),
// inject-above (do not remove this comment)
]Add the comment just before the closing array (inject-above)
- Added ability to name references in #955:
$ generate scaffold posts title:string! content:string! written_by:references:users approved_by:references:users- Added hot-reload like experience to Tera templates #977, in debug builds only.
NOTE: update your initializers after_routes like so:
// src/initializers/view_engine.rs
async fn after_routes(&self, router: AxumRouter, _ctx: &AppContext) -> Result<AxumRouter> {
#[allow(unused_mut)]
let mut tera_engine = engines::TeraView::build()?;
if std::path::Path::new(I18N_DIR).exists() {
let arc = ArcLoader::builder(&I18N_DIR, unic_langid::langid!("en-US"))
.shared_resources(Some(&[I18N_SHARED.into()]))
.customize(|bundle| bundle.set_use_isolating(false))
.build()
.map_err(|e| Error::string(&e.to_string()))?;
#[cfg(debug_assertions)]
tera_engine
.tera
.lock()
.expect("lock")
.register_function("t", FluentLoader::new(arc));
#[cfg(not(debug_assertions))]
tera_engine
.tera
.register_function("t", FluentLoader::new(arc));
info!("locales loaded");
}
Ok(router.layer(Extension(ViewEngine::from(tera_engine))))
}loco doctornow checks for app-specific minimum dependency versions. This should help in upgrades.doctoralso supports "production only" checks which you can run in production withloco doctor --production. This, for example, will check your connections but will not check dependencies. #931- Use a single loco-rs dep for a whole project. #927
- chore: fix generated testcase. #939
- chore: Correct cargo test message. #938
- Add relevant meta tags for better defaults. #943
- Update cli message with correct command. #942
- remove lazy_static. #941
- change update HTTP verb semantics to put+patch. #919
- Fixed HTML scaffold error. #960
- Scaffolded HTML update method should be POST. #963
This release have been primarily about cleanups and simplification.
Please update:
loco-rsloco-cli
Changes:
- generators (BREAKING): all prefixes in starters (e.g.
/api) are now local to each controller, and generators will be prefix-aware (--apigenerator will add an/apiprefix to controllers) #818
To migrate, please move prefixes from app.rs to each controller you use in controllers/, for example in notes controller:
Routes::new()
.prefix("api/notes")
.add("/", get(list))-
starters: removed
.devcontainerwhich can now be found in loco-devcontainer -
starters: removed example
notesscaffold (model, controllers, etc), and unifieduserandauthinto a single file:auth.rs -
generators:
scaffoldgenerator will now generate a CRUD withPUTandPATCHsemantics for updating an entity #896 -
cleanup:
loco-extraswas moved out of the repo, but we've incorporatedMultiDBandExtraDBfromextrasintoloco-rs#917 -
cargo loco doctornow checks for minimal required SeaORM CLI version -
BREAKING Improved migration generator. If you have an existing migration project, add the following comment indicator to the top of the
vecstatement and right below the opening bracked like so inmigration/src/lib.rs:
fn migrations() -> Vec<Box<dyn MigrationTrait>> {
vec![
// inject-below (do not remove this comment)- Upgrade SeaORM to v1.1.0
- Added OpenAPI example
- Improve health route #851
- Add good pragmas to Sqlite #848
- Upgrade to rsbuild 1.0. #792
- Implements fmt::Debug to pub structs. #812
- Add num_workers config for sidekiq queue. #823
- Fix some comments in the starters and example code. #824
- Fix Y2038 bug for JWT on 32 bit platforms. #825
- Make App URL in Boot Banner Clickable. #826
- Add
--no-bannerflag to allow disabling the banner display. #839 - add on_shutdown hook. #842
Format(respond_to): Formatextractor in controller can now be replaced withrespond_to: RespondToextractor for less typing.- When supplying data to views, you can now use
data!instead ofserde_json::json!for shorthand. - Refactor middlewares. #785. Middleware selection, configuration, and tweaking is MUCH more powerful and convenient now. You can keep the
middleware:section empty or remove it now, see more in the middleware docs - NEW (BREAKING) background worker subsystem is now queue agnostic. Providing for both Redis and Postgres with a change of configuration. This means you can now use a full-Postgres stack to remove Redis as a dependency if you wish. Here are steps to migrate your codebase:
// in your app.rs, change the worker registration code:
// BEFORE
fn connect_workers<'a>(p: &'a mut Processor, ctx: &'a AppContext) {
p.register(DownloadWorker::build(ctx));
}
// AFTER
async fn connect_workers(ctx: &AppContext, queue: &Queue) -> Result<()>{
queue.register(DownloadWorker::build(ctx)).await?;
Ok(())
}
// in your app.rs, replace the `worker` module references.
// REMOVE
worker::{AppWorker, Processor},
// REPLACE WITH
bgworker::{BackgroundWorker, Queue},
// in your workers change the signature, and add the `build` function
// BEFORE
impl worker::Worker<DownloadWorkerArgs> for DownloadWorker {
async fn perform(&self, args: DownloadWorkerArgs) -> worker::Result<()> {
// AFTER
#[async_trait]
impl BackgroundWorker<DownloadWorkerArgs> for DownloadWorker {
fn build(ctx: &AppContext) -> Self {
Self { ctx: ctx.clone() }
}
async fn perform(&self, args: DownloadWorkerArgs) -> Result<()> {
// Finally, remove the `AppWorker` trait implementation completely.
// REMOVE
impl worker::AppWorker<DownloadWorkerArgs> for DownloadWorker {
fn build(ctx: &AppContext) -> Self {
Self { ctx: ctx.clone() }
}
}Finally, update your development.yaml and test.yaml with a kind:
queue:
kind: Redis # add this to the existing `queue` section- UPGRADED (BREAKING):
validatorcrate was upgraded which require some small tweaks to work with the new API:
// BEFORE:
#[validate(custom = "validation::is_valid_email")]
pub email: String,
// AFTER:
#[validate(custom (function = "validation::is_valid_email"))]
pub email: String,Then update your Cargo.toml to take version 0.18:
# update
validator = { version = "0.18" }- UPGRADED (BREAKING):
axum-testcrate was upgraded Update yourCargo.tomlto version16:
# update
axum-test = { version = "16" }- Add fallback behavior. #732
- Add Scheduler Feature for Running Cron Jobs. #735
- Add
--html,--htmxand--apiflags to scaffold CLI command. #749 - Add base template for scaffold generation. #752
- Connect Redis only when the worker is BackgroundQueue. #755
- Add loco doctor --config. #736
- Rename demo: blo -> demo_app. #741
- fix: introduce secondary binary for compile-and-run on Windows. #727
- Added: loco-cli (
loco new) now receives options from CLI and/or interactively asks for configuration options such as which asset pipeline, background worker type, or database provider to use. - Fix: custom queue names now merge with default queues.
- Added
remote_ipmiddleware for resolving client remote IP when under a proxy or loadbalancer, similar to the Railsremote_ipmiddleware. - Added
secure_headersmiddleware for setting secure headers by default, similar to how https://github.com/github/secure_headers works. This is now ON by default to promote security-by-default. - Added:
money,blobtypes to entitie generator.
- Moving to timezone aware timestamps. From now on migrations will generate timestamps with time zone by default. Moving to TZ aware timestamps in combination with newly revamped timestamp code generation in SeaORM v1.0.0 finally allows for seamlessly moving between using
sqliteandpostgreswith minimal or no entities code changes (resolved this long standing issue). TZ aware timestamps also aligns us with how Rails works today (initially Rails had a no-tz timestamps, and today the default is to use timestamps). If not specified the TZ is the server TZ, which is usually UTC, therefore semantically this is almost like a no-tz timestamp.
A few highlights:
Generated entities will now always use DateTimeWithTimeZone for the default timestamp fields:
...
Generating users.rs
> Column `created_at`: DateTimeWithTimeZone, not_null
> Column `updated_at`: DateTimeWithTimeZone, not_null
...
For better cross database provider compatibility, from now on prefer the tstz type instead of just ts when using generators (i.e. cargo loco generate model movie released:tstz)
-
remove eyer lib. #650
-
Update the Main Function in src/bin/main
Replace the return type of the main function:
Before:
async fn main() -> eyre::Result<()>
After:
async fn main() -> loco_rs::Result<()>
-
Modify examples/playground.rs You need to apply two changes here:
a. Update the Function Signature **Before:** ```rust async fn main() -> eyre::Result<()> ``` **After:** ```rust async fn main() -> loco_rs::Result<()> ``` b. Adjust the Context Handling **Before:** ```rust let _ctx = playground::<App>().await.context("playground")?; ``` **After:** ```rust let _ctx = playground::<App>().await?; ```Note, If you are using eyre in your project, you can continue to do so. We have only removed this crate from our base code dependencies.
-
-
Bump rstest crate to 0.21.0. #650
-
Bump serial_test crate to 3.1.1. #651
-
Bumo object store to create to 0.10.2. #654
-
Bump axum crate to 0.7.5. #652
-
Add Hooks::before_routes to give user control over initial axum::Router construction. #646
-
Support logger file appender. #636
-
Response from the template. #682
-
Add get_or_insert function to cache layer. #637
-
Bump ORM create to 1.0.0. #684
- Use Rust-based tooling for SaaS starter frontend. #625
- Default binding to localhost to avoid firewall dialogues during development on macOS. #627
- upgrade sea-orm to 1.0.0 RC 7. https://github.com/loco-rs/loco/pull/627
- Add a down migration command. #414
- replace create_postgres_database function table_name to db_name. #647
- Upgrade htmx generator to htmx2. #629
0.6.0 #610
- Bump socketioxide to v0.13.1. #594
- Add CC and BCC fields to the mailers. #599
- Delete reset tokens after use. #602
- Generator html support delete entity. #604
- Breaking changes move task args from BTreeMap to struct. #609
- Change task signature from
async fn run(&self, app_context: &AppContext, vars: &BTreeMap<String, String>)toasync fn run(&self, _app_context: &AppContext, _vars: &task::Vars) -> Result<()> - Breaking changes change default port to 5150. #611
- Change task signature from
- Update shuttle version in deployment generation. #616
v0.5.0 #593
- refactor auth middleware for supporting bearer, cookie and query. #560
- SeaORM upgraded:
rc1->rc4. #585 - Adding Cache to app content. #570
- Apply a layer to a specific handler using
layermethod. #554 - Add the debug macro to the templates to improve the errors. #547
- Opentelemetry initializer. #531
- Refactor auth middleware for supporting bearer, cookie and query #560
- Add redirect response #563
- Breaking changes Adding a custom claims
Option<serde_json::Value>to theUserClaimsstruct (type changed). #578 - Breaking changes Refactored DSL and Pagination: namespace changes. #566
- Replaced
model::query::dsl::withmodel::query. - Replaced
model::query::exec::paginatewithmodel::query::paginate. - Updated the
PaginatedResponsestruct. Refer to its usage example here.
- Replaced
- Breaking changes When introducing the Cache system which is much more flexible than having just Redis, we now call the 'redis' member simply a 'queue' which indicates it should be used only for the internal queue and not as a general purpose cache. In the application configuration setting
redis, change toqueue. #590
# before:
redis:
# after:
queue:- Breaking changes We have made a few parts of the context pluggable, such as the
storageand newcachesubsystems, this is why we decided to let you configure the context entirely before starting up your app. As a result, if you have a storage building hook code it should move toafter_context, see example here. #570
- Refactored model validation for better developer experience. Added a few traits and structs to
loco::preludefor a smoother import story. IntroducingValidatable:
impl Validatable for super::_entities::users::ActiveModel {
fn validator(&self) -> Box<dyn Validate> {
Box::new(Validator {
name: self.name.as_ref().to_owned(),
email: self.email.as_ref().to_owned(),
})
}
}
// now you can call `user.validate()` freely-
Refactored type field mapping to be centralized. Now model, scaffold share the same field mapping, so no more gaps like #513 (e.g. when calling
loco generate model title:stringthe ability to mapstringinto something useful in the code generation side) NOTE the_integerclass of types are now just_int, e.g.big_int, so that it correlate with theintfield name in a better way -
Adding to to quiery dsl
is_inandis_not_in. #507 -
Added: in your configuration you can now use an
initializers:section for initializer specific settings# Initializers Configuration initializers: # oauth2: # authorization_code: # Authorization code grant type # - client_identifier: google # Identifier for the OAuth2 provider. Replace 'google' with your provider's name if different, must be unique within the oauth2 config. # ... other fields
-
Docs: fix schema data types mapping. #506
-
Let Result accept other errors. #505
-
Allow trailing slashes in URIs by adding the NormalizePathLayer. #481
-
BREAKING Move from
Result<impl IntoResponse>toResult<Response>. This enables much greater flexibility building APIs, where withResult<Response>you mix and match response types based on custom logic (returning JSON and HTML/String in the same route). -
Added: mime responders similar to
respond_toin Rails:
- Use the
Formatextractor - Match on
respond_to - Create different content for different response formats
The following route will always return JSON, unless explicitly asked for HTML with a
Content-Type: text/html (or Accept: ) header:
pub async fn get_one(
Format(respond_to): Format,
Path(id): Path<i32>,
State(ctx): State<AppContext>,
) -> Result<Response> {
let item = load_item(&ctx, id).await?;
match respond_to {
RespondTo::Html => format::html(&format!("<html><body>{:?}</body></html>", item.title)),
_ => format::json(item),
}
}- Redisgin pagination. #463
- Wrap seaorm query and condition for common use cases. #463
- Adding to loco-extras initializer for extra or multiple db. #471
- Scaffold now supporting different templates such as API,HTML or htmx, this future is in beta.#474
- Fix generatore fields types + adding tests. #459
- Fix channel cors. #430
- Improve auth controller compatibility with frontend #472
- Breaking changes Upgrade sea-orm to v1.0.0-rc.1. #420
Needs to update
sea-ormcrate to usev1.0.0-rc.1version. - Implemented file upload support with versatile strategies. #423
- Create a
loco_extracrate to share common basic implementations. #425 - Update shuttle deployment template to 0.38. #422
- Enhancement: Move the Serve to Hook flow with the ability to override default serve settings. #418
- Avoid cloning sea_query::ColumnDef. #415
- Allow required UUID type in a scaffold. #408
- Cover
SqlxMySqlPoolConnectionin db.rs. #411 - Update worker docs and change default worker mode. #412
- Added server-side view generation through a new
ViewEngineinfrastructure andTeraserver-side templates: #389 - Added
generate model --migration-only#400 - Add JSON to scaffold gen. #396
- Add --binding(-b) and --port(-b) to
cargo loco start.#402
- Add: support for pre-compressed assets.
- Added: Support socket channels, see working example here. #380
- refactor: optimize checking permissions on Postgres. 9416c
- Added: E2E db. #371
- enable compression for CompressionLayer, not etag. #356
- Fix nullable JSONB column schema definition. #357
- Add: Loco now has Initializers (see the docs). Initializers help you integrate infra into your app in a seamless way, as well as share pieces of setup code between your projects
- Add: an
init_loggerhook insrc/app.rsfor those who want to take ownership of their logging and tracing stack. - Add: Return a JSON schema when payload json could not serialize to a struct. #343
- Init logger in cli.rs. #338
- Add: return JSON schema in panic HTTP layer. #336
- Add: JSON field support in model generation. #327 #332
- Add: float support in model generation. #317
- Fix: conflicting idx definition on M:M migration. #311
- Add: Breaking changes Supply
AppContexttoroutesHook. Migration steps insrc/app.rs:
// src/app.rs: add app context to routes function
impl Hooks for App {
...
fn routes(_ctx: &AppContext) -> AppRoutes;
...
}- Add: Breaking changes change parameter type from
&strto&Environmentinsrc/app.rs
// src/app.rs: change parameter type for `environment` from `&str` to `&Environment`
impl Hooks for App {
...
async fn boot(mode: StartMode, environment: &Environment) -> Result<BootResult> {
create_app::<Self>(mode, environment).await
}
...- Added: setting cookies:
format::render()
.cookies(&[
cookie::Cookie::new("foo", "bar"),
cookie::Cookie::new("baz", "qux"),
])?
.etag("foobar")?
.json(notes)- Adding pagination on Models. #238
- Adding compression middleware. #205 Added support for compression middleware. usage:
middlewares:
compression:
enable: true- Create a new Database from the CLI. #223
- Validate if seaorm CLI is installed before running
cargo loco db entitiesand show a better error to the user. #212 - Adding to
saas andrest-api` starters a redis and DB in GitHub action workflow to allow users work with github action out of the box. #215 - Adding the app name and the environment to the DB name when creating a new starter. #216
- Fix generator when users adding a
created_atorupdate_atfields. #214 - Add:
format::renderwhich allows a builder-like formatting, including setting etag and ad-hoc headers - Add: Etag middleware, enabled by default in starter projects. Once you set an Etag it will check for cache headers and return
304if needed. To enable etag in your existing project:
#...
middlewares:
etag:
enable: trueusage:
format::render()
.etag("foobar")?
.json(Entity::find().all(&ctx.db).await?)-
See #217 Now when you generate a
saas starterorrest apistarter you will get additional authentication methods for free: -
Added: authentication added -- api authentication where each user has an API token in the schema, and you can authenticate with
Beareragainst that user. -
Added: authentication added --
JWTWithUserextractor, which is a convenience for resolving the authenticated JWT claims into a current user from database
migrating an existing codebase
Add the following to your generated src/models/user.rs:
#[async_trait]
impl Authenticable for super::_entities::users::Model {
async fn find_by_api_key(db: &DatabaseConnection, api_key: &str) -> ModelResult<Self> {
let user = users::Entity::find()
.filter(users::Column::ApiKey.eq(api_key))
.one(db)
.await?;
user.ok_or_else(|| ModelError::EntityNotFound)
}
async fn find_by_claims_key(db: &DatabaseConnection, claims_key: &str) -> ModelResult<Self> {
super::_entities::users::Model::find_by_pid(db, claims_key).await
}
}Update imports in this file to include model::Authenticable:
use loco_rs::{
auth, hash,
model::{Authenticable, ModelError, ModelResult},
validation,
validator::Validate,
};- Added:
loco versionfor getting an operable version string containing logical crate version and git SHA if available:0.3.0 (<git sha>)
To migrate to this behavior from earlier versions, it requires adding the following to your app.rs app hooks:
fn app_version() -> String {
format!(
"{} ({})",
env!("CARGO_PKG_VERSION"),
option_env!("BUILD_SHA")
.or(option_env!("GITHUB_SHA"))
.unwrap_or("dev")
)
}Reminder: loco --version will give you the current Loco framework which your app was built against and loco version gives you your app version.
- Added:
loco generate migrationfor adding ad-hoc migrations - Added: added support in model generator for many-to-many link table generation via
loco generate model --link - Docs: added Migration section, added relations documentation 1:M, M:M
- Adding .devcontainer to starter projects #170
- Braking changes: Adding
Hooks::bootapplication. Migration steps:// Load boot::{create_app, BootResult, StartMode} from loco_rs lib // Load migration: use migration::Migrator; Only when using DB // Adding boot hook with the following code impl Hooks for App { ... async fn boot(mode: StartMode, environment: &str) -> Result<BootResult> { // With DB: create_app::<Self, Migrator>(mode, environment).await // Without DB: create_app::<Self>(mode, environment).await } ... }
- Added pretty backtraces #41
- adding tests for note requests #156
- Define the min rust version the loco can run #164
- Added
cargo loco doctorcli command for validate and diagnose configurations. #145 - Added ability to specify
settings:in config files, which are available in context - Adding compilation mode in the banner. #127
- Support shuttle deployment generator. #124
- Adding a static asset middleware which allows to serve static folder/data. Enable this section in config. #134
static: enable: true # ensure that both the folder.path and fallback file path are existence. must_exist: true folder: uri: "/assets" path: "frontend/dist" fallback: "frontend/dist/index.html"
- fix:
loco generate requesttest template. #133 - Improve docker deployment generator. #131
- refactor: local settings are now
<env>.local.yamland available for all environments, for example you can add a localtest.local.yamlanddevelopment.local.yaml - refactor: removed
config-rsand now doing config loading by ourselves. - fix: email template rendering will not escape URLs
- Config with variables: It is now possible to use tera templates in config YAML files
Example of pulling a port from environment:
server:
port: { { get_env(name="NODE_PORT", default=5150) } }It is possible to use any tera templating constructs such as loops, conditionals, etc. inside YAML configuration files.
-
Mailer: expose
stubin non-test -
Hooks::before_runwith a default blank implementation. You can now code some custom loading of resources or other things before the app runs -
an LLM inference example, text generation in Rust, using an API (
examples/inference) -
Loco starters version & create release script #110
-
Configure Cors middleware #114
-
Hooks::after_routesInvoke this function after the Loco routers have been constructed. This function enables you to configure custom Axum logics, such as layers, that are compatible with Axum. #114 -
Adding docker deployment generator #119
DOCS:
- Remove duplicated docs in auth section
- FAQ docs: #116
ENHANCEMENTS:
NEW FEATURES
format:html#74- Create a stateless HTML starter #100
- Added worker generator + adding a way to test workers #92
ENHANCEMENTS:
- CI: allows cargo cli run on fork prs #96