aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorFuwn <[email protected]>2021-05-12 23:48:04 -0700
committerFuwn <[email protected]>2021-05-12 23:48:04 -0700
commit6c2ea68bbef0e1fc0b50b80f113b0ebcdf745a40 (patch)
treea2330c4408f17cb1fc637f5263ee1432c1b62c2b /src/main.rs
downloadlime-old-6c2ea68bbef0e1fc0b50b80f113b0ebcdf745a40.tar.xz
lime-old-6c2ea68bbef0e1fc0b50b80f113b0ebcdf745a40.zip
feat: :star:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs
new file mode 100644
index 0000000..018bae6
--- /dev/null
+++ b/src/main.rs
@@ -0,0 +1,44 @@
+// Copyleft (ɔ) 2021-2021 Fuwn
+// SPDX-License-Identifier: GPL-3.0-only
+
+#[macro_use]
+extern crate actix_web;
+#[macro_use]
+extern crate serde_derive;
+#[macro_use]
+extern crate diesel;
+#[macro_use]
+extern crate simple_error;
+
+pub mod routes;
+pub mod structure;
+
+pub mod db;
+
+use actix_web::web;
+use routes::*;
+
+#[actix_web::main]
+async fn main() -> std::io::Result<()> {
+ dotenv::dotenv().ok();
+
+ actix_web::HttpServer::new(|| {
+ actix_web::App::new()
+ .wrap(actix_cors::Cors::default().allow_any_origin())
+ .service(ui::index)
+ .service(ui::handle)
+ .service(ui::statistics)
+ .service(
+ web::scope("/api/v1")
+ .service(api::create)
+ .service(api::statistics)
+ .service(api::index),
+ )
+ })
+ .bind(format!(
+ "0.0.0.0:{}",
+ std::env::var("PORT").expect("no port was provided... why.")
+ ))?
+ .run()
+ .await
+}