-
Notifications
You must be signed in to change notification settings - Fork 279
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into fuzzy-cli-tests
- Loading branch information
Showing
79 changed files
with
972 additions
and
581 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,8 @@ | |
todo.txt | ||
examples/demo2 | ||
*.sqlite | ||
*.sqlite-wal | ||
*.sqlite-shm | ||
|
||
# IDE config files | ||
.idea | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -87,9 +87,6 @@ impl Model { | |
).await?; | ||
} | ||
} | ||
``` | ||
''' | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ top = false | |
flair =[] | ||
+++ | ||
|
||
|
||
<img style="width:100%; max-width:640px" src="tour.png"/> | ||
<br/> | ||
<br/> | ||
|
@@ -49,6 +50,12 @@ If you select all defaults, you'll have: | |
|
||
|
||
Now `cd` into your `myapp` and start your app by running `cargo loco start`: | ||
|
||
|
||
<div class="infobox"> | ||
|
||
If you have the `Client` asset serving option configured, make sure you build your frontend before starting the server. This can be done by changing into the frontend directory (`cd frontend`) and running `pnpm install` and `pnpm build`. | ||
</div> | ||
|
||
<!-- <snip id="starting-the-server-command-with-output" inject_from="yaml" template="sh"> --> | ||
```sh | ||
|
@@ -76,6 +83,7 @@ listening on port 5150 | |
|
||
|
||
<div class="infobox"> | ||
|
||
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. </div> | ||
|
@@ -84,8 +92,13 @@ listening on port 5150 | |
|
||
We have a base SaaS app with user authentication generated for us. Let's make it a blog backend by adding a `post` and a full CRUD API using `scaffold`: | ||
|
||
<div class="infobox"> | ||
|
||
You can choose between generating an `api`, `html` or `htmx` scaffold using the required `-k` flag. | ||
</div> | ||
|
||
```sh | ||
$ cargo loco generate scaffold post title:string content:text -k api | ||
$ cargo loco generate scaffold post title:string content:text --api | ||
|
||
: | ||
: | ||
|
@@ -127,6 +140,14 @@ listening on port 5150 | |
``` | ||
<!-- </snip> --> | ||
|
||
<div class="infobox"> | ||
|
||
Depending on which `-k` option you chose, the steps for creating a scaffolded resource will change. With the `api` flag or the `htmx` flag you can use the below example. But with the `html` flag, it is recommended you do the post creation steps in your browser. | ||
|
||
If you want to use `curl` to test the `html` scaffold, you will need to send your requests with the Content-Type `application/x-www-form-urlencoded` and the body as `title=Your+Title&content=Your+Content` by default. This can be changed to allow `application/json` as a `Content-Type` in the code if desired. | ||
|
||
</div> | ||
|
||
Next, try adding a `post` with `curl`: | ||
|
||
```sh | ||
|
@@ -147,7 +168,7 @@ For those counting -- the commands for creating a blog backend were: | |
1. `cargo install loco-cli` | ||
2. `cargo install sea-orm-cli` | ||
3. `loco new` | ||
4. `cargo loco generate scaffold post title:string content:text -k api` | ||
4. `cargo loco generate scaffold post title:string content:text --api` | ||
|
||
Done! enjoy your ride with `loco` 🚂 | ||
|
||
|
@@ -160,7 +181,7 @@ Your generated app contains a fully working authentication suite, based on JWTs. | |
The `/api/auth/register` endpoint creates a new user in the database with an `email_verification_token` for account verification. A welcome email is sent to the user with a verification link. | ||
|
||
```sh | ||
$ curl --location '127.0.0.1:5150/api/auth/register' \ | ||
$ curl --location 'localhost:5150/api/auth/register' \ | ||
--header 'Content-Type: application/json' \ | ||
--data-raw '{ | ||
"name": "Loco user", | ||
|
@@ -176,7 +197,7 @@ For security reasons, if the user is already registered, no new user is created, | |
After registering a new user, use the following request to log in: | ||
|
||
```sh | ||
$ curl --location '127.0.0.1:5150/api/auth/login' \ | ||
$ curl --location 'localhost:5150/api/auth/login' \ | ||
--header 'Content-Type: application/json' \ | ||
--data-raw '{ | ||
"email": "[email protected]", | ||
|
@@ -203,7 +224,7 @@ In your client-side app, you save this JWT token and make following requests wit | |
This endpoint is protected by auth middleware. We will use the token we got earlier to perform a request with the _bearer token_ technique (replace `TOKEN` with the JWT token you got earlier): | ||
|
||
```sh | ||
$ curl --location --request GET '127.0.0.1:5150/api/user/current' \ | ||
$ curl --location --request GET 'localhost:5150/api/user/current' \ | ||
--header 'Content-Type: application/json' \ | ||
--header 'Authorization: Bearer TOKEN' | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
+++ | ||
title = "Around the Web" | ||
description = "" | ||
date = 2024-01-21T19:00:00+00:00 | ||
updated = 2024-01-21T19:00:00+00:00 | ||
draft = false | ||
weight = 1 | ||
sort_by = "weight" | ||
template = "docs/page.html" | ||
|
||
[extra] | ||
lead = "" | ||
toc = true | ||
top = false | ||
flair =[] | ||
+++ | ||
|
||
|
||
Check out Loco resources and links from around the Web. | ||
|
||
|
||
## Blogs | ||
|
||
- [Introducing Loco: the "Rust on Rails"](https://blog.rng0.io/introducing-loco/) - by [@jondot](https://x.com/jondot) | ||
- [Loco is a New Framework for Rust Inspired by Rails](https://www.infoq.com/news/2024/02/loco-new-framework-rust-rails/) - by [infoq.com](https://infoq.com) | ||
- [Going in cold inside the locomotive](https://vanhalt.com/post/loco-rs/) by [@vanhalt](https://twitter.com/vanhalt) | ||
- [Introducing Loco: The Rails of Rust](https://www.shuttle.dev/blog/2023/12/20/loco-rust-rails) by [shuttle](https://shuttle.dev) | ||
- [Getting Started with Loco & SeaORM](https://www.sea-ql.org/blog/2024-05-28-getting-started-with-loco-seaorm/) by [Billy Chan (SeaORM)](https://github.com/billy1624) | ||
|
||
## Videos | ||
|
||
- [A Legendary Web Framework is Reborn... in Rust](https://www.youtube.com/watch?v=7utPutDORb4) - by [Code to the Moon](https://www.youtube.com/@codetothemoon) | ||
|
||
|
||
## Ecosystem | ||
|
||
- [rhai-loco](https://docs.rs/rhai-loco/latest/rhai_loco/) - This crate adds [Rhai](https://rhai.rs) script support to [Loco](https://loco.rs) | ||
- [loco-oauth2](https://github.com/yinho999/loco-oauth2) - Loco OAuth2 is a simple OAuth2 initializer for the Loco API. It is designed to be a tiny and easy-to-use library for implementing OAuth2 in your application. | ||
|
||
## App Examples | ||
|
||
* [Chat rooms](https://github.com/loco-rs/chat-rooms) - With opening a web socket | ||
* [Todo list](https://github.com/loco-rs/todo-list) - working with rest API |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.