Skip to content

Commit

Permalink
feat: add sessions and admin dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
migueloller committed Feb 11, 2024
1 parent 00c2d3b commit 5f45d1f
Show file tree
Hide file tree
Showing 20 changed files with 435 additions and 18 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/general.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ jobs:
POSTGRES_DB: postgres
ports:
- 5432:5432
redis:
image: redis:7
ports:
- 6379:6379
steps:
- name: Check out repository code
uses: actions/checkout@v3
Expand Down Expand Up @@ -105,6 +109,10 @@ jobs:
POSTGRES_DB: postgres
ports:
- 5432:5432
redis:
image: redis:7
ports:
- 6379:6379
steps:
- name: Check out repository code
uses: actions/checkout@v3
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

193 changes: 193 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ name = "zero2prod"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
actix-session = { version = "0.7", features = ["redis-rs-tls-session"] }
actix-web = "4"
actix-web-flash-messages = { version = "0.4", features = ["cookies"] }
anyhow = "1"
Expand All @@ -24,6 +25,7 @@ rand = { version = "0.8", features = ["std_rng"] }
secrecy = { version = "0.8", features = ["serde"] }
serde = { version = "1", features = ["derive"] }
serde-aux = "4"
serde_json = "1"
thiserror = "1"
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
tracing = { version = "0.1", features = ["log"] }
Expand All @@ -32,7 +34,7 @@ tracing-bunyan-formatter = "0.3"
tracing-log = "0.1"
tracing-subscriber = { version = "0.3", features = ["registry", "env-filter"] }
unicode-segmentation = "1"
uuid = { version = "1", features = ["v4"] }
uuid = { version = "1", features = ["v4", "serde"] }
validator = "0.16"

[dependencies.sqlx]
Expand Down
1 change: 1 addition & 0 deletions configuration/base.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
redis_uri: "redis://127.0.0.1:6379"
application:
port: 8000
hmac_secret: "long-and-very-secret-random-key-needed-to-verify-message-integrity"
Expand Down
19 changes: 19 additions & 0 deletions scripts/init_redis.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash

set -x
set -eo pipefail

RUNNING_CONTAINER=$(docker ps --filter 'name=redis' --format '{{.ID}}')
if [[ -n $RUNNING_CONTAINER ]]; then
echo >&2 "there is a redis container already running, kill it with"
echo >&2 " docker kill ${RUNNING_CONTAINER}"
exit 1
fi

docker run \
-p 6379:6379 \
-d \
--name "redis_$(date '+%s')" \
redis:7

echo >%2 "Redis is ready to go!"
3 changes: 3 additions & 0 deletions spec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ services:
- key: APP_APPLICATION__HMAC_SECRET
scope: RUN_TIME
value: ${HMAC_SECRET}
- key: APP_REDIS_URI
scope: RUN_TIME
value: ${REDIS_URI}
databases:
- engine: PG
name: newsletter
Expand Down
1 change: 1 addition & 0 deletions src/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ pub struct Settings {
pub database: DatabaseSettings,
pub application: ApplicationSettings,
pub email_client: EmailClientSettings,
pub redis_uri: Secret<String>,
}

#[derive(serde::Deserialize, Clone)]
Expand Down
Loading

0 comments on commit 5f45d1f

Please sign in to comment.