Last active
April 18, 2020 08:50
-
-
Save AselSiriwardena/c6f20cbdb41cf5a9070e80315a21a7f7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![feature(plugin, const_fn, decl_macro, proc_macro_hygiene)] | |
#![allow(proc_macro_derive_resolution_fallback, unused_attributes)] | |
#[macro_use] | |
extern crate diesel; | |
extern crate dotenv; | |
extern crate r2d2; | |
extern crate r2d2_diesel; | |
#[macro_use] | |
extern crate rocket; | |
extern crate rocket_contrib; | |
#[macro_use] | |
extern crate serde_derive; | |
#[macro_use] | |
extern crate serde_json; | |
use dotenv::dotenv; | |
use std::env; | |
use routes::*; | |
use std::process::Command; | |
mod db; | |
mod models; | |
mod routes; | |
mod schema; | |
fn rocket() -> rocket::Rocket { | |
dotenv().ok(); | |
let database_url = env::var("DATABASE_URL").expect("set DATABASE_URL"); | |
let pool = db::init_pool(database_url); | |
rocket::ignite() | |
.manage(pool) | |
.mount( | |
"/api/v1/", | |
routes![get_all, new_user, find_user], | |
) | |
} | |
fn main() { | |
let _output = if cfg!(target_os = "windows") { | |
Command::new("cmd") | |
.args(&["/C", "cd ui && npm start"]) | |
.spawn() | |
.expect("Failed to start UI Application") | |
} else { | |
Command::new("sh") | |
.arg("-c") | |
.arg("cd ui && npm start") | |
.spawn() | |
.expect("Failed to start UI Application") | |
}; | |
rocket().launch(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment