From 17507b09450fb87957b8d3e1b1f3d9e3f4a79dd4 Mon Sep 17 00:00:00 2001 From: Jonas_Jones Date: Wed, 6 Mar 2024 13:58:08 +0100 Subject: [PATCH] temp push --- .env-TEMPLATE | 5 ++ Cargo.lock | 206 +++++++++++++++++++++++++++++++++++++++++++++++++- Cargo.toml | 1 + README.md | 10 +++ 4 files changed, 221 insertions(+), 1 deletion(-) diff --git a/.env-TEMPLATE b/.env-TEMPLATE index 7948092..bc6731b 100644 --- a/.env-TEMPLATE +++ b/.env-TEMPLATE @@ -2,3 +2,8 @@ API_PORT = 5000 API_IP = "127.0.0.1" LASTFM_API_KEY = "" LASTFM_API_SECRET = "" +DB_URL = "localhost" +DB_PORT = 27017 +DB_NAME = "" +DB_USER = "" +DB_PASS = "" diff --git a/Cargo.lock b/Cargo.lock index 26fde4a..2dcb864 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -63,6 +63,17 @@ dependencies = [ "syn", ] +[[package]] +name = "async-trait" +version = "0.1.76" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "531b97fb4cd3dfdce92c35dedbfdc1f0b9d8091c8ca943d6dae340ef5012d514" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "autocfg" version = "1.1.0" @@ -217,6 +228,12 @@ version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77c90badedccf4105eca100756a0b1289e191f6fcbdadd3cee1d2f614f97da8f" +[[package]] +name = "either" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11157ac094ffbdde99aa67b23417ebdd801842852b500e395a45a9c0aac03e4a" + [[package]] name = "encoding_rs" version = "0.8.33" @@ -226,6 +243,18 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "enum_dispatch" +version = "0.3.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f33313078bb8d4d05a2733a94ac4c2d8a0df9a2b84424ebf4f33bfc224a890e" +dependencies = [ + "once_cell", + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "equivalent" version = "1.0.1" @@ -278,6 +307,21 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "futures" +version = "0.3.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da0290714b38af9b4a7b094b8a37086d1b4e61f2df9122c3cad2577669145335" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + [[package]] name = "futures-channel" version = "0.3.29" @@ -294,6 +338,34 @@ version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eb1d22c66e66d9d72e1758f0bd7d4fd0bee04cad842ee34587d68c07e45d088c" +[[package]] +name = "futures-executor" +version = "0.3.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f4fb8693db0cf099eadcca0efe2a5a22e4550f98ed16aba6c48700da29597bc" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-io" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" + +[[package]] +name = "futures-macro" +version = "0.3.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53b153fd91e4b0147f4aced87be237c98248656bb01050b96bf3ee89220a8ddb" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "futures-sink" version = "0.3.29" @@ -312,9 +384,13 @@ version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a19526d624e703a3179b3d322efec918b6246ea0fa51d41124525f00f1cc8104" dependencies = [ + "futures-channel", "futures-core", + "futures-io", + "futures-macro", "futures-sink", "futures-task", + "memchr", "pin-project-lite", "pin-utils", "slab", @@ -411,6 +487,12 @@ dependencies = [ "http", ] +[[package]] +name = "heck" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" + [[package]] name = "hermit-abi" version = "0.3.3" @@ -568,7 +650,7 @@ dependencies = [ [[package]] name = "jonas_jones-api" -version = "0.3.0" +version = "0.4.1" dependencies = [ "chrono", "dotenv", @@ -578,6 +660,7 @@ dependencies = [ "parking_lot", "regex", "reqwest", + "rspotify", "serde", "serde_json", "tokio", @@ -690,6 +773,17 @@ version = "0.4.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" +[[package]] +name = "maybe-async" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "afc95a651c82daf7004c824405aa1019723644950d488571bd718e3ed84646ed" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "memchr" version = "2.6.4" @@ -1039,6 +1133,7 @@ dependencies = [ "tokio", "tokio-native-tls", "tokio-rustls", + "tokio-socks", "tower-service", "url", "wasm-bindgen", @@ -1062,6 +1157,64 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "rspotify" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87c6f1d86b10201655f0cd4002088bafe4abcc75cc610613c995abd719f40fcb" +dependencies = [ + "async-stream", + "async-trait", + "base64", + "chrono", + "futures", + "getrandom", + "log", + "maybe-async", + "rspotify-http", + "rspotify-macros", + "rspotify-model", + "serde", + "serde_json", + "sha2", + "thiserror", + "url", +] + +[[package]] +name = "rspotify-http" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dad45cd393a8685ee36ec6d2accbb2c955e21ac036a2e4eb175985783f30ed78" +dependencies = [ + "async-trait", + "log", + "maybe-async", + "reqwest", + "serde_json", + "thiserror", +] + +[[package]] +name = "rspotify-macros" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc4892882851a97ee7210e423725ce116e8239157c649af37e208fe93855638a" + +[[package]] +name = "rspotify-model" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bae90ab3d6e4cb4ccd7f2887c4363d19b1419800e132d3fb95e2f9b24c05f4d7" +dependencies = [ + "chrono", + "enum_dispatch", + "serde", + "serde_json", + "strum", + "thiserror", +] + [[package]] name = "rustc-demangle" version = "0.1.23" @@ -1112,6 +1265,12 @@ dependencies = [ "untrusted", ] +[[package]] +name = "rustversion" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" + [[package]] name = "ryu" version = "1.0.15" @@ -1235,6 +1394,17 @@ dependencies = [ "digest", ] +[[package]] +name = "sha2" +version = "0.10.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + [[package]] name = "signal-hook-registry" version = "1.4.1" @@ -1285,6 +1455,28 @@ version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" +[[package]] +name = "strum" +version = "0.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "290d54ea6f91c969195bdbcd7442c8c2a2ba87da8bf60a7ee86a235d4bc1e125" +dependencies = [ + "strum_macros", +] + +[[package]] +name = "strum_macros" +version = "0.25.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23dc1fa9ac9c169a78ba62f0b841814b7abae11bdd047b9c58f893439e309ea0" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "rustversion", + "syn", +] + [[package]] name = "syn" version = "2.0.39" @@ -1415,6 +1607,18 @@ dependencies = [ "tokio", ] +[[package]] +name = "tokio-socks" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51165dfa029d2a65969413a6cc96f354b86b464498702f174a4efa13608fd8c0" +dependencies = [ + "either", + "futures-util", + "thiserror", + "tokio", +] + [[package]] name = "tokio-stream" version = "0.1.14" diff --git a/Cargo.toml b/Cargo.toml index c2c6cb0..fc5e865 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,3 +19,4 @@ reqwest = { version = "0.11.22", features = ["json"] } serde_json = "1.0.108" regex = "1" git2 = "0.18.1" +rspotify = "0.12.0" diff --git a/README.md b/README.md index 4c7b7b1..77b77a4 100644 --- a/README.md +++ b/README.md @@ -27,12 +27,22 @@ If you want to run the API in a production environment, you will need to set the - API_IP - LASTFM_API_KEY - LASTFM_API_SECRET +- DB_URL +- DB_PORT +- DB_NAME +- DB_USER +- DB_PASS ```bash export API_PORT={port} export API_IP={ip_address} export LASTFM_API_KEY={lastfm_api_key} export LASTFM_API_SECRET={lastfm_api_secret} +export DB_URL = "{db_url}" +export DB_PORT = {db_port} +export DB_NAME = "{db_name}" +export DB_USER = "{db_user}" +export DB_PASS = "db_password" ``` ## Docker Compose