aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
blob: 66f914cd19c1f18e49207f63907ad90e726f3f91 (plain) (blame)
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
39
40
41
// Copyleft (ɔ) 2021-2021 The Senpy Club
// SPDX-License-Identifier: GPL-3.0-only

#![feature(proc_macro_hygiene, decl_macro, type_ascription)]

#[macro_use]
extern crate rocket;

pub mod constants;
pub mod routes;
pub mod structures;
pub mod utils;

use rocket_cors as cors;

#[launch]
fn rocket() -> _ {
  dotenv::dotenv().ok();

  rocket::build()
    .manage(
      cors::CorsOptions {
        allowed_origins: cors::AllowedOrigins::all(),
        allowed_methods: cors::AllowedMethods::new(),
        allowed_headers: cors::AllowedHeaders::all(),
        ..Default::default()
      }
      .to_cors()
      .unwrap(),
    )
    .mount("/", routes![routes::index])
    .mount(
      "/api/v1",
      routes![
        routes::github,
        routes::languages,
        routes::language,
        routes::random
      ],
    )
}