mirror of
https://github.com/Lumither/nocturne.git
synced 2026-10-17 10:26:21 +00:00
feat(backend) cargo fmt & migration to rust 2024
This commit is contained in:
15 files changed
+22
-23
No files matched your search
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
[workspace]
|
[workspace]
|
||||||
resolver = "2"
|
resolver = "3"
|
||||||
members = [
|
members = [
|
||||||
"server",
|
"server",
|
||||||
"macros",
|
"macros",
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "macros"
|
name = "macros"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2024"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
tracing = "0.1.40"
|
tracing = "0.1.40"
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ mod tests {
|
|||||||
use std::io;
|
use std::io;
|
||||||
use tracing::Level;
|
use tracing::Level;
|
||||||
use tracing_subscriber::prelude::*;
|
use tracing_subscriber::prelude::*;
|
||||||
use tracing_subscriber::{fmt, Registry};
|
use tracing_subscriber::{Registry, fmt};
|
||||||
|
|
||||||
let format = tracing_subscriber::fmt::format()
|
let format = tracing_subscriber::fmt::format()
|
||||||
.with_level(true)
|
.with_level(true)
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "markdown"
|
name = "markdown"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2024"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
uuid = { version = "1.10.0", features = ["v4", "fast-rng", "serde"] }
|
uuid = { version = "1.10.0", features = ["v4", "fast-rng", "serde"] }
|
||||||
serde = { version = "1.0.209", features = ["derive"] }
|
serde = { version = "1.0.209", features = ["derive"] }
|
||||||
serde_json = "1.0.128"
|
serde_json = "1.0.128"
|
||||||
regex = "1.10.4"
|
regex = "1.10.4"
|
||||||
yaml-rust2 = "0.9.0"
|
yaml-rust2 = "0.10.0"
|
||||||
sha2 = "0.10.8"
|
sha2 = "0.10.8"
|
||||||
base64 = "0.22.1"
|
base64 = "0.22.1"
|
||||||
thiserror = "2.0.3"
|
thiserror = "2.0.3"
|
||||||
@@ -8,7 +8,7 @@ use std::str::FromStr;
|
|||||||
use crate::error::Error;
|
use crate::error::Error;
|
||||||
use crate::utils::front_matter::{parse_front_matter, split_md_front_matter};
|
use crate::utils::front_matter::{parse_front_matter, split_md_front_matter};
|
||||||
|
|
||||||
use base64::{engine::general_purpose, Engine};
|
use base64::{Engine, engine::general_purpose};
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
use sha2::{Digest, Sha256};
|
use sha2::{Digest, Sha256};
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "server"
|
name = "server"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2024"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
macros = { path = "../macros" }
|
macros = { path = "../macros" }
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ use dirs::home_dir;
|
|||||||
use tracing::info;
|
use tracing::info;
|
||||||
use tracing_appender::{non_blocking, non_blocking::WorkerGuard, rolling};
|
use tracing_appender::{non_blocking, non_blocking::WorkerGuard, rolling};
|
||||||
use tracing_subscriber::{
|
use tracing_subscriber::{
|
||||||
filter::LevelFilter, fmt, fmt::format::Writer, fmt::time::FormatTime, fmt::MakeWriter,
|
Layer, Registry, filter::LevelFilter, fmt, fmt::MakeWriter, fmt::format::Writer,
|
||||||
layer::SubscriberExt, Layer, Registry,
|
fmt::time::FormatTime, layer::SubscriberExt,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct LocalTimer;
|
struct LocalTimer;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ mod misc;
|
|||||||
|
|
||||||
use std::{env, panic};
|
use std::{env, panic};
|
||||||
|
|
||||||
use crate::modules::{blog::Blog, ModuleTree};
|
use crate::modules::{ModuleTree, blog::Blog};
|
||||||
use macros::error_panic;
|
use macros::error_panic;
|
||||||
|
|
||||||
use tracing::info;
|
use tracing::info;
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
use crate::constants::blog::PAGE_SIZE;
|
use crate::constants::blog::PAGE_SIZE;
|
||||||
|
|
||||||
use axum::{extract::State, Json};
|
use axum::{Json, extract::State};
|
||||||
use serde_json::{json, Value};
|
use serde_json::{Value, json};
|
||||||
use sqlx::{query, PgPool, Row};
|
use sqlx::{PgPool, Row, query};
|
||||||
use tracing::error;
|
use tracing::error;
|
||||||
|
|
||||||
const GET_PAGE_COUNT_QUERY: &str = include_str!("post_page_count.sql");
|
const GET_PAGE_COUNT_QUERY: &str = include_str!("post_page_count.sql");
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ use macros::dev_consume;
|
|||||||
|
|
||||||
use axum::response::IntoResponse;
|
use axum::response::IntoResponse;
|
||||||
use axum::{
|
use axum::{
|
||||||
extract::{Path, State},
|
|
||||||
Json,
|
Json,
|
||||||
|
extract::{Path, State},
|
||||||
};
|
};
|
||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
use sqlx::PgPool;
|
use sqlx::PgPool;
|
||||||
|
|||||||
@@ -15,14 +15,14 @@ use crate::{
|
|||||||
use macros::panic_with_log;
|
use macros::panic_with_log;
|
||||||
|
|
||||||
use git2::{Delta, Repository};
|
use git2::{Delta, Repository};
|
||||||
use sqlx::{Pool, Postgres};
|
use sqlx::{PgPool, Pool, Postgres};
|
||||||
use tracing::{error, info, warn, Level};
|
use tracing::{error, info, warn, Level};
|
||||||
|
|
||||||
mod error;
|
mod error;
|
||||||
mod index;
|
mod index;
|
||||||
mod utils;
|
mod utils;
|
||||||
|
|
||||||
pub fn task(db_connection: &Pool<Postgres>) {
|
pub fn task(db_connection: &PgPool) {
|
||||||
// init
|
// init
|
||||||
let git_work_dir = {
|
let git_work_dir = {
|
||||||
let path = if let Ok(default_log_path) = env::var(var_name::WORK_DIR) {
|
let path = if let Ok(default_log_path) = env::var(var_name::WORK_DIR) {
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ mod cron;
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
modules::{
|
modules::{
|
||||||
|
Module,
|
||||||
blog::{
|
blog::{
|
||||||
api::{
|
api::{
|
||||||
get_page_count,
|
get_page_count,
|
||||||
@@ -11,12 +12,11 @@ use crate::{
|
|||||||
},
|
},
|
||||||
// cron::check_update,
|
// cron::check_update,
|
||||||
},
|
},
|
||||||
Module,
|
|
||||||
},
|
},
|
||||||
scheduler::tasks::CronTask,
|
scheduler::tasks::CronTask,
|
||||||
};
|
};
|
||||||
|
|
||||||
use axum::{routing::get, Router};
|
use axum::{Router, routing::get};
|
||||||
use sqlx::PgPool;
|
use sqlx::PgPool;
|
||||||
|
|
||||||
const MOUNT_POINT: &str = "/blog";
|
const MOUNT_POINT: &str = "/blog";
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ use std::num::ParseIntError;
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
constants::config::server::{default_value, var_name},
|
constants::config::server::{default_value, var_name},
|
||||||
scheduler::{tasks::CronTask, Scheduler},
|
scheduler::{Scheduler, tasks::CronTask},
|
||||||
};
|
};
|
||||||
use macros::error_panic;
|
use macros::error_panic;
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
use std::{
|
use std::{
|
||||||
collections::HashMap,
|
collections::HashMap,
|
||||||
sync::{
|
sync::{
|
||||||
atomic::{AtomicBool, Ordering},
|
atomic::{AtomicBool, Ordering}, Arc,
|
||||||
Arc, RwLock,
|
RwLock,
|
||||||
},
|
},
|
||||||
thread,
|
thread,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -3,12 +3,11 @@
|
|||||||
/// https://github.com/rust-lang/git2-rs/commit/f3b87baed1e33d6c2d94fe1fa6aa6503a071d837
|
/// https://github.com/rust-lang/git2-rs/commit/f3b87baed1e33d6c2d94fe1fa6aa6503a071d837
|
||||||
///
|
///
|
||||||
use git2::{
|
use git2::{
|
||||||
build, AnnotatedCommit, AutotagOption, Delta, FetchOptions, Reference, Remote, Repository,
|
AnnotatedCommit, AutotagOption, Delta, FetchOptions, Reference, Remote, Repository, build,
|
||||||
};
|
};
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use tracing::{error, warn};
|
use tracing::{error, warn};
|
||||||
|
|
||||||
|
|
||||||
#[derive(Debug, Eq, PartialEq)]
|
#[derive(Debug, Eq, PartialEq)]
|
||||||
pub struct FileDelta {
|
pub struct FileDelta {
|
||||||
pub old_path: Option<PathBuf>,
|
pub old_path: Option<PathBuf>,
|
||||||
|
|||||||
Reference in new issue
Block a user