Retire Convex paths and standardize local-first Pi runtime
This commit is contained in:
@@ -19,7 +19,7 @@ use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
use tower_http::compression::CompressionLayer;
|
||||
use tower_http::trace::TraceLayer;
|
||||
use tracing::{error, warn};
|
||||
use tracing::error;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct AppConfig {
|
||||
@@ -27,17 +27,11 @@ pub struct AppConfig {
|
||||
pub service_version: String,
|
||||
pub bind_addr: String,
|
||||
pub public_bind_addr: String,
|
||||
pub legacy_next_base_url: Option<String>,
|
||||
pub enable_legacy_next_compat: bool,
|
||||
pub enable_debug_shell_routes: bool,
|
||||
pub enable_editor_actor: bool,
|
||||
pub enable_page_ai_pi_lab: bool,
|
||||
pub compat_next_base_path: String,
|
||||
pub convex_url: Option<String>,
|
||||
pub convex_admin_key: Option<String>,
|
||||
|
||||
pub allow_dev_fixtures: bool,
|
||||
pub query_fixtures_json: Option<String>,
|
||||
pub mutation_fixtures_json: Option<String>,
|
||||
pub dev_user_id: String,
|
||||
pub dev_user_name: String,
|
||||
pub dev_user_email: String,
|
||||
@@ -56,33 +50,17 @@ impl AppConfig {
|
||||
.unwrap_or_else(|_| "127.0.0.1:0".into()),
|
||||
public_bind_addr: env::var("MNOTE_WEB_PUBLIC_BIND")
|
||||
.unwrap_or_else(|_| "127.0.0.1:3000".into()),
|
||||
legacy_next_base_url: env::var("MNOTE_WEB_LEGACY_NEXT_BASE_URL")
|
||||
.ok()
|
||||
.map(|value| value.trim().trim_end_matches('/').to_string())
|
||||
.filter(|value| !value.is_empty()),
|
||||
enable_legacy_next_compat: env_bool("MNOTE_WEB_ENABLE_LEGACY_NEXT_COMPAT", false),
|
||||
enable_debug_shell_routes: env::var("MNOTE_WEB_ENABLE_DEBUG_SHELL_ROUTES")
|
||||
.ok()
|
||||
.map(|value| matches!(value.trim(), "1" | "true" | "TRUE" | "yes" | "YES"))
|
||||
.unwrap_or(false),
|
||||
enable_editor_actor: env_bool("MNOTE_WEB_ENABLE_EDITOR_ACTOR", true),
|
||||
enable_page_ai_pi_lab: env_bool("MNOTE_PAGE_AI_PI_LAB", true),
|
||||
compat_next_base_path: env::var("MNOTE_WEB_COMPAT_NEXT_BASE_PATH")
|
||||
.unwrap_or_else(|_| "/api/compat/next".into()),
|
||||
convex_url: None,
|
||||
convex_admin_key: None,
|
||||
|
||||
allow_dev_fixtures: env::var("MNOTE_WEB_ALLOW_DEV_FIXTURES")
|
||||
.ok()
|
||||
.map(|value| matches!(value.trim(), "1" | "true" | "TRUE" | "yes" | "YES"))
|
||||
.unwrap_or(false),
|
||||
query_fixtures_json: env::var("MNOTE_WEB_QUERY_FIXTURES_JSON")
|
||||
.ok()
|
||||
.map(|value| value.trim().to_string())
|
||||
.filter(|value| !value.is_empty()),
|
||||
mutation_fixtures_json: env::var("MNOTE_WEB_MUTATION_FIXTURES_JSON")
|
||||
.ok()
|
||||
.map(|value| value.trim().to_string())
|
||||
.filter(|value| !value.is_empty()),
|
||||
dev_user_id: env::var("DEV_USER_ID")
|
||||
.ok()
|
||||
.or_else(|| read_env_or_dotenv("DEV_USER_ID"))
|
||||
@@ -367,23 +345,13 @@ async fn log_failed_response(request: Request, next: Next) -> Response {
|
||||
.get("x-error-code")
|
||||
.and_then(|value| value.to_str().ok())
|
||||
.unwrap_or("");
|
||||
if error_code == "convex_retired" {
|
||||
warn!(
|
||||
method = %method,
|
||||
uri = %uri,
|
||||
status = %status,
|
||||
error_code = %error_code,
|
||||
"退役 legacy cloud/Convex 兼容路径被请求"
|
||||
);
|
||||
} else {
|
||||
error!(
|
||||
method = %method,
|
||||
uri = %uri,
|
||||
status = %status,
|
||||
error_code = %error_code,
|
||||
"mnote-web 请求返回服务端错误"
|
||||
);
|
||||
}
|
||||
error!(
|
||||
method = %method,
|
||||
uri = %uri,
|
||||
status = %status,
|
||||
error_code = %error_code,
|
||||
"mnote-web 请求返回服务端错误"
|
||||
);
|
||||
}
|
||||
response
|
||||
}
|
||||
@@ -399,17 +367,11 @@ mod tests {
|
||||
service_version: "0.1.0".into(),
|
||||
bind_addr: "127.0.0.1:0".into(),
|
||||
public_bind_addr: "127.0.0.1:3000".into(),
|
||||
legacy_next_base_url: None,
|
||||
enable_legacy_next_compat: false,
|
||||
enable_debug_shell_routes: false,
|
||||
enable_editor_actor: true,
|
||||
enable_page_ai_pi_lab: true,
|
||||
compat_next_base_path: "/api/compat/next".into(),
|
||||
convex_url: None,
|
||||
convex_admin_key: None,
|
||||
|
||||
allow_dev_fixtures: false,
|
||||
query_fixtures_json: None,
|
||||
mutation_fixtures_json: None,
|
||||
dev_user_id: "dev-user".into(),
|
||||
dev_user_name: "开发用户".into(),
|
||||
dev_user_email: "dev@mnote.local".into(),
|
||||
|
||||
Reference in New Issue
Block a user