aboutsummaryrefslogtreecommitdiff
path: root/backend/src/lib.rs
blob: 8807637029bd862b3ef2a75c2bec9dd768b4e61c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#![feature(proc_macro_hygiene, decl_macro)]

use rocket::{Build, Rocket};
use rocket_sync_db_pools::database;

#[macro_use]
extern crate rocket;
#[macro_use]
extern crate diesel;

pub mod db;
pub mod routes;
pub mod schema;

#[database("postgresql_database")]
pub struct DbConn(diesel::PgConnection);

#[get("/")]
fn index() -> &'static str {
    "Hello, world!"
}

pub fn rocket() -> Rocket<Build> {
    rocket::build()
        .mount(
            "/",
            routes![
                index,
                routes::users::register,
                routes::users::login,
                routes::users::current_user,
                routes::bots::create_bot,
                routes::bots::get_bot,
                routes::bots::upload_bot_code,
            ],
        )
        .attach(DbConn::fairing())
}