diff --git a/Cargo.lock b/Cargo.lock
index 312acb6..1441370 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -2,6 +2,99 @@
# It is not intended for manual editing.
version = 3
+[[package]]
+name = "actix"
+version = "0.13.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f728064aca1c318585bf4bb04ffcfac9e75e508ab4e8b1bd9ba5dfe04e2cbed5"
+dependencies = [
+ "actix-rt",
+ "actix_derive",
+ "bitflags",
+ "bytes",
+ "crossbeam-channel",
+ "futures-core",
+ "futures-sink",
+ "futures-task",
+ "futures-util",
+ "log",
+ "once_cell",
+ "parking_lot 0.12.0",
+ "pin-project-lite",
+ "smallvec",
+ "tokio",
+ "tokio-util 0.7.1",
+]
+
+[[package]]
+name = "actix-codec"
+version = "0.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "57a7559404a7f3573127aab53c08ce37a6c6a315c374a31070f3c91cd1b4a7fe"
+dependencies = [
+ "bitflags",
+ "bytes",
+ "futures-core",
+ "futures-sink",
+ "log",
+ "memchr",
+ "pin-project-lite",
+ "tokio",
+ "tokio-util 0.7.1",
+]
+
+[[package]]
+name = "actix-http"
+version = "3.0.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a5885cb81a0d4d0d322864bea1bb6c2a8144626b4fdc625d4c51eba197e7797a"
+dependencies = [
+ "actix-codec",
+ "actix-rt",
+ "actix-service",
+ "actix-utils",
+ "ahash",
+ "base64",
+ "bitflags",
+ "brotli",
+ "bytes",
+ "bytestring",
+ "derive_more",
+ "encoding_rs",
+ "flate2",
+ "futures-core",
+ "h2",
+ "http",
+ "httparse",
+ "httpdate",
+ "itoa",
+ "language-tags",
+ "local-channel",
+ "log",
+ "mime",
+ "percent-encoding",
+ "pin-project-lite",
+ "rand",
+ "sha-1 0.10.0",
+ "smallvec",
+ "zstd",
+]
+
+[[package]]
+name = "actix-identity"
+version = "0.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "171fe3ed055b2dd50c61967911d253d47e76e1d4308acfbf99fc7affe5ec42aa"
+dependencies = [
+ "actix-service",
+ "actix-utils",
+ "actix-web",
+ "futures-util",
+ "serde",
+ "serde_json",
+ "time 0.3.9",
+]
+
[[package]]
name = "actix-macros"
version = "0.2.3"
@@ -12,6 +105,20 @@ dependencies = [
"syn",
]
+[[package]]
+name = "actix-router"
+version = "0.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "eb60846b52c118f2f04a56cc90880a274271c489b2498623d58176f8ca21fa80"
+dependencies = [
+ "bytestring",
+ "firestorm",
+ "http",
+ "log",
+ "regex",
+ "serde",
+]
+
[[package]]
name = "actix-rt"
version = "2.7.0"
@@ -23,12 +130,149 @@ dependencies = [
"tokio",
]
+[[package]]
+name = "actix-server"
+version = "2.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0da34f8e659ea1b077bb4637948b815cd3768ad5a188fdcd74ff4d84240cd824"
+dependencies = [
+ "actix-rt",
+ "actix-service",
+ "actix-utils",
+ "futures-core",
+ "futures-util",
+ "mio",
+ "num_cpus",
+ "socket2",
+ "tokio",
+ "tracing",
+]
+
+[[package]]
+name = "actix-service"
+version = "2.0.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3b894941f818cfdc7ccc4b9e60fa7e53b5042a2e8567270f9147d5591893373a"
+dependencies = [
+ "futures-core",
+ "paste",
+ "pin-project-lite",
+]
+
+[[package]]
+name = "actix-utils"
+version = "3.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e491cbaac2e7fc788dfff99ff48ef317e23b3cf63dbaf7aaab6418f40f92aa94"
+dependencies = [
+ "local-waker",
+ "pin-project-lite",
+]
+
+[[package]]
+name = "actix-web"
+version = "4.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f4e5ebffd51d50df56a3ae0de0e59487340ca456f05dd0b90c0a7a6dd6a74d31"
+dependencies = [
+ "actix-codec",
+ "actix-http",
+ "actix-macros",
+ "actix-router",
+ "actix-rt",
+ "actix-server",
+ "actix-service",
+ "actix-utils",
+ "actix-web-codegen",
+ "ahash",
+ "bytes",
+ "bytestring",
+ "cfg-if",
+ "cookie",
+ "derive_more",
+ "encoding_rs",
+ "futures-core",
+ "futures-util",
+ "itoa",
+ "language-tags",
+ "log",
+ "mime",
+ "once_cell",
+ "pin-project-lite",
+ "regex",
+ "serde",
+ "serde_json",
+ "serde_urlencoded",
+ "smallvec",
+ "socket2",
+ "time 0.3.9",
+ "url",
+]
+
+[[package]]
+name = "actix-web-codegen"
+version = "4.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7525bedf54704abb1d469e88d7e7e9226df73778798a69cea5022d53b2ae91bc"
+dependencies = [
+ "actix-router",
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
+[[package]]
+name = "actix_derive"
+version = "0.6.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6d44b8fee1ced9671ba043476deddef739dd0959bf77030b26b738cc591737a7"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
[[package]]
name = "adler"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
+[[package]]
+name = "aead"
+version = "0.4.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0b613b8e1e3cf911a086f53f03bf286f52fd7a7258e4fa606f0ef220d39d8877"
+dependencies = [
+ "generic-array 0.14.5",
+]
+
+[[package]]
+name = "aes"
+version = "0.7.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9e8b47f52ea9bae42228d07ec09eb676433d7c4ed1ebdf0f1d1c29ed446f1ab8"
+dependencies = [
+ "cfg-if",
+ "cipher",
+ "cpufeatures",
+ "opaque-debug 0.3.0",
+]
+
+[[package]]
+name = "aes-gcm"
+version = "0.9.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "df5f85a83a7d8b0442b6aa7b504b8212c1733da07b98aae43d4bc21b2cb3cdf6"
+dependencies = [
+ "aead",
+ "aes",
+ "cipher",
+ "ctr",
+ "ghash",
+ "subtle",
+]
+
[[package]]
name = "ahash"
version = "0.7.6"
@@ -98,6 +342,17 @@ dependencies = [
"num-traits",
]
+[[package]]
+name = "atty"
+version = "0.2.14"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
+dependencies = [
+ "hermit-abi",
+ "libc",
+ "winapi",
+]
+
[[package]]
name = "autocfg"
version = "1.1.0"
@@ -206,11 +461,23 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c4872d67bab6358e59559027aa3b9157c53d9358c51423c17554809a8858e0f8"
+[[package]]
+name = "bytestring"
+version = "1.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "90706ba19e97b90786e19dc0d5e2abd80008d99d4c0c5d1ad0b5e72cec7c494d"
+dependencies = [
+ "bytes",
+]
+
[[package]]
name = "cc"
version = "1.0.73"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11"
+dependencies = [
+ "jobserver",
+]
[[package]]
name = "cfg-if"
@@ -252,6 +519,15 @@ dependencies = [
"phf_codegen",
]
+[[package]]
+name = "cipher"
+version = "0.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7ee52072ec15386f770805afd189a01c8841be8696bed250fa2f13c4c0d6dfb7"
+dependencies = [
+ "generic-array 0.14.5",
+]
+
[[package]]
name = "config"
version = "0.13.1"
@@ -283,6 +559,24 @@ version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e"
+[[package]]
+name = "cookie"
+version = "0.16.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "94d4706de1b0fa5b132270cddffa8585166037822e260a944fe161acd137ca05"
+dependencies = [
+ "aes-gcm",
+ "base64",
+ "hkdf",
+ "hmac",
+ "percent-encoding",
+ "rand",
+ "sha2",
+ "subtle",
+ "time 0.3.9",
+ "version_check",
+]
+
[[package]]
name = "core-foundation"
version = "0.9.3"
@@ -332,6 +626,16 @@ dependencies = [
"cfg-if",
]
+[[package]]
+name = "crossbeam-channel"
+version = "0.5.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5aaa7bd5fb665c6864b5f963dd9097905c54125909c7aa94c9e18507cdbe6c53"
+dependencies = [
+ "cfg-if",
+ "crossbeam-utils",
+]
+
[[package]]
name = "crossbeam-queue"
version = "0.3.5"
@@ -362,6 +666,15 @@ dependencies = [
"typenum",
]
+[[package]]
+name = "ctr"
+version = "0.8.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "049bb91fb4aaf0e3c7efa6cd5ef877dbbbd15b39dad06d9948de4ec8a75761ea"
+dependencies = [
+ "cipher",
+]
+
[[package]]
name = "data-encoding"
version = "2.3.2"
@@ -497,6 +810,19 @@ dependencies = [
"syn",
]
+[[package]]
+name = "env_logger"
+version = "0.7.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36"
+dependencies = [
+ "atty",
+ "humantime",
+ "log",
+ "regex",
+ "termcolor",
+]
+
[[package]]
name = "event-listener"
version = "2.5.2"
@@ -529,6 +855,12 @@ dependencies = [
"url",
]
+[[package]]
+name = "firestorm"
+version = "0.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4d3d6188b8804df28032815ea256b6955c9625c24da7525f387a7af02fbb8f01"
+
[[package]]
name = "flate2"
version = "1.0.23"
@@ -692,6 +1024,16 @@ dependencies = [
"wasi 0.10.2+wasi-snapshot-preview1",
]
+[[package]]
+name = "ghash"
+version = "0.4.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1583cc1656d7839fd3732b80cf4f38850336cdb9b8ded1cd399ca62958de3c99"
+dependencies = [
+ "opaque-debug 0.3.0",
+ "polyval",
+]
+
[[package]]
name = "gitea"
version = "0.1.0"
@@ -868,6 +1210,15 @@ version = "1.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "02296996cb8796d7c6e3bc2d9211b7802812d36999a51bb754123ead7d37d026"
+[[package]]
+name = "humantime"
+version = "1.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f"
+dependencies = [
+ "quick-error",
+]
+
[[package]]
name = "hyper"
version = "0.14.18"
@@ -1005,6 +1356,15 @@ version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1aab8fc367588b89dcee83ab0fd66b72b50b72fa1904d7095045ace2b0c81c35"
+[[package]]
+name = "jobserver"
+version = "0.1.24"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "af25a77299a7f711a01975c35a6a424eb6862092cc2d6c72c4ed6cbc56dfc1fa"
+dependencies = [
+ "libc",
+]
+
[[package]]
name = "js-sys"
version = "0.3.57"
@@ -1025,6 +1385,12 @@ dependencies = [
"serde",
]
+[[package]]
+name = "language-tags"
+version = "0.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d4345964bb142484797b161f473a503a434de77149dd8c7427788c6e13379388"
+
[[package]]
name = "lazy_static"
version = "1.4.0"
@@ -1054,6 +1420,24 @@ version = "0.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7fb9b38af92608140b86b693604b9ffcc5824240a484d1ecd4795bacb2fe88f3"
+[[package]]
+name = "local-channel"
+version = "0.1.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7f303ec0e94c6c54447f84f3b0ef7af769858a9c4ef56ef2a986d3dcd4c3fc9c"
+dependencies = [
+ "futures-core",
+ "futures-sink",
+ "futures-util",
+ "local-waker",
+]
+
+[[package]]
+name = "local-waker"
+version = "0.1.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e34f76eb3611940e0e7d53a9aaa4e6a3151f69541a282fd0dad5571420c53ff1"
+
[[package]]
name = "lock_api"
version = "0.4.7"
@@ -1234,6 +1618,15 @@ dependencies = [
"libc",
]
+[[package]]
+name = "num_threads"
+version = "0.1.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2819ce041d2ee131036f4fc9d6ae7ae125a3a40e97ba64d04fe799ad9dabbb44"
+dependencies = [
+ "libc",
+]
+
[[package]]
name = "once_cell"
version = "1.10.0"
@@ -1246,6 +1639,12 @@ version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c"
+[[package]]
+name = "opaque-debug"
+version = "0.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5"
+
[[package]]
name = "openssl"
version = "0.10.40"
@@ -1496,12 +1895,34 @@ version = "0.3.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1df8c4ec4b0627e53bdf214615ad287367e482558cf84b109250b37464dc03ae"
+[[package]]
+name = "polyval"
+version = "0.5.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8419d2b623c7c0896ff2d5d96e2cb4ede590fed28fcc34934f4c33c036e620a1"
+dependencies = [
+ "cfg-if",
+ "cpufeatures",
+ "opaque-debug 0.3.0",
+ "universal-hash",
+]
+
[[package]]
name = "ppv-lite86"
version = "0.2.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872"
+[[package]]
+name = "pretty_env_logger"
+version = "0.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "926d36b9553851b8b0005f1275891b392ee4d2d833852c417ed025477350fb9d"
+dependencies = [
+ "env_logger",
+ "log",
+]
+
[[package]]
name = "proc-macro-error"
version = "1.0.4"
@@ -1969,7 +2390,7 @@ dependencies = [
"block-buffer 0.7.3",
"digest 0.8.1",
"fake-simd",
- "opaque-debug",
+ "opaque-debug 0.2.3",
]
[[package]]
@@ -2139,7 +2560,7 @@ dependencies = [
"sqlx-rt",
"stringprep",
"thiserror",
- "time",
+ "time 0.2.27",
"tokio-stream",
"url",
"uuid",
@@ -2195,7 +2616,10 @@ dependencies = [
name = "starchart"
version = "0.1.0"
dependencies = [
+ "actix",
+ "actix-identity",
"actix-rt",
+ "actix-web",
"async-trait",
"config",
"db-core",
@@ -2207,6 +2631,7 @@ dependencies = [
"lazy_static",
"log",
"mktemp",
+ "pretty_env_logger",
"publiccodeyml",
"rand",
"reqwest",
@@ -2332,6 +2757,15 @@ dependencies = [
"unic-segment",
]
+[[package]]
+name = "termcolor"
+version = "1.1.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755"
+dependencies = [
+ "winapi-util",
+]
+
[[package]]
name = "thiserror"
version = "1.0.31"
@@ -2371,11 +2805,23 @@ dependencies = [
"libc",
"standback",
"stdweb",
- "time-macros",
+ "time-macros 0.1.1",
"version_check",
"winapi",
]
+[[package]]
+name = "time"
+version = "0.3.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c2702e08a7a860f005826c6815dcac101b19b5eb330c27fe4a5928fec1d20ddd"
+dependencies = [
+ "itoa",
+ "libc",
+ "num_threads",
+ "time-macros 0.2.4",
+]
+
[[package]]
name = "time-macros"
version = "0.1.1"
@@ -2386,6 +2832,12 @@ dependencies = [
"time-macros-impl",
]
+[[package]]
+name = "time-macros"
+version = "0.2.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "42657b1a6f4d817cda8e7a0ace261fe0cc946cf3a80314390b22cc61ae080792"
+
[[package]]
name = "time-macros-impl"
version = "0.1.2"
@@ -2526,6 +2978,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5d0ecdcb44a79f0fe9844f0c4f33a342cbcbb5117de8001e6ba0dc2351327d09"
dependencies = [
"cfg-if",
+ "log",
"pin-project-lite",
"tracing-attributes",
"tracing-core",
@@ -2713,6 +3166,16 @@ version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "39ec24b3121d976906ece63c9daad25b85969647682eee313cb5779fdd69e14e"
+[[package]]
+name = "universal-hash"
+version = "0.4.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9f214e8f697e925001e66ec2c6e37a4ef93f0f78c2eed7814394e10c62025b05"
+dependencies = [
+ "generic-array 0.14.5",
+ "subtle",
+]
+
[[package]]
name = "untrusted"
version = "0.7.1"
@@ -3058,3 +3521,32 @@ checksum = "56c1936c4cc7a1c9ab21a1ebb602eb942ba868cbd44a99cb7cdc5892335e1c85"
dependencies = [
"linked-hash-map",
]
+
+[[package]]
+name = "zstd"
+version = "0.10.2+zstd.1.5.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5f4a6bd64f22b5e3e94b4e238669ff9f10815c27a5180108b849d24174a83847"
+dependencies = [
+ "zstd-safe",
+]
+
+[[package]]
+name = "zstd-safe"
+version = "4.1.6+zstd.1.5.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "94b61c51bb270702d6167b8ce67340d2754b088d0c091b06e593aa772c3ee9bb"
+dependencies = [
+ "libc",
+ "zstd-sys",
+]
+
+[[package]]
+name = "zstd-sys"
+version = "1.6.3+zstd.1.5.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "fc49afa5c8d634e75761feda8c592051e7eeb4683ba827211eb0d731d3402ea8"
+dependencies = [
+ "cc",
+ "libc",
+]
diff --git a/Cargo.toml b/Cargo.toml
index 8671309..44236e7 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -23,6 +23,9 @@ members = [
[dependencies]
actix-rt = "2.7"
+actix-web = "4.0.1"
+actix = "0.13"
+actix-identity = "0.4.0"
async-trait = "0.1.51"
config = "0.13.0"
lazy_static = "1.4.0"
@@ -33,6 +36,7 @@ url = { version = "2.2.2", features = ["serde"] }
validator = { version = "0.15", features = ["derive"]}
derive_more = "0.99.17"
log = "0.4.16"
+pretty_env_logger = "0.4"
[dependencies.reqwest]
features = ["rustls-tls-native-roots", "gzip", "deflate", "brotli", "json"]
@@ -52,13 +56,9 @@ version = "0.21.1"
[dependencies.db-core]
path = "./db/db-core"
-#[dependencies.db-sqlx-postgres]
-#path = "./db/db-sqlx-postgres"
-#
[dependencies.db-sqlx-sqlite]
path = "./db/db-sqlx-sqlite"
-
[dependencies.gitea]
path = "./forge/gitea"
diff --git a/src/federate.rs b/src/federate.rs
index 7a68cc0..52cd577 100644
--- a/src/federate.rs
+++ b/src/federate.rs
@@ -14,14 +14,16 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see .
*/
-use crate::settings::Settings;
-use federate_core::Federate;
+use std::sync::Arc;
+use federate_core::Federate;
use publiccodeyml::{errors::FederateErorr, PccFederate};
-pub type BoxFederate = Box>;
+use crate::settings::Settings;
-pub async fn get_federate(settings: Option) -> BoxFederate {
+pub type ArcFederate = Arc>;
+
+pub async fn get_federate(settings: Option) -> ArcFederate {
let settings = settings.unwrap_or_else(|| Settings::new().unwrap());
- Box::new(PccFederate::new(settings.repository.root).await.unwrap())
+ Arc::new(PccFederate::new(settings.repository.root).await.unwrap())
}
diff --git a/src/main.rs b/src/main.rs
index d4694fb..51b6927 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -15,6 +15,10 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see .
*/
+use std::sync::Arc;
+
+use actix_web::{middleware, web::Data, App, HttpServer};
+
pub mod ctx;
pub mod db;
pub mod federate;
@@ -26,10 +30,52 @@ mod tests;
pub mod utils;
pub mod verify;
+use crate::federate::{get_federate, ArcFederate};
+use ctx::Ctx;
+use db::{sqlite, BoxDB};
+use settings::Settings;
+
pub const VERSION: &str = env!("CARGO_PKG_VERSION");
pub const PKG_NAME: &str = env!("CARGO_PKG_NAME");
pub const GIT_COMMIT_HASH: &str = env!("GIT_HASH");
pub const DOMAIN: &str = "developer-starchart.forgeflux.org";
+pub type ArcCtx = Arc;
+
+pub type WebCtx = Data;
+pub type WebData = Data;
+pub type WebFederate = Data;
+
#[actix_rt::main]
-async fn main() {}
+async fn main() {
+ let settings = Settings::new().unwrap();
+ pretty_env_logger::init();
+
+ let ctx = Ctx::new(settings.clone()).await;
+ let db = sqlite::get_data(Some(settings.clone())).await;
+ let federate = get_federate(Some(settings.clone())).await;
+
+ let socket_addr = settings.server.get_ip();
+
+ HttpServer::new(move || {
+ App::new()
+ .wrap(middleware::Logger::default())
+ .wrap(middleware::Compress::default())
+ .app_data(federate.clone())
+ .app_data(db.clone())
+ .app_data(ctx.clone())
+ .wrap(
+ middleware::DefaultHeaders::new().add(("Permissions-Policy", "interest-cohort=()")),
+ )
+ .configure(services)
+ })
+ .bind(&socket_addr)
+ .unwrap()
+ .run()
+ .await
+ .unwrap();
+}
+
+fn services(cfg: &mut actix_web::web::ServiceConfig) {
+ // cfg.service();
+}
diff --git a/src/spider.rs b/src/spider.rs
index 42fdb17..479186b 100644
--- a/src/spider.rs
+++ b/src/spider.rs
@@ -26,10 +26,10 @@ use gitea::Gitea;
use crate::ctx::Ctx;
use crate::db::BoxDB;
-use crate::federate::BoxFederate;
+use crate::federate::ArcFederate;
impl Ctx {
- pub async fn crawl(&self, instance_url: &str, db: &BoxDB, federate: &BoxFederate) {
+ pub async fn crawl(&self, instance_url: &str, db: &BoxDB, federate: &ArcFederate) {
let gitea = Gitea::new(Url::parse(instance_url).unwrap(), self.client.clone());
let mut page = 1;
let hostname = gitea.get_hostname();
diff --git a/src/tests.rs b/src/tests.rs
index c9c14b2..ab99296 100644
--- a/src/tests.rs
+++ b/src/tests.rs
@@ -21,7 +21,7 @@ pub use std::sync::Arc;
use crate::ctx::Ctx;
pub use crate::db::BoxDB;
-pub use crate::federate::{get_federate, BoxFederate};
+pub use crate::federate::{get_federate, ArcFederate};
use crate::settings::{DBType, Settings};
//pub mod sqlx_postgres {
@@ -41,7 +41,7 @@ pub mod sqlx_sqlite {
use crate::db::sqlite;
use mktemp::Temp;
- pub async fn get_ctx() -> (BoxDB, Arc, BoxFederate, Temp) {
+ pub async fn get_ctx() -> (BoxDB, Arc, ArcFederate, Temp) {
let url = env::var("SQLITE_DATABASE_URL").unwrap();
env::set_var("DATABASE_URL", &url);
println!("found db url: {url}");