-
-
Notifications
You must be signed in to change notification settings - Fork 284
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
create a stateless html starter (#100)
* create a stateless html starter * some chagnes * some chagnes
- Loading branch information
1 parent
41c4bc2
commit ced2a8a
Showing
34 changed files
with
730 additions
and
1 deletion.
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 |
---|---|---|
@@ -0,0 +1,105 @@ | ||
name: STARTER-STATELESS-HTML | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
|
||
env: | ||
RUST_TOOLCHAIN: stable | ||
TOOLCHAIN_PROFILE: minimal | ||
|
||
jobs: | ||
rustfmt: | ||
name: Check Style | ||
runs-on: ubuntu-latest | ||
|
||
permissions: | ||
contents: read | ||
|
||
steps: | ||
- name: Checkout the code | ||
uses: actions/checkout@v4 | ||
- uses: actions-rs/toolchain@v1 | ||
with: | ||
profile: ${{ env.TOOLCHAIN_PROFILE }} | ||
toolchain: ${{ env.RUST_TOOLCHAIN }} | ||
override: true | ||
components: rustfmt | ||
- run: cargo fmt --all -- --check | ||
working-directory: ./starters/stateless_html | ||
|
||
clippy: | ||
name: Run Clippy | ||
needs: [rustfmt] | ||
runs-on: ubuntu-latest | ||
|
||
permissions: | ||
contents: read | ||
|
||
steps: | ||
- name: Checkout the code | ||
uses: actions/checkout@v4 | ||
- uses: actions-rs/toolchain@v1 | ||
with: | ||
profile: ${{ env.TOOLCHAIN_PROFILE }} | ||
toolchain: ${{ env.RUST_TOOLCHAIN }} | ||
override: true | ||
- name: Setup Rust cache | ||
uses: Swatinem/rust-cache@v2 | ||
- name: Run cargo clippy | ||
run: cargo clippy -- -W clippy::nursery -W clippy::pedantic -W rust-2018-idioms -W rust-2021-compatibility | ||
working-directory: ./starters/stateless_html | ||
|
||
test: | ||
name: Run Tests | ||
needs: [rustfmt, clippy] | ||
runs-on: ubuntu-latest | ||
|
||
permissions: | ||
contents: read | ||
steps: | ||
- name: Checkout the code | ||
uses: actions/checkout@v4 | ||
- uses: actions-rs/toolchain@v1 | ||
with: | ||
profile: ${{ env.TOOLCHAIN_PROFILE }} | ||
toolchain: ${{ env.RUST_TOOLCHAIN }} | ||
override: true | ||
- name: Setup Rust cache | ||
uses: Swatinem/rust-cache@v2 | ||
- name: Run cargo test | ||
run: cargo test --all-features --all | ||
working-directory: ./starters/stateless_html | ||
|
||
generate_template: | ||
name: Generate Template | ||
needs: [test] | ||
runs-on: ubuntu-latest | ||
|
||
permissions: | ||
contents: read | ||
|
||
steps: | ||
- name: Checkout the code | ||
uses: actions/checkout@v4 | ||
- uses: actions-rs/toolchain@v1 | ||
with: | ||
profile: ${{ env.TOOLCHAIN_PROFILE }} | ||
toolchain: ${{ env.RUST_TOOLCHAIN }} | ||
override: true | ||
- name: Setup Rust cache | ||
uses: Swatinem/rust-cache@v2 | ||
- name: Inject slug/short variables | ||
uses: rlespinasse/github-slug-action@v3.x | ||
- name: Generate template | ||
run: | | ||
cargo build --release --features github_ci | ||
RUST_LOG=debug LOCO_CURRENT_REPOSITORY=${{ github.event.pull_request.head.repo.html_url }} LOCO_CI_MODE=true LOCO_APP_NAME=stateless_html_starter LOCO_TEMPLATE=stateless_html LOCO_BRANCH=${{ env.GITHUB_HEAD_REF_SLUG }} ./target/release/loco new | ||
cd stateless_html_starter | ||
echo "Building generate template..." | ||
cargo build --release | ||
echo "Run cargo test on generated template..." | ||
cargo test | ||
working-directory: ./loco-cli |
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,2 @@ | ||
[alias] | ||
loco = "run --" |
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,80 @@ | ||
name: CI | ||
on: | ||
push: | ||
branches: | ||
- master | ||
- main | ||
pull_request: | ||
|
||
env: | ||
RUST_TOOLCHAIN: stable | ||
TOOLCHAIN_PROFILE: minimal | ||
|
||
jobs: | ||
rustfmt: | ||
name: Check Style | ||
runs-on: ubuntu-latest | ||
|
||
permissions: | ||
contents: read | ||
|
||
steps: | ||
- name: Checkout the code | ||
uses: actions/checkout@v4 | ||
- uses: actions-rs/toolchain@v1 | ||
with: | ||
profile: ${{ env.TOOLCHAIN_PROFILE }} | ||
toolchain: ${{ env.RUST_TOOLCHAIN }} | ||
override: true | ||
components: rustfmt | ||
- name: Run cargo fmt | ||
uses: actions-rs/cargo@v1 | ||
with: | ||
command: fmt | ||
args: --all -- --check | ||
|
||
clippy: | ||
name: Run Clippy | ||
runs-on: ubuntu-latest | ||
|
||
permissions: | ||
contents: read | ||
|
||
steps: | ||
- name: Checkout the code | ||
uses: actions/checkout@v4 | ||
- uses: actions-rs/toolchain@v1 | ||
with: | ||
profile: ${{ env.TOOLCHAIN_PROFILE }} | ||
toolchain: ${{ env.RUST_TOOLCHAIN }} | ||
override: true | ||
- name: Setup Rust cache | ||
uses: Swatinem/rust-cache@v2 | ||
- name: Run cargo clippy | ||
uses: actions-rs/cargo@v1 | ||
with: | ||
command: clippy | ||
args: --all-features -- -D warnings -W clippy::pedantic -W clippy::nursery -W rust-2018-idioms | ||
|
||
test: | ||
name: Run Tests | ||
runs-on: ubuntu-latest | ||
|
||
permissions: | ||
contents: read | ||
|
||
steps: | ||
- name: Checkout the code | ||
uses: actions/checkout@v4 | ||
- uses: actions-rs/toolchain@v1 | ||
with: | ||
profile: ${{ env.TOOLCHAIN_PROFILE }} | ||
toolchain: ${{ env.RUST_TOOLCHAIN }} | ||
override: true | ||
- name: Setup Rust cache | ||
uses: Swatinem/rust-cache@v2 | ||
- name: Run cargo test | ||
uses: actions-rs/cargo@v1 | ||
with: | ||
command: test | ||
args: --all-features --all |
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,16 @@ | ||
**/config/local.yaml | ||
|
||
# Generated by Cargo | ||
# will have compiled files and executables | ||
debug/ | ||
target/ | ||
|
||
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries | ||
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html | ||
Cargo.lock | ||
|
||
# These are backup files generated by rustfmt | ||
**/*.rs.bk | ||
|
||
# MSVC Windows builds of rustc generate these, which store debugging information | ||
*.pdb |
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,40 @@ | ||
[workspace] | ||
|
||
[package] | ||
name = "loco_starter_template" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
|
||
loco-rs = { path = "../../", default-features = false, features = ["cli"] } | ||
serde = "*" | ||
serde_json = "*" | ||
eyre = "*" | ||
tokio = { version = "1.33.0", default-features = false } | ||
async-trait = "0.1.74" | ||
tracing = "0.1.40" | ||
validator = { version = "*" } | ||
|
||
axum = "0.7.1" | ||
include_dir = "*" | ||
uuid = { version = "*", features = ["v4"] } | ||
tracing-subscriber = { version = "0.3.17", features = ["env-filter", "json"] } | ||
tera = "1.19.1" | ||
cargo_metadata = "0.18.1" | ||
|
||
[[bin]] | ||
name = "loco_starter_template" | ||
path = "src/bin/main.rs" | ||
required-features = [] | ||
|
||
[dev-dependencies] | ||
serial_test = "*" | ||
rstest = "*" | ||
loco-rs = { path = "../../", default-features = false, features = [ | ||
"testing", | ||
"cli", | ||
] } | ||
insta = { version = "*", features = ["redactions", "yaml", "filters"] } |
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,42 @@ | ||
# Welcome to Loco :train: | ||
|
||
Loco is a web and API framework running on Rust. | ||
|
||
This is the **Stateless HTML starter** which comes with no database or state dependencies. | ||
|
||
## Quick Start | ||
|
||
Start your app: | ||
|
||
``` | ||
$ cargo loco start | ||
Finished dev [unoptimized + debuginfo] target(s) in 21.63s | ||
Running `target/debug/myapp start` | ||
: | ||
: | ||
: | ||
controller/app_routes.rs:203: [Middleware] Adding log trace id | ||
▄ ▀ | ||
▀ ▄ | ||
▄ ▀ ▄ ▄ ▄▀ | ||
▄ ▀▄▄ | ||
▄ ▀ ▀ ▀▄▀█▄ | ||
▀█▄ | ||
▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄▄ ▀▀█ | ||
██████ █████ ███ █████ ███ █████ ███ ▀█ | ||
██████ █████ ███ █████ ▀▀▀ █████ ███ ▄█▄ | ||
██████ █████ ███ █████ █████ ███ ████▄ | ||
██████ █████ ███ █████ ▄▄▄ █████ ███ █████ | ||
██████ █████ ███ ████ ███ █████ ███ ████▀ | ||
▀▀▀██▄ ▀▀▀▀▀▀▀▀▀▀ ▀▀▀▀▀▀▀▀▀▀ ▀▀▀▀▀▀▀▀▀▀ ██▀ | ||
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀ | ||
started on port 3000 | ||
``` | ||
|
||
## Getting help | ||
|
||
Check out [a quick tour](https://loco.rs/docs/getting-started/tour/) or [the complete guide](https://loco.rs/docs/getting-started/guide/). |
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,66 @@ | ||
# Loco configuration file documentation | ||
|
||
# Application logging configuration | ||
logger: | ||
# Enable or disable logging. | ||
enable: 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 | ||
|
||
# Web server configuration | ||
server: | ||
# Port on which the server will listen. the server binding is 0.0.0.0:{PORT} | ||
port: 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 | ||
middlewares: | ||
# Allows to limit the payload size request. payload that bigger than this file will blocked the request. | ||
limit_payload: | ||
# Enable/Disable the middleware. | ||
enable: true | ||
# the limit size. can be b,kb,kib,mb,mib,gb,gib | ||
body_limit: 5mb | ||
# Generating a unique request ID and enhancing logging with additional information such as the start and completion of request processing, latency, status code, and other request details. | ||
logger: | ||
# Enable/Disable the middleware. | ||
enable: true | ||
# when your code is panicked, the request still returns 500 status code. | ||
catch_panic: | ||
# Enable/Disable the middleware. | ||
enable: true | ||
# Timeout for incoming requests middleware. requests that take more time from the configuration will cute and 408 status code will returned. | ||
timeout_request: | ||
# Enable/Disable the middleware. | ||
enable: true | ||
# Duration time in milliseconds. | ||
timeout: 5000 | ||
|
||
# Worker Configuration | ||
workers: | ||
# specifies the worker mode. Options: | ||
# - BackgroundQueue - Workers operate asynchronously in the background, processing queued. | ||
# - ForegroundBlocking - Workers operate in the foreground and block until tasks are completed. | ||
# - BackgroundAsync - Workers operate asynchronously in the background, processing tasks with async capabilities. | ||
mode: BackgroundQueue | ||
|
||
# Mailer Configuration. | ||
mailer: | ||
# SMTP mailer configuration. | ||
smtp: | ||
# Enable/Disable smtp mailer. | ||
enable: true | ||
# SMTP server host. e.x localhost, smtp.gmail.com | ||
host: localhost | ||
# SMTP server port | ||
port: 1025 | ||
# Use secure connection (SSL/TLS). | ||
secure: false | ||
# auth: | ||
# user: | ||
# password: |
Empty file.
Oops, something went wrong.