Compare commits

..

2 commits

Author SHA1 Message Date
94c4428bb0 feat: add base_path to api
Lets you replace /api with whatever you want!
2025-05-29 20:41:50 +02:00
3c5f3fd654 style: rename url to frontend_url 2025-05-29 20:29:45 +02:00
8 changed files with 18 additions and 13 deletions

View file

@ -18,7 +18,8 @@ RUN useradd --create-home --home-dir /gorb gorb
USER gorb
ENV WEB_URL=https://gorb.app/web/ \
ENV WEB_FRONTEND_URL=https://gorb.app/web/ \
WEB_BASE_PATH=/api \
DATABASE_USERNAME=gorb \
DATABASE_PASSWORD=gorb \
DATABASE=gorb \

View file

@ -18,7 +18,7 @@ services:
- gorb-backend:/gorb
environment:
#- RUST_LOG=debug
- WEB_URL=https://gorb.app/web/
- WEB_FRONTEND_URL=https://gorb.app/web/
- DATABASE_USERNAME=gorb
- DATABASE_PASSWORD=gorb
- DATABASE=gorb

View file

@ -16,7 +16,7 @@ services:
- gorb-backend:/gorb
environment:
#- RUST_LOG=debug
- WEB_URL=https://gorb.app/web/
- WEB_FRONTEND_URL=https://gorb.app/web/
- DATABASE_USERNAME=gorb
- DATABASE_PASSWORD=gorb
- DATABASE=gorb

View file

@ -11,7 +11,8 @@ fi
if [ ! -f "/gorb/config/config.toml" ]; then
cat > /gorb/config/config.toml <<EOF
[web]
url = "${WEB_URL}"
frontend_url = "${WEB_FRONTEND_URL}"
base_path = "${WEB_BASE_PATH}"
[database]
username = "${DATABASE_USERNAME}"

View file

@ -6,6 +6,6 @@ use actix_web::web;
mod v1;
mod versions;
pub fn web() -> Scope {
web::scope("/api").service(v1::web()).service(versions::get)
pub fn web(path: &str) -> Scope {
web::scope(path.trim_end_matches('/')).service(v1::web()).service(versions::get)
}

View file

@ -38,7 +38,8 @@ pub struct CacheDatabase {
struct WebBuilder {
ip: Option<String>,
port: Option<u16>,
url: Url,
base_path: Option<String>,
frontend_url: Url,
_ssl: Option<bool>,
}
@ -85,7 +86,8 @@ impl ConfigBuilder {
let web = Web {
ip: self.web.ip.unwrap_or(String::from("0.0.0.0")),
port: self.web.port.unwrap_or(8080),
url: self.web.url,
base_path: self.web.base_path.unwrap_or("".to_string()),
frontend_url: self.web.frontend_url,
};
let endpoint = match &*self.bunny.endpoint {
@ -146,7 +148,8 @@ pub struct Config {
pub struct Web {
pub ip: String,
pub port: u16,
pub url: Url,
pub base_path: String,
pub frontend_url: Url,
}
#[derive(Debug, Clone)]

View file

@ -150,7 +150,7 @@ async fn main() -> Result<(), Error> {
App::new()
.app_data(web::Data::new(data.clone()))
.wrap(cors)
.service(api::web())
.service(api::web(&data.config.web.base_path))
})
.bind((web.ip, web.port))?
.run()

View file

@ -1014,7 +1014,7 @@ impl EmailToken {
.execute(&mut conn)
.await?;
let mut verify_endpoint = data.config.web.url.join("verify-email")?;
let mut verify_endpoint = data.config.web.frontend_url.join("verify-email")?;
verify_endpoint.set_query(Some(&format!("token={}", token)));
@ -1104,7 +1104,7 @@ impl PasswordResetToken {
.execute(&mut conn)
.await?;
let mut reset_endpoint = data.config.web.url.join("reset-password")?;
let mut reset_endpoint = data.config.web.frontend_url.join("reset-password")?;
reset_endpoint.set_query(Some(&format!("token={}", token)));
@ -1153,7 +1153,7 @@ impl PasswordResetToken {
.get_result(&mut conn)
.await?;
let login_page = data.config.web.url.join("login")?;
let login_page = data.config.web.frontend_url.join("login")?;
let email = data
.mail_client