37 lines
890 B
Rust
37 lines
890 B
Rust
extern crate actix_web;
|
|
extern crate diesel;
|
|
use std::io;
|
|
|
|
use actix_cors::Cors;
|
|
use actix_web::{App, HttpServer, middleware};
|
|
use diesel::PgConnection;
|
|
use diesel::r2d2::{ConnectionManager, Pool, PooledConnection};
|
|
|
|
mod connection;
|
|
mod constants;
|
|
mod loota;
|
|
mod models;
|
|
mod schema;
|
|
|
|
pub type DBPool = Pool<ConnectionManager<PgConnection>>;
|
|
pub type DBPooledConnection = PooledConnection<ConnectionManager<PgConnection>>;
|
|
|
|
#[actix_rt::main]
|
|
async fn main() -> io::Result<()> {
|
|
env_logger::init();
|
|
|
|
HttpServer::new(|| {
|
|
App::new()
|
|
.wrap(Cors::permissive())
|
|
.wrap(middleware::Logger::default())
|
|
.service(loota::get)
|
|
.service(loota::get_admin_orders)
|
|
.service(loota::get_admin)
|
|
.service(loota::get_admin_boxes)
|
|
.service(loota::update)
|
|
})
|
|
.bind("0.0.0.0:9090")?
|
|
.run()
|
|
.await
|
|
}
|