mirror of
https://github.com/LukeMathWalker/zero-to-production.git
synced 2024-11-27 03:21:08 +00:00
Update dependencies
This commit is contained in:
parent
384916fddd
commit
8b0196d24c
7 changed files with 1146 additions and 734 deletions
53
.github/workflows/general.yml
vendored
53
.github/workflows/general.yml
vendored
|
@ -8,13 +8,13 @@ on:
|
||||||
branches:
|
branches:
|
||||||
- root-chapter-10-part0
|
- root-chapter-10-part0
|
||||||
pull_request:
|
pull_request:
|
||||||
types: [ opened, synchronize, reopened ]
|
types: [opened, synchronize, reopened]
|
||||||
branches:
|
branches:
|
||||||
- root-chapter-10-part0
|
- root-chapter-10-part0
|
||||||
|
|
||||||
env:
|
env:
|
||||||
CARGO_TERM_COLOR: always
|
CARGO_TERM_COLOR: always
|
||||||
SQLX_VERSION: 0.7.1
|
SQLX_VERSION: 0.8.0
|
||||||
SQLX_FEATURES: "rustls,postgres"
|
SQLX_FEATURES: "rustls,postgres"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
@ -23,6 +23,7 @@ jobs:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
services:
|
services:
|
||||||
postgres:
|
postgres:
|
||||||
|
# Docker Hub image
|
||||||
image: postgres:14
|
image: postgres:14
|
||||||
env:
|
env:
|
||||||
POSTGRES_USER: postgres
|
POSTGRES_USER: postgres
|
||||||
|
@ -31,18 +32,34 @@ jobs:
|
||||||
ports:
|
ports:
|
||||||
- 5432:5432
|
- 5432:5432
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
# Downloads a copy of the code in your repository before running CI tests
|
||||||
- uses: dtolnay/rust-toolchain@stable
|
- name: Check out repository code
|
||||||
- uses: Swatinem/rust-cache@v2
|
# The uses keyword specifies that this step will run v3 of the actions/checkout action.
|
||||||
|
# This is an action that checks out your repository onto the runner, allowing you to run scripts or other actions against your code (such as build and test tools).
|
||||||
|
# You should use the checkout action any time your workflow will run against the repository's code.
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
# This GitHub Action installs a Rust toolchain using rustup. It is designed for one-line concise usage and good defaults.
|
||||||
|
- name: Install the Rust toolchain
|
||||||
|
uses: dtolnay/rust-toolchain@stable
|
||||||
|
|
||||||
|
# A GitHub Action that implements smart caching for rust/cargo projects with sensible defaults.
|
||||||
|
- name: Rust Cache Action
|
||||||
|
uses: Swatinem/rust-cache@v2
|
||||||
with:
|
with:
|
||||||
key: sqlx-${{ env.SQLX_VERSION }}
|
key: sqlx-${{ env.SQLX_VERSION }}
|
||||||
- name: Install sqlx-cli
|
- name: Install sqlx-cli
|
||||||
run:
|
run:
|
||||||
cargo install sqlx-cli
|
cargo install sqlx-cli
|
||||||
--version=${{ env.SQLX_VERSION }}
|
--version=${{ env.SQLX_VERSION }}
|
||||||
--features ${{ env.SQLX_FEATURES }}
|
--features ${{ env.SQLX_FEATURES }}
|
||||||
--no-default-features
|
--no-default-features
|
||||||
--locked
|
--locked
|
||||||
|
# The --locked flag can be used to force Cargo to use the packaged Cargo.lock file if it is available.
|
||||||
|
# This may be useful for ensuring reproducible builds, to use the exact same set of dependencies that were available when the package was published.
|
||||||
|
# It may also be useful if a newer version of a dependency is published that no longer builds on your system, or has other problems
|
||||||
|
- name: Install postgresql-client
|
||||||
|
run: sudo apt-get update && sudo apt-get install postgresql-client -y
|
||||||
- name: Migrate database
|
- name: Migrate database
|
||||||
run: |
|
run: |
|
||||||
sudo apt-get install libpq-dev -y
|
sudo apt-get install libpq-dev -y
|
||||||
|
@ -85,12 +102,13 @@ jobs:
|
||||||
with:
|
with:
|
||||||
key: sqlx-${{ env.SQLX_VERSION }}
|
key: sqlx-${{ env.SQLX_VERSION }}
|
||||||
- name: Install sqlx-cli
|
- name: Install sqlx-cli
|
||||||
run:
|
run: cargo install sqlx-cli
|
||||||
cargo install sqlx-cli
|
--version=${{ env.SQLX_VERSION }}
|
||||||
--version=${{ env.SQLX_VERSION }}
|
--features ${{ env.SQLX_FEATURES }}
|
||||||
--features ${{ env.SQLX_FEATURES }}
|
--no-default-features
|
||||||
--no-default-features
|
--locked
|
||||||
--locked
|
- name: Install postgresql-client
|
||||||
|
run: sudo apt-get update && sudo apt-get install postgresql-client -y
|
||||||
- name: Migrate database
|
- name: Migrate database
|
||||||
run: |
|
run: |
|
||||||
sudo apt-get install libpq-dev -y
|
sudo apt-get install libpq-dev -y
|
||||||
|
@ -122,8 +140,7 @@ jobs:
|
||||||
- name: Install tarpaulin
|
- name: Install tarpaulin
|
||||||
run: cargo install cargo-tarpaulin
|
run: cargo install cargo-tarpaulin
|
||||||
- name: Install sqlx-cli
|
- name: Install sqlx-cli
|
||||||
run:
|
run: cargo install sqlx-cli
|
||||||
cargo install sqlx-cli
|
|
||||||
--version=${{ env.SQLX_VERSION }}
|
--version=${{ env.SQLX_VERSION }}
|
||||||
--features ${{ env.SQLX_FEATURES }}
|
--features ${{ env.SQLX_FEATURES }}
|
||||||
--no-default-features
|
--no-default-features
|
||||||
|
|
1778
Cargo.lock
generated
1778
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
37
Cargo.toml
37
Cargo.toml
|
@ -16,33 +16,44 @@ name = "zero2prod"
|
||||||
actix-web = "4"
|
actix-web = "4"
|
||||||
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
|
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
|
||||||
serde = "1.0.115"
|
serde = "1.0.115"
|
||||||
config = { version = "0.13", default-features = false, features = ["yaml"] }
|
config = { version = "0.14", default-features = false, features = ["yaml"] }
|
||||||
sqlx = { version = "0.7", default-features = false, features = ["runtime-tokio-rustls", "macros", "postgres", "uuid", "chrono", "migrate"] }
|
sqlx = { version = "0.8", default-features = false, features = [
|
||||||
|
"runtime-tokio-rustls",
|
||||||
|
"macros",
|
||||||
|
"postgres",
|
||||||
|
"uuid",
|
||||||
|
"chrono",
|
||||||
|
"migrate",
|
||||||
|
] }
|
||||||
uuid = { version = "1", features = ["v4"] }
|
uuid = { version = "1", features = ["v4"] }
|
||||||
chrono = { version = "0.4.22", default-features = false, features = ["clock"] }
|
chrono = { version = "0.4.22", default-features = false, features = ["clock"] }
|
||||||
reqwest = { version = "0.11", default-features = false, features = ["json", "rustls-tls"] }
|
reqwest = { version = "0.12", default-features = false, features = [
|
||||||
|
"json",
|
||||||
|
"rustls-tls",
|
||||||
|
] }
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
tracing = "0.1.19"
|
tracing = "0.1.19"
|
||||||
tracing-subscriber = { version = "0.3", features = ["registry", "env-filter"] }
|
tracing-subscriber = { version = "0.3", features = ["registry", "env-filter"] }
|
||||||
tracing-bunyan-formatter = "0.3"
|
tracing-bunyan-formatter = "0.3.1"
|
||||||
tracing-log = "0.1.1"
|
|
||||||
thiserror = "1.0.24"
|
thiserror = "1.0.24"
|
||||||
serde-aux = "4"
|
serde-aux = "4"
|
||||||
unicode-segmentation = "1.7.1"
|
unicode-segmentation = "1.7.1"
|
||||||
rand = { version = "0.8", features=["std_rng"] }
|
rand = { version = "0.8", features = ["std_rng"] }
|
||||||
anyhow = "1.0.40"
|
anyhow = "1.0.40"
|
||||||
base64 = "0.21.0"
|
base64 = "0.22.0"
|
||||||
argon2 = { version = "0.4", features = ["std"] }
|
argon2 = { version = "0.5", features = ["std"] }
|
||||||
validator = "0.16"
|
validator = "0.18"
|
||||||
|
tracing-log = "0.2.0"
|
||||||
tracing-actix-web = "0.7"
|
tracing-actix-web = "0.7"
|
||||||
secrecy = { version = "0.8", features = ["serde"] }
|
secrecy = { version = "0.8", features = ["serde"] }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
once_cell = "1.7.2"
|
|
||||||
claims = "0.7.0"
|
|
||||||
quickcheck = "0.9.2"
|
quickcheck = "0.9.2"
|
||||||
quickcheck_macros = "0.9.1"
|
quickcheck_macros = "0.9.1"
|
||||||
fake = "~2.3.0"
|
fake = "~2.3.0"
|
||||||
wiremock = "0.5"
|
wiremock = "0.6"
|
||||||
serde_json = "1.0.61"
|
serde_json = "1.0.61"
|
||||||
linkify = "0.9"
|
linkify = "0.10"
|
||||||
|
claims = "0.7"
|
||||||
|
reqwest = { version = "0.12", features = ["json"] }
|
||||||
|
once_cell = "1.7.2"
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
FROM lukemathwalker/cargo-chef:latest-rust-1.72.0 as chef
|
FROM lukemathwalker/cargo-chef:latest-rust-1.80.1 as chef
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
RUN apt update && apt install lld clang -y
|
RUN apt update && apt install lld clang -y
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ fi
|
||||||
if ! [ -x "$(command -v sqlx)" ]; then
|
if ! [ -x "$(command -v sqlx)" ]; then
|
||||||
echo >&2 "Error: sqlx is not installed."
|
echo >&2 "Error: sqlx is not installed."
|
||||||
echo >&2 "Use:"
|
echo >&2 "Use:"
|
||||||
echo >&2 " cargo install --version='~0.7' sqlx-cli --no-default-features --features rustls,postgres"
|
echo >&2 " cargo install --version='~0.8' sqlx-cli --no-default-features --features rustls,postgres"
|
||||||
echo >&2 "to install it."
|
echo >&2 "to install it."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
use validator::validate_email;
|
use validator::ValidateEmail;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct SubscriberEmail(String);
|
pub struct SubscriberEmail(String);
|
||||||
|
|
||||||
impl SubscriberEmail {
|
impl SubscriberEmail {
|
||||||
pub fn parse(s: String) -> Result<SubscriberEmail, String> {
|
pub fn parse(s: String) -> Result<SubscriberEmail, String> {
|
||||||
if validate_email(&s) {
|
if s.validate_email() {
|
||||||
Ok(Self(s))
|
Ok(Self(s))
|
||||||
} else {
|
} else {
|
||||||
Err(format!("{} is not a valid subscriber email.", s))
|
Err(format!("{} is not a valid subscriber email.", s))
|
||||||
|
|
|
@ -179,9 +179,9 @@ pub async fn publish_newsletter(
|
||||||
request: HttpRequest,
|
request: HttpRequest,
|
||||||
) -> Result<HttpResponse, PublishError> {
|
) -> Result<HttpResponse, PublishError> {
|
||||||
let credentials = basic_authentication(request.headers()).map_err(PublishError::AuthError)?;
|
let credentials = basic_authentication(request.headers()).map_err(PublishError::AuthError)?;
|
||||||
tracing::Span::current().record("username", &tracing::field::display(&credentials.username));
|
tracing::Span::current().record("username", tracing::field::display(&credentials.username));
|
||||||
let user_id = validate_credentials(credentials, &pool).await?;
|
let user_id = validate_credentials(credentials, &pool).await?;
|
||||||
tracing::Span::current().record("user_id", &tracing::field::display(&user_id));
|
tracing::Span::current().record("user_id", tracing::field::display(&user_id));
|
||||||
|
|
||||||
let subscribers = get_confirmed_subscribers(&pool).await?;
|
let subscribers = get_confirmed_subscribers(&pool).await?;
|
||||||
for subscriber in subscribers {
|
for subscriber in subscribers {
|
||||||
|
|
Loading…
Reference in a new issue