initial commit, empty rocket server

This commit is contained in:
Philippe Loctaux 2023-02-27 12:25:58 +01:00
commit 27d02a0d5c
11 changed files with 2980 additions and 0 deletions

8
.gitignore vendored Normal file
View file

@ -0,0 +1,8 @@
# rust
/target
# ide
.idea/
# os
.DS_Store

17
.woodpecker/rust.yml Normal file
View file

@ -0,0 +1,17 @@
variables:
- &rust_image 'rust:1.67'
pipeline:
build:
image: *rust_image
commands:
# setup
- rm rust-toolchain.toml # use default installed toolchain
- rustup show
# test
- cargo test
# clippy
- rustup component add clippy
- cargo clippy

2860
Cargo.lock generated Normal file

File diff suppressed because it is too large Load diff

5
Cargo.toml Normal file
View file

@ -0,0 +1,5 @@
[workspace]
members = [
"crates/*"
]

10
crates/ezidam/Cargo.toml Normal file
View file

@ -0,0 +1,10 @@
[package]
name = "ezidam"
version = "0.1.0"
edition = "2021"
[dependencies]
rocket = "0.5.0-rc.2"
rocket_db_pools = { version = "0.1.0-rc.2", features = ["sqlx_sqlite"] }
rocket_dyn_templates = { version = "0.1.0-rc.2", features = ["tera"] }
infer = { version = "0.12.0", default-features = false }

15
crates/ezidam/justfile Executable file
View file

@ -0,0 +1,15 @@
#!/usr/bin/env just --justfile
cargo := "cargo"
# list recipes
default:
just --list
# start web server
start:
{{cargo}} run
# dev server
dev:
{{cargo}} watch -x "run"

21
crates/ezidam/readme.md Normal file
View file

@ -0,0 +1,21 @@
# ezidam
web server for ezidam
## initial setup
- install https://github.com/casey/just (it's like `make` but simpler)
- install https://github.com/watchexec/watchexec (to restart server when updating files)
## tools
- `just start` to start the web server in debug mode
- `just dev` to restart the web server when files are edited
## documentation
head over to [rocket.rs](https://rocket.rs) to read rocket's documentation
## configuration
to configure the web server, see `Rocket.toml` and the [reference](https://rocket.rs/v0.5-rc/guide/configuration/#rockettoml)

19
crates/ezidam/src/main.rs Normal file
View file

@ -0,0 +1,19 @@
mod shutdown;
// see for using rocket with main function https://github.com/intellij-rust/intellij-rust/issues/5975#issuecomment-920620289
#[rocket::main]
async fn main() -> std::result::Result<(), rocket::Error> {
// Build server
let rocket_builder = rocket::build();
// Shutdown
let rocket_builder = shutdown::shutdown(rocket_builder);
// Launch server
let _ = rocket_builder
.launch()
.await
.expect("Failed to launch server");
Ok(())
}

View file

@ -0,0 +1,10 @@
use rocket::fairing::AdHoc;
use rocket::{Build, Rocket};
pub fn shutdown(rocket_builder: Rocket<Build>) -> Rocket<Build> {
rocket_builder.attach(AdHoc::on_shutdown("Shutdown", |_| {
Box::pin(async move {
println!("Shutdown has been requested");
})
}))
}

13
readme.md Normal file
View file

@ -0,0 +1,13 @@
# ezidam
pronounced as "ez" + "idam"
- ez: easy
- idam: identity and access management [wikipedia](https://en.wikipedia.org/wiki/Identity_management)
## setup
1. install rust via [rustup](https://rustup.rs)
2. install the `nightly` toolchain with `rustup toolchain install nightly`
use the nightly toolchain during development, it can provide better errors

2
rust-toolchain.toml Normal file
View file

@ -0,0 +1,2 @@
[toolchain]
channel = "nightly"