Compare commits
21 Commits
v0.1.0-dev
...
v0.4.2-mai
Author | SHA1 | Date | |
---|---|---|---|
6805b15f0e | |||
8f0d123db5 | |||
38e0073cbe | |||
86c5050c7b | |||
0f470ef723 | |||
e51df82f09 | |||
d84a8144ae | |||
3cd42dab6b | |||
e2c83b5219 | |||
b414031af0 | |||
d73fba9899 | |||
020d091446 | |||
84ea6e4c22 | |||
c90f9fb0b4 | |||
7df6fe5821 | |||
e7e6fd904b | |||
3ee8c1e573 | |||
dbe4dc67cb | |||
6c37c19a57 | |||
596d2afdaa | |||
9aa16a3f2e |
18
.env
Normal file
18
.env
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
RANDOM_ENV_KEY="YouDon'tWantToButYouGottaChange|It'sGoingToHurtYouTryingToStayTheSame|AreYouInItOrYouInItForTheFame?|I'mTryingToFigureOutWhoLoveMeForMe"
|
||||||
|
MODNAR_ENV_KEY="FeelingTheMonsterClimbDeepserInsideOfMe|FeelingHimGnawingMyHeartAwayHungrily|I'llNeverLoseThisPain|NeverDreamOfYouAgain"
|
||||||
|
SECRET_MAIN_KEY=Somesupersecretpassword!!!45345435
|
||||||
|
SECRET_KEY=AmIGoodEnoughForYou?
|
||||||
|
SERVICE_PASSPHRASE=T5OCHDHadAtuOWIqRAS7u8XHDDkzKT1Uvvw7mGMkNzKjVdlHA8xGdILf2adDHspO
|
||||||
|
ROOT_DIRECTORY=/path/to/root
|
||||||
|
POSTGRES_MAIN_USER=myuser
|
||||||
|
POSTGRES_MAIN_PASSWORD=password
|
||||||
|
POSTGRES_MAIN_DB=my_db
|
||||||
|
POSTGRES_MAIN_HOST=localhost
|
||||||
|
DATABASE_URL=postgres://${POSTGRES_MAIN_USER}:${POSTGRES_MAIN_PASSWORD}@${POSTGRES_MAIN_HOST}:5432/${POSTGRES_MAIN_DB}
|
||||||
|
ICARUS_BASE_API_URL=https://icarus.com
|
||||||
|
ICARUS_AUTH_BASE_API_URL=https://auth.icarus.com
|
||||||
|
APP_ENV=development
|
||||||
|
BACKEND_PORT=8001
|
||||||
|
FRONTEND_URL=http://localhost:4200
|
||||||
|
RUST_LOG=debug
|
||||||
|
ALLOWED_ORIGINS=https://soaricarus.com,https://www.soaricarus.com
|
18
.env.sample
Normal file
18
.env.sample
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
RANDOM_ENV_KEY="YouDon'tWantToButYouGottaChange|It'sGoingToHurtYouTryingToStayTheSame|AreYouInItOrYouInItForTheFame?|I'mTryingToFigureOutWhoLoveMeForMe"
|
||||||
|
MODNAR_ENV_KEY="FeelingTheMonsterClimbDeepserInsideOfMe|FeelingHimGnawingMyHeartAwayHungrily|I'llNeverLoseThisPain|NeverDreamOfYouAgain"
|
||||||
|
SECRET_MAIN_KEY=Somesupersecretpassword!!!45345435
|
||||||
|
SECRET_KEY=AmIGoodEnoughForYou?
|
||||||
|
SERVICE_PASSPHRASE=T5OCHDHadAtuOWIqRAS7u8XHDDkzKT1Uvvw7mGMkNzKjVdlHA8xGdILf2adDHspO
|
||||||
|
ROOT_DIRECTORY=/path/to/root
|
||||||
|
POSTGRES_MAIN_USER=myuser
|
||||||
|
POSTGRES_MAIN_PASSWORD=password
|
||||||
|
POSTGRES_MAIN_DB=my_db
|
||||||
|
POSTGRES_MAIN_HOST=localhost
|
||||||
|
DATABASE_URL=postgres://${POSTGRES_MAIN_USER}:${POSTGRES_MAIN_PASSWORD}@${POSTGRES_MAIN_HOST}:5432/${POSTGRES_MAIN_DB}
|
||||||
|
ICARUS_BASE_API_URL=https://icarus.com
|
||||||
|
ICARUS_AUTH_BASE_API_URL=https://auth.icarus.com
|
||||||
|
APP_ENV=development
|
||||||
|
BACKEND_PORT=8001
|
||||||
|
FRONTEND_URL=http://localhost:4200
|
||||||
|
RUST_LOG=debug
|
||||||
|
ALLOWED_ORIGINS=https://soaricarus.com,https://www.soaricarus.com
|
@@ -3,7 +3,10 @@ name: Release Tagging
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- devel
|
- main
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
release:
|
release:
|
||||||
@@ -17,7 +20,7 @@ jobs:
|
|||||||
- name: Install Rust
|
- name: Install Rust
|
||||||
uses: actions-rs/toolchain@v1
|
uses: actions-rs/toolchain@v1
|
||||||
with:
|
with:
|
||||||
toolchain: 1.86.0
|
toolchain: 1.88.0
|
||||||
components: cargo
|
components: cargo
|
||||||
|
|
||||||
- name: Extract Version from Cargo.toml
|
- name: Extract Version from Cargo.toml
|
||||||
@@ -28,7 +31,7 @@ jobs:
|
|||||||
BRANCH_REF="${GITHUB_REF}"
|
BRANCH_REF="${GITHUB_REF}"
|
||||||
BRANCH_NAME=$(echo "$BRANCH_REF" | cut -d '/' -f 3)
|
BRANCH_NAME=$(echo "$BRANCH_REF" | cut -d '/' -f 3)
|
||||||
PROJECT_TAG_RELEASE="v$VERSION-$BRANCH_NAME-$PROJECT_COMMIT_HASH"
|
PROJECT_TAG_RELEASE="v$VERSION-$BRANCH_NAME-$PROJECT_COMMIT_HASH"
|
||||||
echo "::set-output name=project_tag_release::$PROJECT_TAG_RELEASE-950"
|
echo "::set-output name=project_tag_release::$PROJECT_TAG_RELEASE-006"
|
||||||
echo "Version: $VERSION"
|
echo "Version: $VERSION"
|
||||||
echo "Hash: $PROJECT_COMMIT_HASH"
|
echo "Hash: $PROJECT_COMMIT_HASH"
|
||||||
echo "Branch: $BRANCH_NAME"
|
echo "Branch: $BRANCH_NAME"
|
||||||
|
62
.gitea/workflows/workflow.yaml
Normal file
62
.gitea/workflows/workflow.yaml
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
name: Rust Build
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
check:
|
||||||
|
name: Check
|
||||||
|
runs-on: ubuntu-24.04
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||||
|
with:
|
||||||
|
toolchain: 1.88.0
|
||||||
|
- run: cargo check
|
||||||
|
|
||||||
|
test:
|
||||||
|
name: Test Suite
|
||||||
|
runs-on: ubuntu-24.04
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||||
|
with:
|
||||||
|
toolchain: 1.88.0
|
||||||
|
- run: cargo test
|
||||||
|
|
||||||
|
fmt:
|
||||||
|
name: Rustfmt
|
||||||
|
runs-on: ubuntu-24.04
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||||
|
with:
|
||||||
|
toolchain: 1.88.0
|
||||||
|
- run: rustup component add rustfmt
|
||||||
|
- run: cargo fmt --all -- --check
|
||||||
|
|
||||||
|
clippy:
|
||||||
|
name: Clippy
|
||||||
|
runs-on: ubuntu-24.04
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||||
|
with:
|
||||||
|
toolchain: 1.88.0
|
||||||
|
- run: rustup component add clippy
|
||||||
|
- run: cargo clippy -- -D warnings
|
||||||
|
|
||||||
|
build:
|
||||||
|
name: build
|
||||||
|
runs-on: ubuntu-24.04
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||||
|
with:
|
||||||
|
toolchain: 1.88.0
|
||||||
|
- run: cargo build
|
556
Cargo.lock
generated
556
Cargo.lock
generated
@@ -2,6 +2,197 @@
|
|||||||
# It is not intended for manual editing.
|
# It is not intended for manual editing.
|
||||||
version = 4
|
version = 4
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "async-channel"
|
||||||
|
version = "1.9.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "81953c529336010edd6d8e358f886d9581267795c61b19475b71314bffa46d35"
|
||||||
|
dependencies = [
|
||||||
|
"concurrent-queue",
|
||||||
|
"event-listener 2.5.3",
|
||||||
|
"futures-core",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "async-channel"
|
||||||
|
version = "2.5.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "924ed96dd52d1b75e9c1a3e6275715fd320f5f9439fb5a4a11fa51f4221158d2"
|
||||||
|
dependencies = [
|
||||||
|
"concurrent-queue",
|
||||||
|
"event-listener-strategy",
|
||||||
|
"futures-core",
|
||||||
|
"pin-project-lite",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "async-executor"
|
||||||
|
version = "1.13.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "497c00e0fd83a72a79a39fcbd8e3e2f055d6f6c7e025f3b3d91f4f8e76527fb8"
|
||||||
|
dependencies = [
|
||||||
|
"async-task",
|
||||||
|
"concurrent-queue",
|
||||||
|
"fastrand",
|
||||||
|
"futures-lite",
|
||||||
|
"pin-project-lite",
|
||||||
|
"slab",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "async-global-executor"
|
||||||
|
version = "2.4.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "05b1b633a2115cd122d73b955eadd9916c18c8f510ec9cd1686404c60ad1c29c"
|
||||||
|
dependencies = [
|
||||||
|
"async-channel 2.5.0",
|
||||||
|
"async-executor",
|
||||||
|
"async-io",
|
||||||
|
"async-lock",
|
||||||
|
"blocking",
|
||||||
|
"futures-lite",
|
||||||
|
"once_cell",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "async-io"
|
||||||
|
version = "2.6.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "456b8a8feb6f42d237746d4b3e9a178494627745c3c56c6ea55d92ba50d026fc"
|
||||||
|
dependencies = [
|
||||||
|
"autocfg",
|
||||||
|
"cfg-if",
|
||||||
|
"concurrent-queue",
|
||||||
|
"futures-io",
|
||||||
|
"futures-lite",
|
||||||
|
"parking",
|
||||||
|
"polling",
|
||||||
|
"rustix",
|
||||||
|
"slab",
|
||||||
|
"windows-sys",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "async-lock"
|
||||||
|
version = "3.4.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5fd03604047cee9b6ce9de9f70c6cd540a0520c813cbd49bae61f33ab80ed1dc"
|
||||||
|
dependencies = [
|
||||||
|
"event-listener 5.4.1",
|
||||||
|
"event-listener-strategy",
|
||||||
|
"pin-project-lite",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "async-std"
|
||||||
|
version = "1.13.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "2c8e079a4ab67ae52b7403632e4618815d6db36d2a010cfe41b02c1b1578f93b"
|
||||||
|
dependencies = [
|
||||||
|
"async-channel 1.9.0",
|
||||||
|
"async-global-executor",
|
||||||
|
"async-io",
|
||||||
|
"async-lock",
|
||||||
|
"crossbeam-utils",
|
||||||
|
"futures-channel",
|
||||||
|
"futures-core",
|
||||||
|
"futures-io",
|
||||||
|
"futures-lite",
|
||||||
|
"gloo-timers",
|
||||||
|
"kv-log-macro",
|
||||||
|
"log",
|
||||||
|
"memchr",
|
||||||
|
"once_cell",
|
||||||
|
"pin-project-lite",
|
||||||
|
"pin-utils",
|
||||||
|
"slab",
|
||||||
|
"wasm-bindgen-futures",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "async-task"
|
||||||
|
version = "4.7.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8b75356056920673b02621b35afd0f7dda9306d03c79a30f5c56c44cf256e3de"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "atomic-waker"
|
||||||
|
version = "1.1.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "autocfg"
|
||||||
|
version = "1.5.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "bitflags"
|
||||||
|
version = "2.9.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "2261d10cca569e4643e526d8dc2e62e433cc8aba21ab764233731f8d369bf394"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "blocking"
|
||||||
|
version = "1.6.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e83f8d02be6967315521be875afa792a316e28d57b5a2d401897e2a7921b7f21"
|
||||||
|
dependencies = [
|
||||||
|
"async-channel 2.5.0",
|
||||||
|
"async-task",
|
||||||
|
"futures-io",
|
||||||
|
"futures-lite",
|
||||||
|
"piper",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "bumpalo"
|
||||||
|
version = "3.19.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "46c5e41b57b8bba42a04676d81cb89e9ee8e859a1a66f80a5a72e1cb76b34d43"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cfg-if"
|
||||||
|
version = "1.0.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "2fd1289c04a9ea8cb22300a459a72a385d7c73d3259e2ed7dcb2af674838cfa9"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "concurrent-queue"
|
||||||
|
version = "2.5.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "4ca0197aee26d1ae37445ee532fefce43251d24cc7c166799f4d46817f1d3973"
|
||||||
|
dependencies = [
|
||||||
|
"crossbeam-utils",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "const_format"
|
||||||
|
version = "0.2.35"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7faa7469a93a566e9ccc1c73fe783b4a65c274c5ace346038dca9c39fe0030ad"
|
||||||
|
dependencies = [
|
||||||
|
"const_format_proc_macros",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "const_format_proc_macros"
|
||||||
|
version = "0.2.34"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1d57c2eccfb16dbac1f4e61e206105db5820c9d26c3c472bc17c774259ef7744"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"unicode-xid",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "crossbeam-utils"
|
||||||
|
version = "0.8.21"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "dotenvy"
|
name = "dotenvy"
|
||||||
version = "0.15.7"
|
version = "0.15.7"
|
||||||
@@ -9,8 +200,369 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "1aaf95b3e5c8f23aa320147307562d361db0ae0d51242340f558153b4eb2439b"
|
checksum = "1aaf95b3e5c8f23aa320147307562d361db0ae0d51242340f558153b4eb2439b"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "icarus_envy"
|
name = "errno"
|
||||||
version = "0.1.0"
|
version = "0.3.14"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"libc",
|
||||||
|
"windows-sys",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "event-listener"
|
||||||
|
version = "2.5.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "event-listener"
|
||||||
|
version = "5.4.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e13b66accf52311f30a0db42147dadea9850cb48cd070028831ae5f5d4b856ab"
|
||||||
|
dependencies = [
|
||||||
|
"concurrent-queue",
|
||||||
|
"parking",
|
||||||
|
"pin-project-lite",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "event-listener-strategy"
|
||||||
|
version = "0.5.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8be9f3dfaaffdae2972880079a491a1a8bb7cbed0b8dd7a347f668b4150a3b93"
|
||||||
|
dependencies = [
|
||||||
|
"event-listener 5.4.1",
|
||||||
|
"pin-project-lite",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "fastrand"
|
||||||
|
version = "2.3.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "futures-channel"
|
||||||
|
version = "0.3.31"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10"
|
||||||
|
dependencies = [
|
||||||
|
"futures-core",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "futures-core"
|
||||||
|
version = "0.3.31"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "futures-io"
|
||||||
|
version = "0.3.31"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "futures-lite"
|
||||||
|
version = "2.6.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f78e10609fe0e0b3f4157ffab1876319b5b0db102a2c60dc4626306dc46b44ad"
|
||||||
|
dependencies = [
|
||||||
|
"fastrand",
|
||||||
|
"futures-core",
|
||||||
|
"futures-io",
|
||||||
|
"parking",
|
||||||
|
"pin-project-lite",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "gloo-timers"
|
||||||
|
version = "0.3.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "bbb143cf96099802033e0d4f4963b19fd2e0b728bcf076cd9cf7f6634f092994"
|
||||||
|
dependencies = [
|
||||||
|
"futures-channel",
|
||||||
|
"futures-core",
|
||||||
|
"js-sys",
|
||||||
|
"wasm-bindgen",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "hermit-abi"
|
||||||
|
version = "0.5.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "fc0fef456e4baa96da950455cd02c081ca953b141298e41db3fc7e36b1da849c"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "icarus_envy"
|
||||||
|
version = "0.4.2"
|
||||||
|
dependencies = [
|
||||||
|
"async-std",
|
||||||
|
"const_format",
|
||||||
"dotenvy",
|
"dotenvy",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "js-sys"
|
||||||
|
version = "0.3.81"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ec48937a97411dcb524a265206ccd4c90bb711fca92b2792c407f268825b9305"
|
||||||
|
dependencies = [
|
||||||
|
"once_cell",
|
||||||
|
"wasm-bindgen",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "kv-log-macro"
|
||||||
|
version = "1.0.7"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "0de8b303297635ad57c9f5059fd9cee7a47f8e8daa09df0fcd07dd39fb22977f"
|
||||||
|
dependencies = [
|
||||||
|
"log",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "libc"
|
||||||
|
version = "0.2.177"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "2874a2af47a2325c2001a6e6fad9b16a53b802102b528163885171cf92b15976"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "linux-raw-sys"
|
||||||
|
version = "0.11.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "df1d3c3b53da64cf5760482273a98e575c651a67eec7f77df96b5b642de8f039"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "log"
|
||||||
|
version = "0.4.28"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "34080505efa8e45a4b816c349525ebe327ceaa8559756f0356cba97ef3bf7432"
|
||||||
|
dependencies = [
|
||||||
|
"value-bag",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "memchr"
|
||||||
|
version = "2.7.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f52b00d39961fc5b2736ea853c9cc86238e165017a493d1d5c8eac6bdc4cc273"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "once_cell"
|
||||||
|
version = "1.21.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "parking"
|
||||||
|
version = "2.2.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f38d5652c16fde515bb1ecef450ab0f6a219d619a7274976324d5e377f7dceba"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "pin-project-lite"
|
||||||
|
version = "0.2.16"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "pin-utils"
|
||||||
|
version = "0.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "piper"
|
||||||
|
version = "0.2.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "96c8c490f422ef9a4efd2cb5b42b76c8613d7e7dfc1caf667b8a3350a5acc066"
|
||||||
|
dependencies = [
|
||||||
|
"atomic-waker",
|
||||||
|
"fastrand",
|
||||||
|
"futures-io",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "polling"
|
||||||
|
version = "3.11.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5d0e4f59085d47d8241c88ead0f274e8a0cb551f3625263c05eb8dd897c34218"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
"concurrent-queue",
|
||||||
|
"hermit-abi",
|
||||||
|
"pin-project-lite",
|
||||||
|
"rustix",
|
||||||
|
"windows-sys",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "proc-macro2"
|
||||||
|
version = "1.0.101"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "89ae43fd86e4158d6db51ad8e2b80f313af9cc74f5c0e03ccb87de09998732de"
|
||||||
|
dependencies = [
|
||||||
|
"unicode-ident",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "quote"
|
||||||
|
version = "1.0.41"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ce25767e7b499d1b604768e7cde645d14cc8584231ea6b295e9c9eb22c02e1d1"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rustix"
|
||||||
|
version = "1.1.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "cd15f8a2c5551a84d56efdc1cd049089e409ac19a3072d5037a17fd70719ff3e"
|
||||||
|
dependencies = [
|
||||||
|
"bitflags",
|
||||||
|
"errno",
|
||||||
|
"libc",
|
||||||
|
"linux-raw-sys",
|
||||||
|
"windows-sys",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rustversion"
|
||||||
|
version = "1.0.22"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "slab"
|
||||||
|
version = "0.4.11"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7a2ae44ef20feb57a68b23d846850f861394c2e02dc425a50098ae8c90267589"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "syn"
|
||||||
|
version = "2.0.106"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ede7c438028d4436d71104916910f5bb611972c5cfd7f89b8300a8186e6fada6"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"unicode-ident",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "unicode-ident"
|
||||||
|
version = "1.0.19"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f63a545481291138910575129486daeaf8ac54aee4387fe7906919f7830c7d9d"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "unicode-xid"
|
||||||
|
version = "0.2.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "value-bag"
|
||||||
|
version = "1.11.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "943ce29a8a743eb10d6082545d861b24f9d1b160b7d741e0f2cdf726bec909c5"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasm-bindgen"
|
||||||
|
version = "0.2.104"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c1da10c01ae9f1ae40cbfac0bac3b1e724b320abfcf52229f80b547c0d250e2d"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
"once_cell",
|
||||||
|
"rustversion",
|
||||||
|
"wasm-bindgen-macro",
|
||||||
|
"wasm-bindgen-shared",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasm-bindgen-backend"
|
||||||
|
version = "0.2.104"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "671c9a5a66f49d8a47345ab942e2cb93c7d1d0339065d4f8139c486121b43b19"
|
||||||
|
dependencies = [
|
||||||
|
"bumpalo",
|
||||||
|
"log",
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
"wasm-bindgen-shared",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasm-bindgen-futures"
|
||||||
|
version = "0.4.54"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7e038d41e478cc73bae0ff9b36c60cff1c98b8f38f8d7e8061e79ee63608ac5c"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
"js-sys",
|
||||||
|
"once_cell",
|
||||||
|
"wasm-bindgen",
|
||||||
|
"web-sys",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasm-bindgen-macro"
|
||||||
|
version = "0.2.104"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7ca60477e4c59f5f2986c50191cd972e3a50d8a95603bc9434501cf156a9a119"
|
||||||
|
dependencies = [
|
||||||
|
"quote",
|
||||||
|
"wasm-bindgen-macro-support",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasm-bindgen-macro-support"
|
||||||
|
version = "0.2.104"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9f07d2f20d4da7b26400c9f4a0511e6e0345b040694e8a75bd41d578fa4421d7"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
"wasm-bindgen-backend",
|
||||||
|
"wasm-bindgen-shared",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasm-bindgen-shared"
|
||||||
|
version = "0.2.104"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "bad67dc8b2a1a6e5448428adec4c3e84c43e561d8c9ee8a9e5aabeb193ec41d1"
|
||||||
|
dependencies = [
|
||||||
|
"unicode-ident",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "web-sys"
|
||||||
|
version = "0.3.81"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9367c417a924a74cae129e6a2ae3b47fabb1f8995595ab474029da749a8be120"
|
||||||
|
dependencies = [
|
||||||
|
"js-sys",
|
||||||
|
"wasm-bindgen",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows-link"
|
||||||
|
version = "0.2.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows-sys"
|
||||||
|
version = "0.61.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc"
|
||||||
|
dependencies = [
|
||||||
|
"windows-link",
|
||||||
|
]
|
||||||
|
@@ -1,8 +1,12 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "icarus_envy"
|
name = "icarus_envy"
|
||||||
version = "0.1.0"
|
version = "0.4.2"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
rust-version = "1.86"
|
rust-version = "1.88"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
dotenvy = { version = "0.15.7" }
|
dotenvy = { version = "0.15.7" }
|
||||||
|
const_format = { version = "0.2.35" }
|
||||||
|
|
||||||
|
[dev-dependencies]
|
||||||
|
async-std = { version = "1.13.2" }
|
||||||
|
5
README.md
Normal file
5
README.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
This is a library used to retrieve environment variables associated with various
|
||||||
|
icarus projects. Rather than having the various icarus projects such as icarus,
|
||||||
|
icarus_auth, songparser, and others, have environment code, it would be more
|
||||||
|
efficient to consolidate it. Especially, if there are commonly used environment
|
||||||
|
variables used throughout the apps.
|
@@ -1,5 +1,106 @@
|
|||||||
|
pub async fn get_db_url() -> crate::EnvVar {
|
||||||
pub async fn get_db_url() -> String {
|
|
||||||
dotenvy::dotenv().ok();
|
dotenvy::dotenv().ok();
|
||||||
std::env::var(crate::keys::DBURL).expect(crate::keys::error::ERROR)
|
let key = crate::keys::DB_URL;
|
||||||
|
let value = std::env::var(key).expect(key);
|
||||||
|
|
||||||
|
crate::init_envvar(key, &value)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn get_secret_main_key() -> crate::EnvVar {
|
||||||
|
dotenvy::dotenv().ok();
|
||||||
|
let key = crate::keys::SECRET_MAIN_KEY;
|
||||||
|
let value = std::env::var(key).expect(key);
|
||||||
|
|
||||||
|
crate::init_envvar(key, &value)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn get_service_passphrase() -> crate::EnvVar {
|
||||||
|
dotenvy::dotenv().ok();
|
||||||
|
let key = crate::keys::SERVICE_PASSPHRASE;
|
||||||
|
let value = std::env::var(key).expect(key);
|
||||||
|
|
||||||
|
crate::init_envvar(key, &value)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn get_secret_key() -> crate::EnvVar {
|
||||||
|
dotenvy::dotenv().ok();
|
||||||
|
let key = crate::keys::SECRET_KEY;
|
||||||
|
let value = std::env::var(key).expect(key);
|
||||||
|
|
||||||
|
crate::init_envvar(key, &value)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn get_root_directory() -> crate::EnvVar {
|
||||||
|
dotenvy::dotenv().ok();
|
||||||
|
let key = crate::keys::ROOT_DIRECTORY;
|
||||||
|
let value = std::env::var(key).expect(key);
|
||||||
|
|
||||||
|
crate::init_envvar(key, &value)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn get_icarus_base_api_url() -> crate::EnvVar {
|
||||||
|
dotenvy::dotenv().ok();
|
||||||
|
let key = crate::keys::ICARUS_BASE_API_URL;
|
||||||
|
let value = std::env::var(key).expect(key);
|
||||||
|
|
||||||
|
crate::init_envvar(key, &value)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn get_icarus_auth_base_api_url() -> crate::EnvVar {
|
||||||
|
dotenvy::dotenv().ok();
|
||||||
|
let key = crate::keys::ICARUS_AUTH_BASE_API_URL;
|
||||||
|
let value = std::env::var(key).expect(key);
|
||||||
|
|
||||||
|
crate::init_envvar(key, &value)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn get_app_env() -> crate::EnvVar {
|
||||||
|
dotenvy::dotenv().ok();
|
||||||
|
let key = crate::keys::APP_ENV;
|
||||||
|
let value = std::env::var(key).expect(key);
|
||||||
|
|
||||||
|
crate::init_envvar(key, &value)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn get_backend_port() -> crate::EnvVar {
|
||||||
|
dotenvy::dotenv().ok();
|
||||||
|
let key = crate::keys::BACKEND_PORT;
|
||||||
|
let value = std::env::var(key).expect(key);
|
||||||
|
crate::init_envvar(key, &value)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn get_frontend_url() -> crate::EnvVar {
|
||||||
|
dotenvy::dotenv().ok();
|
||||||
|
let key = crate::keys::FRONTEND_URL;
|
||||||
|
let value = std::env::var(key).expect(key);
|
||||||
|
|
||||||
|
crate::init_envvar(key, &value)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn get_rust_log() -> crate::EnvVar {
|
||||||
|
dotenvy::dotenv().ok();
|
||||||
|
let key = crate::keys::RUST_LOG;
|
||||||
|
let value = std::env::var(key).expect(key);
|
||||||
|
|
||||||
|
crate::init_envvar(key, &value)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn get_allowed_origins() -> crate::EnvVar {
|
||||||
|
dotenvy::dotenv().ok();
|
||||||
|
let key = crate::keys::ALLOWED_ORIGINS;
|
||||||
|
let value = std::env::var(key).expect(key);
|
||||||
|
|
||||||
|
let mut envvar = crate::init_envvar(key, &value);
|
||||||
|
crate::init_delimiter(&mut envvar, ',');
|
||||||
|
|
||||||
|
envvar
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Get environment not specified in the code
|
||||||
|
pub async fn get_env(environment: &str) -> crate::EnvVar {
|
||||||
|
dotenvy::dotenv().ok();
|
||||||
|
let my_error = format!("{environment} {}", crate::keys::error::GENERAL_ERROR);
|
||||||
|
let value = std::env::var(environment).expect(&my_error);
|
||||||
|
|
||||||
|
crate::init_envvar(environment, &value)
|
||||||
}
|
}
|
||||||
|
51
src/keys.rs
51
src/keys.rs
@@ -1,5 +1,52 @@
|
|||||||
pub const DBURL: &str = "DATABASE_URL";
|
/// Environment key for Database management
|
||||||
|
pub const DB_URL: &str = "DATABASE_URL";
|
||||||
|
|
||||||
|
/// Environment key for secret main key
|
||||||
|
/// Used for the icarus app
|
||||||
|
pub const SECRET_MAIN_KEY: &str = "SECRET_MAIN_KEY";
|
||||||
|
|
||||||
|
/// Environment key for service logins
|
||||||
|
pub const SERVICE_PASSPHRASE: &str = "SERVICE_PASSPHRASE";
|
||||||
|
|
||||||
|
/// Environment key for secret key
|
||||||
|
/// Generic use of secret key that could be found in various apps
|
||||||
|
pub const SECRET_KEY: &str = "SECRET_KEY";
|
||||||
|
|
||||||
|
/// Environment key for root directory for the icarus app
|
||||||
|
pub const ROOT_DIRECTORY: &str = "ROOT_DIRECTORY";
|
||||||
|
|
||||||
|
/// Environment key for icarus api url
|
||||||
|
pub const ICARUS_BASE_API_URL: &str = "ICARUS_BASE_API_URL";
|
||||||
|
|
||||||
|
/// Environment key for icarus auth api url
|
||||||
|
pub const ICARUS_AUTH_BASE_API_URL: &str = "ICARUS_AUTH_BASE_API_URL";
|
||||||
|
|
||||||
|
/// Environment key for App status
|
||||||
|
pub const APP_ENV: &str = "APP_ENV";
|
||||||
|
/// Environment key for backend port. Used for both auth and core functionality
|
||||||
|
pub const BACKEND_PORT: &str = "BACKEND_PORT";
|
||||||
|
/// Environment key for frontend url
|
||||||
|
pub const FRONTEND_URL: &str = "FRONTEND_URL";
|
||||||
|
/// Environment key for application logging
|
||||||
|
pub const RUST_LOG: &str = "RUST_LOG";
|
||||||
|
/// Environment key for allowed origins for CORS support
|
||||||
|
pub const ALLOWED_ORIGINS: &str = "ALLOWED_ORIGINS";
|
||||||
|
|
||||||
pub mod error {
|
pub mod error {
|
||||||
pub const ERROR: &str = "DATABASE_URL must be set in .env";
|
use const_format::concatcp;
|
||||||
|
|
||||||
|
pub const GENERAL_ERROR: &str = "must not be set in enviornment file";
|
||||||
|
pub const DB_URL: &str = concatcp!(super::DB_URL, " ", GENERAL_ERROR);
|
||||||
|
pub const SECRET_MAIN_KEY: &str = concatcp!(super::SECRET_MAIN_KEY, " ", GENERAL_ERROR);
|
||||||
|
pub const SERVICE_LOGIN: &str = concatcp!(super::SERVICE_PASSPHRASE, " ", GENERAL_ERROR);
|
||||||
|
pub const SECRET_KEY: &str = concatcp!(super::SECRET_KEY, " ", GENERAL_ERROR);
|
||||||
|
pub const ROOT_DIRECTORY: &str = concatcp!(super::ROOT_DIRECTORY, " ", GENERAL_ERROR);
|
||||||
|
pub const ICARUS_BASE_API_URL: &str = concatcp!(super::ICARUS_BASE_API_URL, " ", GENERAL_ERROR);
|
||||||
|
pub const ICARUS_AUTH_BASE_API_URL: &str =
|
||||||
|
concatcp!(super::ICARUS_AUTH_BASE_API_URL, " ", GENERAL_ERROR);
|
||||||
|
pub const APP_ENV: &str = concatcp!(super::APP_ENV, " ", GENERAL_ERROR);
|
||||||
|
pub const BACKEND_PORT: &str = concatcp!(super::BACKEND_PORT, " ", GENERAL_ERROR);
|
||||||
|
pub const FRONTEND_URL: &str = concatcp!(super::FRONTEND_URL, " ", GENERAL_ERROR);
|
||||||
|
pub const RUST_LOG: &str = concatcp!(super::RUST_LOG, " ", GENERAL_ERROR);
|
||||||
|
pub const ALLOWED_ORIGINS: &str = concatcp!(super::ALLOWED_ORIGINS, " ", GENERAL_ERROR);
|
||||||
}
|
}
|
||||||
|
40
src/lib.rs
40
src/lib.rs
@@ -1,17 +1,39 @@
|
|||||||
pub mod environment;
|
pub mod environment;
|
||||||
pub mod keys;
|
pub mod keys;
|
||||||
|
pub mod utility;
|
||||||
|
|
||||||
pub fn add(left: u64, right: u64) -> u64 {
|
#[derive(Debug, Default, Clone)]
|
||||||
left + right
|
pub struct EnvVar {
|
||||||
|
pub key: String,
|
||||||
|
pub value: String,
|
||||||
|
pub has_delimiter: bool,
|
||||||
|
pub delimiter: char,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
pub fn init_envvar(key: &str, value: &str) -> EnvVar {
|
||||||
mod tests {
|
EnvVar {
|
||||||
use super::*;
|
key: key.to_string(),
|
||||||
|
value: value.to_string(),
|
||||||
|
has_delimiter: false,
|
||||||
|
..Default::default()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
pub fn init_delimiter(envvar: &mut EnvVar, delimiter: char) {
|
||||||
fn it_works() {
|
let mut amount_of_delimiters_found: i32 = 0;
|
||||||
let result = add(2, 2);
|
|
||||||
assert_eq!(result, 4);
|
for v in envvar.value.chars() {
|
||||||
|
if v == delimiter {
|
||||||
|
amount_of_delimiters_found += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let has_delimiter = amount_of_delimiters_found >= 1;
|
||||||
|
|
||||||
|
if has_delimiter {
|
||||||
|
envvar.has_delimiter = has_delimiter;
|
||||||
|
envvar.delimiter = delimiter;
|
||||||
|
} else {
|
||||||
|
envvar.has_delimiter = has_delimiter;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
15
src/utility.rs
Normal file
15
src/utility.rs
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
/// Take the Environment variable and delimitize it. If the value has a delimiter,
|
||||||
|
/// extract it into some strings
|
||||||
|
pub fn delimitize(var: &crate::EnvVar) -> Result<Vec<String>, std::io::Error> {
|
||||||
|
if var.has_delimiter {
|
||||||
|
Ok(var
|
||||||
|
.value
|
||||||
|
.split(var.delimiter)
|
||||||
|
.map(|c| c.parse::<String>().unwrap())
|
||||||
|
.collect())
|
||||||
|
} else {
|
||||||
|
Err(std::io::Error::other(
|
||||||
|
"Environment variable does not have a delimiter",
|
||||||
|
))
|
||||||
|
}
|
||||||
|
}
|
163
tests/test.rs
Normal file
163
tests/test.rs
Normal file
@@ -0,0 +1,163 @@
|
|||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
#[test]
|
||||||
|
fn test_dburl() {
|
||||||
|
let result = async_std::task::block_on(icarus_envy::environment::get_db_url());
|
||||||
|
assert_eq!(
|
||||||
|
result.value, "postgres://myuser:password@localhost:5432/my_db",
|
||||||
|
"DATABASE_URL does not match {:?}",
|
||||||
|
result
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_get_secret_main_key() {
|
||||||
|
let result = async_std::task::block_on(icarus_envy::environment::get_secret_main_key());
|
||||||
|
assert_eq!(
|
||||||
|
result.value, "Somesupersecretpassword!!!45345435",
|
||||||
|
"SECRET_MAIN_KEY does not match {:?}",
|
||||||
|
result
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_get_service_passphrase() {
|
||||||
|
let result = async_std::task::block_on(icarus_envy::environment::get_service_passphrase());
|
||||||
|
assert_eq!(
|
||||||
|
result.value, "T5OCHDHadAtuOWIqRAS7u8XHDDkzKT1Uvvw7mGMkNzKjVdlHA8xGdILf2adDHspO",
|
||||||
|
"SERVICE_PASSPHRASE does not match {:?}",
|
||||||
|
result
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_get_secret_key() {
|
||||||
|
let result = async_std::task::block_on(icarus_envy::environment::get_secret_key());
|
||||||
|
assert_eq!(
|
||||||
|
result.value, "AmIGoodEnoughForYou?",
|
||||||
|
"SECRET_KEY does not match {:?}",
|
||||||
|
result
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_get_root_directory() {
|
||||||
|
let result = async_std::task::block_on(icarus_envy::environment::get_root_directory());
|
||||||
|
assert_eq!(
|
||||||
|
result.value, "/path/to/root",
|
||||||
|
"ROOT_DIRECTORY does not match {:?}",
|
||||||
|
result
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_get_icarus_base_api_url() {
|
||||||
|
let result = async_std::task::block_on(icarus_envy::environment::get_icarus_base_api_url());
|
||||||
|
assert_eq!(
|
||||||
|
result.value, "https://icarus.com",
|
||||||
|
"ICARUS_BASE_API_URL does not match {:?}",
|
||||||
|
result
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_get_app_env() {
|
||||||
|
let result = async_std::task::block_on(icarus_envy::environment::get_app_env());
|
||||||
|
assert_eq!(
|
||||||
|
result.value,
|
||||||
|
"development",
|
||||||
|
"{} does not match {:?}",
|
||||||
|
icarus_envy::keys::APP_ENV,
|
||||||
|
result
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_get_backend_port() {
|
||||||
|
let result = async_std::task::block_on(icarus_envy::environment::get_backend_port());
|
||||||
|
assert_eq!(
|
||||||
|
result.value,
|
||||||
|
"8001",
|
||||||
|
"{} does not match {:?}",
|
||||||
|
icarus_envy::keys::BACKEND_PORT,
|
||||||
|
result
|
||||||
|
)
|
||||||
|
}
|
||||||
|
#[test]
|
||||||
|
fn test_get_frontend_url() {
|
||||||
|
let result = async_std::task::block_on(icarus_envy::environment::get_frontend_url());
|
||||||
|
assert_eq!(
|
||||||
|
result.value,
|
||||||
|
"http://localhost:4200",
|
||||||
|
"{} does not match {:?}",
|
||||||
|
icarus_envy::keys::FRONTEND_URL,
|
||||||
|
result
|
||||||
|
)
|
||||||
|
}
|
||||||
|
#[test]
|
||||||
|
fn test_get_rust_log() {
|
||||||
|
let result = async_std::task::block_on(icarus_envy::environment::get_rust_log());
|
||||||
|
assert_eq!(
|
||||||
|
result.value,
|
||||||
|
"debug",
|
||||||
|
"{} does not match {:?}",
|
||||||
|
icarus_envy::keys::RUST_LOG,
|
||||||
|
result
|
||||||
|
)
|
||||||
|
}
|
||||||
|
#[test]
|
||||||
|
fn test_get_allowed_origins() {
|
||||||
|
let result = async_std::task::block_on(icarus_envy::environment::get_allowed_origins());
|
||||||
|
assert_eq!(
|
||||||
|
result.value,
|
||||||
|
"https://soaricarus.com,https://www.soaricarus.com",
|
||||||
|
"{} does not match {:?}",
|
||||||
|
icarus_envy::keys::ALLOWED_ORIGINS,
|
||||||
|
result
|
||||||
|
);
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
result.has_delimiter, true,
|
||||||
|
"The {} variable has an issue finding the delimiter",
|
||||||
|
result.key
|
||||||
|
);
|
||||||
|
|
||||||
|
match icarus_envy::utility::delimitize(&result) {
|
||||||
|
Ok(allowed_origins) => {
|
||||||
|
assert_eq!(
|
||||||
|
allowed_origins.len(),
|
||||||
|
2,
|
||||||
|
"The amount of allowed origins does not match. {} {}",
|
||||||
|
allowed_origins.len(),
|
||||||
|
2
|
||||||
|
)
|
||||||
|
}
|
||||||
|
Err(err) => {
|
||||||
|
assert!(false, "Error: {:?}", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_get_env() {
|
||||||
|
let keys = vec![
|
||||||
|
(
|
||||||
|
"RANDOM_ENV_KEY",
|
||||||
|
"YouDon'tWantToButYouGottaChange|It'sGoingToHurtYouTryingToStayTheSame|AreYouInItOrYouInItForTheFame?|I'mTryingToFigureOutWhoLoveMeForMe",
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"MODNAR_ENV_KEY",
|
||||||
|
"FeelingTheMonsterClimbDeepserInsideOfMe|FeelingHimGnawingMyHeartAwayHungrily|I'llNeverLoseThisPain|NeverDreamOfYouAgain",
|
||||||
|
),
|
||||||
|
];
|
||||||
|
|
||||||
|
for (key, value) in keys.iter() {
|
||||||
|
let result = async_std::task::block_on(icarus_envy::environment::get_env(key));
|
||||||
|
assert_eq!(
|
||||||
|
result.value, *value,
|
||||||
|
"{:?} does not match {:?}",
|
||||||
|
key, result
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user